-
Notifications
You must be signed in to change notification settings - Fork 0
/
double_1.json
25 lines (25 loc) · 10.2 KB
/
double_1.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"alias": "doube_slider2",
"name": "Double Slider",
"descriptor": {
"type": "rpc",
"sizeX": 9.5,
"sizeY": 12,
"resources": [
{
"url": "//cdn.bootcss.com/noUiSlider/8.5.1/nouislider.min.css",
"isModule": false
},
{
"url": "//cdn.bootcss.com/noUiSlider/8.5.1/nouislider.js",
"isModule": false
}
],
"templateHtml": "<div class=\"slider\"></div>\n",
"templateCss": "#container {\n padding: 20px;\n}\n\n.slider {\n margin-right: 40px\n}\n\n.noUi-tooltip {\n display: none;\n}\n.noUi-active .noUi-tooltip {\n display: block;\n}\n\n.noUi-connect {\n\tbackground: red;\n}\n\n\n",
"controllerScript": "self.onInit = function() {\n container = self.ctx.$container;\n var scope = self.ctx.$scope;\n var settings = self.ctx.settings;\n var sliderColor = settings.sliderBackgroundColor || tinycolor('green').lighten(2).toRgbString();\n var orientation = 'horizontal';\n if (settings.orientation == \"1\")\n {\n orientation = 'vertical';\n $('.slider', self.ctx.$container)[0].style.height = (parseInt((self.ctx.height), 10)-15)+'px' ;\n $('.slider', self.ctx.$container)[0].style.marginLeft = (parseInt((self.ctx.width), 10) / 2 -30) + 'px';\n $('.slider', self.ctx.$container)[0].style.marginTop = '-20px';\n }\n else\n {\n $('.slider', self.ctx.$container)[0].style.marginLeft = '0px';\n //Align Slider in to the middle of the container\n\n $('.slider', self.ctx.$container)[0].style.marginTop = (parseInt((self.ctx.height), 10) / 2 -30) + 'px';\n }\n \n \n \n \n var slider = $('.slider', self.ctx.$container);\n noUiSlider.create(slider[0], {\n\t start: [settings.sliderInitMinValue || 20, settings.sliderInitMaxValue || 25],\n\t tooltips: [true,true],\n\t range: { min: settings.sliderMinValue || 0, max: settings.sliderMaxValue || 100 },\n\t orientation: orientation,\n step: settings.sliderStepWidth || 1,\n connect: true\n });\n \n slider[0].noUiSlider.on('change.one', sliderValueChanged);\n\n function sliderValueChanged(values, handle, unencoded, tap, positions, noUiSlider) \n {\n var method = settings.sliderMaxChangeRequestMethod;\n \n //Get the Handle which has been used\n if (handle === 0)\n method = settings.sliderMinChangeRequestMethod;\n var paramsBody = values[handle];\n \n \n \n self.ctx.controlApi.sendTwoWayCommand(method, \n paramsBody, scope.requestTimeout)\n .subscribe(\n function success(responseBody) {\n \n }\n );\n }\n \n \n \n $('.noUi-connect', self.ctx.$container)[0].style.background = sliderColor;\n\n if (!settings.sliderHideTooltip)\n {\n document.getElementsByClassName('noUi-tooltip')[0].style.display = \"block\";\n document.getElementsByClassName('noUi-tooltip')[1].style.display = \"block\";\n }\n \n function requestMaxStatus() {\n method = settings.sliderMaxStatusRequestMethod;\n paramsBody = \"\";\n self.ctx.controlApi.sendTwoWayCommand(method, \n paramsBody, \n scope.requestTimeout)\n .subscribe(\n function success(responseBody) {\n slider[0].noUiSlider.set( [null,parseFloat(responseBody)]); \n }\n );\n }\n \n function requestMinStatus() {\n method = settings.sliderMinStatusRequestMethod;\n paramsBody = \"\";\n self.ctx.controlApi.sendTwoWayCommand(method, \n paramsBody, \n scope.requestTimeout)\n .subscribe(\n function success(responseBody) {\n slider[0].noUiSlider.set([parseFloat(responseBody), null]);\n \n }\n )\n }\n \n \n requestMaxStatus()\n requestMinStatus()\n}\n\n\n\n\nself.onResize = function() {\n var settings = self.ctx.settings;\n var orientation = 'horizontal';\n if (settings.orientation == \"1\")\n {\n orientation = 'vertical';\n $('.slider', self.ctx.$container)[0].style.height = (parseInt((self.ctx.height), 10)-15)+'px' ;\n $('.slider', self.ctx.$container)[0].style.marginLeft = (parseInt((self.ctx.width), 10) / 2 -30) + 'px';\n $('.slider', self.ctx.$container)[0].style.marginTop = '-20px';\n }\n else\n {\n $('.slider', self.ctx.$container)[0].style.marginLeft = '0px';\n //Align Slider in to the middle of the container\n\n $('.slider', self.ctx.$container)[0].style.marginTop = (parseInt((self.ctx.height), 10) / 2 -30) + 'px';\n }\n}\n\nself.onDestroy = function() {\n}\n",
"settingsSchema": "{\n \"schema\": {\n \"type\": \"object\",\n \"title\": \"Settings\",\n \"properties\": {\n \n \"requestTimeout\": {\n \"title\": \"RPC request timeout\",\n \"type\": \"number\",\n \"default\": 500\n },\n \"sliderBackgroundColor\": {\n \"title\": \"Slider background color\",\n \"type\": \"string\",\n \"default\": \"#008a00\"\n },\n \"sliderHideTooltip\": {\n \"title\": \"Slider hide tooltip\",\n \"type\": \"boolean\",\n \"default\": true\n },\n \"sliderStepWidth\": {\n \"title\": \"Slider step width\",\n \"type\": \"number\",\n \"default\": 1\n },\n \"sliderMinValue\": {\n \"title\": \"Slider min. Value\",\n \"type\": \"number\",\n \"default\": 1\n },\n \"sliderMaxValue\": {\n \"title\": \"Slider max. Value\",\n \"type\": \"number\",\n \"default\": 100\n },\n \"sliderInitMinValue\": {\n \"title\": \"Slider initialization min. Value\",\n \"type\": \"number\",\n \"default\": 20\n },\n \"sliderInitMaxValue\": {\n \"title\": \"Slider initialization max. Value\",\n \"type\": \"number\",\n \"default\": 25\n },\n \"orientation\": {\n \"title\": \"Orientation\",\n \"type\": \"string\",\n \"enum\": [\n \"0\",\n \"1\"],\n \"default\": \"0\"\n },\n \"sliderMaxChangeRequestMethod\": {\n \"title\": \"Change request max. Value Method\",\n \"type\": \"string\",\n \"default\": \"setTempertureOFFThreshold\"\n },\n \"sliderMaxStatusRequestMethod\": {\n \"title\": \"Status request max. Value Method\",\n \"type\": \"string\",\n \"default\": \"getTempertureOFFThreshold\"\n },\n \"sliderMinChangeRequestMethod\": {\n \"title\": \"Change request min. Value Method\",\n \"type\": \"string\",\n \"default\": \"setTempertureONThreshold\"\n },\n \"sliderMinStatusRequestMethod\": {\n \"title\": \"Status request min. Value Method\",\n \"type\": \"string\",\n \"default\": \"getTempertureONThreshold\"\n }\n },\n \"required\": [\n \"requestTimeout\",\n \"sliderHideTooltip\",\n \"sliderMinValue\",\n \"sliderMaxValue\",\n \"sliderInitMinValue\",\n \"sliderMaxValue\",\n \"sliderStepWidth\",\n \"sliderBackgroundColor\",\n \"orientation\",\n \"sliderMaxChangeRequestMethod\",\n \"sliderMaxStatusRequestMethod\",\n \"sliderMinChangeRequestMethod\",\n \"sliderMinStatusRequestMethod\"\n ]\n },\n \"form\": [\n \"requestTimeout\",\n \"sliderHideTooltip\",\n \"sliderMinValue\",\n \"sliderMaxValue\",\n \"sliderInitMinValue\",\n \"sliderInitMaxValue\",\n \"sliderStepWidth\",\n {\n \"key\": \"sliderBackgroundColor\",\n \"type\": \"color\"\n },\n {\n \"key\": \"orientation\",\n \"type\": \"select\",\n \"titleMap\": [{\n \"value\": \"0\",\n \"name\": \"Horizontal\"\n },\n {\n \"value\": \"1\",\n \"name\": \"Vertical\"\n }]\n },\n \"sliderMaxChangeRequestMethod\",\n \"sliderMaxStatusRequestMethod\",\n \"sliderMinChangeRequestMethod\",\n \"sliderMinStatusRequestMethod\"\n ]\n}",
"dataKeySettingsSchema": "{}\n",
"defaultConfig": "{\"targetDeviceAliases\":[],\"showTitle\":true,\"backgroundColor\":\"#fff\",\"color\":\"rgba(0, 0, 0, 0.87)\",\"padding\":\"0px\",\"settings\":{\"requestTimeout\":500,\"sliderHideTooltip\":true,\"sliderMinValue\":1,\"sliderMaxValue\":100,\"sliderInitMinValue\":20,\"sliderInitMaxValue\":25,\"sliderStepWidth\":1,\"sliderBackgroundColor\":\"#4a148c\",\"sliderMaxChangeRequestMethod\":\"setTempertureONThreshold\",\"sliderMaxStatusRequestMethod\":\"getTempertureONThreshold\",\"sliderMinChangeRequestMethod\":\"setTempertureOFFThreshold\",\"sliderMinStatusRequestMethod\":\"getTempertureOFFThreshold\",\"orientation\":\"1\"},\"title\":\"Double Slider\",\"showTitleIcon\":true,\"titleIcon\":\"more_horiz\",\"iconColor\":\"rgba(0, 0, 0, 0.87)\",\"iconSize\":\"24px\",\"titleTooltip\":\"eeee\",\"dropShadow\":true,\"enableFullscreen\":true,\"widgetStyle\":{},\"titleStyle\":{\"fontSize\":\"16px\",\"fontWeight\":400},\"useDashboardTimewindow\":true,\"displayTimewindow\":true,\"showLegend\":false,\"actions\":{}}"
}
}