@jkandasa, thanks for helping me out.
currently i have this as template:
<style type="text/css">
.wrap {
color: #fff;
background: #171F30;
margin: 0 auto;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
</style>
<div class="wrap">
<div class="colorPicker"></div>
</div>
<script>
var colorPicker = new iro.ColorPicker(".colorPicker", {
width: 320,
height: 320,
color: {r: 255, g: 0, b: 0},
anticlockwise: true,
borderWidth: 1,
borderColor: "#fff",
});
colorPicker.on("color:change", function(color) {
console.log("hex: " + color.hexString);
});
</script>
and this for the script:
var colorSensor = mcApi.uidTag().getByUid("hi-wz-rgb-1").getResource();
var uuid = mcApi.utils().getUUID();
i tried to copy the "Sensors" controller from github modify it to make for a "Sensors2" controller an pasted that into the "AngularJS custom controllers":
'use strict';
angular.module('adf.widget.myc-sen-vars2', [])
.config(function(dashboardProvider){
dashboardProvider
.widget('mycSenVars2', {
title: 'Sensors2',
description: 'Monitor and change sensors state',
templateUrl: 'controllers/adf-widgets/adf-myc-sen-vars/view.html?mcv=${mc.gui.version}',
controller: 'mycSenVarsController2',
controllerAs: 'mycSenVars2',
config: {
variableIds:[],
showIcon: true,
itemsPerRow:"2",
refreshTime:30,
},
edit: {
templateUrl: 'controllers/adf-widgets/adf-myc-sen-vars/edit.html?mcv=${mc.gui.version}',
controller: 'mycSenVarsEditController2',
controllerAs: 'mycSenVarsEdit2',
}
});
})
.controller('mycSenVarsController2', function($scope, $interval, config, mchelper, $filter, SensorsFactory, TypesFactory, CommonServices){
var mycSenVars2 = this;
mycSenVars2.showLoading = true;
mycSenVars2.isSyncing = true;
mycSenVars2.variables = {};
$scope.tooltipEnabled = false;
$scope.hideVariableName= !config.showIcon;
$scope.cs = CommonServices;
//HVAC heater options - HVAC flow state
$scope.hvacOptionsFlowState = TypesFactory.getHvacOptionsFlowState();
//HVAC heater options - HVAC flow mode
$scope.hvacOptionsFlowMode = TypesFactory.getHvacOptionsFlowMode();
//HVAC heater options - HVAC fan speed
$scope.hvacOptionsFanSpeed = TypesFactory.getHvacOptionsFanSpeed();
//Defined variable types list
$scope.definedVariableTypes = CommonServices.getSensorVariablesKnownList();
//update rgba color
$scope.updateRgba = function(variable){
variable.value = CommonServices.rgba2hex(variable.rgba);
$scope.updateVariable(variable);
};
function loadVariables(){
mycSenVars2.isSyncing = true;
SensorsFactory.getVariables({'ids':config.variableIds}, function(response){
mycSenVars2.variables = response;
mycSenVars2.isSyncing = false;
if(mycSenVars2.showLoading){
mycSenVars2.showLoading = false;
}
});
};
function updateVariables(){
if(mycSenVars2.isSyncing){
return;
}else if(config.variableIds.length > 0){
loadVariables();
}
}
//load variables initially
loadVariables();
//updateVariables();
//Update Variable / Send Payload
$scope.updateVariable = function(variable){
SensorsFactory.updateVariable(variable, function(){
//update Success
},function(error){
displayRestError.display(error);
});
};
// refresh every second
var promise = $interval(updateVariables, config.refreshTime*1000);
// cancel interval on scope destroy
$scope.$on('$destroy', function(){
$interval.cancel(promise);
});
}).controller('mycSenVarsEditController2', function($scope, $interval, config, mchelper, $filter, TypesFactory, CommonServices){
var mycSenVarsEdit2 = this;
mycSenVarsEdit2.cs = CommonServices;
mycSenVarsEdit2.variables = TypesFactory.getSensorVariables();
});
but this does not show up at all in the dashboard.
that's why i am asking for a simple example for a custom angular controller as i am not too familiar with angular yet.