From ff6b91e1ce2f91f5a09eac17c6cc729ee7a4cb72 Mon Sep 17 00:00:00 2001 From: IS Date: Tue, 16 May 2017 10:27:26 +0200 Subject: [PATCH] lang.js file - decode name of keys to texts --- README.md | 8 ++++ public/app/app.js | 94 ++++++++++++++++++++++++++++---------- public/app/common.js | 22 ++++++++- public/app/lang.js | 58 +++++++++++++++++++++++ public/index.html | 2 + public/views/config.html | 6 ++- public/views/logging.html | 24 +--------- public/views/services.html | 51 +++++++++++++++++---- server.js | 53 +++++++++------------ 9 files changed, 229 insertions(+), 89 deletions(-) create mode 100644 README.md create mode 100644 public/app/lang.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..3bda3d6 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +Indoor WebConfig tool +===================== + +RASPBERRY Pi 2 Model B: + - NodeJs + - ExpressJs + - AngularJs + - Bootstrap diff --git a/public/app/app.js b/public/app/app.js index 8028afc..767d92a 100644 --- a/public/app/app.js +++ b/public/app/app.js @@ -16,6 +16,10 @@ app.factory("services", ['$http', function($http) { return $http.get(serviceBase + 'all'); } + obj.getFileContent = function(name, dir='tmp') { + return $http.get(serviceBase + 'getfile/' + dir + '/' + name); + } + obj.applyCfgChanges = function() { return $http.post(serviceBase + 'apply'); } @@ -28,23 +32,6 @@ app.factory("services", ['$http', function($http) { }); }; -/* - obj.getCustomer = function(customerID){ - return $http.get(serviceBase + 'customer?id=' + customerID); - } - - obj.insertCustomer = function (customer) { - return $http.post(serviceBase + 'insertCustomer', customer).then(function (results) { - return results; - }); - }; - - obj.deleteCustomer = function (id) { - return $http.delete(serviceBase + 'deleteCustomer?id=' + id).then(function (status) { - return status.data; - }); - }; -//*/ return obj; }]); @@ -53,24 +40,28 @@ app.controller('configCtrl', function ($scope, services) { $scope.keys = []; $scope.updateCfg = 0; + $scope.langtxt = function(key) { + return langstr[key] || key; + }; + services.getIniItems().then(function(data){ $scope.customers = data.data; $scope.keys = Object.keys(data.data); }); $scope.changeItem = function(sect,item,vals) { - console.log('changeItem:',sect,item,vals); +// console.log('changeItem:',sect,item,vals); $scope.updateCfg = 1; services.updateIniItem(sect,item,vals).then(function(data){ - console.log('changeItem:',data); +// console.log('changeItem:',data); }); }; $scope.applyCfgChanges = function() { - console.log('applyCfgChanges:'); +// console.log('applyCfgChanges:'); $scope.updateCfg = 0; services.applyCfgChanges().then(function(data){ - console.log('applyCfgChanges:',data); +// console.log('applyCfgChanges:',data); }); }; }); @@ -80,10 +71,65 @@ app.controller('logCtrl', function ($scope, services) { }); app.controller('serviceCtrl', function ($scope, services) { + $scope.msg = ''; + $scope.logs = []; + $scope.cntrs = {}; + $scope.keys = []; + + $scope.langtxt = function(key) { + return langstr[key] || key; + }; + + $scope.reinitScopes = function() { + $scope.msg = ''; + $scope.logs = []; + $scope.cntrs = {}; + $scope.keys = []; + }; + $scope.restartApp = function() { - console.log('restartApp:'); +// console.log('restartApp:'); + $scope.reinitScopes(); services.applyCfgChanges().then(function(data){ - console.log('restartApp:',data); +// console.log('restartApp:',data); + $scope.msg = data.data; + }); + }; + + $scope.getCallCntrs = function() { + console.log('getCallCntrs:'); + $scope.reinitScopes(); + services.getFileContent('call-cntr.dat').then(function(data){ + console.log('getCallCntrs:',data.data); + $scope.cntrs = data.data; + $scope.keys = Object.keys(data.data); + }); + }; + + $scope.getCallLog = function() { +// console.log('getCallLog:'); + $scope.reinitScopes(); + services.getFileContent('call-log.dat').then(function(data){ +// console.log('getCallLog:',data.data); + $scope.logs = data.data; + }); + }; + + $scope.getAppLog = function() { +// console.log('getAppLog:'); + $scope.reinitScopes(); + services.getFileContent('app-log.dat').then(function(data){ +// console.log('getAppLog:',data.data); + $scope.logs = data.data; + }); + }; + + $scope.getSipLog = function() { +// console.log('getSipLog:'); + $scope.reinitScopes(); + services.getFileContent('sip-log.dat').then(function(data){ +// console.log('getSipLog:',data.data); + $scope.logs = data.data; }); }; }); @@ -94,7 +140,7 @@ app.controller('mainCtrl', function ($scope, services) { var timerFlag = 0; $scope.getStatusApp = function() { - console.log('getStatusApp:'); +// console.log('getStatusApp:'); services.getAppStatus().then(function(data){ var d = data.data; console.log('getAppStatus:',d); diff --git a/public/app/common.js b/public/app/common.js index d4232fe..66835de 100644 --- a/public/app/common.js +++ b/public/app/common.js @@ -17,4 +17,24 @@ function highlightMenuItem() { } logActive = 0; // logging activity flag -} \ No newline at end of file +} + +/** select content for Copy&Paste */ +function selectText(element) { + var doc = document + , text = doc.getElementById(element) + , range, selection; + + if (doc.body.createTextRange) { + range = doc.body.createTextRange(); + range.moveToElementText(text); + range.select(); + } else + if (window.getSelection) { + selection = window.getSelection(); + range = doc.createRange(); + range.selectNodeContents(text); + selection.removeAllRanges(); + selection.addRange(range); + } +} diff --git a/public/app/lang.js b/public/app/lang.js new file mode 100644 index 0000000..eb5cd8c --- /dev/null +++ b/public/app/lang.js @@ -0,0 +1,58 @@ + +var langstr = { + // services: + 'in': 'Incomming calls' + , 'out': 'Outgoing calls' + , 'noansw': 'No answered calls' + , 'noresp': 'No responded calls' + + // config: + , 'screen_saver': 'Screen saver [min]' + , 'back_light': 'Turn display off [0/1]' + , 'watches': 'Use analog/digital watches' + , 'brightness': 'Brightness [20..255]' + , 'dnd_mode': 'Do not disturb mode [True/False]' + , 'sip_mode': 'SIP mode [server/peer-to-peer]' + , 'sip_username': 'SIP user name' + , 'sip_server_addr': 'SIP server address' + , 'sip_p4ssw0rd': 'Password for SIP autentification' + , 'sip_port': 'SIP port' + , 'sip_authentication_name': 'SIP authentication name' + , 'ringtone': 'Ringing tone [tone1.wav/tone2.wav/oldphone.wav]' + , 'volume': 'Speaker volume [20-100]' + , 'micvolume': 'Microphone volume [20-100]' + , 'screen_mode': 'Number of screens [1/2/4]' + , 'screen_orientation': 'Screen orientation [0/90/180/270]' + , 'server_ip_address_1': 'Outdoor device address 1' + , 'server_ip_address_2': 'Outdoor device address 2' + , 'server_ip_address_3': 'Outdoor device address 3' + , 'server_ip_address_4': 'Outdoor device address 4' + , 'server_stream_1': 'Video stream URL address 1' + , 'server_stream_2': 'Video stream URL address 2' + , 'server_stream_3': 'Video stream URL address 3' + , 'server_stream_4': 'Video stream URL address 4' + , 'sip_call1': 'SIP call IP/number 1' + , 'sip_call2': 'SIP call IP/number 2' + , 'sip_call3': 'SIP call IP/number 3' + , 'sip_call4': 'SIP call IP/number 4' + , 'picture_1': 'Picture format 1 [fill/4:3/16:9]' + , 'picture_2': 'Picture format 2 [fill/4:3/16:9]' + , 'picture_3': 'Picture format 3 [fill/4:3/16:9]' + , 'picture_4': 'Picture format 4 [fill/4:3/16:9]' + , 'broadcast': 'Broadcast address' + , 'netmask': 'Network mask' + , 'network': 'Network address' + , 'dns': 'DNS server address' + , 'ipaddress': 'Device IP address' + , 'gateway': 'Gateway address' + , 'inet': 'IP address type [dhcp/static]' + , 'serial': 'RPi board serial number' + , 'app_name': 'Application name' + , 'app_ver': 'Version' + , 'uptime': 'PRi operaton uptime' + , 'licencekey': 'Licence key string' + , 'regaddress': 'Licence key email address' + , 'masterpwd': 'Master password' + , '': '' + +}; \ No newline at end of file diff --git a/public/index.html b/public/index.html index b9c9327..fbe97b3 100644 --- a/public/index.html +++ b/public/index.html @@ -13,6 +13,8 @@ + +