eeprom read write
This commit is contained in:
@@ -163,6 +163,8 @@
|
||||
<div>
|
||||
<textarea id="json" cols=50 rows=10></textarea>
|
||||
<button id="submit">Submit</button>
|
||||
<button id="backup">Backup</button>
|
||||
<button id="restorebackup">Restore</button>
|
||||
<div id="submit_status"></div>
|
||||
</div>
|
||||
<div id="fileview" class="subcontainer">
|
||||
|
@@ -138,6 +138,17 @@ export class Controller {
|
||||
controller.firmWareView.setVersion(versionInfo);
|
||||
})
|
||||
}
|
||||
|
||||
getBackupConfig() {
|
||||
controller.progressview.addIndeterminate("get_backup_config", "Downloading Backup")
|
||||
fetch(PUBLIC_URL + "/get_backup_config")
|
||||
.then(response => response.json())
|
||||
.then(loaded => {
|
||||
controller.progressview.removeProgress("get_config")
|
||||
alert(loaded)
|
||||
})
|
||||
}
|
||||
|
||||
downloadConfig() {
|
||||
controller.progressview.addIndeterminate("get_config", "Downloading Config")
|
||||
fetch(PUBLIC_URL + "/get_config")
|
||||
@@ -166,6 +177,16 @@ export class Controller {
|
||||
//load from remote to be clean
|
||||
controller.downloadConfig()
|
||||
}
|
||||
backupConfig(json: string, statusCallback: (status: string) => void) {
|
||||
controller.progressview.addIndeterminate("backup_config", "Backingup Config")
|
||||
fetch(PUBLIC_URL + "/backup_config", {
|
||||
method: "POST",
|
||||
body: json,
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(text => statusCallback(text))
|
||||
controller.progressview.removeProgress("backup_config")
|
||||
}
|
||||
syncRTCFromBrowser() {
|
||||
controller.progressview.addIndeterminate("write_rtc", "Writing RTC")
|
||||
var value: SetTime = {
|
||||
|
@@ -1,22 +1,34 @@
|
||||
import { Controller } from "./main";
|
||||
|
||||
export class SubmitView{
|
||||
json: HTMLInputElement;
|
||||
submitFormBtn: HTMLButtonElement;
|
||||
submit_status: HTMLElement;
|
||||
|
||||
constructor(controller: Controller){
|
||||
this.json = document.getElementById('json') as HTMLInputElement
|
||||
this.submitFormBtn = document.getElementById("submit") as HTMLButtonElement
|
||||
this.submit_status = document.getElementById("submit_status") as HTMLElement
|
||||
this.submitFormBtn.onclick = () => {
|
||||
controller.uploadConfig(this.json.value, (status:string) => {
|
||||
this.submit_status.innerHTML = status;
|
||||
});
|
||||
}
|
||||
export class SubmitView {
|
||||
json: HTMLInputElement;
|
||||
submitFormBtn: HTMLButtonElement;
|
||||
submit_status: HTMLElement;
|
||||
backupBtn: HTMLButtonElement;
|
||||
restoreBackupBtn: HTMLButtonElement;
|
||||
|
||||
constructor(controller: Controller) {
|
||||
this.json = document.getElementById('json') as HTMLInputElement
|
||||
this.submitFormBtn = document.getElementById("submit") as HTMLButtonElement
|
||||
this.backupBtn = document.getElementById("backup") as HTMLButtonElement
|
||||
this.restoreBackupBtn = document.getElementById("restorebackup") as HTMLButtonElement
|
||||
this.submit_status = document.getElementById("submit_status") as HTMLElement
|
||||
this.submitFormBtn.onclick = () => {
|
||||
controller.uploadConfig(this.json.value, (status: string) => {
|
||||
this.submit_status.innerHTML = status;
|
||||
});
|
||||
}
|
||||
|
||||
setJson(pretty: string) {
|
||||
this.json.value = pretty
|
||||
this.backupBtn.onclick = () => {
|
||||
controller.backupConfig(this.json.value, (status: string) => {
|
||||
this.submit_status.innerHTML = status;
|
||||
});
|
||||
this.restoreBackupBtn.onclick = () => {
|
||||
controller.getBackupConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setJson(pretty: string) {
|
||||
this.json.value = pretty
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user