@c8y/ng1-modules 1017.85.0 → 1017.86.0
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,
|
|
1
|
+
"use strict";!function(){function e(n,e,c,o,t,r,s,a,i,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,t.canAdminMOs([v.device]).then(function(e){return v.canAdminDevice=e,v.canAdminDevice?n.resolve():(s.danger(w),n.reject())}).then(f).finally(function(){v.ownerInfoFetched=!0}))}function f(){return m(!1),c.getOwnerObject(_.get(v,"device.id"),{silentError:!0}).then(function(e){v.owner=e}).catch(function(e){e.serviceUser&&m(e.serviceUser),e.accessDenied&&(v.errorTooltipMessage=d("You don't have permission to enable/disable this owner user.")),e.notFound&&!e.serviceUser&&s.danger(u.getString('Device owner not found for device "{{name}}".',v.device)),e.accessDenied||e.notFound||e.serviceUser||s.danger(r.getResErrorMessage(e))})}function b(){v.isEditMode?v.isEditMode=!1:(v.isEditMode=!0,l=_.get(v,"device.owner"))}function m(e){_.set(v,"serviceUserDevice",e)}function y(){if(v.device.owner){var e=d("Change owner"),n=d("Change owner"),t={status:"warning",title:e,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:n,cancel:d("Cancel")}};a(t).then(function(){b(),o.detail(_.get(v,"device.owner"),{silentError:!0}).then(function(){return c.save(_.pick(v.device,["id","owner"]))}).then(function(){s.success(d("Device owner updated."))}).then(function(){g()}).catch(function(){var e=v.device.owner;D(l),s.danger(u.getString('Could not find user "{{errorUser}}". Device owner reverted to "{{owner}}".',{errorUser:e,owner:v.device.owner}))})}).catch(function(){p()})}else p()}function p(){b(),D(l)}function D(e){_.set(v,"device.owner",e)}_.assign(v,{$onChanges:function(e){e.device.currentValue&&g()},toggleOwner:function(){var e=v.owner.enabled,n=_.get(v,"device.id"),t=function(){v.owner.enabled=!e};n&&v.canAdminDevice||t();var o=d(e?"Enable owner":"Disable owner"),r=d(e?"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?"),i={title:o,body:r,status:"danger",size:"sm",labels:{ok:o,cancel:d("Cancel")}};a(i).then(function(){return c.setOwnerEnabled(n,e).then(function(e){v.owner=e,s.success(d("Owner status updated."))}).catch(function(){return t()})}).catch(function(){return t()})},toggleEdit:b,getTooltip:function(){return v.errorTooltipMessage?"":h},keyPressHandler:function(e){return i.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:"<"}})}();
|