@c8y/ng1-modules 1020.14.4 → 1020.14.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(n,e,i,t,o,r,c,s,a,d,u){var l,v=this,h=d("Enable/disable owner"),w=d("You don't have permission to admin this device.");function g(){r.hasId(v.device)&&(v.ownerInfoFetched=!1,o.canAdminMOs([v.device]).then(function(e){return v.canAdminDevice=e,v.canAdminDevice?n.resolve():(c.danger(w),n.reject())}).then(f).finally(function(){v.ownerInfoFetched=!0}))}function f(){return b(!1),i.getOwnerObject(_.get(v,"device.id"),{silentError:!0}).then(function(e){v.owner=e}).catch(function(e){e.serviceUser&&b(e.serviceUser),e.accessDenied&&(v.errorTooltipMessage=d("You don't have permission to enable/disable this owner user.")),e.notFound&&!e.serviceUser&&c.danger(u.getString('Device owner not found for device "{{name}}".',v.device)),e.accessDenied||e.notFound||e.serviceUser||c.danger(r.getResErrorMessage(e))})}function m(){v.isEditMode?v.isEditMode=!1:(v.isEditMode=!0,l=_.get(v,"device.owner"))}function b(e){_.set(v,"serviceUserDevice",e)}function y(){var e,n;v.device.owner?(n=d("Change owner`owner may be a human or system user`"),e=d("Change owner`owner may be a human or system user`"),n={status:"warning",title:n,body:u.getString('You are about to change the owner of this device to "{{ owner }}" user. Unless the credentials on the device are changed accordingly this may interrupt the communication between this device and the platform. Do you want to proceed?',{owner:v.device.owner}),size:"sm",labels:{ok:e,cancel:d("Cancel")}},s(n).then(function(){m(),t.detail(_.get(v,"device.owner"),{silentError:!0}).then(function(){return i.save(_.pick(v.device,["id","owner"]))}).then(function(){c.success(d("Device owner updated."))}).then(function(){g()}).catch(function(){var e=v.device.owner;D(l),c.danger(u.getString('Could not find user "{{errorUser}}". Device owner reverted to "{{owner}}".',{errorUser:e,owner:v.device.owner}))})}).catch(function(){p()})):p()}function p(){m(),D(l)}function D(e){_.set(v,"device.owner",e)}_.assign(v,{$onChanges:function(e){e.device.currentValue&&g()},toggleOwner:function(){function
|
|
1
|
+
"use strict";!function(){function e(n,e,i,t,o,r,c,s,a,d,u){var l,v=this,h=d("Enable/disable owner"),w=d("You don't have permission to admin this device.");function g(){r.hasId(v.device)&&(v.ownerInfoFetched=!1,o.canAdminMOs([v.device]).then(function(e){return v.canAdminDevice=e,v.canAdminDevice?n.resolve():(c.danger(w),n.reject())}).then(f).finally(function(){v.ownerInfoFetched=!0}))}function f(){return b(!1),i.getOwnerObject(_.get(v,"device.id"),{silentError:!0}).then(function(e){v.owner=e}).catch(function(e){e.serviceUser&&b(e.serviceUser),e.accessDenied&&(v.errorTooltipMessage=d("You don't have permission to enable/disable this owner user.")),e.notFound&&!e.serviceUser&&c.danger(u.getString('Device owner not found for device "{{name}}".',v.device)),e.accessDenied||e.notFound||e.serviceUser||c.danger(r.getResErrorMessage(e))})}function m(){v.isEditMode?v.isEditMode=!1:(v.isEditMode=!0,l=_.get(v,"device.owner"))}function b(e){_.set(v,"serviceUserDevice",e)}function y(){var e,n;v.device.owner?(n=d("Change owner`owner may be a human or system user`"),e=d("Change owner`owner may be a human or system user`"),n={status:"warning",title:n,body:u.getString('You are about to change the owner of this device to "{{ owner }}" user. Unless the credentials on the device are changed accordingly this may interrupt the communication between this device and the platform. Do you want to proceed?',{owner:v.device.owner}),size:"sm",labels:{ok:e,cancel:d("Cancel")}},s(n).then(function(){m(),t.detail(_.get(v,"device.owner"),{silentError:!0}).then(function(){return i.save(_.pick(v.device,["id","owner"]))}).then(function(){c.success(d("Device owner updated."))}).then(function(){g()}).catch(function(){var e=v.device.owner;D(l),c.danger(u.getString('Could not find user "{{errorUser}}". Device owner reverted to "{{owner}}".',{errorUser:e,owner:v.device.owner}))})}).catch(function(){p()})):p()}function p(){m(),D(l)}function D(e){_.set(v,"device.owner",e)}_.assign(v,{$onChanges:function(e){e.device.currentValue&&g()},toggleOwner:function(e){function n(){v.owner.enabled=!t}var t=e.target.checked,o=_.get(v,"device.id");o&&v.canAdminDevice||n();var e=d(t?"Enable owner":"Disable owner"),r=d(t?"You are about to enable this device owner. Do you want to proceed?":"You are about to disable this device owner, this user will be locked and logged out of the platform. Do you want to proceed?"),r={title:e,body:r,status:"danger",size:"sm",labels:{ok:e,cancel:d("Cancel")}};s(r).then(function(){return i.setOwnerEnabled(o,t).then(function(e){v.owner=e,c.success(d("Owner status updated."))}).catch(n)}).catch(n)},toggleEdit:m,getTooltip:function(){return v.errorTooltipMessage?"":h},keyPressHandler:function(e){return a.handle(e,y,p)},save:y,cancel:p,shouldShowToggle:function(){return!v.isEditMode&&v.ownerInfoFetched&&!v.serviceUserDevice}})}e.$inject=["$q","$scope","c8yInventory","c8yUser","c8yPermissions","c8yBase","c8yAlert","c8yModal","keyboardKeyHandler","gettext","gettextCatalog"],angular.module("c8y.deviceStatus").component("ownerStatus",{controller:e,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/ownerStatus.html",bindings:{device:"<"}})}();
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div
|
|
2
|
+
class="d-flex a-i-center separator-top"
|
|
3
|
+
style="min-height: 36px"
|
|
4
|
+
>
|
|
2
5
|
<div
|
|
3
6
|
class="col-xs-5 text-12 d-flex a-i-center p-l-0 p-r-4 text-medium flex-no-shrink"
|
|
4
7
|
ng-hide="vm.isEditMode"
|
|
5
8
|
>
|
|
6
9
|
<p translate>Owner</p>
|
|
7
10
|
</div>
|
|
8
|
-
<div
|
|
9
|
-
|
|
11
|
+
<div
|
|
12
|
+
class="col-xs-7 p-l-4 p-r-0 flex-grow d-flex a-i-center"
|
|
13
|
+
ng-hide="vm.isEditMode"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
class="flex-no-shrink p-l-4 d-flex a-i-center"
|
|
17
|
+
ng-if="vm.shouldShowToggle()"
|
|
18
|
+
>
|
|
10
19
|
<label
|
|
11
20
|
class="c8y-switch c8y-switch--inline"
|
|
12
21
|
aria-label="{{ vm.getTooltip() | translate }}"
|
|
@@ -17,52 +26,63 @@
|
|
|
17
26
|
>
|
|
18
27
|
<input
|
|
19
28
|
type="checkbox"
|
|
20
|
-
ng-click="vm.toggleOwner()"
|
|
29
|
+
ng-click="vm.toggleOwner($event)"
|
|
30
|
+
data-cy="ownerStatus-toogle-owner"
|
|
21
31
|
ng-model="vm.owner.enabled"
|
|
22
32
|
ng-disabled="!(vm.canAdminDevice && vm.owner)"
|
|
23
33
|
/>
|
|
24
34
|
<span></span>
|
|
25
35
|
</label>
|
|
26
36
|
</div>
|
|
27
|
-
<span
|
|
37
|
+
<span
|
|
38
|
+
class="text-truncate"
|
|
39
|
+
title="{{ vm.device.owner }}"
|
|
40
|
+
ng-show="!vm.isEditMode"
|
|
41
|
+
>
|
|
28
42
|
{{ vm.device.owner }}
|
|
29
43
|
</span>
|
|
30
44
|
<button
|
|
31
45
|
class="btn btn-dot m-l-auto"
|
|
32
|
-
type="button"
|
|
33
46
|
aria-label="{{ 'Edit' | translate }}"
|
|
34
47
|
uib-tooltip="{{ 'Edit' | translate }}"
|
|
35
48
|
tooltip-popup-delay="500"
|
|
36
49
|
tooltip-trigger="'mouseenter'"
|
|
50
|
+
type="button"
|
|
37
51
|
ng-show="!vm.isEditMode && vm.canAdminDevice"
|
|
38
52
|
ng-click="vm.toggleEdit()"
|
|
39
53
|
>
|
|
40
54
|
<i c8y-icon="pencil"></i>
|
|
41
55
|
</button>
|
|
42
56
|
</div>
|
|
43
|
-
<div
|
|
57
|
+
<div
|
|
58
|
+
class="fit-w"
|
|
59
|
+
ng-show="vm.isEditMode"
|
|
60
|
+
>
|
|
44
61
|
<div class="input-group">
|
|
45
62
|
<input
|
|
46
63
|
class="form-control"
|
|
47
|
-
ng-model="vm.device.owner"
|
|
48
64
|
placeholder="{{ 'e.g.' | translate }} device_{{ 'exampleUser' | translate }}"
|
|
65
|
+
ng-model="vm.device.owner"
|
|
49
66
|
ng-keyup="vm.keyPressHandler($event)"
|
|
50
67
|
/>
|
|
51
68
|
<div class="input-group-btn">
|
|
52
69
|
<button
|
|
53
70
|
class="btn btn-dot"
|
|
54
|
-
type="button"
|
|
55
71
|
title="{{ 'Save' | translate }}"
|
|
72
|
+
type="button"
|
|
56
73
|
ng-click="vm.save()"
|
|
57
74
|
>
|
|
58
|
-
<i
|
|
75
|
+
<i
|
|
76
|
+
class="text-success"
|
|
77
|
+
c8y-icon="check"
|
|
78
|
+
></i>
|
|
59
79
|
</button>
|
|
60
80
|
</div>
|
|
61
81
|
<div class="input-group-btn">
|
|
62
82
|
<button
|
|
63
83
|
class="btn btn-dot btn-dot--danger"
|
|
64
|
-
type="button"
|
|
65
84
|
title="{{ 'Cancel' | translate }}"
|
|
85
|
+
type="button"
|
|
66
86
|
ng-click="vm.cancel()"
|
|
67
87
|
>
|
|
68
88
|
<i c8y-icon="times"></i>
|