angular.module("c8y.deviceDetailIdentity").controller("deviceDetailIdentityCtrl",["$scope","$routeParams","c8yIdentity","c8yModal","c8yAlert","gettext","gettextCatalog","c8yGainsightService",function(t,e,n,a,r,d,i,l){var o=e.deviceId,e=d("The external ID links the device information and the physical world (for example, serial number, IMEI).\n\nIf for some reason the hardware needs to be replaced, the external ID must also be replaced with the appropriate information.\n\nWith this procedure the new hardware is still linked to the information that was created by its predecessor.");function c(e){t.ids=e}function s(){h(),delete t.newId}function h(){return n.listExternalIds(o).then(c)}t.onClickDelete=function(e){a({title:d("Delete external ID"),body:i.getString('You are about to delete the external ID "{{externalId}}" of the type "{{type}}". Do you want to proceed?',e),labels:{ok:d("Delete")},status:"danger"}).then(_.partial(n.deleteIdentity,e)).then(h).then(_.partial(r.success,d("External ID deleted.")))},t.create=function(e){_.some(t.ids,{externalId:e.externalId,type:e.type})?(r.danger(i.getString('Could not add identity. External ID "{{externalId}}" of the type "{{type}}" already exists.',e)),l.triggerEvent("dmIdentityManagement",{action:"addFailure",name:"externalId"})):n.createIdentity(o,e).then(s).then(_.partial(r.success,d("External ID added."))).then(l.triggerEvent("dmIdentityManagement",{action:"addSuccess",name:"externalId"}))},t.paging={refresh:!0},t.refresh=function(){t.refreshLoading=!0,h().finally(function(){t.refreshLoading=!1})},t.add=function(){t.newId={}},t.cancel=function(){delete t.newId},t.helpText=e,h()}]);