@c8y/ng1-modules 1017.146.0 → 1017.147.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.
- package/binaryArtefactsManagement/controllers/list.js +1 -1
- package/core/core/services/application.js +1 -1
- package/core/locales/de.po +228 -162
- package/core/locales/en.po +28 -14
- package/core/ui/directives/binaryInput.js +1 -1
- package/core/ui/schemaForm/overrides/decorators/bootstrap/default.html +0 -1
- package/core/ui/views/loadmore.html +1 -1
- package/dataPointExplorer/controllers/dataPointWidgetConfig.js +1 -1
- package/eventList/cumulocity.json +3 -2
- package/eventList/eventListConfig.controller.js +1 -0
- package/eventList/views/eventListConfig.html +5 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function binaryArtefactsListCtrl(e,n,i,t,a,r,o){var l,s=[];function c(t){e.files&&!e.refreshLoading||(e.files=[]),e.paging=t.paging,t.forEach(function(t){t.icon=a.icon(t),e.files.push(t)})}function f(){t.changeTitle({title:r("Files repository")})}function g(){e.refreshLoading=!0,e.paging.refresh().then(c).finally(function(){e.refreshLoading=!1})}function u(t){return s.indexOf(t)}function p(t){return-1<u(t)}e.loadNext=function(){e.paging.loading=!0,e.paging.next().then(c).finally(function(){e.paging.loading=!1})},e.refresh=g,e.toggle=function(t){p(t)?s.splice(u(t),1):(s.push(t),function(e){a.isImage(e)&&!e.dataUri&&a.downloadAsDataUri(e).then(function(t){e.dataUri=t})}(t))},e.isOpen=p,e.onClickDelete=function(t){n({title:r("Delete file"),body:o.getString('You are about to delete file "{{name}}". Do you want to proceed?',t),status:"danger",labels:{ok:r("Delete")}}).then(angular.bind(a,a.removeBinary,t)).then(angular.bind(i,i.removeFromList,e.files,t))},e.upload=function(){n({templateUrl:":::PLUGIN_PATH:::/views/upload.html",controller:"binaryArtefactsUploadCtrl",title:r("Upload files"),backdrop:"static"}).then(g)},e.size=a.size,e.isImage=a.isImage,e.popoverTemplateUrl=":::PLUGIN_PATH:::/views/popover.html",e.isApplicationBinary=function(t){return _.has(t,"c8y_applications_storage")},a.list(l).then(c).then(f)}binaryArtefactsListCtrl.$inject=["$scope","c8yModal","c8yBase","c8yTitle","c8yBinary","gettext","gettextCatalog"],angular.module("c8y.binaryArtefactsManagement").controller("binaryArtefactsListCtrl",binaryArtefactsListCtrl);
|
|
1
|
+
"use strict";function binaryArtefactsListCtrl(e,n,i,t,a,r,o){var l,s=[];function c(t){e.files&&!e.refreshLoading||(e.files=[]),e.paging=t.paging,t.forEach(function(t){t.icon=a.icon(t),e.files.push(t)})}function f(){t.changeTitle({title:r("Files repository")})}function g(){e.refreshLoading=!0,e.paging.refresh().then(c).finally(function(){e.refreshLoading=!1})}function u(t){return s.indexOf(t)}function p(t){return-1<u(t)}e.loadNext=function(){e.paging.loading=!0,e.paging.next().then(c).finally(function(){e.paging.loading=!1})},e.refresh=g,e.toggle=function(t){p(t)?s.splice(u(t),1):(s.push(t),function(e){a.isImage(e)&&!e.dataUri&&a.downloadAsDataUri(e).then(function(t){e.dataUri=t})}(t))},e.isOpen=p,e.onClickDelete=function(t){n({title:r("Delete file"),body:o.getString('You are about to delete file "{{ name }}". Do you want to proceed?',t),status:"danger",labels:{ok:r("Delete")}}).then(angular.bind(a,a.removeBinary,t)).then(angular.bind(i,i.removeFromList,e.files,t))},e.upload=function(){n({templateUrl:":::PLUGIN_PATH:::/views/upload.html",controller:"binaryArtefactsUploadCtrl",title:r("Upload files"),backdrop:"static"}).then(g)},e.size=a.size,e.isImage=a.isImage,e.popoverTemplateUrl=":::PLUGIN_PATH:::/views/popover.html",e.isApplicationBinary=function(t){return _.has(t,"c8y_applications_storage")},a.list(l).then(c).then(f)}binaryArtefactsListCtrl.$inject=["$scope","c8yModal","c8yBase","c8yTitle","c8yBinary","gettext","gettextCatalog"],angular.module("c8y.binaryArtefactsManagement").controller("binaryArtefactsListCtrl",binaryArtefactsListCtrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _objectSpread(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?Object(arguments[t]):{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.forEach(function(t){_defineProperty(n,t,e[t])})}return n}function _defineProperty(t,n,e){return(n=_toPropertyKey(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function _toPropertyKey(t){var n=_toPrimitive(t,"string");return"symbol"===_typeof(n)?n:String(n)}function _toPrimitive(t,n){if("object"!==_typeof(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);var r=e.call(t,n||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function t(c,u,e,p,o,t,l,s,n,f,r,g,d,h,i,m){var v,a=i("humanizeAppName"),y="application/",S="".concat(y,"applications"),E={headers:f.contentHeaders("application",!0)},b=this,A={HOSTED:"cloud",EXTERNAL:"external-link",SMARTAPP:"puzzle-piece",MICROSERVICE:"microchip",APAMA_CEP_RULE:"file-code-o"},P=["HOSTED","EXTERNAL","REPOSITORY"],O=["HOSTED","EXTERNAL","REPOSITORY"],x={HOSTED:h("Hosted application"),REPOSITORY:h("Repository"),EXTERNAL:h("External application"),MICROSERVICE:h("Microservice"),APAMA_CEP_RULE:h("Apama CEP rule")},D=f.createEnum([{name:"UP",label:h("Up"),value:"Up",icon:"check-circle text-success"},{name:"DOWN",label:h("Down"),value:"Down",icon:"warning status critical"},{name:"UNHEALTHY",label:h("Unhealthy"),value:"Unhealth",icon:"exclamation-circle status major"},{name:"UNHEALTHY",label:h("Unhealthy"),value:"Unhealthy",icon:"exclamation-circle status major"}]),R=1e3,C=10;try{v=n.get("gettextCatalog")}catch(t){v={getString:_.identity}}function w(c,o){return r.current().then(function(t){var n=t.tenant,e=f.pageSizeFilter(o),r={params:e},i="".concat(f.url(c),"/").concat(n),a=f.cleanListCallback("applications",angular.bind(b,w,c),e);return u.get(i,r).then(a).then(rt).then(M)})}function T(t){var n=t.desired,e=t.active;return{active:e,unhealthy:function(t,n){return _.isNumber(n)?t-n:t}(n,e),desired:n}}function j(c,o){return r.current().then(function(t){var n=c||t,e=f.pageSizeFilter(o),r={params:_.defaults(e,{noPaging:!0,dropOverwrittenApps:!0})},i=f.url("".concat(y,"applicationsByUser/").concat(encodeURIComponent(n.id))),a=f.cleanListCallback("applications",angular.bind(b,j,n),e);return u.get(i,r).then(a).then(rt).then(M)})}function M(t){var n=_.sortBy(t,[function(t){return a(t)}]);return _.assign(n,_.pick(t,["statistics","paging"])),n}function L(t){return w("".concat(y,"applicationsByTenant"),t)}function U(t){var n=f.url("".concat(S,"/").concat(t.contextPath,"/manifest")),e={params:f.pageSizeNoTotalFilter()};return u.get(n,e).then(function(t){return _.map(t.data.imports,N)})}function k(t){var n=k.cache,e=t.id||t,r=f.url("".concat(S,"/").concat(e,"/binaries/plugins")),i={params:f.pageSizeNoTotalFilter()};function a(){delete n[e]}return n[e]||(n[e]=l(_.noop,2e3).then(function(){return u.get(r,i).then(f.getResData).finally(a)})),n[e]}function N(t){return{id:t.id,contextPath:t.rootContextPath,directoryName:t.directoryName,manifest:t}}function I(t){var n=t.id||t;return f.url("".concat(S,"/").concat(n))}function B(t){var n=I(t);return u.get(n)}function H(n,t){var e=I(n),r=function(t){var n=_.cloneDeep(t);return delete n.type,n}(n),i=_.defaults(t||{},E),a=u.put(e,r,i).finally(function(){o.localStorage.setItem("refresh",n.contextPath)});return a.then(function(t){c.$emit("c8yApplication:update",{app:n,res:t})}),a}function F(n,t){var e=f.url(S),r=_.defaults(t||{},E),i=u.post(e,n,r);return i.then(function(t){return c.$emit("c8yApplication:create",{app:n,res:t})}).catch(function(){s.error("Could not emit c8yApplication:create for:",{app:n})}),i}function $(t,n){return t.id?H(t,n):F(t,n)}function z(i){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=2<arguments.length?arguments[2]:void 0,n=3<arguments.length?arguments[3]:void 0,c=C,o=n||p.defer(),u=t||0,e=0===u?"":"-".concat(u);return $(function(t,n){var e=function(t){return"".concat(t).concat(n)};return _objectSpread({},t,{name:e(t.name),key:e(t.key),contextPath:e(t.contextPath)})}(i,e),_objectSpread({silentError:!0},a)).then(function(t){o.resolve(f.getResData(t))},function(t){if(409===t.status&&u<c)z(i,a,u+1,o);else{var n=_.get(t,"data.message")||_.get(t,"data.details.exceptionMessage"),e=n?v.getString(n):h("Could not create application."),r=t.data;o.reject({errorMessage:e,errorDetails:r})}}),o.promise}function Y(r){var t=B(r).then(f.getResData);return p.all({appDetails:t,appPlugins:t.then(k).then(q),appManifest:t.then(V),appIndex:t.then(J)}).then(function(t){t.appDetails;var n=t.appPlugins,e=t.appManifest,r=t.appIndex,i=function(n,t){return _(t.imports).map(function(t){return _.find(n,{pluginName:t})}).compact().concat(n).uniq().value()}(n,e);return p.all({newAppManifest:function(t,n){var e=_.cloneDeep(n);return e.imports=_.map(t,"pluginName"),e}(i,e),newAppIndex:function(t,n,e){var r=e;return r=function(t,n,e){var r=e,i=_(n).map(function(t){var n=_.get(t,"pluginPackage.css",[]);return!!(n=n.length?n:_.get(t,"pluginPackage.less",[])).length&&"".concat(t.pluginName,"/style.css")}).filter(_.identity).value(),a=_.flattenDeep(["\x3c!--MODULES_CSS--\x3e",_.map(i.slice(0,1),function(t){return'<link rel="stylesheet" href="'.concat(t,'"></link>')}),"\x3c!--/MODULES_CSS--\x3e"]).join("\n"),c=_.flattenDeep(["\x3c!--MODULES_CSS_DEFER--\x3e","<script>",["[",'"'.concat(i.slice(1).join('", "'),'"'),"].forEach(function(f){loadCSS(f)})"].join(""),"<\/script>","\x3c!--/MODULES_CSS_DEFER--\x3e"]).join("\n");return r=(r=r.replace(new RegExp("\x3c!--MODULES_CSS--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_CSS--\x3e","gm"),a)).replace(new RegExp("\x3c!--MODULES_CSS_DEFER--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_CSS_DEFER--\x3e","gm"),c)}(0,n,r),r=function(t,n,e){var r=_.flattenDeep(["\x3c!--MODULES_JS--\x3e",_(n).map(function(t){var n=_.get(t,"pluginPackage.js",[]);return!!n.length&&"".concat(t.pluginName,"/main.js")}).filter(_.identity).map(function(t){return'<script defer src="'.concat(t,'"><\/script>')}).value(),"\x3c!--/MODULES_JS--\x3e"]).join("\n");return e.replace(new RegExp("\x3c!--MODULES_JS--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_JS--\x3e","gm"),r)}(0,n,r),r=function(t,n,e){var r=['C8Y_NG_MODULES=["',_.uniq(_.flattenDeep(_.map(n,function(t){return _.get(t,"pluginPackage.ngModules",[])}))).join('","'),'"];'].join("");return e.replace(new RegExp("C8Y_NG_MODULES=\\[(.|\\n|\\r)*?\\];","gm"),r)}(0,n,r)}(0,i,r)})}).then(function(t){var n=t.newAppManifest,e=t.newAppIndex;return X(r,[{path:"cumulocity.json",file:new Blob([JSON.stringify(n)],{type:"application/json"})},{path:"index.html",file:new Blob([e],{type:"text/html"})}])})}function q(t){var n=[],e=_.sortBy(t,function(t){return-1*_.get(t,"pluginPackage.priority",0)});return _.forEach(e,function(t){!function e(t,r,i){var n=K(r,_.get(t,"pluginPackage.contextPath"));if(n)return;var a=_.get(t,"pluginPackage.imports",[]);_.forEach(a,function(t){var n=K(i,t);n?e(n,r,i):s.error("Plugin with context path ".concat(t," is missing."))});r.push(t)}(t,n,e)}),n}function K(t,n){var e=function(t){var n=t;(function(t){return/^core\//.test(t)||/^administration\//.test(t)||/^devicemanagement\//.test(t)||/^cockpit\//.test(t)||/^platformadmin\//.test(t)||/^fieldbus4\//.test(t)||/^fieldbus3\//.test(t)||/^fieldbus2\//.test(t)||/^fieldbus\//.test(t)||/^demoboard\//.test(t)||/^vendme_plugins\//.test(t)})(n)&&(n=n.replace(/\//g,"_"));return n}(n);return _.find(t,function(t){return t&&t.pluginPackage&&t.pluginPackage.contextPath===e})}function V(t){var n="".concat(W(t),"/cumulocity.json");return u.get(n).then(f.getResData)}function J(t){var n="".concat(W(t),"/index.html");return u.get(n).then(f.getResData)}function W(t){return f.url("apps/".concat(t.contextPath))}function X(t,n){var e="".concat(I(t),"/binaries/files"),r=new FormData;return _.forEach(n,function(t){r.append(t.path,new File([t.file],t.path))}),u.post(e,r,{transformRequest:_.identity,headers:{"Content-Type":void 0}})}function G(){var t=o.location.pathname.match(/\/apps\/(public\/){0,1}(.+?)(\/|\?|#|$)/);return t&&t[2]}function Q(){var t=o.location.pathname.match(/\/apps\/(public\/([^/]+)|([^/]+))/);return t&&-1!==t[1].indexOf("public")}function Z(){var e=G(),r=!!Q();function n(t){var n="MARKET"===t.availability;return t.contextPath===e&&(!r||n)}return j(null,{dropOverwrittenApps:!1}).then(function(t){return _.find(t,n)})}function tt(n){return g.list({type:"c8y_SmartAppApplication"}).then(function(t){return _.find(t,{appId:n.id})||null})}function nt(t){var n;return(t?p.resolve(t):Z()).then(function(t){return n=t}).then(tt).then(function(t){return n.config=t,n})}function et(t){return _(t).uniq("id").filter(function(t){var n=t.manifest,e=!1;return n&&(e=n.noAppSwitcher),!e&&_.includes(["HOSTED","EXTERNAL"],t.type)}).value()}function rt(t){var n=_.reject(t,function(t){return"management"===t.name&&"management"===t.owner.tenant.id});return _.assign(n,_.pick(t,_.filter(_.keys(t),function(t){return _.isNaN(_.toNumber(t))}))),n}function it(t,n){var e=_.isString(n)?function(n){return function(t){return t.name===n||t.contextPath===n||t.key===n}}(n):n;return _.some(t,e)}function at(t){return"HOSTED"===t.type||"REPOSITORY"===t.type}function ct(){if(ct.cache)return ct.cache;function n(t){return{url:t,noAppKey:!0}}return u(n([f.url(S),(Q()?"public/":"")+G(),"manifest"].join("/"))).then(function(t){return u(n([f.url(S),t.data.application.id].join("/")))}).then(f.getResData).then(function(t){return ct.cache=p.when(t)})}return h("Administration"),h("Cockpit"),h("Device management"),h("Fieldbus4"),h("Streaming Analytics"),k.cache={},f.getFlag("test")&&(ct.cache=p.when({name:"app",manifest:{}})),{list:L,listByUser:j,listByTenant:L,listByOwner:function(t){return w("".concat(y,"applicationsByOwner"),t)},listPlugins:function(){var t=f.url("".concat(y,"plugins")),n={params:{pageSize:R}};return u.get(t,n).then(function(t){return _.uniqBy(t.data.plugins,"id")})},listPluginsByTenant:function(){return L().then(function(t){var n=_.uniqBy(t,"id"),e=[];return _.forEach(n,function(t){at(t)&&e.push(U(t))}),p.all(e).then(_.flattenDeep).then(function(t){return _.uniqBy(t,"id")})})},listPluginsByApplication:U,listPluginsByPaasApp:k,listByVisibleLinks:function(){return j().then(et).then(function(t){return p.when(t)})},listApplications:function t(n){var e=f.url("".concat(S)),r={params:f.pageSizeFilter(n)},i=f.cleanListCallback("applications",t,n);return u.get(e,r).then(i).then(M)},getApplicationMO:function(t){var n="c8y_Application_".concat(t);return g.list({type:n}).then(function(t){return _.head(t)})},getApplicationMOs:function(t){var n=t||{},e=n.tenantId,r=n.filters,i=void 0===r?{}:r,a={type:"c8y_Application_*"};return e&&(a=m.addAndFilter(a,{__has:"c8y_Subscriptions.".concat(e)})),g.listQuery(a,i,!0)},getInstanceCounts:T,getSubscriptionsList:function(t){var n=_.get(t,"c8y_Subscriptions");return _.reduce(n,function(t,n,e){var r=_.get(n,"details"),i=_.get(n,"status"),a=T(r);return t.concat(_objectSpread({},a,{tenantName:e,status:i}))},[])},getApplicationStatusForTenant:function(t,n){return _.get(t,["c8y_Subscriptions",n])},status:D,isAvailable:function(n){return j().then(function(t){return it(t,n)})},areAllAvailable:function(t){return j().then(function(n){return _.every(t,function(t){return it(n,t)})})},isAnyAvailable:function(t){return j().then(function(n){return _.some(t,function(t){return it(n,t)})})},detail:B,update:H,create:F,remove:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=I(e),r=nt(_.isObjectLike(e)?e:{id:e}).then(function(t){return!_.get(t,"config.id")||g.remove(t.config)}),i=u.delete(n,{params:t}),a=p.all({cfg:r,res:i});return a.then(function(t){var n=t.res;c.$emit("c8yApplication:delete",{app:e,res:n})}),a},save:$,trySave:z,clone:function(t,n){var e="".concat(I(t),"/clone");return u.post(e).then(f.getResData).then(function(t){return _.isObjectLike(n)?(_.assign(t,n),z(t).then(f.getResData)):t})},getHref:function(t){return at(t)?function(t){var n=e.port();return n=80===n||443===n?"":":".concat(n),"".concat(e.protocol(),"://").concat(e.host()).concat(n,"/apps/").concat(t.public?"public/":"").concat(t.contextPath)}(t):t.externalUrl},isHosted:function(t){return"HOSTED"===t.type},isApamaCepRule:function(t){return"APAMA_CEP_RULE"===_.get(t,"type")},isMicroserviceWithManifest:function(n){return g.list({type:"c8y_microservice_manifest_".concat(n.id)}).then(function(t){return"MICROSERVICE"===n.type&&0<t.length})},canOpenInBrowser:function(t){return(_.isObjectLike(t)?p.resolve(t):B(t).then(f.getResData)).then(function(t){var n=!t.name.match(/feature-/),e=_.includes(P,t.type);return n&&e})},canAddPlugin:function(t){return console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications."),(_.isObjectLike(t)?p.resolve(t):B(t).then(function(t){return t.data})).then(function(t){return!_.isEmpty(t.manifest)&&_.includes(O,_.get(t,"type"))})},icon:function(t){var n=_.isString(t)?t:t.type;return t.manifest&&"MICROSERVICE"!==n&&(n="SMARTAPP"),A[n]},typeLabel:function(t){var n=_.isString(t)?t:t.type;return x[n]},getCurrent:Z,getConfig:nt,pollRefreshMessages:function(){t(function(){!function(t){o.localStorage.getItem("refresh")===G()&&(o.localStorage.setItem("refresh",void 0),t||o.location.reload())}()},1e3,0,!1)},getCurrentContextPath:G,updateManifest:function(t,e){return B(t).then(function(t){var n=t.data;return n.manifest=e,n}).then(H)},listArchives:function(t,n){var e="".concat(I(t),"/binaries"),r={params:f.pageSizeNoTotalFilter(n),silentError:!0};return u.get(e,r).then(f.getResData)},uploadArchive:function(t,n){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r={url:"".concat(I(t),"/binaries"),method:"POST",headers:{Content:"multipart/form-data",Accept:"application/json"},file:n,fileName:function(t){return t.replace(/\s+/g,"_")}(n.name)};return _.assign(r,e),d.upload(r)},deleteArchive:function(t,n){var e=n.id||n,r=[I(t),"binaries",e].join("/");return u.delete(r)},setActiveArchive:function(t,n){return $({id:t.id,activeVersionId:n.id})},addPaasAppPlugin:function(t,n){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var e=function(t){var n=t.name.split(".");return n.pop(),n.join(".")}(n),r="".concat(I(t),"/binaries/plugins/").concat(e),i=d.upload({url:r,method:"POST",headers:{Content:"multipart/form-data",Accept:"application/json"},file:n}),a=i.then(_.partial(Y,t));return a.progress=i.progress,a},removePaasAppPlugin:function(t,n){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var e=n.pluginName||n,r="".concat(I(t),"/binaries/plugins/").concat(e);return u.delete(r).then(_.partial(Y,t))},uploadPaasAppFiles:X,getPaasAppManifest:V,refreshPaasApp:Y,refreshHostedApp:function(t){var n="".concat(I(t),"/refresh");return u.post(n)},isPaasApp:function(t){return V(t).then(function(t){return t._webpaas},function(){return!1})},convertType:function(t){var n=_.cloneDeep(t);return void 0===n.type||(n.type=function(t){return"HOSTED"===t.type&&t.resourcesUrl&&"/"!==t.resourcesUrl.charAt(0)}(n)?"REPOSITORY":n.type),n},revertType:function(t){var n=_.cloneDeep(t);return"HOSTED"===n.type&&(n.resourcesUrl="/"),"REPOSITORY"===n.type&&(n.type="HOSTED"),n},parseAppName:function(t){var n=t&&t.toLowerCase();return"devicemanagement"===n?"Device management":"digital-twin-manager"===n?"Digital twin manager":t||"Cumulocity"},currentAppCached:ct,sortApps:M,isAppOnTheList:it}}t.$inject=["$rootScope","$http","$location","$q","$window","$interval","$timeout","$log","$injector","c8yBase","c8yUser","c8yInventory","$upload","gettext","$filter","c8yQueriesUtil"],angular.module("c8y.core").factory("c8yApplication",t)}();
|
|
1
|
+
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _objectSpread(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?Object(arguments[t]):{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.forEach(function(t){_defineProperty(n,t,e[t])})}return n}function _defineProperty(t,n,e){return(n=_toPropertyKey(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function _toPropertyKey(t){var n=_toPrimitive(t,"string");return"symbol"===_typeof(n)?n:String(n)}function _toPrimitive(t,n){if("object"!==_typeof(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);var r=e.call(t,n||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function t(c,u,e,p,o,t,l,s,n,f,r,g,h,d,i,m){var v,a=i("humanizeAppName"),y="application/",S="".concat(y,"applications"),E={headers:f.contentHeaders("application",!0)},b=this,A={HOSTED:"cloud",EXTERNAL:"external-link",SMARTAPP:"puzzle-piece",MICROSERVICE:"microchip",APAMA_CEP_RULE:"file-code-o"},P=["HOSTED","EXTERNAL","REPOSITORY"],O=["HOSTED","EXTERNAL","REPOSITORY"],x={HOSTED:d("Hosted application"),REPOSITORY:d("Repository"),EXTERNAL:d("External application"),MICROSERVICE:d("Microservice"),APAMA_CEP_RULE:d("Apama CEP rule")},D=f.createEnum([{name:"UP",label:d("Up"),value:"Up",icon:"check-circle text-success"},{name:"DOWN",label:d("Down"),value:"Down",icon:"warning status critical"},{name:"UNHEALTHY",label:d("Unhealthy"),value:"Unhealth",icon:"exclamation-circle status major"},{name:"UNHEALTHY",label:d("Unhealthy"),value:"Unhealthy",icon:"exclamation-circle status major"}]),R=1e3,C=10;try{v=n.get("gettextCatalog")}catch(t){v={getString:_.identity}}function w(c,o){return r.current().then(function(t){var n=t.tenant,e=f.pageSizeFilter(o),r={params:e},i="".concat(f.url(c),"/").concat(n),a=f.cleanListCallback("applications",angular.bind(b,w,c),e);return u.get(i,r).then(a).then(rt).then(M)})}function T(t){var n=t.desired,e=t.active;return{active:e,unhealthy:function(t,n){return _.isNumber(n)?t-n:t}(n,e),desired:n}}function j(c,o){return r.current().then(function(t){var n=c||t,e=f.pageSizeFilter(o),r={params:_.defaults(e,{noPaging:!0,dropOverwrittenApps:!0})},i=f.url("".concat(y,"applicationsByUser/").concat(encodeURIComponent(n.id))),a=f.cleanListCallback("applications",angular.bind(b,j,n),e);return u.get(i,r).then(a).then(rt).then(M)})}function M(t){var n=_.sortBy(t,[function(t){return a(t)}]);return _.assign(n,_.pick(t,["statistics","paging"])),n}function L(t){return w("".concat(y,"applicationsByTenant"),t)}function U(t){var n=f.url("".concat(S,"/").concat(t.contextPath,"/manifest")),e={params:f.pageSizeNoTotalFilter()};return u.get(n,e).then(function(t){return _.map(t.data.imports,k)})}function N(t){var n=N.cache,e=t.id||t,r=f.url("".concat(S,"/").concat(e,"/binaries/plugins")),i={params:f.pageSizeNoTotalFilter()};function a(){delete n[e]}return n[e]||(n[e]=l(_.noop,2e3).then(function(){return u.get(r,i).then(f.getResData).finally(a)})),n[e]}function k(t){return{id:t.id,contextPath:t.rootContextPath,directoryName:t.directoryName,manifest:t}}function I(t){var n=t.id||t;return f.url("".concat(S,"/").concat(n))}function B(t){var n=I(t);return u.get(n)}function H(n,t){var e=I(n),r=function(t){var n=_.cloneDeep(t);return delete n.type,n}(n),i=_.defaults(t||{},E),a=u.put(e,r,i).finally(function(){o.localStorage.setItem("refresh",n.contextPath)});return a.then(function(t){c.$emit("c8yApplication:update",{app:n,res:t})}),a}function F(n,t){var e=f.url(S),r=_.defaults(t||{},E),i=u.post(e,n,r);return i.then(function(t){return c.$emit("c8yApplication:create",{app:n,res:t})}).catch(function(){s.error("Could not emit c8yApplication:create for:",{app:n})}),i}function $(t,n){return t.id?H(t,n):F(t,n)}function z(i){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=2<arguments.length?arguments[2]:void 0,n=3<arguments.length?arguments[3]:void 0,c=C,o=n||p.defer(),u=t||0,e=0===u?"":"-".concat(u);return $(function(t,n){var e=function(t){return"".concat(t).concat(n)};return _objectSpread({},t,{name:e(t.name),key:e(t.key),contextPath:e(t.contextPath)})}(i,e),_objectSpread({silentError:!0},a)).then(function(t){o.resolve(f.getResData(t))},function(t){if(409===t.status&&u<c)z(i,a,u+1,o);else{var n=_.get(t,"data.message")||_.get(t,"data.details.exceptionMessage"),e=n?v.getString(n):d("Could not create application."),r=t.data;o.reject({errorMessage:e,errorDetails:r})}}),o.promise}function Y(r){var t=B(r).then(f.getResData);return p.all({appDetails:t,appPlugins:t.then(N).then(q),appManifest:t.then(V),appIndex:t.then(J)}).then(function(t){t.appDetails;var n=t.appPlugins,e=t.appManifest,r=t.appIndex,i=function(n,t){return _(t.imports).map(function(t){return _.find(n,{pluginName:t})}).compact().concat(n).uniq().value()}(n,e);return p.all({newAppManifest:function(t,n){var e=_.cloneDeep(n);return e.imports=_.map(t,"pluginName"),e}(i,e),newAppIndex:function(t,n,e){var r=e;return r=function(t,n,e){var r=e,i=_(n).map(function(t){var n=_.get(t,"pluginPackage.css",[]);return!!(n=n.length?n:_.get(t,"pluginPackage.less",[])).length&&"".concat(t.pluginName,"/style.css")}).filter(_.identity).value(),a=_.flattenDeep(["\x3c!--MODULES_CSS--\x3e",_.map(i.slice(0,1),function(t){return'<link rel="stylesheet" href="'.concat(t,'"></link>')}),"\x3c!--/MODULES_CSS--\x3e"]).join("\n"),c=_.flattenDeep(["\x3c!--MODULES_CSS_DEFER--\x3e","<script>",["[",'"'.concat(i.slice(1).join('", "'),'"'),"].forEach(function(f){loadCSS(f)})"].join(""),"<\/script>","\x3c!--/MODULES_CSS_DEFER--\x3e"]).join("\n");return r=(r=r.replace(new RegExp("\x3c!--MODULES_CSS--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_CSS--\x3e","gm"),a)).replace(new RegExp("\x3c!--MODULES_CSS_DEFER--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_CSS_DEFER--\x3e","gm"),c)}(0,n,r),r=function(t,n,e){var r=_.flattenDeep(["\x3c!--MODULES_JS--\x3e",_(n).map(function(t){var n=_.get(t,"pluginPackage.js",[]);return!!n.length&&"".concat(t.pluginName,"/main.js")}).filter(_.identity).map(function(t){return'<script defer src="'.concat(t,'"><\/script>')}).value(),"\x3c!--/MODULES_JS--\x3e"]).join("\n");return e.replace(new RegExp("\x3c!--MODULES_JS--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_JS--\x3e","gm"),r)}(0,n,r),r=function(t,n,e){var r=['C8Y_NG_MODULES=["',_.uniq(_.flattenDeep(_.map(n,function(t){return _.get(t,"pluginPackage.ngModules",[])}))).join('","'),'"];'].join("");return e.replace(new RegExp("C8Y_NG_MODULES=\\[(.|\\n|\\r)*?\\];","gm"),r)}(0,n,r)}(0,i,r)})}).then(function(t){var n=t.newAppManifest,e=t.newAppIndex;return X(r,[{path:"cumulocity.json",file:new Blob([JSON.stringify(n)],{type:"application/json"})},{path:"index.html",file:new Blob([e],{type:"text/html"})}])})}function q(t){var n=[],e=_.sortBy(t,function(t){return-1*_.get(t,"pluginPackage.priority",0)});return _.forEach(e,function(t){!function e(t,r,i){var n=K(r,_.get(t,"pluginPackage.contextPath"));if(n)return;var a=_.get(t,"pluginPackage.imports",[]);_.forEach(a,function(t){var n=K(i,t);n?e(n,r,i):s.error("Plugin with context path ".concat(t," is missing."))});r.push(t)}(t,n,e)}),n}function K(t,n){var e=function(t){var n=t;(function(t){return/^core\//.test(t)||/^administration\//.test(t)||/^devicemanagement\//.test(t)||/^cockpit\//.test(t)||/^platformadmin\//.test(t)||/^fieldbus4\//.test(t)||/^fieldbus3\//.test(t)||/^fieldbus2\//.test(t)||/^fieldbus\//.test(t)||/^demoboard\//.test(t)||/^vendme_plugins\//.test(t)})(n)&&(n=n.replace(/\//g,"_"));return n}(n);return _.find(t,function(t){return t&&t.pluginPackage&&t.pluginPackage.contextPath===e})}function V(t){var n="".concat(W(t),"/cumulocity.json");return u.get(n).then(f.getResData)}function J(t){var n="".concat(W(t),"/index.html");return u.get(n).then(f.getResData)}function W(t){return f.url("apps/".concat(t.contextPath))}function X(t,n){var e="".concat(I(t),"/binaries/files"),r=new FormData;return _.forEach(n,function(t){r.append(t.path,new File([t.file],t.path))}),u.post(e,r,{transformRequest:_.identity,headers:{"Content-Type":void 0}})}function G(){var t=o.location.pathname.match(/\/apps\/(public\/){0,1}(.+?)(\/|\?|#|$)/);return t&&t[2]}function Q(){var t=o.location.pathname.match(/\/apps\/(public\/([^/]+)|([^/]+))/);return t&&-1!==t[1].indexOf("public")}function Z(){var e=G(),r=!!Q();function n(t){var n="MARKET"===t.availability;return t.contextPath===e&&(!r||n)}return j(null,{dropOverwrittenApps:!1}).then(function(t){return _.find(t,n)})}function tt(n){return g.list({type:"c8y_SmartAppApplication"}).then(function(t){return _.find(t,{appId:n.id})||null})}function nt(t){var n;return(t?p.resolve(t):Z()).then(function(t){return n=t}).then(tt).then(function(t){return n.config=t,n})}function et(t){return _(t).uniq("id").filter(function(t){var n=t.manifest,e=!1;return n&&(e=n.noAppSwitcher),!e&&_.includes(["HOSTED","EXTERNAL"],t.type)}).value()}function rt(t){var n=_.reject(t,function(t){return"management"===t.name&&"management"===t.owner.tenant.id});return _.assign(n,_.pick(t,_.filter(_.keys(t),function(t){return _.isNaN(_.toNumber(t))}))),n}function it(t,n){var e=_.isString(n)?function(n){return function(t){return t.name===n||t.contextPath===n||t.key===n}}(n):n;return _.some(t,e)}function at(t){return"HOSTED"===t.type||"REPOSITORY"===t.type}function ct(){if(ct.cache)return ct.cache;function n(t){return{url:t,noAppKey:!0}}return u(n([f.url(S),(Q()?"public/":"")+G(),"manifest"].join("/"))).then(function(t){return u(n([f.url(S),t.data.application.id].join("/")))}).then(f.getResData).then(function(t){return ct.cache=p.when(t)})}return N.cache={},f.getFlag("test")&&(ct.cache=p.when({name:"app",manifest:{}})),{list:L,listByUser:j,listByTenant:L,listByOwner:function(t){return w("".concat(y,"applicationsByOwner"),t)},listPlugins:function(){var t=f.url("".concat(y,"plugins")),n={params:{pageSize:R}};return u.get(t,n).then(function(t){return _.uniqBy(t.data.plugins,"id")})},listPluginsByTenant:function(){return L().then(function(t){var n=_.uniqBy(t,"id"),e=[];return _.forEach(n,function(t){at(t)&&e.push(U(t))}),p.all(e).then(_.flattenDeep).then(function(t){return _.uniqBy(t,"id")})})},listPluginsByApplication:U,listPluginsByPaasApp:N,listByVisibleLinks:function(){return j().then(et).then(function(t){return p.when(t)})},listApplications:function t(n){var e=f.url("".concat(S)),r={params:f.pageSizeFilter(n)},i=f.cleanListCallback("applications",t,n);return u.get(e,r).then(i).then(M)},getApplicationMO:function(t){var n="c8y_Application_".concat(t);return g.list({type:n}).then(function(t){return _.head(t)})},getApplicationMOs:function(t){var n=t||{},e=n.tenantId,r=n.filters,i=void 0===r?{}:r,a={type:"c8y_Application_*"};return e&&(a=m.addAndFilter(a,{__has:"c8y_Subscriptions.".concat(e)})),g.listQuery(a,i,!0)},getInstanceCounts:T,getSubscriptionsList:function(t){var n=_.get(t,"c8y_Subscriptions");return _.reduce(n,function(t,n,e){var r=_.get(n,"details"),i=_.get(n,"status"),a=T(r);return t.concat(_objectSpread({},a,{tenantName:e,status:i}))},[])},getApplicationStatusForTenant:function(t,n){return _.get(t,["c8y_Subscriptions",n])},status:D,isAvailable:function(n){return j().then(function(t){return it(t,n)})},areAllAvailable:function(t){return j().then(function(n){return _.every(t,function(t){return it(n,t)})})},isAnyAvailable:function(t){return j().then(function(n){return _.some(t,function(t){return it(n,t)})})},detail:B,update:H,create:F,remove:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=I(e),r=nt(_.isObjectLike(e)?e:{id:e}).then(function(t){return!_.get(t,"config.id")||g.remove(t.config)}),i=u.delete(n,{params:t}),a=p.all({cfg:r,res:i});return a.then(function(t){var n=t.res;c.$emit("c8yApplication:delete",{app:e,res:n})}),a},save:$,trySave:z,clone:function(t,n){var e="".concat(I(t),"/clone");return u.post(e).then(f.getResData).then(function(t){return _.isObjectLike(n)?(_.assign(t,n),z(t).then(f.getResData)):t})},getHref:function(t){return at(t)?function(t){var n=e.port();return n=80===n||443===n?"":":".concat(n),"".concat(e.protocol(),"://").concat(e.host()).concat(n,"/apps/").concat(t.public?"public/":"").concat(t.contextPath)}(t):t.externalUrl},isHosted:function(t){return"HOSTED"===t.type},isApamaCepRule:function(t){return"APAMA_CEP_RULE"===_.get(t,"type")},isMicroserviceWithManifest:function(n){return g.list({type:"c8y_microservice_manifest_".concat(n.id)}).then(function(t){return"MICROSERVICE"===n.type&&0<t.length})},canOpenInBrowser:function(t){return(_.isObjectLike(t)?p.resolve(t):B(t).then(f.getResData)).then(function(t){var n=!t.name.match(/feature-/),e=_.includes(P,t.type);return n&&e})},canAddPlugin:function(t){return console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications."),(_.isObjectLike(t)?p.resolve(t):B(t).then(function(t){return t.data})).then(function(t){return!_.isEmpty(t.manifest)&&_.includes(O,_.get(t,"type"))})},icon:function(t){var n=_.isString(t)?t:t.type;return t.manifest&&"MICROSERVICE"!==n&&(n="SMARTAPP"),A[n]},typeLabel:function(t){var n=_.isString(t)?t:t.type;return x[n]},getCurrent:Z,getConfig:nt,pollRefreshMessages:function(){t(function(){!function(t){o.localStorage.getItem("refresh")===G()&&(o.localStorage.setItem("refresh",void 0),t||o.location.reload())}()},1e3,0,!1)},getCurrentContextPath:G,updateManifest:function(t,e){return B(t).then(function(t){var n=t.data;return n.manifest=e,n}).then(H)},listArchives:function(t,n){var e="".concat(I(t),"/binaries"),r={params:f.pageSizeNoTotalFilter(n),silentError:!0};return u.get(e,r).then(f.getResData)},uploadArchive:function(t,n){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r={url:"".concat(I(t),"/binaries"),method:"POST",headers:{Content:"multipart/form-data",Accept:"application/json"},file:n,fileName:function(t){return t.replace(/\s+/g,"_")}(n.name)};return _.assign(r,e),h.upload(r)},deleteArchive:function(t,n){var e=n.id||n,r=[I(t),"binaries",e].join("/");return u.delete(r)},setActiveArchive:function(t,n){return $({id:t.id,activeVersionId:n.id})},addPaasAppPlugin:function(t,n){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var e=function(t){var n=t.name.split(".");return n.pop(),n.join(".")}(n),r="".concat(I(t),"/binaries/plugins/").concat(e),i=h.upload({url:r,method:"POST",headers:{Content:"multipart/form-data",Accept:"application/json"},file:n}),a=i.then(_.partial(Y,t));return a.progress=i.progress,a},removePaasAppPlugin:function(t,n){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var e=n.pluginName||n,r="".concat(I(t),"/binaries/plugins/").concat(e);return u.delete(r).then(_.partial(Y,t))},uploadPaasAppFiles:X,getPaasAppManifest:V,refreshPaasApp:Y,refreshHostedApp:function(t){var n="".concat(I(t),"/refresh");return u.post(n)},isPaasApp:function(t){return V(t).then(function(t){return t._webpaas},function(){return!1})},convertType:function(t){var n=_.cloneDeep(t);return void 0===n.type||(n.type=function(t){return"HOSTED"===t.type&&t.resourcesUrl&&"/"!==t.resourcesUrl.charAt(0)}(n)?"REPOSITORY":n.type),n},revertType:function(t){var n=_.cloneDeep(t);return"HOSTED"===n.type&&(n.resourcesUrl="/"),"REPOSITORY"===n.type&&(n.type="HOSTED"),n},parseAppName:function(t){var n=t&&t.toLowerCase();return"devicemanagement"===n?"Device management":"digital-twin-manager"===n?"Digital twin manager":t||"Cumulocity"},currentAppCached:ct,sortApps:M,isAppOnTheList:it}}t.$inject=["$rootScope","$http","$location","$q","$window","$interval","$timeout","$log","$injector","c8yBase","c8yUser","c8yInventory","$upload","gettext","$filter","c8yQueriesUtil"],angular.module("c8y.core").factory("c8yApplication",t)}();
|