Add button clear everything and reload default apps
parent
8992ad545a
commit
692ff509e5
|
|
@ -0,0 +1 @@
|
||||||
|
["boot","launch","mclock","setting","sbat","sbt"]
|
||||||
|
|
@ -126,7 +126,8 @@
|
||||||
|
|
||||||
<h3>Utilities</h3>
|
<h3>Utilities</h3>
|
||||||
<p><button class="btn" id="settime">Set Bangle.js Time</button>
|
<p><button class="btn" id="settime">Set Bangle.js Time</button>
|
||||||
<button class="btn" id="removeall">Remove all Apps</button></p>
|
<button class="btn" id="removeall">Remove all Apps</button>
|
||||||
|
<button class="btn" id="installdefault">Install default apps</button></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
33
index.js
33
index.js
|
|
@ -432,3 +432,36 @@ document.getElementById("removeall").addEventListener("click",event=>{
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// Install all default apps in one go
|
||||||
|
document.getElementById("installdefault").addEventListener("click",event=>{
|
||||||
|
var defaultApps
|
||||||
|
httpGet("defaultapps.json").then(json=>{
|
||||||
|
defaultApps = JSON.parse(json);
|
||||||
|
defaultApps = defaultApps.map( appid => appJSON.find(app=>app.id==appid) );
|
||||||
|
if (defaultApps.some(x=>x===undefined))
|
||||||
|
throw "Not all apps found";
|
||||||
|
return showPrompt("Install Defaults","Remove everything and install default apps?");
|
||||||
|
}).then(() => {
|
||||||
|
return Comms.removeAllApps();
|
||||||
|
}).then(()=>{
|
||||||
|
showToast("Existing apps removed","success");
|
||||||
|
return new Promise(resolve => {
|
||||||
|
function upload() {
|
||||||
|
var app = defaultApps.shift();
|
||||||
|
if (app===undefined) return resolve();
|
||||||
|
Comms.uploadApp(app).then((appJSON) => {
|
||||||
|
if (appJSON) appsInstalled.push(appJSON);
|
||||||
|
showToast(app.name+" Uploaded", "success");
|
||||||
|
upload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
upload();
|
||||||
|
});
|
||||||
|
}).then(()=>{
|
||||||
|
showToast("Default apps successfully installed!","success");
|
||||||
|
refreshMyApps();
|
||||||
|
refreshLibrary();
|
||||||
|
}).catch(err=>{
|
||||||
|
showToast("App Install failed, "+err,"error");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue