Skip to content
This repository was archived by the owner on Jun 4, 2023. It is now read-only.

Commit 22cf7e6

Browse files
committed
admin: when editing a display, allow to select group
On mobile, drag'n'drop is not supported. Hence the alternate way.
1 parent 6441873 commit 22cf7e6

File tree

6 files changed

+49
-17
lines changed

6 files changed

+49
-17
lines changed

app/scripts/controllers/display.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ angular.module('dashkiosk.controllers')
33
'use strict';
44

55
})
6-
.controller('EditDisplayCtrl', function($scope) {
6+
.controller('EditDisplayCtrl', function($scope, $q) {
77
'use strict';
88

99
var realDisplay = $scope.$parent.display,
@@ -18,17 +18,33 @@ angular.module('dashkiosk.controllers')
1818
}
1919
return false;
2020
});
21-
realDisplay
22-
.$update(modified)
23-
.then(function() {
24-
$scope.$hide();
21+
22+
var deferred = $q.defer(),
23+
promise = deferred.promise;
24+
if (!_.isEmpty(_.omit(modified, 'group'))) {
25+
promise.then(function() {
26+
return realDisplay.$update(_.omit(modified, 'group'));
27+
});
28+
}
29+
if (_.has(modified, 'group')) {
30+
promise.then(function() {
31+
return $scope.groups[modified.group].$attach(realDisplay.name);
2532
});
33+
}
34+
promise.then(function() {
35+
$scope.$hide();
36+
});
37+
deferred.resolve(true);
38+
return promise;
2639
};
2740

2841
// Destroy the display
2942
$scope.delete = function() {
30-
realDisplay.$delete();
31-
$scope.$hide();
43+
realDisplay
44+
.$delete()
45+
.then(function() {
46+
$scope.$hide();
47+
});
3248
};
3349

3450
});

app/scripts/directives/display.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ angular.module('dashkiosk.directives')
66
restrict: 'E',
77
replace: true,
88
scope: {
9-
display: '='
9+
display: '=',
10+
groups: '='
1011
},
1112
templateUrl: 'display.html',
1213
controller: 'DisplayCtrl'

app/scripts/directives/group.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ angular.module('dashkiosk.directives')
66
restrict: 'E',
77
replace: true,
88
scope: {
9-
group: '='
9+
group: '=',
10+
groups: '='
1011
},
1112
templateUrl: 'group.html',
1213
controller: 'GroupCtrl'

app/views/display.edit.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,26 @@ <h4 class="modal-title" ng-bind="display.name"></h4>
2323
placeholder="Description" name="description"
2424
ng-model="display.description">
2525
</div>
26-
<div class="input-group" ng-class="{'has-error': displayForm.viewport.$invalid}">
27-
<span class="input-group-addon"><span title="Viewport" class="glyphicon glyphicon-fullscreen"></span></span>
28-
<input type="text" class="form-control" viewport
29-
autocapitalize="off" autocorrect="off"
30-
placeholder="Viewport size (height × width)" name="viewport"
31-
ng-model="display.viewport">
26+
<div class="row">
27+
<div class="col-md-6">
28+
<div class="input-group" ng-class="{'has-error': displayForm.viewport.$invalid}">
29+
<span class="input-group-addon"><span title="Viewport" class="glyphicon glyphicon-tag"></span></span>
30+
<select class="form-control"
31+
name="group" required
32+
ng-options="g.id as g.name for (k, g) in groups"
33+
ng-model="display.group">
34+
</select>
35+
</div>
36+
</div>
37+
<div class="col-md-6">
38+
<div class="input-group" ng-class="{'has-error': displayForm.viewport.$invalid}">
39+
<span class="input-group-addon"><span title="Viewport" class="glyphicon glyphicon-fullscreen"></span></span>
40+
<input type="text" class="form-control" viewport
41+
autocapitalize="off" autocorrect="off"
42+
placeholder="Viewport size (height × width)" name="viewport"
43+
ng-model="display.viewport">
44+
</div>
45+
</div>
3246
</div>
3347
</div>
3448
<div class="modal-footer">

app/views/group.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div class="displays">
2323
<dk-display
2424
ng-repeat="display in group.displays | orderBy:['-connected','name']"
25-
display="display">
25+
display="display" groups="groups">
2626
</dk-display>
2727
</div>
2828
</div>

app/views/groups.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ul data-ui-element="dk-group-list">
22
<li ng-repeat="group in groups" class="col-md-6">
3-
<dk-group group="group">
3+
<dk-group group="group" groups="groups">
44
</dk-group>
55
</li>
66
<li class="col-md-2">

0 commit comments

Comments
 (0)