-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added encryption for stored passwords, fix #47, minor gui fixes, remo…
…ved private/public access from operations table
- Loading branch information
Showing
34 changed files
with
507 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
dist/src/main/package/www/controllers/adf-widgets/adf-myc-cb/adf-myc-custom-buttons.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
49 changes: 49 additions & 0 deletions
49
dist/src/main/package/www/controllers/adf-widgets/adf-myc-cb/edit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
36 changes: 36 additions & 0 deletions
36
dist/src/main/package/www/controllers/adf-widgets/adf-myc-cb/view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.