Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hschneider committed Dec 19, 2023
1 parent 339ce0a commit 08383e6
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 4 deletions.
47 changes: 43 additions & 4 deletions resources/js/neutralino-autoupdate/autoupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class NeutralinoAutoupdate {
// opt debug: Toggle console debug output
// opt lang: Dialog language, defaults to en

this.version = '1.1.2';
this.version = '1.1.3';
this.debug = opt.debug || true;

this.urlManifest = urlManifest; // Manifest URL
this.manifest = undefined; // Manifest object
this.os = NL_OS; // OS platform
this.arch = opt.arch || 'x64'; // CPU architecture
this.token = opt.token || ''; // X-Auth-App Token
this.token = opt.token || ''; // X-Auth-App token

this.headers = new Headers(); // Custom request headers
if(this.token !== '') {
Expand All @@ -54,13 +54,17 @@ class NeutralinoAutoupdate {
'txtNewVersion': 'A new version of {appName} is available.',
'txtAskUpdate': 'You have version {versionCurrent}. Do you want to install version {versionUpdate}?',
'btnCancel': 'Not yet',
'btnOK': 'Install'
'btnOK': 'Install',
'errorChecksum': "Update failed: The download seems to be corrupted.",
'errorUnpack': 'Update failed: Download cannot be unpacked.'
},
'de': {
'txtNewVersion': 'Eine neue Version von {appName} ist verfügbar.',
'txtAskUpdate': 'Sie haben Version {versionCurrent}. Möchten Sie Version {versionUpdate} installieren?',
'btnCancel': 'Jetzt nicht',
'btnOK': 'Installieren'
'btnOK': 'Installieren',
'errorChecksum': "Update Error: Der Download ist anscheinend defekt.",
'errorUnpack': 'Update Error: Der Download kann nicht entpackt werden.'
}
}

Expand Down Expand Up @@ -138,6 +142,11 @@ class NeutralinoAutoupdate {
this.modalBtnCancel.addEventListener('click', () => {
this._modalClose();
});

this.alertBtnClose = document.getElementById('_autoupdate_alert_btnClose');
this.alertBtnClose.addEventListener('click', () => {
this._alertClose();
});
}
addHeader(key, val) {
//
Expand Down Expand Up @@ -177,6 +186,34 @@ class NeutralinoAutoupdate {
e.style.opacity = '1';
e.style.visibility = 'visible';
}
_reportError(code) {
var msg = this.langStrings[this.lang][code];
this._modalClose();

let e = document.getElementById('_autoupdate_alert_msg')
e.innerHTML = msg;
e = document.querySelector('._autoupdate_alert');
e.style.opacity = '1';
e.style.visibility = 'visible';
}
_alertClose() {
//
// Close alert dialog.

let e = document.querySelector('._autoupdate_modal_inner');
e.classList.add('animate__fadeOutUp');

setTimeout( () => {
e = document.querySelector('._autoupdate_alert');
e.classList.add('animate__animated');
e.classList.add('animate__fadeOut');
e.classList.add('animate__faster');
setTimeout( () => {
e.style.opacity = '0';
e.style.visibility = 'hidden';
}, 500);
}, 500);
}
async check() {
//
// Call .checkSilent and open a modal dialog,
Expand Down Expand Up @@ -284,6 +321,7 @@ class NeutralinoAutoupdate {
this.log('ERROR: Download checksum mismatch.');
this._loaderOff();
this.updating = false;
this._reportError('errorChecksum');
return false;
}
this.log('Checksum OK.')
Expand All @@ -310,6 +348,7 @@ class NeutralinoAutoupdate {
if(res.exitCode === 1) {
this.log("Unpack failed.")
this.updating = false;
this._reportError('errorUnpack');
return false;
}

Expand Down
9 changes: 9 additions & 0 deletions resources/js/neutralino-autoupdate/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@
</div>
</div>
</div>

<div class="_autoupdate_alert">
<label class="_autoupdate_modal_bg"></label>
<div class="_autoupdate_alert_inner animate__animated animate__fadeInDown animate__faster">
<label id="_autoupdate_alert_btnClose"></label>
<div id="_autoupdate_alert_msg" style="margin-top:10px">
</div>
</div>
</div>
67 changes: 67 additions & 0 deletions resources/js/neutralino-autoupdate/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
._autoupdate_alert {
opacity: 0;
visibility: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
text-align: left;
background: rgba(0,0,0, .7);
transition: opacity .25s ease;
}
._autoupdate_alert_inner {
transition: top .25s ease;
position: absolute;
top: -50%;
right: 0;
bottom: 0;
left: 0;
width: 75%;
margin: auto;
background: #f67272;
border-radius: 9px;
padding: 20px 20px 20px 20px;
height: auto;
min-height: 40px;
max-height: 40px;
max-width: 500px;
overflow: hidden;
font-family: 'San Francisco', 'Helvetica Neue', 'Lucida Grande', sans-serif;
font-size: 14px;
font-weight: bolder;
color: #333;
}

#_autoupdate_alert_btnClose {
position: absolute;
right: 1em;
top: 1em;
width: 1.1em;
height: 1.1em;
cursor: pointer;
}

#_autoupdate_alert_btnClose:after,
#_autoupdate_alert_btnClose:before {
content: '';
position: absolute;
width: 2px;
height: 1.5em;
background: #333;
display: block;
transform: rotate(45deg);
left: 50%;
margin: -3px 0 0 -1px;
top: 0;
}

#_autoupdate_alert_btnClose:hover:after,
#_autoupdate_alert_btnClose:hover:before {
background: #333;
}

#_autoupdate_alert_btnClose:before {
transform: rotate(-45deg);
}

._autoupdate_modal {
opacity: 0;
visibility: hidden;
Expand Down

0 comments on commit 08383e6

Please sign in to comment.