aboutsummaryrefslogtreecommitdiff
path: root/web/static
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-31 14:09:39 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-31 14:09:39 +0100
commit803148d5a23afe207fb5de9ac73c986a324feb9c (patch)
treeb887cede3f56e4e24c05dd9640dbd01afc2b9367 /web/static
parent02d6e77bd180cbbf6f7f6e1a69c670e922d8204d (diff)
downloaddiller-server-803148d5a23afe207fb5de9ac73c986a324feb9c.tar.gz
diller-server-803148d5a23afe207fb5de9ac73c986a324feb9c.tar.bz2
diller-server-803148d5a23afe207fb5de9ac73c986a324feb9c.tar.xz
diller-server-803148d5a23afe207fb5de9ac73c986a324feb9c.zip
core:
o Improved transaction handling. web: o Supporting changing a device's name and description.
Diffstat (limited to 'web/static')
-rw-r--r--web/static/app/app.js15
-rw-r--r--web/static/app/templates/device-edit-attribute.modal.html23
-rw-r--r--web/static/app/templates/device.html14
3 files changed, 39 insertions, 13 deletions
diff --git a/web/static/app/app.js b/web/static/app/app.js
index 134afc8..fedfb54 100644
--- a/web/static/app/app.js
+++ b/web/static/app/app.js
@@ -17,15 +17,18 @@
var ctrl = this;
ctrl.attributeName = attributeName;
+ ctrl.label = attributeName.substr(0, 1).toUpperCase() + attributeName.substr(1);
ctrl.value = outer.device[attributeName];
- ctrl.value = 'yoyo';
+ ctrl.error = 'fail';
ctrl.update = function () {
-
DillerRpc.patchDevice(outer.device.id, {attribute: attributeName, value: ctrl.value})
.then(function (res) {
+ outer.device = res.data.device;
$uibModalInstance.close({});
+ }, function (res) {
+ ctrl.error = res.data.message;
});
};
},
@@ -69,7 +72,6 @@
}
function DlTimestampDirective() {
- console.log('DlTimestampDirective', DlTimestampDirective);
return {
restrict: 'E',
scope: {
@@ -123,12 +125,14 @@
});
}
+ function run($log) {
+ window.console = $log;
+ }
+
function DillerConfig() {
var head = document.getElementsByTagName('head')[0];
var base = head.getElementsByTagName('base')[0];
- console.log('base =', base);
var baseUrl = base.href.replace(/\/$/, '');
- console.log('baseUrl =', baseUrl);
return {
baseUrl: baseUrl
};
@@ -137,6 +141,7 @@
angular
.module('Diller', ['ngRoute', 'ui.bootstrap'])
.config(config)
+ .run(run)
.filter('timestamp', TimestampFilter)
.directive('dlTimestamp', DlTimestampDirective)
.directive('dlDots', DlDotsDirective)
diff --git a/web/static/app/templates/device-edit-attribute.modal.html b/web/static/app/templates/device-edit-attribute.modal.html
index e471e5f..fc22d7b 100644
--- a/web/static/app/templates/device-edit-attribute.modal.html
+++ b/web/static/app/templates/device-edit-attribute.modal.html
@@ -2,12 +2,27 @@
<button type="button" class="close" ng-click="$dismiss()">
<span>&times;</span>
</button>
- <h4 class="modal-title">Edit device {{attributeName}}</h4>
+ <h4 class="modal-title">Edit device {{ctrl.attributeName}}</h4>
</div>
<div class="modal-body">
- <p>One fine body&hellip;</p>
+ <form>
+ <fieldset class="form-group">
+ <label for="attribute" style="text-transform: capitalize">{{ctrl.label}}</label>
+ <input type="email" class="form-control" id="attribute" ng-model="ctrl.value"/>
+ </fieldset>
+ </form>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-secondary" ng-click="$dismiss()">Cancel</button>
- <button type="button" class="btn btn-primary" ng-click="ctrl.update()">Update</button>
+
+ <div class="row">
+ <div class="col-sm-7 text-left">
+ <p class="form-control-static">
+ {{ctrl.error}}
+ </p>
+ </div>
+ <div class="col-sm-5">
+ <button type="button" class="btn btn-secondary" ng-click="$dismiss()">Cancel</button>
+ <button type="button" class="btn btn-primary" ng-click="ctrl.update()">Update</button>
+ </div>
+ </div>
</div>
diff --git a/web/static/app/templates/device.html b/web/static/app/templates/device.html
index d126f1d..270c461 100644
--- a/web/static/app/templates/device.html
+++ b/web/static/app/templates/device.html
@@ -56,19 +56,25 @@
<dl class="dl-horizontalX">
<dt class="col-sm-3">Created</dt>
- <dd class="col-sm-9">{{ctrl.device.created_timestamp | date}}</dd>
+ <dd class="col-sm-9">&nbsp;
+ {{ctrl.device.created_timestamp | date}}</dd>
<dt class="col-sm-3">Name</dt>
<dd class="col-sm-9">
- &nbsp;{{ctrl.device.name}}
-
+ {{ctrl.device.name}}
<a ng-click="ctrl.editDeviceAttribute('name')" class="pull-right">
<i class="fa fa-edit"/>
</a>
</dd>
<dt class="col-sm-3">Description</dt>
- <dd class="col-sm-9">&nbsp;{{ctrl.device.description}}</dd>
+ <dd class="col-sm-9">
+ {{ctrl.device.description}}
+
+ <a ng-click="ctrl.editDeviceAttribute('description')" class="pull-right">
+ <i class="fa fa-edit"/>
+ </a>
+ </dd>
</dl>
<h3>Properties</h3>