Skip to content

Commit

Permalink
added encryption for stored passwords, fix #47, minor gui fixes, remo…
Browse files Browse the repository at this point in the history
…ved private/public access from operations table
  • Loading branch information
jkandasa committed Apr 14, 2016
1 parent 991d9d9 commit fcabac9
Show file tree
Hide file tree
Showing 34 changed files with 507 additions and 80 deletions.
10 changes: 10 additions & 0 deletions dist/src/main/package/www/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,16 @@ input.mc-color-steel-blue{
margin:0px;
}

/* custom buttons */
#custom-buttons-wrapper .btn {
margin: 3px 0px 3px 3px;
font-weight: bold;
font-size: 21px;
}
.adf-myc-cb-margin{
margin-top:5px;
margin-bottom:5px;
}



Expand Down
20 changes: 16 additions & 4 deletions dist/src/main/package/www/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var myControllerModule = angular.module('myController',[
'adf.widget.myc-sensors-mixed-graph',
'adf.widget.myc-sensors-bullet-graph',
'adf.widget.myc-heat-map',
'adf.widget.myc-custom-buttons',
'adf.widget.myc-dsi',
'adf.widget.myc-time',
'adf.widget.myc-sunrisetime',
Expand Down Expand Up @@ -562,10 +563,10 @@ myControllerModule.controller('McNavBarCtrl', function($scope, $location, $trans

//Show hide main menu
$scope.showHideMainMenu = function () {
if(mchelper.user.hideMenu){
mchelper.user.hideMenu = false;
if(mchelper.userSettings.hideMenu){
mchelper.userSettings.hideMenu = false;
}else{
mchelper.user.hideMenu = true;
mchelper.userSettings.hideMenu = true;
}
//Update mchelper
CommonServices.saveMchelper(mchelper);
Expand Down Expand Up @@ -597,7 +598,11 @@ myControllerModule.run(function ($rootScope, $state, $location, $http, mchelper,
angular.element( document.querySelector( '#rootView' ) ).removeClass( "container-fluid top-buffer-m top-buffer-nm" );
}else{
angular.element( document.querySelector( '#rootId' ) ).removeClass( "login-pf" );
angular.element( document.querySelector( '#rootView' ) ).addClass( "container-fluid" );
if(!mchelper.userSettings.hideMenu){
angular.element( document.querySelector( '#rootView' ) ).addClass( "container-fluid top-buffer-m");
}else{
angular.element( document.querySelector( '#rootView' ) ).addClass( "container-fluid top-buffer-nm");
}
}
var requireLogin = toState.data.requireLogin;
// redirect to login page if not logged in
Expand Down Expand Up @@ -642,6 +647,7 @@ myControllerModule.controller('LoginController',
mchelper.languages = langResponse;
SettingsFactory.getUserSettings(function(userNativeSettings){
mchelper.userSettings = userNativeSettings;
mchelper.userSettings.hideMenu = false;
//Store all the configurations locally
CommonServices.saveMchelper(mchelper);
});
Expand Down Expand Up @@ -735,6 +741,12 @@ myControllerModule.filter('mcHtml', function($sce) {
};
});

myControllerModule.filter('slice', function() {
return function(arr, start, end) {
return (arr || []).slice(start, end);
};
});

/**
* i18n Language support
* */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// don't forget to declare this service module as a dependency in your main app constructor!
//http://js2.coffee/#coffee2js
//https://coderwall.com/p/r_bvhg/angular-ui-bootstrap-alert-service-for-angular-js

'use strict';

angular.module('adf.widget.myc-custom-buttons', [])
.config(function(dashboardProvider){
dashboardProvider
.widget('mycCustomBtns', {
title: 'Sensor custom buttons',
description: 'Create custom buttons',
templateUrl: 'controllers/adf-widgets/adf-myc-cb/view.html',
controller: 'mycCusBtnsController',
controllerAs: 'mycCBtns',
config: {
variableId:null,
refreshTime:30,
minBtnHeight:30,
minBtnWidth:90,
buttonsJson:"[\n]",
},
edit: {
templateUrl: 'controllers/adf-widgets/adf-myc-cb/edit.html',
controller: 'mycSenVarsEditController',
controllerAs: 'mycCBtnsEdit',
}
});
})
.controller('mycCusBtnsController', function($scope, $interval, config, mchelper, $filter, SensorsFactory, TypesFactory, CommonServices){
var mycCBtns = this;

mycCBtns.showLoading = true;
mycCBtns.isSyncing = true;
mycCBtns.variable = {};
$scope.tooltipEnabled = false;
$scope.hideVariableName=true;
$scope.cs = CommonServices;
mycCBtns.buttons = angular.fromJson(config.buttonsJson);


function loadVariable(){
mycCBtns.isSyncing = true;
SensorsFactory.getVariables({'ids':config.variableId}, function(response){
if(response.length > 0){
mycCBtns.variable = response[0];
}
mycCBtns.isSyncing = false;
if(mycCBtns.showLoading){
mycCBtns.showLoading = false;
}
});
};

function updateVariable(){
if(mycCBtns.isSyncing){
return;
}else if(config.variableId){
loadVariable();
}
}

//load variables initially
loadVariable();
//updateVariables();

//Update Variable / Send Payload
$scope.updateSVariable = function(button){
var variable = angular.copy(mycCBtns.variable);
variable.value = button.payload;
SensorsFactory.updateVariable(variable, function(){
//update Success
loadVariable();
},function(error){
displayRestError.display(error);
});
};

// refresh every second
var promise = $interval(updateVariable, config.refreshTime*1000);

// cancel interval on scope destroy
$scope.$on('$destroy', function(){
$interval.cancel(promise);
});
}).controller('mycCusBtnsEditController', function($scope, $interval, config, mchelper, $filter, TypesFactory, CommonServices){
var mycCBtnsEdit = this;
mycCBtnsEdit.cs = CommonServices;
mycCBtnsEdit.variables = TypesFactory.getSensorVariables();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
Copyright (C) 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<form role="form">
<div class="form-group">
<label>{{ 'REFRESH_TIME_SECONDS' | translate }}</label>
<input type="text" class="form-control" id="refreshTime" placeholder="{{'REFRESH_TIME_SECONDS' | translate}}" ng-model="config.refreshTime" pf-validation="mycCBtnsEdit.cs.isNumber(input)" required>
<span class="help-block">{{ 'VALIDATION_ERROR_NUMBER' | translate }}</span>
</div>

<div class="form-group">
<label>{{ 'SENSOR_VARIABLE' | translate }}</label>
<select id="mycCBtns" class="form-control" pf-select data-live-search="true" ng-model="config.variableId" required>
<option value="" ng-hide="true"></option>
<option ng-repeat="res in mycCBtnsEdit.variables" ng-bind-html="res.displayName | mcResourceRepresentation" value="{{res.id}}" ng-selected="res.id.toString().indexOf(config.variableId) != -1"></option>
</select>
</div>

<legend><small>{{ 'BUTTON_SETTINGS' | translate }}</small></legend>

<div class="form-group">
<label class="mc-margin-right">{{ 'MINIMUM_HEIGHT' | translate }}</label>
<input type="text" id="height-min" class="mc-margin-right" placeholder="{{'MINIMUM_HEIGHT' | translate}}" ng-model="config.minBtnHeight" pf-validation="mycCBtnsEdit.cs.isNumber(input)" required>
<span class="help-block">{{ 'VALIDATION_ERROR_NUMBER' | translate }}</span>
<label class="mc-margin-right">{{ 'MINIMUM_WIDTH' | translate }}</label>
<input type="text" id="width-min" placeholder="{{'MINIMUM_WIDTH' | translate}}" ng-model="config.minBtnWidth" pf-validation="mycCBtnsEdit.cs.isNumber(input)" required>
<span class="help-block">{{ 'VALIDATION_ERROR_NUMBER' | translate }}</span>
</div>

<div class="form-group">
<label>{{ 'JSON' | translate }}</label>
<textarea class="form-control" rows="12" style="resize:none" ng-model="config.buttonsJson" required ></textarea>
</div>

</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
Copyright (C) 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Loading icon disaplay -->
<div ng-show="mycCBtns.showLoading">
<div ng-include src="'partials/common-html/loading-sm.html'"></div>
</div>

<div ng-hide="mycCBtns.showLoading">
<div ng-if="config.variableId" >
<span><span ng-bind-html="mycCBtns.variable.resourceName | mcResourceRepresentation"></span> <span class="badge">{{mycCBtns.variable.value}} {{mycCBtns.variable.unit}}</span></span>
<hr class="adf-myc-cb-margin">
<div id="custom-buttons-wrapper" class="row-fluid">
<button ng-repeat="button in mycCBtns.buttons track by $index" ng-click="updateSVariable(button)" class="btn"
ng-class="button.btnType ? 'btn-{{button.btnType}}' : 'btn-default'"
ng-style="{'min-width':'{{config.minBtnWidth}}px', 'min-height':'{{config.minBtnHeight}}px'}"
ng-bind-html="button.name"></button>
</div>
</div>
<!-- display no items configured -->
<div ng-if="!config.variableId" ng-include src="'partials/common-html/no-items-filter-sm.html'"></div>
</div>
9 changes: 5 additions & 4 deletions dist/src/main/package/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<script src="controllers/adf-widgets/adf-myc-sbg/adf-myc-sensors-bullet-graph.js"></script>
<script src="controllers/adf-widgets/adf-myc-dsi/adf-myc-display-static-image.js"></script>
<script src="controllers/adf-widgets/adf-myc-hm/adf-myc-heat-map.js"></script>
<script src="controllers/adf-widgets/adf-myc-cb/adf-myc-custom-buttons.js"></script>

<!-- Google api for maps: https://github.com/allenhwkim/angularjs-google-maps -->
<script src="libs/angularjs-google-maps/ng-map.min.js"></script>
Expand Down Expand Up @@ -239,8 +240,8 @@
<li ng-class="{ active: $state.current.name.indexOf('settingsProfile') == 0 }">
<a ui-sref="settingsProfileUpdate"><i class="pficon pficon-user"></i> {{ 'PROFILE' | translate }}</a>
</li>
<li ng-if="mchelper.user.hideMenu"><a href="" ng-click="showHideMainMenu()"><i class="fa fa-expand fa-lg"></i> {{ 'SHOW_MENU' | translate }}</a></li>
<li ng-if="!mchelper.user.hideMenu"><a href="" ng-click="showHideMainMenu()"><i class="fa fa-compress fa-lg"></i> {{ 'HIDE_MENU' | translate }}</a></li>
<li ng-if="mchelper.userSettings.hideMenu"><a href="" ng-click="showHideMainMenu()"><i class="fa fa-expand fa-lg"></i> {{ 'SHOW_MENU' | translate }}</a></li>
<li ng-if="!mchelper.userSettings.hideMenu"><a href="" ng-click="showHideMainMenu()"><i class="fa fa-compress fa-lg"></i> {{ 'HIDE_MENU' | translate }}</a></li>
<li>
<a ui-sref="login"><i class="fa fa-sign-out fa-lg"></i> {{ 'LOG_OUT' | translate }}</a><!-- Logout Link -->
</li>
Expand All @@ -249,7 +250,7 @@
</ul>

<!-- Main Menu (header type)-->
<ul ng-if="!mchelper.user.hideMenu" class="nav navbar-nav navbar-primary persistent-secondary">
<ul ng-if="!mchelper.userSettings.hideMenu" class="nav navbar-nav navbar-primary persistent-secondary">
<!-- Dashboard -->
<li ng-class="{ active: $state.current.url.indexOf('/dashboard') == 0 }">
<a ui-sref="dashboard"><i class="fa fa-tachometer fa-lg"></i> {{ 'DASHBOARDS' | translate }}</a>
Expand Down Expand Up @@ -311,7 +312,7 @@
</div><!-- /.navbar-collapse -->
</nav>

<div class="container-fluid" ng-class="mchelper.user.hideMenu ? 'top-buffer-nm' : 'top-buffer-m'" id="rootView">
<div class="container-fluid" ng-class="{'top-buffer-nm' : mchelper.userSettings.hideMenu, 'top-buffer-m' : !mchelper.userSettings.hideMenu}" id="rootView">
<div ui-view></div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions dist/src/main/package/www/languages/mc_locale_gui-ca_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"BLOCKS": "Blocks",
"BROKET_HOST": "Host amfitrió",
"BUNDLE": "Bundle",
"BUTTON_SETTINGS": "Button settings:",
"CANCEL": "Cancelar",
"CARDINAL": "Cardinal",
"CARDINAL_CLOSED": "Cardinal tancat",
Expand Down Expand Up @@ -236,6 +237,7 @@
"JAVA_HOME": "Java Home",
"JAVA_VENDOR_URL": "Java Vendor Url",
"JAVA_VIRTUAL_MACHINE_SPECIFICATION": "Especificación Java Virtual Machine",
"JSON": "JSON",
"LANGUAGE": "Llenguatge ",
"LAST_6_HOURS": "Ultimes 6 hores",
"LAST_12_HOURS": "Ultimes 12 hores",
Expand Down Expand Up @@ -275,6 +277,8 @@
"MESSAGE_TYPE": "Tipus de missatge",
"METRIC": "Metric",
"METRICS": "Metrics",
"MINIMUM_HEIGHT": "Minimum height",
"MINIMUM_WIDTH": "Minimum width",
"MINUTES": "Minuts",
"MIN_MAX": "Min/Max",
"MODIFIY_SENSOR_VARIABLES_MAPPING": "Modificación sensor i variables",
Expand Down
4 changes: 4 additions & 0 deletions dist/src/main/package/www/languages/mc_locale_gui-da_dk.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"BLOCKS": "Blocks",
"BROKET_HOST": "Broker host",
"BUNDLE": "Bundle",
"BUTTON_SETTINGS": "Button settings:",
"CANCEL": "Cancel",
"CARDINAL": "Cardinal",
"CARDINAL_CLOSED": "Cardinal closed",
Expand Down Expand Up @@ -236,6 +237,7 @@
"JAVA_HOME": "Java Home",
"JAVA_VENDOR_URL": "Java Vendor Url",
"JAVA_VIRTUAL_MACHINE_SPECIFICATION": "Java Virtual Machine Specification",
"JSON": "JSON",
"LANGUAGE": "Language",
"LAST_6_HOURS": "Last 6 hours",
"LAST_12_HOURS": "Last 12 hours",
Expand Down Expand Up @@ -275,6 +277,8 @@
"MESSAGE_TYPE": "Message type",
"METRIC": "Metric",
"METRICS": "Metrics",
"MINIMUM_HEIGHT": "Minimum height",
"MINIMUM_WIDTH": "Minimum width",
"MINUTES": "Minutes",
"MIN_MAX": "Min/Max",
"MODIFIY_SENSOR_VARIABLES_MAPPING": "Modify sensor and variables mapping",
Expand Down

0 comments on commit fcabac9

Please sign in to comment.