1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

[TypeScript] Settings module (#398)

* Convert settings to TypeScript.

* Simplify loadSettings using await.

* Re-write save feature settings.

* Minor fixes.
This commit is contained in:
Oscar Hinton
2017-11-26 14:35:49 +01:00
committed by Kyle Spearrin
parent 7c525d3f3a
commit 78c4ea7ecb
38 changed files with 915 additions and 876 deletions

View File

@@ -0,0 +1,47 @@
import * as template from './sync.component.html';
class SyncController {
i18n: any;
lastSync = '--';
loading = false;
constructor(private syncService: any, private toastr: any, private $analytics: any, private i18nService: any) {
this.i18n = i18nService;
this.setLastSync();
}
sync() {
this.loading = true;
this.syncService
.fullSync(true)
.then((success: boolean) => {
this.loading = false;
if (success) {
this.setLastSync();
this.$analytics.eventTrack('Synced Full');
this.toastr.success(this.i18nService.syncingComplete);
} else {
this.toastr.error(this.i18nService.syncingFailed);
}
});
}
setLastSync() {
this.syncService
.getLastSync()
.then((lastSync: any) => {
if (lastSync) {
this.lastSync = lastSync.toLocaleDateString() + ' ' + lastSync.toLocaleTimeString();
} else {
this.lastSync = this.i18nService.never;
}
});
}
}
export const SyncComponent = {
bindings: {},
controller: SyncController,
template,
};