Skip to content

Commit

Permalink
lang.js file - decode name of keys to texts
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 committed May 16, 2017
1 parent 4b3708c commit ff6b91e
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 89 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Indoor WebConfig tool
=====================

RASPBERRY Pi 2 Model B:
- NodeJs
- ExpressJs
- AngularJs
- Bootstrap
94 changes: 70 additions & 24 deletions public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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;
}]);

Expand All @@ -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);
});
};
});
Expand All @@ -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;
});
};
});
Expand All @@ -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);
Expand Down
22 changes: 21 additions & 1 deletion public/app/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,24 @@ function highlightMenuItem() {
}

logActive = 0; // logging activity flag
}
}

/** 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);
}
}
58 changes: 58 additions & 0 deletions public/app/lang.js
Original file line number Diff line number Diff line change
@@ -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'
, '': ''

};
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>

<script src="app/lang.js"></script>

<style type="text/css">
ul>li, a{ cursor: pointer; }
/* Set black background color, white text and some padding */
Expand Down
6 changes: 5 additions & 1 deletion public/views/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ <h3>Configuration</h3>
<li ng-repeat="k in keys">
<h4><span class="label label-info">{{ k }}</span></h4>
<div ng-repeat="(ke,va) in customers[k]" class="row">
<span class="col-sm-3 text-right">{{ ke }}</span>
<span ng-hide="(va.indexOf('button_') > -1) || (ke === 'uptime')">
<span class="col-sm-4 text-right">
{{langtxt(ke)}}
</span>
<input type="text" maxlength="128" class="col-sm-6"
ng-change="changeItem(k,ke,somename_$$k.id)"
ng-model-options="{ updateOn: 'blur' }"
ng-model="somename_$$k.id" ng-init="somename_$$k.id=va"
ng-disabled="(va.indexOf('button_') > -1) || (ke.indexOf('app_') > -1) || (ke.indexOf('_log') > 0) || (ke === 'uptime') || (ke === 'serial') || (ke === 'screen_orientation')" />
</span>
</div>
</li>
</ul>
Expand Down
24 changes: 2 additions & 22 deletions public/views/logging.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,8 @@ <h3>Logging</h3>

<script>

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);
}
}

$(function() {
console.log( "ready!", window.location.hostname );
// console.log( "ready!", window.location.hostname );

highlightMenuItem();

Expand All @@ -59,8 +40,7 @@ <h3>Logging</h3>
$('<span>' + data + '</span><br/>').appendTo('#logcontent');
$('div#logcontent').animate({"scrollTop": $('div#logcontent')[0].scrollHeight}, 1);
}
catch(err) {
}
catch(err) { }
}
});

Expand Down
51 changes: 42 additions & 9 deletions public/views/services.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,56 @@
<div class="container-fluid">
<div class="row content">
<h3>Services</h3>
</div>
</div>

<div class="row content">
<div class="col-sm-8 col-sm-offset-2 text-left">
<button class="btn btn-md" type="button" ng-click="restartApp()"> Restart RPi GUI application </button>
</div>
</div>

<div class="col-sm-12 text-left" ng-show="logs.length > 0">
<div class="row content">
<div class="col-sm-2 text-right">
<p><button class="btn btn-md" type="button" title="Display application log" ng-click="getAppLog()">
App log
</button></p>
<p><button class="btn btn-md" type="button" title="Display call counters" ng-click="getCallCntrs()">
Call counters
</button></p>
<p><button class="btn btn-md" type="button" title="Display call log" ng-click="getCallLog()">
Call log
</button><p/>
<p><button class="btn btn-md" type="button" title="Display SIP log" ng-click="getSipLog()">
SIP log
</button></p>
<p><button class="btn btn-md" type="button" title="Restart RPi GUI application" ng-click="restartApp()">
Restart GUI app
</button></p>
</div>

<div class="col-sm-4 col-sm-offset-4 text-center" ng-show="logs.length == 0">No Services found</div>
</div>
<div class="col-sm-offset-2 text-left">
<div ng-show="msg != ''"> {{ msg }} </div>

<div class="col-sm-offset-10" ng-show="logs.length > 0">
<button id="btnSelec" class="btn btn-md" type="button" title="Select content for Copy & Paste"> Select </button>
</div>
<div ng-show="logs.length > 0" id="logcontent">
<div ng-repeat="v in logs"> {{ v }} </div>
</div>

<div ng-show="keys.length > 0">
<div ng-repeat="(k,v) in cntrs">
<span class="col-sm-3 text-right">{{langtxt(k)}}</span>: {{ v }}
</div>
</div>
</div>
</div>

<script>
$(function() {
highlightMenuItem();

$('#logcontent').css({'height':'450px', 'overflow':'auto', 'margin-top':'16px', 'border':'1px solid black'});

$('#btnSelec').click(function(){
// console.log(this);
selectText('logcontent');
});

});
</script>
Loading

0 comments on commit ff6b91e

Please sign in to comment.