UNPKG

domotz-remote-pawn

Version:

Domotz Agent

18 lines (17 loc) 22.2 kB
/** This file is part of Domotz Agent. * Copyright (C) 2021 Domotz Ltd * * Domotz Agent is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Domotz Agent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Domotz Agent. If not, see <http://www.gnu.org/licenses/>. **/ !function(){"use strict";angular.module("agent",["ionic","ngResource","zxcvbn","domotzEntities","domotzAngularWidgets","agent.template","agent.nettools","angularMoment","ngLodash","agent.http","pascalprecht.translate","ngclipboard"]).constant("ANGULAR_WIDGETS_PATH","../node_modules/domotz-angular-widgets/").constant("APPLICATION_IDENTIFIER","remote_pawn").constant("UTM_MEDIUM","agent").constant("AUTO_LOGIN",!1).constant("IP_ADDRESS_API",[]).constant("amTimeAgoConfig",{withoutSuffix:!0}).config(["$stateProvider","$urlRouterProvider","$translateProvider",function(t,e,n){n.useStaticFilesLoader({prefix:"resources/i18n/locale-",suffix:".json"});var o="en-EN";n.preferredLanguage(o),n.useSanitizeValueStrategy("sce"),e.otherwise("/agentinfo");e=["agentStatus","pawnUtilsService",function(t,e){var n=e.data.status,e="Agent";n&&"adi"===n.tenant&&(e="Capture"),document.title=e}];t.state("action_required",{url:"/action_required",abstract:!0,templateUrl:"partials/action_required/action_required.html",controller:"ActionController as ctrl",resolve:{i18nLoaded:["$translate",function(t){return t.use(o)}],agentStatus:["pawnUtilsService","$state","$q",function(t,e,n){var o=n.defer();return t.getStatus().finally(function(){t.actionRequired()||t.isRestricted()?o.resolve(t.data.status):(o.reject(),e.go("app.agentinfo"))}),o.promise}]}}).state("action_required.snap_instructions",{url:"/snap_instructions",views:{main:{templateUrl:"partials/action_required/snap_instructions.html"}}}).state("restricted",{url:"/restricted",template:'<ion-view class="dmt-dark-background-view"></ion-view>',controller:"RestrictedController as vm",resolve:{i18nLoaded:["$translate",function(t){return t.use(o)}],agentStatus:["pawnUtilsService","$state","$q",function(t,e,n){var o=n.defer();return t.getStatus().finally(function(){t.actionRequired()?(o.resolve(),e.go("action_required.snap_instructions")):t.isRestricted()?o.resolve(t.data.status):(o.reject(),e.go("app.agentinfo"))}),o.promise}],setAgentTitle:e}}).state("app",{url:"",abstract:!0,templateUrl:"partials/layout/menu.html",controller:"MenuController as ctrl",resolve:{i18nLoaded:["$translate",function(t){return t.use(o)}],agentStatus:["pawnUtilsService","$state","$q",function(t,e,n){var o=n.defer();return t.getStatus().finally(function(){t.actionRequired()?(o.resolve(),e.go("action_required.snap_instructions")):t.isRestricted()?(o.reject(),e.go("restricted")):o.resolve(t.data.status)}),o.promise}],setAgentTitle:e,agentInfo:["pawnAgentService",function(t){return t.fetchInfo()}]},params:{k:null,kid:null,id:null,cell:null,mobile:null}}).state("app.agentinfo",{url:"/agentinfo",views:{menuContent:{templateUrl:"resources/templates/agentinfo.html",controller:"AgentController as agentCtrl"}}}).state("app.netinfo",{url:"/netinfo",views:{menuContent:{templateUrl:"partials/nettools/netinfo.html"}}})}]),angular.module("agent.template",[])}(),function(){"use strict";angular.module("agent.http",[]).config(["$httpProvider",function(t){t.interceptors.push("httpRequestHandlerService")}])}(),function(){"use strict";angular.module("agent.nettools",[])}(),function(){"use strict";angular.module("agent").controller("ActionController",["$rootScope","$scope","$state","globalLoaderService","pawnUtilsService","$timeout","dmtPopup","translationService",function(t,e,n,o,a,r,i,s){var c=this;c.snapActions=["snap connect domotzpro-agent-publicstore:firewall-control","snap connect domotzpro-agent-publicstore:network-observe","snap connect domotzpro-agent-publicstore:network-setup-control","snap connect domotzpro-agent-publicstore:network-setup-observe","snap connect domotzpro-agent-publicstore:raw-usb","snap connect domotzpro-agent-publicstore:shutdown","snap connect domotzpro-agent-publicstore:system-observe","snap connect domotzpro-agent-publicstore:network-control"],c.restartAgent=function(){o.showLoader(s.getTranslationByKey("CHECKING_AGENT_STATUS")),a.restartAgent().then(function(){l(20)})};var l=function(t){0<t?a.getStatus().finally(function(){a.actionRequired()?r(function(){l(--t)},5e3):(o.hideLoader(),n.go("restricted.welcome"))}):(o.hideLoader(),i.alert({scope:e,title:s.getTranslationByKey("ERROR"),subTitle:s.getTranslationByKey("PROBLEM_WITH_THE_CHECK_PLEASE_RETRY")}))};c.onClipboardCopySuccess=function(){i.alert({iconClass:"icon-tick2",scope:e,title:s.getTranslationByKey("SUCCESS"),subTitle:s.getTranslationByKey("COMMANDS_COPIED_TO_CLIPBOARD")})}}])}(),function(){"use strict";angular.module("agent").controller("AgentController",["pawnAgentService","$state","$interval","$window","agentStatus","$stateParams","XORCipher","agentInfo",function(t,e,n,o,a,r,i,s){var c=this,l=r.k,u=r.kid,d=r.id,f=r.cell;c.isFromMobile=r.mobile;var a=/(.+:\/\/)?([^\/]+)(\/.*)*/i.exec(a.portal_api_endpoint),g=a[1]+a[2];!(c.webapp=function(){var t,e,n;null!==l&&null!==u&&null!==d&&null!==f?(t=Math.random().toString(36).substr(2,5),e=i.encode(t,l),n=i.encode(t,f),window.open(g+"/webapp/sso?a="+encodeURIComponent(e)+"&e="+encodeURIComponent(n)+"&id="+d+"&kid="+u+"&k="+encodeURIComponent(t)+(s&&s.id?"&agentid="+s.id:""),"_blank")):window.open(g+"/webapp/"+(s&&s.id?"?agentid="+s.id:""),"_blank")})===c.isFromMobile&&c.webapp(),c.email={value:"",focus:!1},c.password={value:"",focus:!1},c.errorOccurred=!1,c.errorMessage="",c.pawnAgentServiceData=t.data,c.getAgentName=function(){return t.getName()},c.getTimeZone=function(){return t.getTimeZone()},c.goToAgentInfo=function(){e.go("app.agentinfo")},c.openUrl=function(t){o.open(t,"_blank")},c.updateConnectivityInfo=function(){t.getConnectivityStatus().then(function(t){c.connectivity=t.status,"offline"===c.connectivity&&(c.offline_since=new Date((new Date).getTime()-1e3*t.offline_since).toISOString())})},c.updateConnectivityInfo(),n(function(){c.updateConnectivityInfo()},3e4)}])}(),function(){"use strict";angular.module("agent").factory("pawnAgentService",["$resource",function(e){var n={};return{fetchInfo:function(){var t=e("/api/v1/agent",{},{read:{method:"GET"}}).read().$promise;return t.then(function(t){n=t},function(t){n.error=(t.message,t.message)}),t},getName:function(){return n.display_name},getConnectivityStatus:function(){return e("/api/v1/connectivity",{},{read:{method:"GET"}}).read().$promise},getLocation:function(){return n.location},setAddress:function(t){n.location.address=t},getTimeZone:function(){return n.timezone},data:n}}])}(),function(){"use strict";angular.module("agent.http").factory("httpRequestHandlerService",[function(){return{request:function(t){return-1<t.url.indexOf("maps.googleapis.com")?(delete t.headers["X-Session-Token"],delete t.headers.Authorization):0!==t.url.indexOf("http")&&-1<t.url.indexOf("/api/v1/")&&(t.headers["X-API-Minor-Version"]="13"),t}}}])}(),function(){"use strict";angular.module("agent").controller("MenuController",["$stateParams",function(t){}])}(),function(){"use strict";angular.module("agent").factory("netToolsService",["$resource",function(t){var e=t("/api/v1/net-info"),n=t("/api/v1/mtr"),o=t("/api/v1/network-speed"),a=t("/api/v1/ndt-server",{timeout:5,attempts:6});return{fetchNetworkInfo:function(){return e.get().$promise},startMtrTest:function(t,e){return n.get({destination:t,count:e}).$promise},startSpeedTest:function(t){return o.get({"server-id":t}).$promise},fetchSpeedTestServer:function(){return a.get().$promise}}}])}(),function(){"use strict";angular.module("agent").factory("networkConfigService",["$resource","$timeout","$q",function(t,s,c){var o=t("/api/v1/vlan-config/:tag",{},{get:{timeout:45e3}}),r=t("/api/v1/network-config",{});return{fetchVlanConfig:function(){return o.query().$promise},addVlan:function(t,e,n){return o.save({tag:t,ip_address:e,netmask:n}).$promise},removeVlan:function(t){return o.delete({tag:t}).$promise},resetVlan:function(){return o.delete().$promise},setStaticIp:function(t,e,n,o,a){return r.save({ip_address:t,netmask:e,gateway:n,primary_dns:o,secondary_dns:a}).$promise},checkStaticIp:function(){return r.get().$promise},setDHCP:function(){return r.delete().$promise},checkResource:function t(e,n,o){var a=void 0===n?10:n,r=void 0===n?1:o,i=c.defer();return e.get().$promise.then(function(){i.resolve()}).catch(function(){0<a?s(function(){t(e,a-1,r+1).then(i.resolve,i.reject)},3e3):i.reject(!0)}),i.promise}}}])}(),function(){"use strict";angular.module("agent").controller("NetworkInfoController",["$scope","$rootScope","netToolsService","networkConfigService","$timeout","$ionicModal","$q","dmtPopup","globalLoaderService","$window","$location","$resource","pawnUtilsService","translationService",function(i,t,e,s,c,n,o,l,u,d,f,g,p,m){var T=this,a={title:m.getTranslationByKey("GENERIC_ALERT.TITLE"),subtitle:m.getTranslationByKey("GENERIC_ALERT.SUBTITLE")},r={16:"^255\\.255\\.(0|128|192|224|240|248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",17:"^255\\.255\\.(128|192|224|240|248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",18:"^255\\.255\\.(192|224|240|248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",19:"^255\\.255\\.(224|240|248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",20:"^255\\.255\\.(240|248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",21:"^255\\.255\\.(248|252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",22:"^255\\.255\\.(252|254)\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",23:"^255\\.255\\.254\\.0$|^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",24:"^255\\.255\\.255\\.(0|128|192|224|240|248|252|254|255)$",25:"^255\\.255\\.255\\.(128|192|224|240|248|252|254|255)$",26:"^255\\.255\\.255\\.(192|224|240|248|252|254|255)$",27:"^255\\.255\\.255\\.(224|240|248|252|254|255)$",28:"^255\\.255\\.255\\.(240|248|252|254|255)$",29:"^255\\.255\\.255\\.(248|252|254|255)$",30:"^255\\.255\\.255\\.(252|254|255)$",31:"^255\\.255\\.255\\.(254|255)$",32:"^255\\.255\\.255\\.255$"};T.networkInformation={loading:!1,error:!1,advancedConfig:!0,vlanConfig:[],dhcp:!0,data:{},big_networks:{error_message:m.getTranslationByKey("NETWORK_CONFIG.PLEASE_ENTER_VALID_NETMASK")}},i.netmaskRegex=r[22];var _=5e3;function v(){p.isNetworkConfigAvailable()?o.all([s.fetchVlanConfig(),s.checkStaticIp()]).then(function(t){T.networkInformation.advancedConfig=!0,T.networkInformation.vlanConfig=t[0],T.networkInformation.dhcp=t[1].dhcp,T.networkInformation.big_networks.enabled=t[1].big_networks.enabled,T.networkInformation.big_networks.netmask_bits=t[1].big_networks.netmask_bits,T.networkInformation.big_networks.enabled&&(T.networkInformation.big_networks.error_message=m.getTranslationByKey("NETWORK_CONFIG.PLEASE_ENTER_VALID_NETMASK_FOR_BIG_NETWORKS",{netmask_bits:t[1].big_networks.netmask_bits}),i.netmaskRegex=r[T.networkInformation.big_networks.netmask_bits])}).catch(function(t){T.networkInformation.advancedConfig=!1}).finally(u.hideLoader):T.networkInformation.advancedConfig=!1,e.fetchNetworkInfo().then(function(t){T.networkInformation.data=t}).catch(function(){T.networkInformation.data={},T.networkInformation.error=!0}).finally(function(){T.networkInformation.loading=!1})}function I(){if(T.networkInformation.data.local_network)for(var t=T.networkInformation.data.local_network,e=0;e<t.interfaces.length;e++)if("eth0"==t.interfaces[e].name)return{ip:angular.copy(t.interfaces[e].address),network:function(t){for(var e=[],n=0;n<4;n++){var o=Math.min(t,8);e.push(256-Math.pow(2,8-o)),t-=o}return e.join(".")}(t.interfaces[e].netmask)}}function E(){i.checkbox={1:!1,2:!1},i.checkboxError={1:!1,2:!1}}function h(){var t=angular.copy(T.networkInformation.data.local_network);i.modalData.focus={ip_address:!1,gateway:!1,primaryDns:!1,secondaryDns:!1},i.modalData.ip_address=I().ip,i.modalData.netmask=I().network,i.modalData.gateway=t.servers.gateway,i.modalData.primaryDns=0<t.servers.dns.length?t.servers.dns[0]:"",i.modalData.secondaryDns=1<t.servers.dns.length?t.servers.dns[1]:""}function y(){u.hideLoader(),l.alert({title:m.getTranslationByKey("NETWORK_CONFIG.CONFIGURATION_APPLIED"),subTitle:m.getTranslationByKey("NETWORKING_SERVICE_RESTARTING"),iconClass:"icon-tick2"}).then(function(){u.showLoader(m.getTranslationByKey("NETWORK_CONFIG.UPDATING_CONFIGURATION"),!0),c(function(){var t=g("/api/v1/status",{},{get:{timeout:1e4,method:"GET"}});s.checkResource(t).then(function(){v()})},_)})}T.fetchNetworkInfo=function(){T.networkInformation.loading||(T.networkInformation.loading=!0,T.networkInformation.error=!1,c(v,3e3))},T.fetchNetworkInfo(),i.$on("$destroy",function(){i.ifConfigModal&&i.ifConfigModal.remove(),i.vlanConfigModal&&i.vlanConfigModal.remove()}),i.modalData={},i.ipRegex="^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",i.ipSubnetRegex="^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[0]?[1-9][0-9]?)$",i.idRegex="^([1-9][0-9]{0,2}|[1-3][0-9][0-9][0-9]|40([0-8][0-9]|9[0-6]))$",E(),T.ifConfig=function(){i.formSubmitted=!1,T.networkInformation.data.local_network&&(n.fromTemplateUrl("/netConfigModal.html",{scope:i,animation:"slide-in-up"}).then(function(t){(i.ifConfigModal=t).show()}),i.toggleDhcp=function(t){t&&T.networkInformation.dhcp&&h()},i.showIfConfigModal=function(){i.ifConfigModal&&i.ifConfigModal.show()},i.hideIfConfigModal=function(){i.ifConfigModal&&i.ifConfigModal.hide()},h(),i.modalData.dhcp=angular.copy(T.networkInformation.dhcp),i.saveConfiguration=function(){function t(t){return o.test(t)}var e,n=!1,o=new RegExp(i.ipRegex),a=new RegExp(i.ipSubnetRegex),r=new RegExp(i.netmaskRegex);e=i.modalData.ip_address,a.test(e)&&t(i.modalData.gateway)&&t(i.modalData.primaryDns)&&t(i.modalData.secondaryDns)||(n=!0),r.test(i.modalData.netmask)?n?i.formSubmitted=!0:i.modalData.dhcp&&T.networkInformation.dhcp?i.hideIfConfigModal():(i.hideIfConfigModal(),l.confirm({cssClass:"dmt-destructive",title:m.getTranslationByKey("WARNING"),subTitle:m.getTranslationByKey("NETWORK_CONFIG.APPLYING_NEW_CONFIG_ARE_YOU_SURE"),okText:m.getTranslationByKey("YES_APPLY"),okType:"dmt-destructive"}).then(function(t){t&&(u.showLoader(m.getTranslationByKey("NETWORK_CONFIG.APPLYING_CONFIGURATION"),!0),(i.modalData.dhcp?s.setDHCP():s.setStaticIp(i.modalData.ip_address,i.modalData.netmask,i.modalData.gateway,i.modalData.primaryDns,i.modalData.secondaryDns)).then(function(){var t,n,e;i.modalData.dhcp?(u.hideLoader(),l.alert({title:m.getTranslationByKey("NETWORK_CONFIG.CONFIGURATION_APPLIED"),subTitle:m.getTranslationByKey("NETWORK_CONFIG.NETWORKING_SERVICE_RESTARTING"),iconClass:"icon-tick2"})):(t=m.getTranslationByKey("NETWORK_CONFIG.VERIFYING_CONFIGURATION"),e=5e3,p.isUbuntuCore()&&(t=m.getTranslationByKey("SYSTEM_RESTARTING"),n=100,e=2e4),u.showLoader(t,!0),c(function(){var t="http://"+i.modalData.ip_address+":"+f.port(),e=g(t+"/api/v1/status",{},{get:{timeout:1e4,method:"GET"}});s.checkResource(e,n).then(function(){d.location.href=t}).finally(u.hideLoader)},e))}).catch(function(t){u.hideLoader()}))})):n=!0})},T.form={},T.addVlan=function(){i.formSubmitted=!1,i.modalData.vlanId="",i.modalData.vlanIp="",i.modalData.vlanNetmask="",n.fromTemplateUrl("/vlanConfigModal.html",{scope:i,animation:"slide-in-up"}).then(function(t){(i.vlanConfigModal=t).show()}),i.toggleCheckbox=function(t){i.checkbox[t]&&(i.checkboxError[t]=!1)},i.showVlanConfigModal=function(){i.vlanConfigModal&&i.vlanConfigModal.show()},i.hideVlanConfigModal=function(){i.vlanConfigModal&&i.vlanConfigModal.hide()},E(),i.saveVlanConfiguration=function(){var t=new RegExp(i.idRegex),e=new RegExp(i.ipSubnetRegex),n=new RegExp(i.netmaskRegex),o=!1;t.test(i.modalData.vlanId)&&e.test(i.modalData.vlanIp)&&n.test(i.modalData.vlanNetmask)||(o=!0),i.checkbox[1]||(o=!0,i.checkboxError[1]=!0),i.checkbox[2]||(o=!0,i.checkboxError[2]=!0),o?i.formSubmitted=!0:(i.hideVlanConfigModal(),l.confirm({cssClass:"dmt-destructive",title:m.getTranslationByKey("WARNING"),subTitle:m.getTranslationByKey("NETWORK_CONFIG.APPLYING_NEW_CONFIG_ARE_YOU_SURE"),okText:m.getTranslationByKey("NETWORK_CONFIG.YES_ADD_VLAN"),okType:"dmt-destructive"}).then(function(t){t&&(u.showLoader(m.getTranslationByKey("VLAN_CONFIG.CREATING_VLAN"),!0),s.addVlan(i.modalData.vlanId,i.modalData.vlanIp,i.modalData.vlanNetmask).then(y).catch(function(t){u.hideLoader(),l.alert(a)}))}))}},T.remVlan=function(e,t){l.confirm({cssClass:"dmt-destructive",title:m.getTranslationByKey("VLAN_CONFIG.WANT_DELETE_VLAN"),subTitle:"<b>"+t+" (eth0."+e+")</b><br>"+m.getTranslationByKey("VLAN_CONFIG.ALL_RELATED_DEVICES_WILL_APPEAR_OFFLINE"),okText:m.getTranslationByKey("YES_DELETE"),okType:"dmt-destructive"}).then(function(t){t&&(u.showLoader(m.getTranslationByKey("NETWORK_CONFIG.APPLYING_CONFIGURATION"),!0),s.removeVlan(e).then(y).catch(function(t){u.hideLoader(),l.alert(a)}))})},T.resetVlan=function(){var t="";T.networkInformation.dhcp||(t="<u>"+m.getTranslationByKey("NETWORK_CONFIG.ADDITIONAL_WARNING_ETH0")+"</u><br>"),l.confirm({cssClass:"dmt-destructive",title:m.getTranslationByKey("NETWORK_CONFIG.RESET_THE_DEFAULT_NETWORK_CONFIG"),subTitle:"<b>"+m.getTranslationByKey("NETWORK_CONFIG.THIS_WILL_ERASE_ALL_CUSTOM_SETTINGS")+"</b><br>"+t+m.getTranslationByKey("NETWORK_CONFIG.ALL_VLAN_DEVICES_APPEAR_OFFLINE"),okText:m.getTranslationByKey("YES_RESET"),okType:"dmt-destructive"}).then(function(t){t&&(u.showLoader(m.getTranslationByKey("NETWORK_CONFIG.APPLYING_CONFIGURATION"),!0),s.resetVlan().then(y).catch(function(t){u.hideLoader(),l.alert(a)}))})}}])}(),function(){"use strict";angular.module("agent").controller("RestrictedController",["pawnUtilsService","$resource","$timeout","dmtPopup","$scope","$window","globalLoaderService","$sce","agentStatus","translationService",function(i,t,s,c,l,u,e,n,o,d){if(e.showLoader(),i.isUpdating())!function(){var t=[d.getTranslationByKey("UPDATE_POPUP.CHECKING_UPDATES"),d.getTranslationByKey("UPDATE_POPUP.UPDATE_FOUND")],e=[d.getTranslationByKey("UPDATE_POPUP.APPLYING_CHANGES"),d.getTranslationByKey("UPDATE_POPUP.UPDATING_INTERFACE"),d.getTranslationByKey("UPDATE_POPUP.INSTALLING_FEATURES"),d.getTranslationByKey("UPDATE_POPUP.THANK_YOU"),d.getTranslationByKey("UPDATE_POPUP.PATCHING_BUGS")],n=d.getTranslationByKey("UPDATE_POPUP.RESTARTING_SERVICES");l.progressMsg=t[0];var o=t,a=0,r=function(){a>=o.length&&(o=e,a=0),o===e&&0<a&&a%2==0?i.getStatus().finally(function(){i.isUpdating()?s(r,7e3):(l.progressMsg=n,s(function(){l.closeCurrentPopup(),u.location.reload()},7e3))}):s(r,7e3),l.progressMsg=o[a],a++};c.custom({scope:l,title:d.getTranslationByKey("UPDATING_LOCAL_AGENT"),preventClosing:!0,contentTemplate:'<div class="dmt-popup-subtitle">{{progressMsg}}</div><div class="dmt-spinner-wrapper"><ion-spinner icon="android" class="dmt-spinner"></ion-spinner></div>'}),r()}();else{const r=/(.+:\/\/)?([^\/]+)(\/.*)*/i;var o=r.exec(o.portal_api_endpoint),a=n.trustAsResourceUrl(o[1]+o[2]);t("/api/v1/activation-token",{},{generate:{method:"POST"}}).generate().$promise.then(function(t){u.location=a+"/webapp/agent-activation?token="+t.token}).catch(function(){c.custom({scope:l,title:d.getTranslationByKey("UNABLE_TO_CONNECT"),preventClosing:!0,contentTemplate:'<div class="dmt-popup-subtitle">'+d.getTranslationByKey("AN_ERROR_OCCURRED_WHILE_ATTEMPTING_TO_CONNECT")+"</div>",buttons:[{text:d.getTranslationByKey("TRY_NOW"),type:"secondary",leftIcon:null,rightIcon:null,onTap:function(){u.location.reload()}}]}),e.hideLoader()})}}])}(),function(){"use strict";angular.module("agent").factory("pawnUtilsService",["$resource",function(t){var e=["FING_SUPPORT"],n={status:{},location:{}},o=t("/api/v1/status",{request_id:function(){return Math.floor(4503599627370496*(1+Math.random()))}}),a=t("/api/v1/restart",{},{restart:{method:"POST"}});return{data:n,getStatus:function(){return o.get().$promise.then(function(t){return n.status=t})},restartAgent:function(){return a.restart().$promise},isRestricted:function(){return n.status&&("RESTRICTED"===n.status.mode||"UPDATING"===n.status.mode||!0===n.status.mode)},isUpdating:function(){return n.status&&"UPDATING"===n.status.mode},actionRequired:function(){return n.status&&"ACTION_REQUIRED"===n.status.mode},isNetworkConfigAvailable:function(){return(!n.status.package||"ubuntu_core_public"!==n.status.package.full_platform)&&("eth0"===n.status.default_interface&&!(0<=e.indexOf(n.status.type)))},isUbuntuCore:function(){return!(!n.status.package||!n.status.package.pkg_platform||"ubuntu_core"!==n.status.package.pkg_platform)}}}])}(),function(){"use strict";angular.module("agent").directive("scrollResize",["$window","$ionicScrollDelegate",function(a,r){return function(t,e,n){function o(){r.getScrollView(e).resize(),e[0].offsetHeight<e.children()[0].offsetHeight?e.addClass("dmt-long-content"):e.removeClass("dmt-long-content")}angular.element(a).bind("resize",function(){o()}),t.$on("scroll-resize",function(t,e){e.handler==n.delegateHandle&&setTimeout(o,100)}),setTimeout(o,100)}}])}(),function(){"use strict";ionic.Platform.isIE=function(){return-1<ionic.Platform.ua.toLowerCase().indexOf("trident")},ionic.Platform.isIE()&&angular.module("ionic").factory("$ionicNgClick",["$parse","$timeout",function(a,r){return function(e,t,n){var o=angular.isFunction(n)?n:a(n);t.on("click",function(t){e.$apply(function(){e.clicktimer||(o(e,{$event:t}),e.clicktimer=r(function(){delete e.clicktimer},1,!1))})}),t.onclick=function(t){}}}])}();