|
@@ -7,6 +7,7 @@
|
|
|
<link rel="stylesheet" href="../../script/semantic/semantic.min.css">
|
|
|
<script type="text/javascript" src="../../script/jquery.min.js"></script>
|
|
|
<script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
|
|
|
+ <script type="text/javascript" src="../../script/ao_module.js"></script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="ui container">
|
|
@@ -19,19 +20,99 @@
|
|
|
</div>
|
|
|
</h3>
|
|
|
<div class="ui divider"></div>
|
|
|
+ <!-- Status Messages-->
|
|
|
+ <div id="warning" class="ui negative visible icon message">
|
|
|
+ <i class="red exclamation circle icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header">
|
|
|
+ WARNING
|
|
|
+ </div>
|
|
|
+ <p>Backup all the important files before performing system update</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="checking" class="ui icon blue message" style="display:none;">
|
|
|
+ <i class="notched circle loading icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header">
|
|
|
+ Connectiong to Download Server
|
|
|
+ </div>
|
|
|
+ <p>We're fetching that content for you.</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="confirmDownload" class="ui icon yellow message" style="display:none;">
|
|
|
+ <i class="yellow exclamation icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header">
|
|
|
+ Confirm Update?
|
|
|
+ </div>
|
|
|
+ <p><span>This updates will take up </span><span id="spaceEst" style="font-weight: bold;"></span> <span>of space.</span></p>
|
|
|
+ <p><b>Please make sure you have back up all important files and config files before you proceeds.</b></p>
|
|
|
+ <div class="ui buttons">
|
|
|
+ <button class="ui yellow button" onclick="confirmURLUpdate();">Confirm Update</button>
|
|
|
+ <button class="ui button" onclick="cancelUpdateStatus();"><i class="ui remove icon"></i> Cancel Update</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="downloading" class="ui icon blue message" style="display:none;">
|
|
|
+ <i class="notched circle loading icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header" id="downloadStatusText">
|
|
|
+ Starting Download Session
|
|
|
+ </div>
|
|
|
+ <br>
|
|
|
+ <p id="fallbackmodeExp" style="display:none;">You are seeing this message is because the websocket connection to your host failed to establish. No worry, updates can still be done using AJAX fallback mode, just without the real time progress updates. <br>Please wait until the download complete before closing this page.</br></p>
|
|
|
+ <div class="ui blue active progress">
|
|
|
+ <div id="downloadProgressBar" class="bar">
|
|
|
+ <div class="progress">0.00%</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="success" class="ui icon green message" style="display:none;">
|
|
|
+ <i class="green checkmark icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header" id="downloadStatusText">
|
|
|
+ Update Download Succeed
|
|
|
+ </div>
|
|
|
+ <p>Restart ArozOS using the launcher or apply manual update files overwrite to finish the update process.</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="failed" class="ui icon red message" style="display:none;">
|
|
|
+ <i class="red remove icon"></i>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header" id="downloadStatusText">
|
|
|
+ Update Download Failed
|
|
|
+ </div>
|
|
|
+ <p id="failedErrorMessage">Unknown Error Occured</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="restartPanel" class="ui inversed red message" style="display:none;">
|
|
|
+ <div class="header" >
|
|
|
+ Launcher Exists: <span id="launcherName"></span>
|
|
|
+ </div>
|
|
|
+ <p>You will need to restart ArozOS in order to apply the updates.</p>
|
|
|
+ <p>Warning! Make sure you have physical access to this ArozOS Host before pressing the restart button.<br> Update failure might require a manual restart of the ArozOS system host and its launcher.</p>
|
|
|
+ <button class="ui red button" onclick="restartArozOS();">RESTART ArozOS WITH LAUNCHER</button>
|
|
|
+ </div>
|
|
|
+ <!-- End of Status Messages -->
|
|
|
<h4>Update via Download</h4>
|
|
|
<p>Binary Executable Download URL</p>
|
|
|
<div class="ui fluid input">
|
|
|
- <input type="text" placeholder="Binary Download URL">
|
|
|
+ <input id="burl" type="text" placeholder="Binary Download URL">
|
|
|
</div>
|
|
|
<small>Usually with pattern like: arozos_{platform}_{cpu_arch}</small>
|
|
|
<br><br>
|
|
|
<p>Webpack Download URL</p>
|
|
|
<div class="ui fluid input">
|
|
|
- <input type="text" placeholder="Webpack Download URL">
|
|
|
+ <input id="wurl" type="text" placeholder="Webpack Download URL">
|
|
|
</div>
|
|
|
<small>Usually with named as: webpack.tar.gz</small>
|
|
|
+ <br><br>
|
|
|
+ <button class="ui red button" onclick="updateViaURL();"><i class="cloud upload icon"></i> Execute Update</button>
|
|
|
+
|
|
|
<div class="ui divider"></div>
|
|
|
+
|
|
|
+
|
|
|
<div class="ui message">
|
|
|
<h4><i class="info circle icon"></i>Update Instruction</h4>
|
|
|
<p>To update your ArozOS system, you will need two files: A compiled binary of the newer version of ArozOS and the webpack compress file in .tar.gz format.
|
|
@@ -75,6 +156,139 @@
|
|
|
</div>
|
|
|
<script>
|
|
|
$(".accordion").accordion();
|
|
|
+
|
|
|
+ function updateViaURL(){
|
|
|
+ let binaryDownloadURL = $("#burl").val().trim();
|
|
|
+ let webpackDownloadURL = $("#wurl").val().trim();
|
|
|
+ if (binaryDownloadURL == "" || webpackDownloadURL == ""){
|
|
|
+ alert("Invalid or Empty URL given");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //Check space need
|
|
|
+ $("#checking").slideDown("fast");
|
|
|
+ $("#warning").slideUp("fast");
|
|
|
+ $.get(`/system/update/checksize?webpack=${webpackDownloadURL}&binary=${binaryDownloadURL}`, function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ cancelUpdateStatus();
|
|
|
+ alert("Update failed: " + data.error)
|
|
|
+ }else{
|
|
|
+ let totalDownloadBytes = data[0] + data[1];
|
|
|
+ $("#spaceEst").text(ao_module_utils.formatBytes(totalDownloadBytes, 2));
|
|
|
+ $("#confirmDownload").slideDown("fast");
|
|
|
+ $("#checking").slideUp("fast");
|
|
|
+ console.log(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function confirmURLUpdate(){
|
|
|
+ let binaryDownloadURL = $("#burl").val().trim();
|
|
|
+ let webpackDownloadURL = $("#wurl").val().trim();
|
|
|
+ if (binaryDownloadURL == "" || webpackDownloadURL == ""){
|
|
|
+ alert("Invalid or Empty URL given");
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var wsroot = ao_module_utils.getWebSocketEndpoint();
|
|
|
+ var requestEndpoint = wsroot + `/system/update/download?webpack=${webpackDownloadURL}&binary=${binaryDownloadURL}&ws=true`
|
|
|
+ console.log("Connecting to: ", requestEndpoint);
|
|
|
+
|
|
|
+ hideAllStatus();
|
|
|
+ $("#downloading").slideDown("fast");
|
|
|
+
|
|
|
+ let socket = new WebSocket(requestEndpoint);
|
|
|
+
|
|
|
+ socket.onopen = function(e) {
|
|
|
+ $("#downloadStatusText").text("Download Started");
|
|
|
+ };
|
|
|
+
|
|
|
+ socket.onmessage = function(event) {
|
|
|
+ let status = JSON.parse(event.data);
|
|
|
+ if (status.error !== undefined){
|
|
|
+ hideAllStatus();
|
|
|
+ $("#failed").slideDown();
|
|
|
+ $("#failedErrorMessage").text(status.error);
|
|
|
+ }else{
|
|
|
+ //Progressing
|
|
|
+ let progressText = status.Progress.toFixed(2) + "%";
|
|
|
+ $("#downloadProgressBar").find(".progress").text(progressText);
|
|
|
+ $("#downloadProgressBar").css("width",status.Progress + "%");
|
|
|
+ $("#downloadStatusText").text(`[${status.Stage}] ${status.StatusText}`);
|
|
|
+ }
|
|
|
+ console.log(event.data);
|
|
|
+ };
|
|
|
+
|
|
|
+ socket.onclose = function(event) {
|
|
|
+ hideAllStatus();
|
|
|
+ $("#success").slideDown();
|
|
|
+ checkLauncher();
|
|
|
+ };
|
|
|
+
|
|
|
+ socket.onerror = function(error) {
|
|
|
+ console.log("Websocket Connection Error: ", error, " Running in fallback mode")
|
|
|
+ downloadUpdateFallbackMode(binaryDownloadURL, webpackDownloadURL);
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ function downloadUpdateFallbackMode(binaryDownloadURL, webpackDownloadURL){
|
|
|
+ hideAllStatus();
|
|
|
+ $("#downloading").slideDown("fast");
|
|
|
+ $("#downloadStatusText").text("Waiting for Download Complete (Fallback Mode)");
|
|
|
+ $("#fallbackmodeExp").show();
|
|
|
+ $("#downloadProgressBar").find(".progress").text("Downloading");
|
|
|
+ $("#downloadProgressBar").css("width", "50%");
|
|
|
+ $.get(`../../system/update/download?webpack=${webpackDownloadURL}&binary=${binaryDownloadURL}`, function(data){
|
|
|
+ if (data.error !== undefined){
|
|
|
+ hideAllStatus();
|
|
|
+ $("#failed").slideDown();
|
|
|
+ $("#failedErrorMessage").text(data.error);
|
|
|
+ }else{
|
|
|
+ hideAllStatus();
|
|
|
+ $("#success").slideDown();
|
|
|
+ checkLauncher();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function checkLauncher(){
|
|
|
+ $.get("/system/update/restart", function(data){
|
|
|
+ if (data.error !== undefined){
|
|
|
+ //No launcher
|
|
|
+ }else{
|
|
|
+ $("#launcherName").text(data);
|
|
|
+ }
|
|
|
+ console.log("Launcher check: ", data);
|
|
|
+ })
|
|
|
+ $("#restartPanel").show();
|
|
|
+ }
|
|
|
+
|
|
|
+ function restartArozOS(){
|
|
|
+ if (confirm("CONFIRM RESTART?")){
|
|
|
+ $.ajax({
|
|
|
+ url: "/system/update/restart",
|
|
|
+ method: "POST",
|
|
|
+ data: {exec: true},
|
|
|
+ success: function(data){
|
|
|
+ console.log(data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function cancelUpdateStatus(){
|
|
|
+ hideAllStatus();
|
|
|
+ $("#warning").slideDown("fast");
|
|
|
+ }
|
|
|
+
|
|
|
+ function hideAllStatus(){
|
|
|
+ $("#warning").slideUp("fast");
|
|
|
+ $("#confirmDownload").slideUp("fast");
|
|
|
+ $("#checking").slideUp("fast");
|
|
|
+ $("#downloading").slideUp("fast");
|
|
|
+ $("#success").slideUp("fast");
|
|
|
+ $("#failed").slideUp("fast");
|
|
|
+ }
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|