@c8y/ng1-modules 1017.52.0 → 1017.54.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/NOTICES
CHANGED
|
@@ -10653,6 +10653,32 @@ SOFTWARE.
|
|
|
10653
10653
|
|
|
10654
10654
|
-----
|
|
10655
10655
|
|
|
10656
|
+
The following software may be included in this product: cypress-terminal-report. A copy of the source code may be downloaded from git+https://github.com/archfz/cypress-terminal-report.git. This software contains the following license and notice below:
|
|
10657
|
+
|
|
10658
|
+
MIT License
|
|
10659
|
+
|
|
10660
|
+
Copyright (c) 2020 Fodor Zoltan
|
|
10661
|
+
|
|
10662
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10663
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10664
|
+
in the Software without restriction, including without limitation the rights
|
|
10665
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10666
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10667
|
+
furnished to do so, subject to the following conditions:
|
|
10668
|
+
|
|
10669
|
+
The above copyright notice and this permission notice shall be included in all
|
|
10670
|
+
copies or substantial portions of the Software.
|
|
10671
|
+
|
|
10672
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
10673
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
10674
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
10675
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
10676
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
10677
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
10678
|
+
SOFTWARE.
|
|
10679
|
+
|
|
10680
|
+
-----
|
|
10681
|
+
|
|
10656
10682
|
The following software may be included in this product: d, es6-symbol. A copy of the source code may be downloaded from git://github.com/medikoo/d.git (d), git://github.com/medikoo/es6-symbol.git (es6-symbol). This software contains the following license and notice below:
|
|
10657
10683
|
|
|
10658
10684
|
ISC License
|
|
@@ -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(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?Object(arguments[t]):{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),r.forEach(function(t){_defineProperty(e,t,n[t])})}return e}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function t(c,u,n,p,o,t,s,l,e,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=e.get("gettextCatalog")}catch(t){v={getString:_.identity}}function T(c,o){return r.current().then(function(t){var e=t.tenant,n=f.pageSizeFilter(o),r={params:n},i="".concat(f.url(c),"/").concat(e),a=f.cleanListCallback("applications",angular.bind(b,T,c),n);return u.get(i,r).then(a).then(rt).then(M)})}function w(t){var e=t.desired,n=t.active;return{active:n,unhealthy:function(t,e){return _.isNumber(e)?t-e:t}(e,n),desired:e}}function j(c,o){return r.current().then(function(t){var e=c||t,n=f.pageSizeFilter(o),r={params:_.defaults(n,{noPaging:!0,dropOverwrittenApps:!0})},i=f.url("".concat(y,"applicationsByUser/").concat(encodeURIComponent(e.id))),a=f.cleanListCallback("applications",angular.bind(b,j,e),n);return u.get(i,r).then(a).then(rt).then(M)})}function M(t){var e=_.sortBy(t,[function(t){return a(t)}]);return _.assign(e,_.pick(t,["statistics","paging"])),e}function L(t){return T("".concat(y,"applicationsByTenant"),t)}function U(t){var e=f.url("".concat(S,"/").concat(t.contextPath,"/manifest")),n={params:f.pageSizeNoTotalFilter()};return u.get(e,n).then(function(t){return _.map(t.data.imports,N)})}function k(t){var e=k.cache,n=t.id||t,r=f.url("".concat(S,"/").concat(n,"/binaries/plugins")),i={params:f.pageSizeNoTotalFilter()};function a(){delete e[n]}return e[n]||(e[n]=s(_.noop,2e3).then(function(){return u.get(r,i).then(f.getResData).finally(a)})),e[n]}function N(t){return{id:t.id,contextPath:t.rootContextPath,directoryName:t.directoryName,manifest:t}}function I(t){var e=t.id||t;return f.url("".concat(S,"/").concat(e))}function B(t){var e=I(t);return u.get(e)}function H(e,t){var n=I(e),r=function(t){var e=_.cloneDeep(t);return delete e.type,e}(e),i=_.defaults(t||{},E),a=u.put(n,r,i).finally(function(){o.localStorage.setItem("refresh",e.contextPath)});return a.then(function(t){c.$emit("c8yApplication:update",{app:e,res:t})}),a}function F(e,t){var n=f.url(S),r=_.defaults(t||{},E),i=u.post(n,e,r);return i.then(function(t){return c.$emit("c8yApplication:create",{app:e,res:t})}).catch(function(){l.error("Could not emit c8yApplication:create for:",{app:e})}),i}function $(t,e){return t.id?H(t,e):F(t,e)}function z(i){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=2<arguments.length?arguments[2]:void 0,e=3<arguments.length?arguments[3]:void 0,c=C,o=e||p.defer(),u=t||0,n=0===u?"":"-".concat(u);return $(function(t,e){var n=function(t){return"".concat(t).concat(e)};return _objectSpread({},t,{name:n(t.name),key:n(t.key),contextPath:n(t.contextPath)})}(i,n),_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 e=_.get(t,"data.message")||_.get(t,"data.details.exceptionMessage"),n=e?v.getString(e):d("Could not create application."),r=t.data;o.reject({errorMessage:n,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 e=t.appPlugins,n=t.appManifest,r=t.appIndex,i=function(e,t){return _(t.imports).map(function(t){return _.find(e,{pluginName:t})}).compact().concat(e).uniq().value()}(e,n);return p.all({newAppManifest:function(t,e){var n=_.cloneDeep(e);return n.imports=_.map(t,"pluginName"),n}(i,n),newAppIndex:function(t,e,n){var r=n;return r=function(t,e,n){var r=n,i=_(e).map(function(t){var e=_.get(t,"pluginPackage.css",[]);return!!(e=e.length?e:_.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,e,r),r=function(t,e,n){var r=_.flattenDeep(["\x3c!--MODULES_JS--\x3e",_(e).map(function(t){var e=_.get(t,"pluginPackage.js",[]);return!!e.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 n.replace(new RegExp("\x3c!--MODULES_JS--\x3e(.|\\n|\\r)*\x3c!--\\/MODULES_JS--\x3e","gm"),r)}(0,e,r),r=function(t,e,n){var r=['C8Y_NG_MODULES=["',_.uniq(_.flattenDeep(_.map(e,function(t){return _.get(t,"pluginPackage.ngModules",[])}))).join('","'),'"];'].join("");return n.replace(new RegExp("C8Y_NG_MODULES=\\[(.|\\n|\\r)*?\\];","gm"),r)}(0,e,r)}(0,i,r)})}).then(function(t){var e=t.newAppManifest,n=t.newAppIndex;return X(r,[{path:"cumulocity.json",file:new Blob([JSON.stringify(e)],{type:"application/json"})},{path:"index.html",file:new Blob([n],{type:"text/html"})}])})}function q(t){var e=[],n=_.sortBy(t,function(t){return-1*_.get(t,"pluginPackage.priority",0)});return _.forEach(n,function(t){!function n(t,r,i){var e=K(r,_.get(t,"pluginPackage.contextPath"));if(e)return;var a=_.get(t,"pluginPackage.imports",[]);_.forEach(a,function(t){var e=K(i,t);e?n(e,r,i):l.error("Plugin with context path ".concat(t," is missing."))});r.push(t)}(t,e,n)}),e}function K(t,e){var n=function(t){var e=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)})(e)&&(e=e.replace(/\//g,"_"));return e}(e);return _.find(t,function(t){return t&&t.pluginPackage&&t.pluginPackage.contextPath===n})}function V(t){var e="".concat(W(t),"/cumulocity.json");return u.get(e).then(f.getResData)}function J(t){var e="".concat(W(t),"/index.html");return u.get(e).then(f.getResData)}function W(t){return f.url("apps/".concat(t.contextPath))}function X(t,e){var n="".concat(I(t),"/binaries/files"),r=new FormData;return _.forEach(e,function(t){r.append(t.path,new File([t.file],t.path))}),u.post(n,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 n=G(),r=!!Q();function e(t){var e="MARKET"===t.availability;return t.contextPath===n&&(!r||e)}return j(null,{dropOverwrittenApps:!1}).then(function(t){return _.find(t,e)})}function tt(e){return g.list({type:"c8y_SmartAppApplication"}).then(function(t){return _.find(t,{appId:e.id})||null})}function et(t){var e;return(t?p.resolve(t):Z()).then(function(t){return e=t}).then(tt).then(function(t){return e.config=t,e})}function nt(t){return _(t).uniq("id").filter(function(t){var e=t.manifest,n=!1;return e&&(n=e.noAppSwitcher),!n&&_.includes(["HOSTED","EXTERNAL"],t.type)}).value()}function rt(t){var e=_.reject(t,function(t){return"management"===t.name&&"management"===t.owner.tenant.id});return _.assign(e,_.pick(t,_.filter(_.keys(t),function(t){return _.isNaN(_.toNumber(t))}))),e}function it(t,e){var n=_.isString(e)?function(e){return function(t){return t.name===e||t.contextPath===e||t.key===e}}(e):e;return _.some(t,n)}function at(t){return"HOSTED"===t.type||"REPOSITORY"===t.type}function ct(){if(ct.cache)return ct.cache;function e(t){return{url:t,noAppKey:!0}}return u(e([f.url(S),(Q()?"public/":"")+G(),"manifest"].join("/"))).then(function(t){return u(e([f.url(S),t.data.application.id].join("/")))}).then(f.getResData).then(function(t){return ct.cache=p.when(t)})}return d("Administration"),d("Cockpit"),d("Device management"),d("Fieldbus4"),d("Streaming Analytics"),k.cache={},f.getFlag("test")&&(ct.cache=p.when({name:"app",manifest:{}})),{list:L,listByUser:j,listByTenant:L,listByOwner:function(t){return T("".concat(y,"applicationsByOwner"),t)},listPlugins:function(){var t=f.url("".concat(y,"plugins")),e={params:{pageSize:R}};return u.get(t,e).then(function(t){return _.uniqBy(t.data.plugins,"id")})},listPluginsByTenant:function(){return L().then(function(t){var e=_.uniqBy(t,"id"),n=[];return _.forEach(e,function(t){at(t)&&n.push(U(t))}),p.all(n).then(_.flattenDeep).then(function(t){return _.uniqBy(t,"id")})})},listPluginsByApplication:U,listPluginsByPaasApp:k,listByVisibleLinks:function(){return j().then(nt).then(function(t){return p.when(t)})},listApplications:function t(e){var n=f.url("".concat(S)),r={params:f.pageSizeFilter(e)},i=f.cleanListCallback("applications",t,e);return u.get(n,r).then(i).then(M)},getApplicationMO:function(t){var e="c8y_Application_".concat(t);return g.list({type:e}).then(function(t){return _.head(t)})},getApplicationMOs:function(t){var e=t||{},n=e.tenantId,r=e.filters,i=void 0===r?{}:r,a={type:"c8y_Application_*"};return n&&(a=m.addAndFilter(a,{__has:"c8y_Subscriptions.".concat(n)})),g.listQuery(a,i,!0)},getInstanceCounts:w,getSubscriptionsList:function(t){var e=_.get(t,"c8y_Subscriptions");return _.reduce(e,function(t,e,n){var r=_.get(e,"details"),i=_.get(e,"status"),a=w(r);return t.concat(_objectSpread({},a,{tenantName:n,status:i}))},[])},getApplicationStatusForTenant:function(t,e){return _.get(t,["c8y_Subscriptions",e])},status:D,isAvailable:function(e){return j().then(function(t){return it(t,e)})},areAllAvailable:function(t){return j().then(function(e){return _.every(t,function(t){return it(e,t)})})},isAnyAvailable:function(t){return j().then(function(e){return _.some(t,function(t){return it(e,t)})})},detail:B,update:H,create:F,remove:function(n){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=I(n),r=et(_.isObjectLike(n)?n:{id:n}).then(function(t){return!_.get(t,"config.id")||g.remove(t.config)}),i=u.delete(e,{params:t}),a=p.all({cfg:r,res:i});return a.then(function(t){var e=t.res;c.$emit("c8yApplication:delete",{app:n,res:e})}),a},save:$,trySave:z,clone:function(t,e){var n="".concat(I(t),"/clone");return u.post(n).then(f.getResData).then(function(t){return _.isObjectLike(e)?(_.assign(t,e),z(t).then(f.getResData)):t})},getHref:function(t){return at(t)?function(t){var e=n.port();return e=80===e||443===e?"":":".concat(e),"".concat(n.protocol(),"://").concat(n.host()).concat(e,"/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(e){return g.list({type:"c8y_microservice_manifest_".concat(e.id)}).then(function(t){return"MICROSERVICE"===e.type&&0<t.length})},canOpenInBrowser:function(t){return(_.isObjectLike(t)?p.resolve(t):B(t).then(f.getResData)).then(function(t){var e=!t.name.match(/feature-/),n=_.includes(P,t.type);return e&&n})},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 e=_.isString(t)?t:t.type;return t.manifest&&"MICROSERVICE"!==e&&(e="SMARTAPP"),A[e]},typeLabel:function(t){var e=_.isString(t)?t:t.type;return x[e]},getCurrent:Z,getConfig:et,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,n){return B(t).then(function(t){var e=t.data;return e.manifest=n,e}).then(H)},listArchives:function(t,e){var n="".concat(I(t),"/binaries"),r={params:f.pageSizeNoTotalFilter(e),silentError:!0};return u.get(n,r).then(f.getResData)},uploadArchive:function(t,e){var n=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:e,fileName:function(t){return t.replace(/\s+/g,"_")}(e.name)};return _.assign(r,n),h.upload(r)},deleteArchive:function(t,e){var n=e.id||e,r=[I(t),"binaries",n].join("/");return u.delete(r)},setActiveArchive:function(t,e){return $({id:t.id,activeVersionId:e.id})},addPaasAppPlugin:function(t,e){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var n=function(t){var e=t.name.split(".");return e.pop(),e.join(".")}(e),r="".concat(I(t),"/binaries/plugins/").concat(n),i=h.upload({url:r,method:"POST",headers:{Content:"multipart/form-data",Accept:"application/json"},file:e}),a=i.then(_.partial(Y,t));return a.progress=i.progress,a},removePaasAppPlugin:function(t,e){console.warning("This method is now deprecated. Consider using Web SDK to customize and extend applications.");var n=e.pluginName||e,r="".concat(I(t),"/binaries/plugins/").concat(n);return u.delete(r).then(_.partial(Y,t))},uploadPaasAppFiles:X,getPaasAppManifest:V,refreshPaasApp:Y,refreshHostedApp:function(t){var e="".concat(I(t),"/refresh");return u.post(e)},isPaasApp:function(t){return V(t).then(function(t){return t._webpaas},function(){return!1})},convertType:function(t){var e=_.cloneDeep(t);return void 0===e.type||(e.type=function(t){return"HOSTED"===t.type&&t.resourcesUrl&&"/"!==t.resourcesUrl.charAt(0)}(e)?"REPOSITORY":e.type),e},revertType:function(t){var e=_.cloneDeep(t);return"HOSTED"===e.type&&(e.resourcesUrl="/"),"REPOSITORY"===e.type&&(e.type="HOSTED"),e},parseAppName:function(t){return t&&"devicemanagement"===t.toLowerCase()?"Device management":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,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)}();
|
package/package.json
CHANGED