From 02d6e77bd180cbbf6f7f6e1a69c670e922d8204d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 31 Oct 2015 12:04:28 +0100 Subject: web: o Starting on edit button for device name. --- web/static/app/app.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'web/static/app/app.js') diff --git a/web/static/app/app.js b/web/static/app/app.js index 6fa1f71..134afc8 100644 --- a/web/static/app/app.js +++ b/web/static/app/app.js @@ -5,10 +5,35 @@ ctrl.devices = devices.data.devices; } - function DeviceController(device) { + function DeviceController($uibModal, device, DillerRpc) { var ctrl = this; ctrl.device = device.data.device; + + ctrl.editDeviceAttribute = function (attributeName) { + var outer = ctrl; + $uibModal.open({ + controller: function ($uibModalInstance) { + var ctrl = this; + + ctrl.attributeName = attributeName; + ctrl.value = outer.device[attributeName]; + + ctrl.value = 'yoyo'; + + ctrl.update = function () { + + DillerRpc.patchDevice(outer.device.id, {attribute: attributeName, value: ctrl.value}) + .then(function (res) { + $uibModalInstance.close({}); + }); + }; + }, + controllerAs: 'ctrl', + bindToController: true, + templateUrl: 'app/templates/device-edit-attribute.modal.html' + }); + } } function PropertyController($timeout, $route, DillerRpc, device, values) { @@ -110,7 +135,7 @@ } angular - .module('Diller', ['ngRoute']) + .module('Diller', ['ngRoute', 'ui.bootstrap']) .config(config) .filter('timestamp', TimestampFilter) .directive('dlTimestamp', DlTimestampDirective) -- cgit v1.2.3