diff --git a/package.json b/package.json
index 49f9866de..590d46e40 100644
--- a/package.json
+++ b/package.json
@@ -91,4 +91,4 @@
"android"
]
}
-}
+}
\ No newline at end of file
diff --git a/src/classes/storageClass.ts b/src/classes/storageClass.ts
index cf33e36d3..21d2263d2 100644
--- a/src/classes/storageClass.ts
+++ b/src/classes/storageClass.ts
@@ -53,7 +53,7 @@ export abstract class StorageClass {
this.isInitialized = -1;
this.__initializeStorage();
}
- private __initializeStorage() {
+ protected __initializeStorage() {
this.uiStorage.get(this.DB_PATH).then((_data) => {
if (_data === null || _data === undefined) {
//No beans have been added yet
diff --git a/src/pages/brews/add/brews-add.html b/src/pages/brews/add/brews-add.html
index 8fafd2c7e..73fc93603 100644
--- a/src/pages/brews/add/brews-add.html
+++ b/src/pages/brews/add/brews-add.html
@@ -19,10 +19,10 @@
Gewicht
-
+
-
+
Temperatur
diff --git a/src/pages/settings/settings.ts b/src/pages/settings/settings.ts
index a1a592af1..342ac6919 100644
--- a/src/pages/settings/settings.ts
+++ b/src/pages/settings/settings.ts
@@ -41,6 +41,10 @@ export class SettingsPage {
private uiPreparationStorage: UIPreparationStorage,
private uiBeanStorage: UIBeanStorage,
private uiBrewStorage: UIBrewStorage) {
+this.__initializeSettings();
+ }
+
+ private __initializeSettings(){
this.settings = this.uiSettingsStorage.getSettings();
}
@@ -75,39 +79,6 @@ export class SettingsPage {
}
- private test() {
- this.uiStorage.export().then((_back) => {
- let parsedContent = _back;
- if (parsedContent[this.uiPreparationStorage.getDBPath()] &&
- parsedContent[this.uiBeanStorage.getDBPath()] &&
- parsedContent[this.uiBrewStorage.getDBPath()] &&
- parsedContent[this.uiSettingsStorage.getDBPath()]) {
-
- this.__cleanupImportBeanData(parsedContent[this.uiBeanStorage.getDBPath()]);
- this.__cleanupImportBrewData(parsedContent[this.uiBrewStorage.getDBPath()]);
-
- this.uiStorage.import(parsedContent).then((_data) => {
- if (_data.BACKUP === false) {
- this.__reinitializeStorages().then(() => {
- this.uiAlert.showMessage("Import erfolgreich");
- })
-
- }
- else {
- this.uiAlert.showMessage("Import unerfolgreich, Daten wurden nicht verändert");
- }
-
- }, () => {
- this.uiAlert.showMessage("Import unerfolgreich, Daten wurden nicht verändert");
- })
-
- }
- else {
- this.uiAlert.showMessage("Invalider Dateiinhalt");
- }
- })
- }
-
private __readJSONFile(path, file) {
var promise = new Promise((resolve, reject) => {
this.file.readAsText(path, file)
@@ -124,6 +95,7 @@ export class SettingsPage {
this.uiStorage.import(parsedContent).then((_data) => {
if (_data.BACKUP === false) {
this.__reinitializeStorages().then(() => {
+ this.__initializeSettings();
this.uiAlert.showMessage("Import erfolgreich");
})
diff --git a/src/services/uiSettingsStorage.ts b/src/services/uiSettingsStorage.ts
index 0da3e0dc2..f70ee2bfd 100644
--- a/src/services/uiSettingsStorage.ts
+++ b/src/services/uiSettingsStorage.ts
@@ -38,6 +38,23 @@ export class UISettingsStorage extends StorageClass {
})
}
+ public reinitializeStorage(){
+ super.reinitializeStorage();
+
+ super.storageReady().then(() => {
+ let entries: Array = this.getAllEntries();
+ if (entries.length > 0) {
+ //We already had some settings here.
+ this.settings.initializeByObject(entries[0]);
+ }
+ else {
+ //Take the new settings obj.
+ super.add(this.settings);
+ }
+ }, () => {
+ //Outsch, cant do much.
+ })
+ }
public getSettings(): Settings {
return this.settings;
}