From: Kilian Saffran Date: Thu, 21 Feb 2019 20:26:10 +0000 (+0100) Subject: load preferences X-Git-Tag: 0.7beta~36 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=a740f8aa91998142485e76f5377141790b4ec3e0;p=invoicejournal.git load preferences --- diff --git a/index.html b/index.html index 60455e8..1b5b8bd 100644 --- a/index.html +++ b/index.html @@ -18,8 +18,8 @@ -
-
+
+ +
+
+
-
- -
- -
+
+
+
+ +
+
+
+
+
-
- Verbindung -
+
Verbindung
-
- -
- -
+
+ +
-
- -
- -
+
+ +
-
- -
- -
+
+ + +
+
+ +
-
- -
- -
-
@@ -80,19 +79,14 @@ Standard Werte
-
- -
- -
-
-
- -
- -
-
- +
+ + +
+
+ + +
@@ -102,60 +96,50 @@ E-Mail Server
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+
+ + +
+
+ +
+ + +
+
+
+ + +
+
+ + +
-
-
-
-
+
+
+
+
+ -
-
+ @@ -166,26 +150,20 @@
-
-
-
-
-
-
+
+
+
+
- -
+ diff --git a/modules/settings/index.js b/modules/settings/index.js index 1caddee..543d6ec 100644 --- a/modules/settings/index.js +++ b/modules/settings/index.js @@ -1,4 +1,4 @@ function initpage(){ console.log(parent.usersystem.getsysinfo()); - parent.usersystem.setProperty("testproperty",{id:"TEST"}); + //parent.usersystem.setProperty("testproperty",{id:"TEST"}); } \ No newline at end of file diff --git a/null.json b/null.json deleted file mode 100644 index 63032c3..0000000 --- a/null.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"DKS Buchhaltung","type":"local","server":"","dbfile":"","vpn":"","vat":"","currency":"","mailserver":"","mailport":"","mailencryption":"","maillogin":"","mailpassword":""} \ No newline at end of file diff --git a/renderer.js b/renderer.js index fb2acd1..a6d612c 100644 --- a/renderer.js +++ b/renderer.js @@ -29,7 +29,7 @@ var usersystem = { showError: function(errtitle,errmsg){ dialog.showErrorBox(errtitle, errmsg); }, - setPreference(key,data){ + setPreference: function(key,data){ console.log("save preferences to: " + this.profilepath() + key + ".json"); if ((typeof data == 'object') || (typeof data == 'array')){ @@ -47,51 +47,50 @@ var usersystem = { }); return false; }, - getPreference(key){ + getPreference: function(key,callback=null){ var data = null; if (fs.existsSync(this.profilepath() + key + ".json")){ + console.log("Read Key:" + key); fs.readFile(this.profilepath() + key + ".json", 'utf-8', (err, data) => { if(err){ //this.showError("Error reading Preference!",err.message); console.log("Error reading Preference!" + err.message); return data; } + //console.log(data); if (data.startsWith("{") || data.startsWith("[")){ data = JSON.parse(data); } + if (callback){ + callback(key,data); + } + // Change how to handle the file content - console.log("The preference content is : " + data); - return JSON.stringify(data); + //console.log("The preference content is : " ); + //console.log(data); + return data; }); } return data; }, - getLocalDataSets(){ + getLocalDataSets: function(callback=null){ var datasets =[]; fs.readdir(this.profilepath(), function (err, files) { //handling error if (err) { return console.log('Unable to scan directory: ' + err); } - //listing all files using forEach files.forEach(function (file) { - console.log(file); if (file.match('db\..*\.json')){ - var key = file.replace('.json',''); - var data = this.getPreference(file); - if (data){ - datasets.push({"key":key,"name":data.name}); - } + console.log(file); + datasets.push(file.replace('.json','')); } - - }); - return datasets; + callback(datasets); }); - return datasets; }, - getsysinfo(){ + getsysinfo: function(){ return { "hostname": os.hostname(), "userdir": os.homedir(),