new toast impl, wip
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {Controller} from "./main";
|
||||
import {BackupHeader} from "./api";
|
||||
import {toast} from "./toast";
|
||||
|
||||
export class SubmitView {
|
||||
json: HTMLDivElement;
|
||||
@@ -28,11 +29,9 @@ export class SubmitView {
|
||||
controller.uploadConfig(this.json.textContent as string, (status: string) => {
|
||||
if (status != "OK") {
|
||||
// Show error toast (click to dismiss only)
|
||||
const {toast} = require('./toast');
|
||||
toast.error(status);
|
||||
} else {
|
||||
// Show info toast (auto hides after 5s, or click to dismiss sooner)
|
||||
const {toast} = require('./toast');
|
||||
toast.info('Config uploaded successfully');
|
||||
}
|
||||
this.submit_status.innerHTML = status;
|
||||
@@ -41,10 +40,21 @@ export class SubmitView {
|
||||
this.backupBtn.onclick = () => {
|
||||
controller.progressview.addIndeterminate("backup", "Backup to EEPROM running")
|
||||
controller.backupConfig(this.json.textContent as string).then(saveStatus => {
|
||||
if (saveStatus === "OK") {
|
||||
toast.success("Configuration backup successful");
|
||||
} else {
|
||||
toast.error(`Backup failed: ${saveStatus}`);
|
||||
}
|
||||
controller.getBackupInfo().then(r => {
|
||||
controller.progressview.removeProgress("backup")
|
||||
this.submit_status.innerHTML = saveStatus;
|
||||
});
|
||||
}).catch(error => {
|
||||
toast.error(`Backup error: ${error}`);
|
||||
controller.getBackupInfo().then(r => {
|
||||
controller.progressview.removeProgress("backup")
|
||||
this.submit_status.innerHTML = "Error";
|
||||
});
|
||||
});
|
||||
}
|
||||
this.restoreBackupBtn.onclick = () => {
|
||||
|
||||
Reference in New Issue
Block a user