@c8y/ng1-modules 1018.510.3 → 1019.0.3
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 +6626 -4790
- package/administration-auditLogs/cumulocity.json +1 -1
- package/asset-notes/assetNotes.component.js +1 -1
- package/cell-id-information-activator/cell-id-information-activator.service.js +1 -1
- package/cell-id-usage-statistics/cell-id-usage-statistics.component.js +1 -1
- package/cell-id-usage-statistics/cell-id-usage-statistics.service.js +1 -1
- package/core/angular-locales.js +1 -1
- package/core/core/services/deviceShell.js +1 -1
- package/core/cumulocity.json +0 -2
- package/core/index.js +1 -1
- package/core/locales/en.po +2 -2
- package/device-protocol-canbus/canbus-device.provider.js +1 -1
- package/device-protocol-canopen/canopen-device.provider.js +1 -1
- package/device-protocol-modbus/modbus-device.provider.js +1 -1
- package/device-protocol-opcua/opcua-device.provider.js +1 -1
- package/device-protocol-profibus/profibus-device.provider.js +1 -1
- package/device-protocol-snmp/snmp-device.provider.js +1 -1
- package/device-protocols/device-protocol-import-button.component.js +1 -1
- package/deviceDatabase4/detail/device-type-detail.component.js +1 -1
- package/deviceDatabase4/device-database.service.js +1 -1
- package/deviceDatabase4/device-type-list.component.js +1 -1
- package/deviceDatabase4/modals/import-device-type.component.js +1 -1
- package/deviceStatusWidget/deviceStatus.component.js +1 -1
- package/modbusConfiguration4/fieldbus-device-list.component.js +1 -1
- package/modbusWidget4/modbus-widget.service.js +1 -1
- package/modbusWidget4/widget-config.component.js +1 -1
- package/modbusWidget4/widget.component.js +1 -1
- package/nvd3ChartDirectives/cumulocity.json +1 -0
- package/package.json +1 -1
- package/remoteAccess/remoteAccess.service.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return o};var o={},e=Object.prototype,s=e.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",a=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a,i,o,u,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),r=new S(r||[]);return c(t,"_invoke",{value:(a=e,i=n,o=r,u="suspendedStart",function(e,t){if("executing"===u)throw new Error("Generator is already running");if("completed"===u){if("throw"===e)throw t;return M()}for(o.method=e,o.arg=t;;){var n=o.delegate;if(n){n=function e(t,n){var r=n.method,a=t.iterator[r];if(void 0===a)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=void 0,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;r=p(a,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,l;a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,l):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,l)}(n,o);if(n){if(n===l)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if("suspendedStart"===u)throw u="completed",o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);u="executing";n=p(a,i,o);if("normal"===n.type){if(u=o.done?"completed":"suspendedYield",n.arg===l)continue;return{value:n.arg,done:o.done}}"throw"===n.type&&(u="completed",o.method="throw",o.arg=n.arg)}})}),t}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=u;var l={};function m(){}function f(){}function d(){}var t={},y=(i(t,r,function(){return this}),Object.getPrototypeOf),y=y&&y(y(T([]))),g=(y&&y!==e&&s.call(y,r)&&(t=y),d.prototype=m.prototype=Object.create(t));function _(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function v(o,u){var t;c(this,"_invoke",{value:function(n,r){function e(){return new u(function(e,t){!function t(e,n,r,a){var i,e=p(o[e],o,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&s.call(n,"__await")?u.resolve(n.__await).then(function(e){t("next",e,r,a)},function(e){t("throw",e,r,a)}):u.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,a)});a(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function h(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(h,this),this.reset(!0)}function T(t){if(t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(s.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:M}}function M(){return{value:void 0,done:!0}}return c(g,"constructor",{value:f.prototype=d,configurable:!0}),c(d,"constructor",{value:f,configurable:!0}),f.displayName=i(d,a,"GeneratorFunction"),o.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},o.awrap=function(e){return{__await:e}},_(v.prototype),i(v.prototype,n,function(){return this}),o.AsyncIterator=v,o.async=function(e,t,n,r,a){void 0===a&&(a=Promise);var i=new v(u(e,t,n,r),a);return o.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},_(g),i(g,a,"Generator"),i(g,r,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),o.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},o.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var a=this.tryEntries[t],i=a.completion;if("root"===a.tryLoc)return e("end");if(a.tryLoc<=this.prev){var o=s.call(a,"catchLoc"),u=s.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return e(a.catchLoc,!0);if(this.prev<a.finallyLoc)return e(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return e(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return e(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}var i=(a=a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc?null:a)?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,a=this.tryEntries[t];if(a.tryLoc===e)return"throw"===(n=a.completion).type&&(r=n.arg,b(a)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},o}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,u=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function asyncGeneratorStep(e,t,n,r,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,a)}function _asyncToGenerator(u){return function(){var e=this,o=arguments;return new Promise(function(t,n){var r=u.apply(e,o);function a(e){asyncGeneratorStep(r,t,n,a,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,a,i,"throw",e)}a(void 0)})}}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(r,o,e,u,N,s,L,V,B,a,i,c){var G={name:"feature-fieldbus4"},n=e.has("FIELDBUS_UI_VERSION")?e.get("FIELDBUS_UI_VERSION"):4,p="c8y_IsDeviceType",l="c8y_ModbusDeviceType",m="%%",f=u.createEnum(["DISCRETE_IO","REGISTER"]),e=u.createEnum([{name:"FPORT",label:"FPort"},{name:"PAYLOAD",label:"Payload"}]),d=u.dataFilePath("devicetypes"),y={common:{name:null},deviceType:{c8y_Coils:[],c8y_Registers:[]},element:{number:null},discreteIO:{},discreteOutput:{input:!1},discreteInput:{input:!0},register:{multiplier:1,divisor:1,offset:0,decimalPlaces:0,startBit:0,noBits:16,unit:"",signed:!1},canbusRegister:{noBits:64,offset:0},canopenRegister:{},holdingRegister:{input:!1},inputRegister:{input:!0}},t=[],g=[];return{ElementType:f,MessageIdSources:e,metaDefaults:{discreteIO:{enumValues:[{value:0,label:"0"},{value:1,label:"1"}]}},registerFeaturesManifest:function(e){e=r.resolve(e);t.push(e),e.then(function(e){e&&g.push(e)})},areAnyFeaturesManifestsRegistered:function(){return v().then(function(e){return 0<e.length})},getFeaturesManifestsAsync:v,getFeaturesManifests:function(){return g},getDeviceTypeFeatures:k,getElementTypeLabel:function(e,t){var n,r=_.get(e,"meta.type");r&&(e=_.get(e,"input"),r===f.DISCRETE_IO?n=i(e?"Discrete input":"Coil (discrete output)"):r===f.REGISTER&&(n=e?i("Input register"):(r=k(t),_.get(r,"holdingRegisters.elementTypeLabel",i("Holding register")))));return n},getFieldbusVersion:X,getEmptyDeviceType:function(){var e=y.common,t=y.deviceType;return _.cloneDeep(_objectSpread(_objectSpread({},e),t))},getAvailableDeviceTypes:function(e){return h.apply(this,arguments)},getDeviceTypeFromDevice:function(e){var t=_.flatten(_.map(g,"deviceFragments")),e=_.head(_.compact(_.at(e,t))),t=_.get(e,"type"),e=t&&t.match(/\/inventory\/managedObjects\/(\d+)/),t=_.nth(e,1);if(t)return b(t);return r.resolve(null)},getFieldbusVersionFromDevice:function(e){var t=_.map(g,"deviceConfiguration.fragment"),e=_.head(_.compact(_.at(e,t)));return _.get(e,"maxFieldbusVersion",4)},getDeviceType:b,save:J,exportDeviceTypeAndSaveAs:function(e){var t="".concat(e.name,".json"),e=JSON.stringify(function(e){return e.c8y_ModbusDeviceTypeInfo=function(e){return _.omit(_objectSpread(_objectSpread({},_.get(e,"c8y_ModbusDeviceTypeInfo",{})),{},{name:e.name,minFieldbusUI:n,fieldbusType:e.fieldbusType}),["id","category","description"])}(e),e.c8y_Coils=_.map(e.c8y_Coils,le),e.c8y_Registers=_.map(e.c8y_Registers,le),_.pick(e,["c8y_ModbusDeviceTypeInfo","c8y_Coils","c8y_Registers","c8y_useServerTime","c8y_MessageIdConfiguration"])}(e),null,2),e=new Blob([e],{type:"application/json"});window.saveAs(e,t)},importDeviceTypeWithUI:function(){return a({component:"c8yImportDeviceTypeModal"}).then(J)},getPredefinedDeviceTypeInfos:function(){return me.apply(this,arguments)},isDeviceTypeSupported:ye,isDeviceTypeSupportedAsync:function(n){return v().then(function(e){return _.map(e,"fieldbusType")}).then(function(e){var t=P(n);return _.includes(e,t)})},getPredefinedDeviceType:Xe,downloadPredefinedDeviceTypeAndSaveAs:function(e){return ge.apply(this,arguments)},upgradeDeviceType:S,getElementsWithMeta:function(t){var e=_.get(t,"c8y_Coils",[]),n=_.get(t,"c8y_Registers",[]);return _.union(_.map(e,O),_.map(n,function(e){return D(e,t)}))},addDiscreteIOsMeta:function(e){if(e)return e.c8y_Coils=_.map(e.c8y_Coils,O),e;return},addDiscreteIOMeta:O,removeDiscreteIOMeta:function(e){e.meta&&(e=_.flow([Te,Me,we,Re,Ee])(e),_.unset(e,"meta"));return e},addRegistersMeta:function(t){if(t)return t.c8y_Registers=_.map(t.c8y_Registers,function(e){return D(e,t)}),t;return},addRegisterMeta:D,removeRegisterMeta:function(e){var t=e;e.meta&&(t=_.flow([Ne,Le,Ve,Be,Ge,Fe,$e,We,He,Je])(e),_.unset(t,"meta"));return t},removeAllElements:function(e){e.c8y_Registers=[],e.c8y_Coils=[]},getElementRefId:function(e){e=_.compact(ze(e));return _.head(e)},findElementBestMatchingRefId:function(e,i,o){return _(e).chain().map(function(e){return{score:(n=i,r=o,r=(t=e).meta.type.value===o,t=ze(t),a=_.findIndex(t,_.negate(_.isUndefined)),t=_.indexOf(t,n),r&&0<=t?a-t:void 0),element:e};var t,n,r,a}).reject(function(e){return _.isUndefined(e.score)}).orderBy("score").head().get("element").value()},getDiscreteOutputsCategorized:function(e){return _(e.c8y_Coils).reject("input").groupBy(U).value()},getDiscreteInputsCategorized:function(e){return _(e.c8y_Coils).filter("input").groupBy(U).value()},getHoldingRegistersCategorized:function(e){return _(e.c8y_Registers).reject("input").groupBy(U).value()},getInputRegistersCategorized:function(e){return _(e.c8y_Registers).filter("input").groupBy(U).value()},getEmptyDiscreteOutput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteOutput))},getEmptyDiscreteInput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteInput))},getEmptyHoldingRegister:function(e){return"canbus"!==e.fieldbusType?"canopen"!==e.fieldbusType?_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.holdingRegister)):_.cloneDeep(_objectSpread(_objectSpread({},y.common),y.canopenRegister)):_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.canbusRegister),y.holdingRegister))},getEmptyInputRegister:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.inputRegister))},editDiscreteIOWithUI:function(e,t){return a({component:"c8yConfigureDiscreteIOModal",title:Ke(e),resolve:_objectSpread({title:function(){return Ke(e)}},qe(e,t.c8y_Coils,t))})},editRegisterWithUI:function(n,r){return a({component:"c8yConfigureRegisterModal",resolve:_objectSpread({title:function(){var e=n,t=r;return t=k(t),e.input?e.name?c.getString('Edit input register: "{{name}}"',e):i("New input register"):e.name?c.getString(_.get(t,"holdingRegisters.editRegisterModalTitle",i('Edit holding register: "{{name}}"')),e):_.get(t,"holdingRegisters.newRegisterModalTitle",i("New holding register"))}},qe(n,r.c8y_Registers,r))})},addEmptyEnumValue:function(e){e.meta.enumValues=e.meta.enumValues||[],e.meta.enumValues.push({value:null,label:null})},removeEnumValue:function(e,t){e.meta.enumValues=_.without(e.meta.enumValues,t)},areOverlappingRegisters:function(e,t,n){e=Ye(e,n),t=Ye(t,n),n=Math.max(e.start,t.start),e=Math.min(e.end,t.end);return n<=e},getValuesRange:Pe,openFieldbusSelector:function(e){return a({component:"c8ySelectFieldbusPropertyModal",resolve:{modalParams:function(){return _.defaults(e,{})}}})},downloadPredefinedDeviceTypeHref:function(e){return Qe.apply(this,arguments)},predefinedDeviceTypeHrefFilename:function(e){return"".concat(e.id,".json")},isFieldbusDevice:function(t){return _.some(g,function(e){return _.some(e.deviceFragments,function(e){return _.has(t,e)})})},isFeatureFieldbus4Available:function(){return N.isSubscribed(G)},addElementId:T};function v(){return r.all(t).then(_.compact)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i,o=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=1<o.length&&void 0!==o[1]?o[1]:{},r=2<o.length?o[2]:void 0,i={__and:[{__or:[{__has:p},{type:l}]},{fieldbusType:{__in:_.map(g,"fieldbusType")}}]},_.isEmpty(t)||(i.__and=[].concat(_toConsumableArray(i.__and),[t])),a=u.createListMapper(S),e.next=8,s.listQuery(i,n,!0,r).then(a);case 8:return i=e.sent,e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e){return F.apply(this,arguments)}function F(){return(F=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=u,e.next=3,s.detail(t);case 3:return e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1),e.abrupt("return",S(n));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function S(e){return _.flow([$,W,H,Y,Q])(e)}function $(e){return _.forEach(e.c8y_Coils,function(e){!e.enumValues&&e.statusMapping&&_.isArray(e.statusMapping.enumValues)&&(e.enumValues={0:e.statusMapping.enumValues[0],1:e.statusMapping.enumValues[1]},_.unset(e,"statusMapping.enumValues")),_.isUndefined(e.input)&&(e.input=y.discreteOutput.input)}),e}function W(e){var n=k(e);return _.forEach(e.c8y_Registers,function(e){var t=e.input?"inputRegisters":"holdingRegisters",t=_.get(n,t,{});_.get(t,"startBit")&&_.defaults(e,{startBit:y.register.startBit}),_.get(t,"noBits")&&_.defaults(e,{noBits:y.register.noBits}),_.get(t,"options.signed")&&_.defaults(e,{signed:y.register.signed}),!e.unit&&e.measurementMapping&&e.measurementMapping.unit&&(e.unit=e.measurementMapping.unit,_.unset(e,"measurementMapping.unit")),_.isUndefined(e.input)&&(e.input=y.holdingRegister.input)}),e}function H(e){return e.fieldbusType=P(e),e}function J(e){return z.apply(this,arguments)}function z(){return(z=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=_.flow([q,Y,Z,ee,te,ne,Q])(t),e.next=3,function(){return K.apply(this,arguments)}(n);case 3:return n=e.sent,e.abrupt("return",s.save(n).then(u.getResData).then(function(e){return t.id?e:function(){return pe.apply(this,arguments)}(e).then(function(){return e})}));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function K(){return(K=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=s,e.t1=t,e.next=4,B.getGlobalParam(t.type);case 4:return e.t2=e.sent,e.abrupt("return",e.t0.addGlobalFlag.call(e.t0,e.t1,e.t2));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function q(e){var t;return e.type||(t=k(e),e.type=_.get(t,"type",l)),e}function Y(e){return _.set(e,p,{})}function Q(e){return _.set(e,"fieldbusVersion",X(e))}function X(t){var e=k(t).versions,e=_.findLast(e,function(e){return _.some(e.checks,function(e){return e(t)})});return _.get(e,"number",4)}function Z(e){return e.c8y_Coils=_.map(e.c8y_Coils,T),e.c8y_Registers=_.map(e.c8y_Registers,T),e}function T(e){return e.id||(e.id=String(Math.random()).substr(2)),e}function ee(e){return e.c8y_Coils=_.orderBy(e.c8y_Coils,["input","number"]),e.c8y_Registers=_.orderBy(e.c8y_Registers,["input","number","startBit","index","subIndex"]),e}function te(e){var a,t=k(e);return!!_.get(t,"configuration.messageIdConfiguration.length")&&(e.c8y_MessageTypes=(a=e,_.reduce(["c8y_Registers","c8y_Coils"],function(e,t){return _.merge(e,(n=a,r=t,e=_.groupBy(n[r],"messageTypeId"),e=_.mapValues(e,function(e){return _.map(e,function(e){return _.indexOf(n[r],e)})}),_.reduce(e,function(e,t,n){return e[n]={},e[n][r]=t,e},{})));var n,r},{}))),e}function ne(e){r=k(t=e).customizeSmartRestTemplates||_.identity,n={requestTemplates:_.flattenDeep([function(e){return{msgId:100,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_CoilStatus",value:new j(M(e.c8y_Coils).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Coils).map(function(){return"UNSIGNED"}).value()))}}(t),function(e){return{msgId:101,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_RegisterStatus",value:new j(M(e.c8y_Registers).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Registers).map(function(){return"NUMBER"}).value()))}}(t),[w(102,"EXECUTING"),w(103,"SUCCESSFUL"),w(104,"FAILED")],function(e){return _.flow([re,ue,se])({deviceType:e,msgId:300,templates:[]}).templates}(t)]),responseTemplates:_.flattenDeep([{msgId:200,condition:"$.c8y_SetCoil",pattern:["$.id","$.c8y_SetCoil.address","$.c8y_SetCoil.input","$.c8y_SetCoil.coil","$.c8y_SetCoil.value"]},{msgId:201,condition:"$.c8y_SetRegister",pattern:["$.id","$.c8y_SetRegister.ipAddress","$.c8y_SetRegister.address","$.c8y_SetRegister.input","$.c8y_SetRegister.register","$.c8y_SetRegister.startBit","$.c8y_SetRegister.noBits","$.c8y_SetRegister.value"]},{msgId:202,condition:"$.c8y_ModbusDevice",pattern:["$.id","$.deviceId","$.c8y_ModbusDevice.id","$.c8y_ModbusDevice.address","$.c8y_ModbusDevice.type","$.c8y_ModbusDevice.protocol"]},{msgId:203,condition:"$.c8y_ModbusSource",pattern:["$.id"]}])};var t,n,r=r(n,t);return _.set(e,"com_cumulocity_model_smartrest_SmartRestTemplate",r)}function M(e){return _(e).filter("statusMapping.status")}function w(e,t){return{msgId:e,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.operation+json",placeholder:m,resourceUri:"/devicecontrol/operations/".concat(m),templateString:E({status:t}),values:["UNSIGNED"]}}function re(e){var t=e.deviceType,n=e.msgId,r=e.templates,e=_.filter(t.c8y_Coils,"alarmMapping"),a=_.filter(t.c8y_Registers,"alarmMapping"),i=k(t),o=i.getCoilSource||ie,u=i.getRegisterSource||oe,s=n;return _.forEach(e,function(e){r.push(ae(s,t,e.alarmMapping,o(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),_.forEach(a,function(e){r.push(ae(s,t,e.alarmMapping,u(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),{deviceType:t,templates:r,msgId:s}}function ae(e,t,n,r){return{msgId:e,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.alarm+json",accept:"application/vnd.com.nsn.cumulocity.alarm+json",placeholder:m,resourceUri:"/alarm/alarms",templateString:E([{key:"source",value:{id:m}},{key:"type",value:n.type},{key:"status",value:L.status.ACTIVE},{key:"severity",value:n.severity},{key:"time",value:m},{key:"text",value:n.text},{key:r.key,value:r.value}]),values:["UNSIGNED",R(t)]}}function ie(e){return{key:"c8y_ModbusSource",value:{coil:_.pick(e,"input","number")}}}function oe(e){return{key:"c8y_ModbusSource",value:{register:_.pick(e,["input","number","startBit","noBits"])}}}function ue(e){var r=e.deviceType,t=e.msgId,o=e.templates,e=_([].concat(_toConsumableArray(r.c8y_Coils),_toConsumableArray(r.c8y_Registers))).filter("measurementMapping").groupBy("measurementMapping.type").value(),u=t;return _.forEach(e,function(e,t){var n,a,i,e=_.map(e,function(e){return _.set(e.measurementMapping,"unit",e.unit||e.measurementMapping.unit)});o.push((n=r,a=t,i=e,{msgId:u,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.measurement+json",placeholder:m,resourceUri:"/measurement/measurements",templateString:E(function(){var n=a,r=_defineProperty({source:{id:m},time:m,type:n},n,{});return _.forEach(i,function(e){var t=e.series,e=e.unit;r[n][t]={value:"%n",unit:e}}),r}()),values:["UNSIGNED",R(n)].concat(_toConsumableArray(_.map(i,function(){return"NUMBER"})))})),_.forEach(e,function(e){e.sendMeasurementTemplate=u,_.unset(e,"unit")}),u+=1}),{deviceType:r,templates:o,msgId:u}}function se(e){var a=e.deviceType,t=e.msgId,i=e.templates,e=[].concat(_toConsumableArray(a.c8y_Coils),_toConsumableArray(a.c8y_Registers)),o=t;return _.forEach(e,function(e){var t,n,r;_.isUndefined(e.eventMapping)||(i.push((t=o,n=a,r=e.eventMapping,{msgId:t,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.event+json",placeholder:m,resourceUri:"/event/events",templateString:E([{key:"source",value:{id:m}},{key:"time",value:m},{key:"type",value:r.type},{key:"text",value:r.text},{key:e.name,value:m,raw:!0}]),values:["UNSIGNED",R(n),"NUMBER"]})),e.eventMapping.eventTemplate=o,o+=1)}),{deviceType:a,templates:i,msgId:o}}function R(e){return e.c8y_useServerTime?"NOW":"DATE"}function E(e,t){var n;return e instanceof j?n=I(e.kvObj):_.isArray(e)?n=I(e):_.isObjectLike(e)&&(n=angular.toJson(e)),n=n.replace(/"%n"/g,t||m)}function I(e){e=_.map(e,ce);return"{".concat(e.join(","),"}")}function ce(e){var t=e.key,n=e.value,e=e.raw,r={},e=n instanceof j?(r[t]=":::INNER_OBJECT_STRING:::",JSON.stringify(r).replace('":::INNER_OBJECT_STRING:::"',I(n.kvObj))):e?(r[t]=":::RAW_VALUE:::",JSON.stringify(r).replace('":::RAW_VALUE:::"',n)):(r[t]=n,JSON.stringify(r));return e.substr(1,e.length-2)}function j(e){this.kvObj=e}function pe(){return(pe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,V.createIdentity(t,{type:"c8y_SmartRestDeviceIdentifier",externalId:t.name},{silentError:!0});case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),n=r.reject.bind(r,{errorMessage:e.t0.data.message}),e.abrupt("return",s.remove(t).then(n,n));case 10:case"end":return e.stop()}},e,null,[[0,6]])}))).apply(this,arguments)}function le(e){return e.eventMapping&&(e.eventMapping=_.omit(e.eventMapping,["eventTemplate"])),e.alarmMapping&&(e.alarmMapping=_.omit(e.alarmMapping,["raiseAlarmTemplate"])),e.measurementMapping&&(e.measurementMapping=_.omit(e.measurementMapping,["sendMeasurementTemplate"])),_.omit(e,["id","originalName","originalNumber","originalStartBit","meta"])}function me(){return(me=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,t=et(),n=t&&_.map(t)){e.next=8;break}return r="".concat(d,"/index.json"),e.t0=u,e.next=6,o.get(r);case 6:e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1);case 8:return e.abrupt("return",_.flow([fe,de])(n));case 9:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function fe(e){return _.filter(e,ye)}function de(e){return _.filter(e,function(e){return e.minFieldbusUI<=n})}function ye(e){var t=_.map(g,"fieldbusType"),e=P(e);return _.includes(t,e)}function ge(){return(ge=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(t,".json"),r="predefinedDeviceTypesUrl/".concat(n),e.next=4,o.get(r);case 4:r=e.sent,i=JSON.stringify(r.data,null,2),a=r.headers("Content-Type"),i=new Blob([i],{type:a}),window.saveAs(i,n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function O(e){return e.meta=e.meta||{},_.flow([_e,ve,he,be,Se])(e)}function _e(e){return e.meta.type=e.meta.type||f.DISCRETE_IO,e}function ve(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function he(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function be(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Se(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Te(e){return e.meta.type=void 0,e}function Me(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function we(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Re(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Ee(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function D(e,n){return e.meta=e.meta||{},_.flow([Ie,je,De,xe,Ae,Ce,Ue,function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"dataType.choices",[]),e.meta.dataType=e.meta.dataType||_.find(t.values(),{value:e.dataType}),e},function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"accessType.choices",[]),e.meta.accessType=e.meta.accessType||_.find(t.values(),{value:e.accessType}),e},ke])(e)}function Ie(e){return e.meta.type=e.meta.type||f.REGISTER,e}function je(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function Oe(e,t){return{label:e,value:parseFloat(t)}}function De(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function xe(e){var t=_.get(e,"measurementMapping.sendMeasurementTemplate");return e.meta.sendMeasurement=e.meta.sendMeasurement||!_.isUndefined(t),e}function Ae(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Ce(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Ue(e){return e.meta.sendManagedObjectUpdate=e.meta.sendManagedObjectUpdate||!!e.managedObjectMapping,e}function ke(e){return e.meta.valuesRange=e.meta.valuesRange||Pe(e),e}function Pe(e){var t,n=_.get(e.meta,"dataType",{}),r=_.get(n,"baseValuesRange",{}),a=x([n.divisor,e.divisor,1]),i=x([n.multiplier,e.multiplier,1]),o=x([n.decimalPlaces,e.decimalPlaces,0]),u=x([n.noBits,e.noBits]),n=x([n.signed,e.signed,!1]),s=r.min,r=r.max;return _.isUndefined(o)||null===o||_.isUndefined(i)||_.isUndefined(a)||(t=A(i*Math.pow(10,-o)/a)),_.isUndefined(n)||_.isUndefined(u)||_.isUndefined(t)||(_.isUndefined(s)&&(s=A((n?-Math.pow(2,u-1):0)*t)),_.isUndefined(r)&&(r=A((n?Math.pow(2,u-1)-1:Math.pow(2,u)-1)*t))),{base:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:s,max:r},custom:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:Math.max(s,e.min||s),max:Math.min(r,e.max||r)},mask:{min:0,max:Math.pow(2,u)},possiblePrecisionLoss:function(e,t){e=53<e,t=!_.isUndefined(t)&&10<=function(e){if(Math.floor(e)===e)return 0;return(_slicedToArray(e.toString().split("."),2)[1]||"").length}(t);return e||t}(u,t)}}function x(e){return _.head(_.reject(e,_.isUndefined))}function A(e){var t=Math.pow(10,10);return Math.round(e*t)/t}function Ne(e){return e.meta.type=void 0,e}function Le(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function Ve(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Be(e){return e.meta.sendMeasurement?(e.measurementMapping=e.measurementMapping||{},e.measurementMapping.sendMeasurementTemplate=null):e.measurementMapping=void 0,e}function Ge(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Fe(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function $e(e){return e.meta.sendManagedObjectUpdate?e.managedObjectMapping=e.managedObjectMapping||{}:e.managedObjectMapping=void 0,e}function We(e){return e.meta.dataType?e.dataType=e.meta.dataType.value:e.dataType=void 0,e}function He(e){return e.meta.accessType?e.accessType=e.meta.accessType.value:e.accessType=void 0,e}function Je(e){return e.meta.valuesRange=void 0,e}function ze(e){return[_.get(e,"id"),C(e,["input","number","startBit"]),C(e,["input","number"]),C(e,["number"])]}function C(e,t){t=_.map(t,_.propertyOf(e));if(_.every(t,_.negate(_.isUndefined)))return t.join(",")}function U(e){return e.category||""}function Ke(e){return e.input?e.name?c.getString('Edit discrete input: "{{name}}"',e):i("New discrete input"):e.name?c.getString('Edit coil: "{{name}}"',e):i("New coil")}function qe(e,t,n){return{element:function(){return _.cloneDeep(function(e){if(e)return _objectSpread(_objectSpread({},e),{},{meta:{original:_.cloneDeep(e)}});return}(e))},existingElements:function(){return _.cloneDeep(t)},existingCategories:function(){return _.cloneDeep((e=n,_([].concat(_toConsumableArray(_.get(e,"c8y_Coils",[])),_toConsumableArray(_.get(e,"c8y_Registers",[])))).filter("category").map("category").uniq().map(function(e){return{name:e}}).value()));var e},deviceType:function(){return _.cloneDeep(n)},fieldbusType:function(){return P(n)},features:function(){return k(n)}}}function k(e){return _.find(g,{fieldbusType:P(e)})||{}}function P(e){return e.fieldbusType||"modbus"}function Ye(e,t){var n=e.number,r=e.startBit,e=e.noBits,n=n*_.get(t,"noBits.base",_.get(t,"noBits.max"))+r;return{start:n,end:n+e-1}}function Qe(){return(Qe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id||t,e.next=3,Xe(n);case 3:return n=e.sent,e.abrupt("return",window.btoa(unescape(encodeURIComponent(JSON.stringify(n,null,2)))));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Xe(e){return Ze.apply(this,arguments)}function Ze(){return(Ze=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(e){e=(et()||{})[e];return e&&_.clone(e._item)}(t)){e.next=8;break}return r="".concat(d,"/").concat(t,".json"),e.t0=u,e.next=6,o.get(r);case 6:return e.t1=e.sent,e.abrupt("return",e.t0.getResData.call(e.t0,e.t1));case 8:return e.abrupt("return",n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function et(){return _.get(window,"c8y.collections.devicetypes")}}e.$inject=["$q","$http","$injector","c8yBase","c8yTenant","c8yInventory","c8yAlarms","c8yIdentity","c8yGlobalConfigService","c8yModal","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").factory("c8yDeviceDatabase",e)}();
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return o};var s,o={},e=Object.prototype,c=e.hasOwnProperty,p=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",a=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(s){i=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a,i,o,u,t=t&&t.prototype instanceof _?t:_,t=Object.create(t.prototype),r=new E(r||[]);return p(t,"_invoke",{value:(a=e,i=n,o=r,u=m,function(e,t){if(u===d)throw new Error("Generator is already running");if(u===y){if("throw"===e)throw t;return{value:s,done:!0}}for(o.method=e,o.arg=t;;){var n=o.delegate;if(n){n=function e(t,n){var r=n.method,a=t.iterator[r];if(a===s)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=s,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;r=l(a,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,g;a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=s),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}(n,o);if(n){if(n===g)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(u===m)throw u=y,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);u=d;n=l(a,i,o);if("normal"===n.type){if(u=o.done?y:f,n.arg===g)continue;return{value:n.arg,done:o.done}}"throw"===n.type&&(u=y,o.method="throw",o.arg=n.arg)}})}),t}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=u;var m="suspendedStart",f="suspendedYield",d="executing",y="completed",g={};function _(){}function v(){}function h(){}var t={},b=(i(t,r,function(){return this}),Object.getPrototypeOf),b=b&&b(b(I([]))),T=(b&&b!==e&&c.call(b,r)&&(t=b),h.prototype=_.prototype=Object.create(t));function S(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function M(o,u){var t;p(this,"_invoke",{value:function(n,r){function e(){return new u(function(e,t){!function t(e,n,r,a){var i,e=l(o[e],o,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&c.call(n,"__await")?u.resolve(n.__await).then(function(e){t("next",e,r,a)},function(e){t("throw",e,r,a)}):u.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,a)});a(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function I(t){if(t||""===t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(c.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=s,e.done=!0,e}).next=e}throw new TypeError(_typeof(t)+" is not iterable")}return p(T,"constructor",{value:v.prototype=h,configurable:!0}),p(h,"constructor",{value:v,configurable:!0}),v.displayName=i(h,a,"GeneratorFunction"),o.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,i(e,a,"GeneratorFunction")),e.prototype=Object.create(T),e},o.awrap=function(e){return{__await:e}},S(M.prototype),i(M.prototype,n,function(){return this}),o.AsyncIterator=M,o.async=function(e,t,n,r,a){void 0===a&&(a=Promise);var i=new M(u(e,t,n,r),a);return o.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},S(T),i(T,a,"Generator"),i(T,r,function(){return this}),i(T,"toString",function(){return"[object Generator]"}),o.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},o.values=I,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&c.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=s)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=s),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var a=this.tryEntries[t],i=a.completion;if("root"===a.tryLoc)return e("end");if(a.tryLoc<=this.prev){var o=c.call(a,"catchLoc"),u=c.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return e(a.catchLoc,!0);if(this.prev<a.finallyLoc)return e(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return e(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return e(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}var i=(a=a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc?null:a)?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,a=this.tryEntries[t];if(a.tryLoc===e)return"throw"===(n=a.completion).type&&(r=n.arg,R(a)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=s),g}},o}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,u=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function asyncGeneratorStep(e,t,n,r,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,a)}function _asyncToGenerator(u){return function(){var e=this,o=arguments;return new Promise(function(t,n){var r=u.apply(e,o);function a(e){asyncGeneratorStep(r,t,n,a,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,a,i,"throw",e)}a(void 0)})}}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(r,o,e,u,N,s,L,V,B,a,i,c){var G={name:"feature-fieldbus4"},n=e.has("FIELDBUS_UI_VERSION")?e.get("FIELDBUS_UI_VERSION"):4,p="c8y_IsDeviceType",l="c8y_ModbusDeviceType",m="%%",f=u.createEnum(["DISCRETE_IO","REGISTER"]),e=u.createEnum([{name:"FPORT",label:"FPort"},{name:"PAYLOAD",label:"Payload"}]),d=u.dataFilePath("devicetypes"),y={common:{name:null},deviceType:{c8y_Coils:[],c8y_Registers:[]},element:{number:null},discreteIO:{},discreteOutput:{input:!1},discreteInput:{input:!0},register:{multiplier:1,divisor:1,offset:0,decimalPlaces:0,startBit:0,noBits:16,unit:"",signed:!1},canbusRegister:{noBits:64,offset:0},canopenRegister:{},holdingRegister:{input:!1},inputRegister:{input:!0}},t=[],g=[];return{ElementType:f,MessageIdSources:e,metaDefaults:{discreteIO:{enumValues:[{value:0,label:"0"},{value:1,label:"1"}]}},registerFeaturesManifest:function(e){e=r.resolve(e);t.push(e),e.then(function(e){e&&g.push(e)})},areAnyFeaturesManifestsRegistered:function(){return v().then(function(e){return 0<e.length})},getFeaturesManifestsAsync:v,getFeaturesManifests:function(){return g},getDeviceTypeFeatures:k,getElementTypeLabel:function(e,t){var n,r=_.get(e,"meta.type");r&&(e=_.get(e,"input"),r===f.DISCRETE_IO?n=i(e?"Discrete input":"Coil (discrete output)"):r===f.REGISTER&&(n=e?i("Input register"):(r=k(t),_.get(r,"holdingRegisters.elementTypeLabel",i("Holding register")))));return n},getFieldbusVersion:X,getEmptyDeviceType:function(){var e=y.common,t=y.deviceType;return _.cloneDeep(_objectSpread(_objectSpread({},e),t))},getAvailableDeviceTypes:function(e){return h.apply(this,arguments)},getDeviceTypeFromDevice:function(e){var t=_.flatten(_.map(g,"deviceFragments")),e=_.head(_.compact(_.at(e,t))),t=_.get(e,"type"),e=t&&t.match(/\/inventory\/managedObjects\/(\d+)/),t=_.nth(e,1);if(t)return b(t);return r.resolve(null)},getFieldbusVersionFromDevice:function(e){var t=_.map(g,"deviceConfiguration.fragment"),e=_.head(_.compact(_.at(e,t)));return _.get(e,"maxFieldbusVersion",4)},getDeviceType:b,save:J,exportDeviceTypeAndSaveAs:function(e){var t="".concat(e.name,".json"),e=JSON.stringify(function(e){return e.c8y_ModbusDeviceTypeInfo=function(e){return _.omit(_objectSpread(_objectSpread({},_.get(e,"c8y_ModbusDeviceTypeInfo",{})),{},{name:e.name,minFieldbusUI:n,fieldbusType:e.fieldbusType}),["id","category","description"])}(e),e.c8y_Coils=_.map(e.c8y_Coils,le),e.c8y_Registers=_.map(e.c8y_Registers,le),_.pick(e,["c8y_ModbusDeviceTypeInfo","c8y_Coils","c8y_Registers","c8y_useServerTime","c8y_MessageIdConfiguration"])}(e),null,2),e=new Blob([e],{type:"application/json"});window.saveAs(e,t)},importDeviceTypeWithUI:function(){return a({component:"c8yImportDeviceTypeModal"}).then(J)},getPredefinedDeviceTypeInfos:function(){return me.apply(this,arguments)},isDeviceTypeSupported:ye,isDeviceTypeSupportedAsync:function(n){return v().then(function(e){return _.map(e,"fieldbusType")}).then(function(e){var t=P(n);return _.includes(e,t)})},getPredefinedDeviceType:Xe,downloadPredefinedDeviceTypeAndSaveAs:function(e){return ge.apply(this,arguments)},upgradeDeviceType:T,getElementsWithMeta:function(t){var e=_.get(t,"c8y_Coils",[]),n=_.get(t,"c8y_Registers",[]);return _.union(_.map(e,O),_.map(n,function(e){return D(e,t)}))},addDiscreteIOsMeta:function(e){if(e)return e.c8y_Coils=_.map(e.c8y_Coils,O),e;return},addDiscreteIOMeta:O,removeDiscreteIOMeta:function(e){e.meta&&(e=_.flow([Se,Me,we,Re,Ee])(e),_.unset(e,"meta"));return e},addRegistersMeta:function(t){if(t)return t.c8y_Registers=_.map(t.c8y_Registers,function(e){return D(e,t)}),t;return},addRegisterMeta:D,removeRegisterMeta:function(e){var t=e;e.meta&&(t=_.flow([Ne,Le,Ve,Be,Ge,Fe,$e,We,He,Je])(e),_.unset(t,"meta"));return t},removeAllElements:function(e){e.c8y_Registers=[],e.c8y_Coils=[]},getElementRefId:function(e){e=_.compact(ze(e));return _.head(e)},findElementBestMatchingRefId:function(e,i,o){return _(e).chain().map(function(e){return{score:(n=i,r=o,r=(t=e).meta.type.value===o,t=ze(t),a=_.findIndex(t,_.negate(_.isUndefined)),t=_.indexOf(t,n),r&&0<=t?a-t:void 0),element:e};var t,n,r,a}).reject(function(e){return _.isUndefined(e.score)}).orderBy("score").head().get("element").value()},getDiscreteOutputsCategorized:function(e){return _(e.c8y_Coils).reject("input").groupBy(U).value()},getDiscreteInputsCategorized:function(e){return _(e.c8y_Coils).filter("input").groupBy(U).value()},getHoldingRegistersCategorized:function(e){return _(e.c8y_Registers).reject("input").groupBy(U).value()},getInputRegistersCategorized:function(e){return _(e.c8y_Registers).filter("input").groupBy(U).value()},getEmptyDiscreteOutput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteOutput))},getEmptyDiscreteInput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteInput))},getEmptyHoldingRegister:function(e){return"canbus"!==e.fieldbusType?"canopen"!==e.fieldbusType?_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.holdingRegister)):_.cloneDeep(_objectSpread(_objectSpread({},y.common),y.canopenRegister)):_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.canbusRegister),y.holdingRegister))},getEmptyInputRegister:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.inputRegister))},editDiscreteIOWithUI:function(e,t){return a({component:"c8yConfigureDiscreteIOModal",title:Ke(e),resolve:_objectSpread({title:function(){return Ke(e)}},qe(e,t.c8y_Coils,t))})},editRegisterWithUI:function(n,r){return a({component:"c8yConfigureRegisterModal",resolve:_objectSpread({title:function(){var e=n,t=r;return t=k(t),e.input?e.name?c.getString('Edit input register: "{{name}}"',e):i("New input register"):e.name?c.getString(_.get(t,"holdingRegisters.editRegisterModalTitle",i('Edit holding register: "{{name}}"')),e):_.get(t,"holdingRegisters.newRegisterModalTitle",i("New holding register"))}},qe(n,r.c8y_Registers,r))})},addEmptyEnumValue:function(e){e.meta.enumValues=e.meta.enumValues||[],e.meta.enumValues.push({value:null,label:null})},removeEnumValue:function(e,t){e.meta.enumValues=_.without(e.meta.enumValues,t)},areOverlappingRegisters:function(e,t,n){e=Ye(e,n),t=Ye(t,n),n=Math.max(e.start,t.start),e=Math.min(e.end,t.end);return n<=e},getValuesRange:Pe,openFieldbusSelector:function(e){return a({component:"c8ySelectFieldbusPropertyModal",resolve:{modalParams:function(){return _.defaults(e,{})}}})},downloadPredefinedDeviceTypeHref:function(e){return Qe.apply(this,arguments)},predefinedDeviceTypeHrefFilename:function(e){return"".concat(e.id,".json")},isFieldbusDevice:function(t){return _.some(g,function(e){return _.some(e.deviceFragments,function(e){return _.has(t,e)})})},isFeatureFieldbus4Available:function(){return N.isSubscribed(G)},addElementId:S};function v(){return r.all(t).then(_.compact)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i,o=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=1<o.length&&void 0!==o[1]?o[1]:{},r=2<o.length?o[2]:void 0,i={__and:[{__or:[{__has:p},{type:l}]},{fieldbusType:{__in:_.map(g,"fieldbusType")}}]},_.isEmpty(t)||(i.__and=[].concat(_toConsumableArray(i.__and),[t])),a=u.createListMapper(T),e.next=8,s.listQuery(i,n,!0,r).then(a);case 8:return i=e.sent,e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e){return F.apply(this,arguments)}function F(){return(F=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=u,e.next=3,s.detail(t);case 3:return e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1),e.abrupt("return",T(n));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return _.flow([$,W,H,Y,Q])(e)}function $(e){return _.forEach(e.c8y_Coils,function(e){!e.enumValues&&e.statusMapping&&_.isArray(e.statusMapping.enumValues)&&(e.enumValues={0:e.statusMapping.enumValues[0],1:e.statusMapping.enumValues[1]},_.unset(e,"statusMapping.enumValues")),_.isUndefined(e.input)&&(e.input=y.discreteOutput.input)}),e}function W(e){var n=k(e);return _.forEach(e.c8y_Registers,function(e){var t=e.input?"inputRegisters":"holdingRegisters",t=_.get(n,t,{});_.get(t,"startBit")&&_.defaults(e,{startBit:y.register.startBit}),_.get(t,"noBits")&&_.defaults(e,{noBits:y.register.noBits}),_.get(t,"options.signed")&&_.defaults(e,{signed:y.register.signed}),!e.unit&&e.measurementMapping&&e.measurementMapping.unit&&(e.unit=e.measurementMapping.unit,_.unset(e,"measurementMapping.unit")),_.isUndefined(e.input)&&(e.input=y.holdingRegister.input)}),e}function H(e){return e.fieldbusType=P(e),e}function J(e){return z.apply(this,arguments)}function z(){return(z=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=_.flow([q,Y,Z,ee,te,ne,Q])(t),e.next=3,function(){return K.apply(this,arguments)}(n);case 3:return n=e.sent,e.abrupt("return",s.save(n).then(u.getResData).then(function(e){return t.id?e:function(){return pe.apply(this,arguments)}(e).then(function(){return e})}));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function K(){return(K=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=s,e.t1=t,e.next=4,B.getGlobalParam(t.type);case 4:return e.t2=e.sent,e.abrupt("return",e.t0.addGlobalFlag.call(e.t0,e.t1,e.t2));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function q(e){var t;return e.type||(t=k(e),e.type=_.get(t,"type",l)),e}function Y(e){return _.set(e,p,{})}function Q(e){return _.set(e,"fieldbusVersion",X(e))}function X(t){var e=k(t).versions,e=_.findLast(e,function(e){return _.some(e.checks,function(e){return e(t)})});return _.get(e,"number",4)}function Z(e){return e.c8y_Coils=_.map(e.c8y_Coils,S),e.c8y_Registers=_.map(e.c8y_Registers,S),e}function S(e){return e.id||(e.id=String(Math.random()).substr(2)),e}function ee(e){return e.c8y_Coils=_.orderBy(e.c8y_Coils,["input","number"]),e.c8y_Registers=_.orderBy(e.c8y_Registers,["input","number","startBit","index","subIndex"]),e}function te(e){var a,t=k(e);return!!_.get(t,"configuration.messageIdConfiguration.length")&&(e.c8y_MessageTypes=(a=e,_.reduce(["c8y_Registers","c8y_Coils"],function(e,t){return _.merge(e,(n=a,r=t,e=_.groupBy(n[r],"messageTypeId"),e=_.mapValues(e,function(e){return _.map(e,function(e){return _.indexOf(n[r],e)})}),_.reduce(e,function(e,t,n){return e[n]={},e[n][r]=t,e},{})));var n,r},{}))),e}function ne(e){r=k(t=e).customizeSmartRestTemplates||_.identity,n={requestTemplates:_.flattenDeep([function(e){return{msgId:100,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_CoilStatus",value:new j(M(e.c8y_Coils).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Coils).map(function(){return"UNSIGNED"}).value()))}}(t),function(e){return{msgId:101,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_RegisterStatus",value:new j(M(e.c8y_Registers).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Registers).map(function(){return"NUMBER"}).value()))}}(t),[w(102,"EXECUTING"),w(103,"SUCCESSFUL"),w(104,"FAILED")],function(e){return _.flow([re,ue,se])({deviceType:e,msgId:300,templates:[]}).templates}(t)]),responseTemplates:_.flattenDeep([{msgId:200,condition:"$.c8y_SetCoil",pattern:["$.id","$.c8y_SetCoil.address","$.c8y_SetCoil.input","$.c8y_SetCoil.coil","$.c8y_SetCoil.value"]},{msgId:201,condition:"$.c8y_SetRegister",pattern:["$.id","$.c8y_SetRegister.ipAddress","$.c8y_SetRegister.address","$.c8y_SetRegister.input","$.c8y_SetRegister.register","$.c8y_SetRegister.startBit","$.c8y_SetRegister.noBits","$.c8y_SetRegister.value"]},{msgId:202,condition:"$.c8y_ModbusDevice",pattern:["$.id","$.deviceId","$.c8y_ModbusDevice.id","$.c8y_ModbusDevice.address","$.c8y_ModbusDevice.type","$.c8y_ModbusDevice.protocol"]},{msgId:203,condition:"$.c8y_ModbusSource",pattern:["$.id"]}])};var t,n,r=r(n,t);return _.set(e,"com_cumulocity_model_smartrest_SmartRestTemplate",r)}function M(e){return _(e).filter("statusMapping.status")}function w(e,t){return{msgId:e,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.operation+json",placeholder:m,resourceUri:"/devicecontrol/operations/".concat(m),templateString:E({status:t}),values:["UNSIGNED"]}}function re(e){var t=e.deviceType,n=e.msgId,r=e.templates,e=_.filter(t.c8y_Coils,"alarmMapping"),a=_.filter(t.c8y_Registers,"alarmMapping"),i=k(t),o=i.getCoilSource||ie,u=i.getRegisterSource||oe,s=n;return _.forEach(e,function(e){r.push(ae(s,t,e.alarmMapping,o(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),_.forEach(a,function(e){r.push(ae(s,t,e.alarmMapping,u(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),{deviceType:t,templates:r,msgId:s}}function ae(e,t,n,r){return{msgId:e,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.alarm+json",accept:"application/vnd.com.nsn.cumulocity.alarm+json",placeholder:m,resourceUri:"/alarm/alarms",templateString:E([{key:"source",value:{id:m}},{key:"type",value:n.type},{key:"status",value:L.status.ACTIVE},{key:"severity",value:n.severity},{key:"time",value:m},{key:"text",value:n.text},{key:r.key,value:r.value}]),values:["UNSIGNED",R(t)]}}function ie(e){return{key:"c8y_ModbusSource",value:{coil:_.pick(e,"input","number")}}}function oe(e){return{key:"c8y_ModbusSource",value:{register:_.pick(e,["input","number","startBit","noBits"])}}}function ue(e){var r=e.deviceType,t=e.msgId,o=e.templates,e=_([].concat(_toConsumableArray(r.c8y_Coils),_toConsumableArray(r.c8y_Registers))).filter("measurementMapping").groupBy("measurementMapping.type").value(),u=t;return _.forEach(e,function(e,t){var n,a,i,e=_.map(e,function(e){return _.set(e.measurementMapping,"unit",e.unit||e.measurementMapping.unit)});o.push((n=r,a=t,i=e,{msgId:u,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.measurement+json",placeholder:m,resourceUri:"/measurement/measurements",templateString:E(function(){var n=a,r=_defineProperty({source:{id:m},time:m,type:n},n,{});return _.forEach(i,function(e){var t=e.series,e=e.unit;r[n][t]={value:"%n",unit:e}}),r}()),values:["UNSIGNED",R(n)].concat(_toConsumableArray(_.map(i,function(){return"NUMBER"})))})),_.forEach(e,function(e){e.sendMeasurementTemplate=u,_.unset(e,"unit")}),u+=1}),{deviceType:r,templates:o,msgId:u}}function se(e){var a=e.deviceType,t=e.msgId,i=e.templates,e=[].concat(_toConsumableArray(a.c8y_Coils),_toConsumableArray(a.c8y_Registers)),o=t;return _.forEach(e,function(e){var t,n,r;_.isUndefined(e.eventMapping)||(i.push((t=o,n=a,r=e.eventMapping,{msgId:t,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.event+json",placeholder:m,resourceUri:"/event/events",templateString:E([{key:"source",value:{id:m}},{key:"time",value:m},{key:"type",value:r.type},{key:"text",value:r.text},{key:e.name,value:m,raw:!0}]),values:["UNSIGNED",R(n),"NUMBER"]})),e.eventMapping.eventTemplate=o,o+=1)}),{deviceType:a,templates:i,msgId:o}}function R(e){return e.c8y_useServerTime?"NOW":"DATE"}function E(e,t){var n;return e instanceof j?n=I(e.kvObj):_.isArray(e)?n=I(e):_.isObjectLike(e)&&(n=angular.toJson(e)),n=n.replace(/"%n"/g,t||m)}function I(e){e=_.map(e,ce);return"{".concat(e.join(","),"}")}function ce(e){var t=e.key,n=e.value,e=e.raw,r={},e=n instanceof j?(r[t]=":::INNER_OBJECT_STRING:::",JSON.stringify(r).replace('":::INNER_OBJECT_STRING:::"',I(n.kvObj))):e?(r[t]=":::RAW_VALUE:::",JSON.stringify(r).replace('":::RAW_VALUE:::"',n)):(r[t]=n,JSON.stringify(r));return e.substr(1,e.length-2)}function j(e){this.kvObj=e}function pe(){return(pe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,V.createIdentity(t,{type:"c8y_SmartRestDeviceIdentifier",externalId:t.name},{silentError:!0});case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),n=r.reject.bind(r,{errorMessage:e.t0.data.message}),e.abrupt("return",s.remove(t).then(n,n));case 10:case"end":return e.stop()}},e,null,[[0,6]])}))).apply(this,arguments)}function le(e){return e.eventMapping&&(e.eventMapping=_.omit(e.eventMapping,["eventTemplate"])),e.alarmMapping&&(e.alarmMapping=_.omit(e.alarmMapping,["raiseAlarmTemplate"])),e.measurementMapping&&(e.measurementMapping=_.omit(e.measurementMapping,["sendMeasurementTemplate"])),_.omit(e,["id","originalName","originalNumber","originalStartBit","meta"])}function me(){return(me=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,t=et(),n=t&&_.map(t)){e.next=8;break}return r="".concat(d,"/index.json"),e.t0=u,e.next=6,o.get(r);case 6:e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1);case 8:return e.abrupt("return",_.flow([fe,de])(n));case 9:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function fe(e){return _.filter(e,ye)}function de(e){return _.filter(e,function(e){return e.minFieldbusUI<=n})}function ye(e){var t=_.map(g,"fieldbusType"),e=P(e);return _.includes(t,e)}function ge(){return(ge=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(t,".json"),r="predefinedDeviceTypesUrl/".concat(n),e.next=4,o.get(r);case 4:r=e.sent,i=JSON.stringify(r.data,null,2),a=r.headers("Content-Type"),i=new Blob([i],{type:a}),window.saveAs(i,n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function O(e){return e.meta=e.meta||{},_.flow([_e,ve,he,be,Te])(e)}function _e(e){return e.meta.type=e.meta.type||f.DISCRETE_IO,e}function ve(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function he(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function be(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Te(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Se(e){return e.meta.type=void 0,e}function Me(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function we(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Re(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Ee(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function D(e,n){return e.meta=e.meta||{},_.flow([Ie,je,De,Ae,xe,Ce,Ue,function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"dataType.choices",[]),e.meta.dataType=e.meta.dataType||_.find(t.values(),{value:e.dataType}),e},function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"accessType.choices",[]),e.meta.accessType=e.meta.accessType||_.find(t.values(),{value:e.accessType}),e},ke])(e)}function Ie(e){return e.meta.type=e.meta.type||f.REGISTER,e}function je(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function Oe(e,t){return{label:e,value:parseFloat(t)}}function De(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function Ae(e){var t=_.get(e,"measurementMapping.sendMeasurementTemplate");return e.meta.sendMeasurement=e.meta.sendMeasurement||!_.isUndefined(t),e}function xe(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Ce(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Ue(e){return e.meta.sendManagedObjectUpdate=e.meta.sendManagedObjectUpdate||!!e.managedObjectMapping,e}function ke(e){return e.meta.valuesRange=e.meta.valuesRange||Pe(e),e}function Pe(e){var t,n=_.get(e.meta,"dataType",{}),r=_.get(n,"baseValuesRange",{}),a=A([n.divisor,e.divisor,1]),i=A([n.multiplier,e.multiplier,1]),o=A([n.decimalPlaces,e.decimalPlaces,0]),u=A([n.noBits,e.noBits]),n=A([n.signed,e.signed,!1]),s=r.min,r=r.max;return _.isUndefined(o)||null===o||_.isUndefined(i)||_.isUndefined(a)||(t=x(i*Math.pow(10,-o)/a)),_.isUndefined(n)||_.isUndefined(u)||_.isUndefined(t)||(_.isUndefined(s)&&(s=x((n?-Math.pow(2,u-1):0)*t)),_.isUndefined(r)&&(r=x((n?Math.pow(2,u-1)-1:Math.pow(2,u)-1)*t))),{base:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:s,max:r},custom:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:Math.max(s,e.min||s),max:Math.min(r,e.max||r)},mask:{min:0,max:Math.pow(2,u)},possiblePrecisionLoss:function(e,t){e=53<e,t=!_.isUndefined(t)&&10<=function(e){if(Math.floor(e)===e)return 0;return(_slicedToArray(e.toString().split("."),2)[1]||"").length}(t);return e||t}(u,t)}}function A(e){return _.head(_.reject(e,_.isUndefined))}function x(e){var t=Math.pow(10,10);return Math.round(e*t)/t}function Ne(e){return e.meta.type=void 0,e}function Le(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function Ve(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Be(e){return e.meta.sendMeasurement?(e.measurementMapping=e.measurementMapping||{},e.measurementMapping.sendMeasurementTemplate=null):e.measurementMapping=void 0,e}function Ge(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Fe(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function $e(e){return e.meta.sendManagedObjectUpdate?e.managedObjectMapping=e.managedObjectMapping||{}:e.managedObjectMapping=void 0,e}function We(e){return e.meta.dataType?e.dataType=e.meta.dataType.value:e.dataType=void 0,e}function He(e){return e.meta.accessType?e.accessType=e.meta.accessType.value:e.accessType=void 0,e}function Je(e){return e.meta.valuesRange=void 0,e}function ze(e){return[_.get(e,"id"),C(e,["input","number","startBit"]),C(e,["input","number"]),C(e,["number"])]}function C(e,t){t=_.map(t,_.propertyOf(e));if(_.every(t,_.negate(_.isUndefined)))return t.join(",")}function U(e){return e.category||""}function Ke(e){return e.input?e.name?c.getString('Edit discrete input: "{{name}}"',e):i("New discrete input"):e.name?c.getString('Edit coil: "{{name}}"',e):i("New coil")}function qe(e,t,n){return{element:function(){return _.cloneDeep(function(e){if(e)return _objectSpread(_objectSpread({},e),{},{meta:{original:_.cloneDeep(e)}});return}(e))},existingElements:function(){return _.cloneDeep(t)},existingCategories:function(){return _.cloneDeep((e=n,_([].concat(_toConsumableArray(_.get(e,"c8y_Coils",[])),_toConsumableArray(_.get(e,"c8y_Registers",[])))).filter("category").map("category").uniq().map(function(e){return{name:e}}).value()));var e},deviceType:function(){return _.cloneDeep(n)},fieldbusType:function(){return P(n)},features:function(){return k(n)}}}function k(e){return _.find(g,{fieldbusType:P(e)})||{}}function P(e){return e.fieldbusType||"modbus"}function Ye(e,t){var n=e.number,r=e.startBit,e=e.noBits,n=n*_.get(t,"noBits.base",_.get(t,"noBits.max"))+r;return{start:n,end:n+e-1}}function Qe(){return(Qe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id||t,e.next=3,Xe(n);case 3:return n=e.sent,e.abrupt("return",window.btoa(unescape(encodeURIComponent(JSON.stringify(n,null,2)))));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Xe(e){return Ze.apply(this,arguments)}function Ze(){return(Ze=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(e){e=(et()||{})[e];return e&&_.clone(e._item)}(t)){e.next=8;break}return r="".concat(d,"/").concat(t,".json"),e.t0=u,e.next=6,o.get(r);case 6:return e.t1=e.sent,e.abrupt("return",e.t0.getResData.call(e.t0,e.t1));case 8:return e.abrupt("return",n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function et(){return _.get(window,"c8y.collections.devicetypes")}}e.$inject=["$q","$http","$injector","c8yBase","c8yTenant","c8yInventory","c8yAlarms","c8yIdentity","c8yGlobalConfigService","c8yModal","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").factory("c8yDeviceDatabase",e)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},e=Object.prototype,u=e.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof f?t:f,t=Object.create(t.prototype),n=new _(n||[]);return s(t,"_invoke",{value:(o=e,i=r,a=n,c="suspendedStart",function(e,t){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===e)throw t;return T()}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;n=l(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,p;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,p):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}(r,a);if(r){if(r===p)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";r=l(o,i,a);if("normal"===r.type){if(c=a.done?"completed":"suspendedYield",r.arg===p)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c="completed",a.method="throw",a.arg=r.arg)}})}),t}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var p={};function f(){}function y(){}function h(){}var t={},d=(i(t,n,function(){return this}),Object.getPrototypeOf),d=d&&d(d(x([]))),v=(d&&d!==e&&u.call(d,n)&&(t=d),h.prototype=f.prototype=Object.create(t));function g(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function m(a,c){var t;s(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=l(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function x(t){if(t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(u.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:T}}function T(){return{value:void 0,done:!0}}return s(v,"constructor",{value:y.prototype=h,configurable:!0}),s(h,"constructor",{value:y,configurable:!0}),y.displayName=i(h,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,i(e,o,"GeneratorFunction")),e.prototype=Object.create(v),e},a.awrap=function(e){return{__await:e}},g(m.prototype),i(m.prototype,r,function(){return this}),a.AsyncIterator=m,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new m(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},g(v),i(v,o,"Generator"),i(v,n,function(){return this}),i(v,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=x,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&u.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,w(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(r,t,n,o,i,a,c,u,s,l){var p=this;function e(){return(e=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a.changeTitle({title:s("Device database")}),e.t0=m,e.next=4,g();case 4:e.t1=e.sent,(0,e.t0)(e.t1),r.$apply();case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(e){e=_.get(e,"id","new");n.path("/device-types/".concat(e))}function y(){return(y=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,i.importDeviceTypeWithUI();case 3:return u.success(s("New device type imported.")),e.next=6,h();case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),t=e.t0,_.isObjectLike(t)&&((t=t.errorMessage)?u.danger(l.getString('Could not import device type due to: "{{errorMessage | translate}}".',{errorMessage:t})):u.danger(s("Could not import device type.")));case 11:r.$apply();case 12:case"end":return e.stop()}var t},e,null,[[0,8]])}))).apply(this,arguments)}function h(){return d.apply(this,arguments)}function d(){return(d=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.deviceTypes=void 0,t.refreshLoading=!0,e.prev=2,e.t0=m,e.next=6,g();case 6:e.t1=e.sent,(0,e.t0)(e.t1);case 8:return e.prev=8,t.refreshLoading=!1,e.finish(8);case 11:r.$apply();case 12:case"end":return e.stop()}},e,null,[[2,,8,11]])}))).apply(this,arguments)}function v(){return(v=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.paging.loading=!0,e.prev=1,e.t0=m,e.next=5,g();case 5:e.t1=e.sent,(0,e.t0)(e.t1);case 7:return e.prev=7,t.paging.loading=!1,e.finish(7);case 10:r.$apply();case 11:case"end":return e.stop()}},e,null,[[1,,7,10]])}))).apply(this,arguments)}function g(){return i.getAvailableDeviceTypes()}function m(e){p.deviceTypes||(p.deviceTypes=[]),p.deviceTypes=[].concat(_toConsumableArray(p.deviceTypes),_toConsumableArray(e)),t.paging=e.paging||{refresh:!0},r.$apply()}function b(){return(b=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c({title:s("Delete device type"),body:l.getString('You are about to delete device type "{{name}}". Connected devices of this type will become unavailable. Do you want to proceed?',t),status:"danger",labels:{ok:s("Delete")}});case 3:return e.next=5,o.remove(t);case 5:p.deviceTypes=_.without(p.deviceTypes,t),u.success(s("Device type deleted.")),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),e.t0&&u.danger(e.t0);case 12:r.$apply();case 13:case"end":return e.stop()}},e,null,[[0,9]])}))).apply(this,arguments)}_.assign(p,{$onInit:function(){return e.apply(this,arguments)},addDeviceType:f,importDeviceType:function(){return y.apply(this,arguments)},navigateToDetails:f,onClickExport:function(e){return i.exportDeviceTypeAndSaveAs(e)},onClickDelete:function(e){return b.apply(this,arguments)},getFieldbusTypeLabel:function(e){return _.get(i.getDeviceTypeFeatures(e),"label",e.fieldbusType)},getFieldbusVersion:i.getFieldbusVersion}),t.paging={},t.loadNext=function(){return v.apply(this,arguments)},t.refresh=h}e.$inject=["$rootScope","$scope","$location","c8yInventory","c8yDeviceDatabase","c8yTitle","c8yModal","c8yAlert","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yDeviceTypeList",{templateUrl:":::PLUGIN_PATH:::/device-type-list.html",bindings:{},controllerAs:"vm",controller:e})}();
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var u,a={},e=Object.prototype,s=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(u){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof g?t:g,t=Object.create(t.prototype),n=new E(n||[]);return l(t,"_invoke",{value:(o=e,i=r,a=n,c=f,function(e,t){if(c===h)throw new Error("Generator is already running");if(c===d){if("throw"===e)throw t;return{value:u,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=u,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;n=p(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,v;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}(r,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===f)throw c=d,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;r=p(o,i,a);if("normal"===r.type){if(c=a.done?d:y,r.arg===v)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c=d,a.method="throw",a.arg=r.arg)}})}),t}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var f="suspendedStart",y="suspendedYield",h="executing",d="completed",v={};function g(){}function m(){}function b(){}var t={},w=(i(t,n,function(){return this}),Object.getPrototypeOf),w=w&&w(w(S([]))),_=(w&&w!==e&&s.call(w,n)&&(t=w),b.prototype=g.prototype=Object.create(t));function x(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function T(a,c){var t;l(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=p(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&s.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function S(t){if(t||""===t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(s.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=u,e.done=!0,e}).next=e}throw new TypeError(_typeof(t)+" is not iterable")}return l(_,"constructor",{value:m.prototype=b,configurable:!0}),l(b,"constructor",{value:m,configurable:!0}),m.displayName=i(b,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,i(e,o,"GeneratorFunction")),e.prototype=Object.create(_),e},a.awrap=function(e){return{__await:e}},x(T.prototype),i(T.prototype,r,function(){return this}),a.AsyncIterator=T,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new T(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},x(_),i(_,o,"Generator"),i(_,n,function(){return this}),i(_,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=S,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,A(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=u),v}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(r,t,n,o,i,a,c,u,s,l){var p=this;function e(){return(e=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a.changeTitle({title:s("Device database")}),e.t0=m,e.next=4,g();case 4:e.t1=e.sent,(0,e.t0)(e.t1),r.$apply();case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(e){e=_.get(e,"id","new");n.path("/device-types/".concat(e))}function y(){return(y=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,i.importDeviceTypeWithUI();case 3:return u.success(s("New device type imported.")),e.next=6,h();case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),t=e.t0,_.isObjectLike(t)&&((t=t.errorMessage)?u.danger(l.getString('Could not import device type due to: "{{errorMessage | translate}}".',{errorMessage:t})):u.danger(s("Could not import device type.")));case 11:r.$apply();case 12:case"end":return e.stop()}var t},e,null,[[0,8]])}))).apply(this,arguments)}function h(){return d.apply(this,arguments)}function d(){return(d=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.deviceTypes=void 0,t.refreshLoading=!0,e.prev=2,e.t0=m,e.next=6,g();case 6:e.t1=e.sent,(0,e.t0)(e.t1);case 8:return e.prev=8,t.refreshLoading=!1,e.finish(8);case 11:r.$apply();case 12:case"end":return e.stop()}},e,null,[[2,,8,11]])}))).apply(this,arguments)}function v(){return(v=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.paging.loading=!0,e.prev=1,e.t0=m,e.next=5,g();case 5:e.t1=e.sent,(0,e.t0)(e.t1);case 7:return e.prev=7,t.paging.loading=!1,e.finish(7);case 10:r.$apply();case 11:case"end":return e.stop()}},e,null,[[1,,7,10]])}))).apply(this,arguments)}function g(){return i.getAvailableDeviceTypes()}function m(e){p.deviceTypes||(p.deviceTypes=[]),p.deviceTypes=[].concat(_toConsumableArray(p.deviceTypes),_toConsumableArray(e)),t.paging=e.paging||{refresh:!0},r.$apply()}function b(){return(b=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c({title:s("Delete device type"),body:l.getString('You are about to delete device type "{{name}}". Connected devices of this type will become unavailable. Do you want to proceed?',t),status:"danger",labels:{ok:s("Delete")}});case 3:return e.next=5,o.remove(t);case 5:p.deviceTypes=_.without(p.deviceTypes,t),u.success(s("Device type deleted.")),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),e.t0&&u.danger(e.t0);case 12:r.$apply();case 13:case"end":return e.stop()}},e,null,[[0,9]])}))).apply(this,arguments)}_.assign(p,{$onInit:function(){return e.apply(this,arguments)},addDeviceType:f,importDeviceType:function(){return y.apply(this,arguments)},navigateToDetails:f,onClickExport:function(e){return i.exportDeviceTypeAndSaveAs(e)},onClickDelete:function(e){return b.apply(this,arguments)},getFieldbusTypeLabel:function(e){return _.get(i.getDeviceTypeFeatures(e),"label",e.fieldbusType)},getFieldbusVersion:i.getFieldbusVersion}),t.paging={},t.loadNext=function(){return v.apply(this,arguments)},t.refresh=h}e.$inject=["$rootScope","$scope","$location","c8yInventory","c8yDeviceDatabase","c8yTitle","c8yModal","c8yAlert","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yDeviceTypeList",{templateUrl:":::PLUGIN_PATH:::/device-type-list.html",bindings:{},controllerAs:"vm",controller:e})}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},e=Object.prototype,u=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof p?t:p,t=Object.create(t.prototype),n=new T(n||[]);return l(t,"_invoke",{value:(o=e,i=r,a=n,c="suspendedStart",function(e,t){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===e)throw t;return x()}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),s;n=f(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,s;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,s):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,s)}(r,a);if(r){if(r===s)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";r=f(o,i,a);if("normal"===r.type){if(c=a.done?"completed":"suspendedYield",r.arg===s)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c="completed",a.method="throw",a.arg=r.arg)}})}),t}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var s={};function p(){}function d(){}function y(){}var t={},h=(i(t,n,function(){return this}),Object.getPrototypeOf),h=h&&h(h(_([]))),v=(h&&h!==e&&u.call(h,n)&&(t=h),y.prototype=p.prototype=Object.create(t));function m(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function g(a,c){var t;l(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=f(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function _(t){if(t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(u.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:x}}function x(){return{value:void 0,done:!0}}return l(v,"constructor",{value:d.prototype=y,configurable:!0}),l(y,"constructor",{value:d,configurable:!0}),d.displayName=i(y,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,i(e,o,"GeneratorFunction")),e.prototype=Object.create(v),e},a.awrap=function(e){return{__await:e}},m(g.prototype),i(g.prototype,r,function(){return this}),a.AsyncIterator=g,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new g(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},m(v),i(v,o,"Generator"),i(v,n,function(){return this}),i(v,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=_,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&u.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,s):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),b(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,b(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:_(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(e,a,c,t,r,n,o){var i=this,u={predefined:{info:null,deviceType:null},custom:{file:null,deviceType:null},newName:{value:null,edited:!1}};function l(){return(l=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=[],e.t1=_toConsumableArray(i.predefinedDeviceTypeInfos),e.t2=_toConsumableArray,e.next=5,c.getPredefinedDeviceTypeInfos();case 5:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),i.predefinedDeviceTypeInfos=e.t0.concat.call(e.t0,e.t1,e.t4),a.$apply();case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(){return(f=_asyncToGenerator(_regeneratorRuntime().mark(function e(r){var n,o,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.id,n=r.name,o=r.fieldbusType,s(),e.next=4,c.getPredefinedDeviceType(i);case 4:i=e.sent,t=i,u.predefined.info=r,u.predefined.deviceType=t,p(n,o),a.$apply();case 8:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function s(){u.custom.file=null,u.custom.deviceType=null}function p(e,t){u.newName.edited||(u.newName.value=e),u.fieldbusType=t}function d(e){i.customDeviceTypeFeedback=e}function y(t){var r=y.cache||{},e=(y.cache=r)[t.id];return e||(e=c.downloadPredefinedDeviceTypeHref(t).then(function(e){r[t.id]=e}),r[t.id]=e),e.then?"":e}_.assign(i,{$onInit:function(){return l.apply(this,arguments)},selection:u,predefinedDeviceTypeInfos:[],downloadPredefinedDeviceType:function(e){return c.downloadPredefinedDeviceTypeAndSaveAs(e.id)},onPredefinedDeviceTypeInfoSelected:function(e){return f.apply(this,arguments)},isPredefinedDeviceTypeInfoSelected:function(e){return u.predefined.info===e},onCustomDeviceTypeFileSelected:function(e){{var n;_.isEmpty(e)||(n=_.head(e),d({type:"progress",summary:o.getString("Processing file…")}),t.parseFile(n).then(function(e){var t,r=e.deviceType,e=e.feedback;u.predefined.info=null,u.predefined.deviceType=null,t=r,u.custom.file=n,u.custom.deviceType=t,p(r.name,r.fieldbusType),d(e)}).catch(function(e){e=e.feedback;s(),d(e)}))}},onNewNameEdited:function(){u.newName.edited=!0},import:function(){var e=u.predefined,t=u.custom,r=u.newName,n=u.fieldbusType,e=_.cloneDeep(e.deviceType||t.deviceType);e.name=r.value,e.fieldbusType=n,i.close({$value:e})},downloadFileName:c.predefinedDeviceTypeHrefFilename,downloadFileHref:y})}e.$inject=["$scope","$rootScope","c8yDeviceDatabase","c8yDeviceTypeParser","c8yAlert","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yImportDeviceTypeModal",{templateUrl:":::PLUGIN_PATH:::/modals/import-device-type.html",bindings:{close:"&",dismiss:"&"},controllerAs:"vm",controller:e})}();
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var u,a={},e=Object.prototype,l=e.hasOwnProperty,f=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(u){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),n=new E(n||[]);return f(t,"_invoke",{value:(o=e,i=r,a=n,c=p,function(e,t){if(c===d)throw new Error("Generator is already running");if(c===h){if("throw"===e)throw t;return{value:u,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=u,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;n=s(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,v;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}(r,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===p)throw c=h,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=d;r=s(o,i,a);if("normal"===r.type){if(c=a.done?h:y,r.arg===v)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c=h,a.method="throw",a.arg=r.arg)}})}),t}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var p="suspendedStart",y="suspendedYield",d="executing",h="completed",v={};function m(){}function g(){}function w(){}var t={},b=(i(t,n,function(){return this}),Object.getPrototypeOf),b=b&&b(b(A([]))),T=(b&&b!==e&&l.call(b,n)&&(t=b),w.prototype=m.prototype=Object.create(t));function _(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function L(a,c){var t;f(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=s(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&l.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function A(t){if(t||""===t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(l.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=u,e.done=!0,e}).next=e}throw new TypeError(_typeof(t)+" is not iterable")}return f(T,"constructor",{value:g.prototype=w,configurable:!0}),f(w,"constructor",{value:g,configurable:!0}),g.displayName=i(w,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,i(e,o,"GeneratorFunction")),e.prototype=Object.create(T),e},a.awrap=function(e){return{__await:e}},_(L.prototype),i(L.prototype,r,function(){return this}),a.AsyncIterator=L,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new L(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},_(T),i(T,o,"Generator"),i(T,n,function(){return this}),i(T,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=A,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&l.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=l.call(o,"catchLoc"),c=l.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,S(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=u),v}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(e,a,c,t,r,n,o){var i=this,u={predefined:{info:null,deviceType:null},custom:{file:null,deviceType:null},newName:{value:null,edited:!1}};function l(){return(l=_asyncToGenerator(_regeneratorRuntime().mark(function e(){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=[],e.t1=_toConsumableArray(i.predefinedDeviceTypeInfos),e.t2=_toConsumableArray,e.next=5,c.getPredefinedDeviceTypeInfos();case 5:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),i.predefinedDeviceTypeInfos=e.t0.concat.call(e.t0,e.t1,e.t4),a.$apply();case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(){return(f=_asyncToGenerator(_regeneratorRuntime().mark(function e(r){var n,o,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.id,n=r.name,o=r.fieldbusType,s(),e.next=4,c.getPredefinedDeviceType(i);case 4:i=e.sent,t=i,u.predefined.info=r,u.predefined.deviceType=t,p(n,o),a.$apply();case 8:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function s(){u.custom.file=null,u.custom.deviceType=null}function p(e,t){u.newName.edited||(u.newName.value=e),u.fieldbusType=t}function y(e){i.customDeviceTypeFeedback=e}function d(t){var r=d.cache||{},e=(d.cache=r)[t.id];return e||(e=c.downloadPredefinedDeviceTypeHref(t).then(function(e){r[t.id]=e}),r[t.id]=e),e.then?"":e}_.assign(i,{$onInit:function(){return l.apply(this,arguments)},selection:u,predefinedDeviceTypeInfos:[],downloadPredefinedDeviceType:function(e){return c.downloadPredefinedDeviceTypeAndSaveAs(e.id)},onPredefinedDeviceTypeInfoSelected:function(e){return f.apply(this,arguments)},isPredefinedDeviceTypeInfoSelected:function(e){return u.predefined.info===e},onCustomDeviceTypeFileSelected:function(e){{var n;_.isEmpty(e)||(n=_.head(e),y({type:"progress",summary:o.getString("Processing file…")}),t.parseFile(n).then(function(e){var t,r=e.deviceType,e=e.feedback;u.predefined.info=null,u.predefined.deviceType=null,t=r,u.custom.file=n,u.custom.deviceType=t,p(r.name,r.fieldbusType),y(e)}).catch(function(e){e=e.feedback;s(),y(e)}))}},onNewNameEdited:function(){u.newName.edited=!0},import:function(){var e=u.predefined,t=u.custom,r=u.newName,n=u.fieldbusType,e=_.cloneDeep(e.deviceType||t.deviceType);e.name=r.value,e.fieldbusType=n,i.close({$value:e})},downloadFileName:c.predefinedDeviceTypeHrefFilename,downloadFileHref:d})}e.$inject=["$scope","$rootScope","c8yDeviceDatabase","c8yDeviceTypeParser","c8yAlert","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yImportDeviceTypeModal",{templateUrl:":::PLUGIN_PATH:::/modals/import-device-type.html",bindings:{close:"&",dismiss:"&"},controllerAs:"vm",controller:e})}();
|
|
@@ -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 _regeneratorRuntime(){_regeneratorRuntime=function(){return c};var c={},t=Object.prototype,
|
|
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 _regeneratorRuntime(){_regeneratorRuntime=function(){return c};var u,c={},t=Object.prototype,s=t.hasOwnProperty,l=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(u){i=function(t,e,r){return t[e]=r}}function a(t,e,r,n){var o,i,c,a,e=e&&e.prototype instanceof g?e:g,e=Object.create(e.prototype),n=new G(n||[]);return l(e,"_invoke",{value:(o=t,i=r,c=n,a=h,function(t,e){if(a===y)throw new Error("Generator is already running");if(a===v){if("throw"===t)throw e;return{value:u,done:!0}}for(c.method=t,c.arg=e;;){var r=c.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=u,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;n=f(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,d;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}(r,c);if(r){if(r===d)continue;return r}}if("next"===c.method)c.sent=c._sent=c.arg;else if("throw"===c.method){if(a===h)throw a=v,c.arg;c.dispatchException(c.arg)}else"return"===c.method&&c.abrupt("return",c.arg);a=y;r=f(o,i,c);if("normal"===r.type){if(a=c.done?v:p,r.arg===d)continue;return{value:r.arg,done:c.done}}"throw"===r.type&&(a=v,c.method="throw",c.arg=r.arg)}})}),e}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}c.wrap=a;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",d={};function g(){}function m(){}function w(){}var e={},b=(i(e,n,function(){return this}),Object.getPrototypeOf),b=b&&b(b(O([]))),L=(b&&b!==t&&s.call(b,n)&&(e=b),w.prototype=g.prototype=Object.create(e));function _(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function x(c,a){var e;l(this,"_invoke",{value:function(r,n){function t(){return new a(function(t,e){!function e(t,r,n,o){var i,t=f(c[t],c,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&s.call(r,"__await")?a.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):a.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function G(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function O(e){if(e||""===e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(s.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=u,t.done=!0,t}).next=t}throw new TypeError(_typeof(e)+" is not iterable")}return l(L,"constructor",{value:m.prototype=w,configurable:!0}),l(w,"constructor",{value:m,configurable:!0}),m.displayName=i(w,o,"GeneratorFunction"),c.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},c.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,i(t,o,"GeneratorFunction")),t.prototype=Object.create(L),t},c.awrap=function(t){return{__await:t}},_(x.prototype),i(x.prototype,r,function(){return this}),c.AsyncIterator=x,c.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new x(a(t,e,r,n),o);return c.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},_(L),i(L,o,"Generator"),i(L,n,function(){return this}),i(L,"toString",function(){return"[object Generator]"}),c.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},c.values=O,G.prototype={constructor:G,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),a=s.call(o,"finallyLoc");if(c&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,S(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=u),d}},c}function asyncGeneratorStep(t,e,r,n,o,i,c){try{var a=t[i](c),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(a){return function(){var t=this,c=arguments;return new Promise(function(e,r){var n=a.apply(t,c);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}!function(){function t(t,e,r,n,o,i,c,a,u){var s=r("Restart device"),l=this;function f(t){l.status=i.status(t)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function t(){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.delete(l.device);case 2:n.success(r("Device deleted.")),e.path("/device");case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}_.assign(l,{$onInit:function(){o.detailRealtime(l.config.device.id,t,f).then(function(t){l.device=t,l.displayReplaceBtn=a.canShowReplaceDevice(t),l.displayRestartBtn=o.supportsOperation(t,"c8y_Restart")})},replace:function(){a.openDrawer(l.device)},restart:function(){c.create({deviceId:l.device.id,description:s,c8y_Restart:{}}).then(function(){n.success(r("Device will be restarted."))})},deleteDevice:function(){return h.apply(this,arguments)}})}t.$inject=["$scope","$location","gettext","c8yAlert","c8yDevices","c8yDeviceStatus","c8yDeviceControl","c8yReplaceDeviceService","c8yDeviceGridService"],angular.module("c8y.deviceStatus").component("c8yDeviceStatus",{controller:t,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/deviceStatus.html",bindings:{config:"<"}})}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},e=Object.prototype,u=e.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var o,i,a,c,t=t&&t.prototype instanceof f?t:f,t=Object.create(t.prototype),r=new w(r||[]);return s(t,"_invoke",{value:(o=e,i=n,a=r,c="suspendedStart",function(e,t){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===e)throw t;return x()}for(a.method=e,a.arg=t;;){var n=a.delegate;if(n){n=function e(t,n){var r=n.method,o=t.iterator[r];if(void 0===o)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=void 0,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;r=d(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,l;o=r.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,l):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,l)}(n,a);if(n){if(n===l)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";n=d(o,i,a);if("normal"===n.type){if(c=a.done?"completed":"suspendedYield",n.arg===l)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(c="completed",a.method="throw",a.arg=n.arg)}})}),t}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var l={};function f(){}function p(){}function v(){}var t={},h=(i(t,r,function(){return this}),Object.getPrototypeOf),h=h&&h(h(E([]))),y=(h&&h!==e&&u.call(h,r)&&(t=h),v.prototype=f.prototype=Object.create(t));function m(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function g(a,c){var t;s(this,"_invoke",{value:function(n,r){function e(){return new c(function(e,t){!function t(e,n,r,o){var i,e=d(a[e],a,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&u.call(n,"__await")?c.resolve(n.__await).then(function(e){t("next",e,r,o)},function(e){t("throw",e,r,o)}):c.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,o)});o(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function E(t){if(t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(u.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:x}}function x(){return{value:void 0,done:!0}}return s(y,"constructor",{value:p.prototype=v,configurable:!0}),s(v,"constructor",{value:p,configurable:!0}),p.displayName=i(v,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,i(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},a.awrap=function(e){return{__await:e}},m(g.prototype),i(g.prototype,n,function(){return this}),a.AsyncIterator=g,a.async=function(e,t,n,r,o){void 0===o&&(o=Promise);var i=new g(c(e,t,n,r),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},m(y),i(y,o,"Generator"),i(y,r,function(){return this}),i(y,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=E,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&u.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&u.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(n=o.completion).type&&(r=n.arg,b(o)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:E(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,n){var r=c.apply(e,a);function o(e){asyncGeneratorStep(r,t,n,o,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,o,i,"throw",e)}o(void 0)})}}!function(){function e(o,n,i,a,c,u,s,d,l,r,f){var e,p=this,t=l.snmpVersions,v=l.snmpAuthPrivProtocols,h=l.snmpAuthProtocols,y=l.snmpSecurityLevels;function m(){return(m=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=p.mode,r=p.device,t.adding=!0,t.protocol=n,e.prev=3,S())return e.next=7,l.update(r,t);e.next=7;break;case 7:p.expandedId="",p.reloadDevices(),i.success(f("Child device changes saved.")),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(3),t.adding=!1,i.danger(f("Failed to change child device."));case 13:o.$apply();case 14:case"end":return e.stop()}},e,null,[[3,10]])}))).apply(this,arguments)}function g(){return(g=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=p.mode,n=p.device,(r=p.newDevice).adding=!0,r.protocol=t,e.prev=3,w())return e.next=7,a.create(n,r);e.next=9;break;case 7:e.next=32;break;case 9:if(E())return e.next=12,c.create(n,r);e.next=14;break;case 12:e.next=32;break;case 14:if(x())return e.next=17,u.create(n,r);e.next=19;break;case 17:e.next=32;break;case 19:if(D())return e.next=22,s.create(n,r);e.next=24;break;case 22:e.next=32;break;case 24:if(N())return e.next=27,d.create(n,r);e.next=29;break;case 27:e.next=32;break;case 29:if(S())return e.next=32,l.create(n,r);e.next=32;break;case 32:b(),p.reloadDevices(),i.success(f("New child device added.")),e.next=38;break;case 35:e.prev=35,e.t0=e.catch(3),p.newDevice.adding=!1,i.danger(f("Failed to add new child device."));case 38:o.$apply();case 39:case"end":return e.stop()}},e,null,[[3,35]])}))).apply(this,arguments)}function b(){p.expandedId="",_.unset(p,"newDevice"),p[e].$setPristine(),document.getElementsByName("vm.".concat(e))[0].reset()}function w(){return"modbus"===p.tab}function E(){return"canbus"===p.tab}function x(){return"opcua"===p.tab}function D(){return"profibus"===p.tab}function N(){return"canopen"===p.tab}function S(){return"snmp"===p.tab}_.assign(p,{$onInit:function(){e="new".concat(p.mode,"DeviceForm"),p.expandedId=""},shouldShowSection:function(){var e=p.device,t=p.mode,n=!1;w()?"TCP"===t?n=r.supportsOperation(e,"c8y_ModbusDevice"):"RTU"===t&&(n=r.supportsOperation(e,"c8y_ModbusDevice")&&e.c8y_SerialConfiguration):E()&&"CAN"===t?n=r.supportsOperation(e,"c8y_CanDevice"):D()&&"Profibus"===t?n=r.supportsOperation(e,"c8y_ProfibusDevice"):N()&&"CANopen"===t&&(n=r.supportsOperation(e,"c8y_CANopenAddDevice"));return n},isModbusTab:w,isCanBusTab:E,isOPCUATab:x,isProfibusTab:D,isCanOpenTab:N,isSNMPTab:S,invalid:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(p.mode,"DeviceForm");return function(e){var t=p.mode,n=p.fieldErrors;{var r,o,i,a;"TCP"===t||"RTU"===t?(a=p[e],(i=a.address)&&(o=i.$modelValue,"TCP"===t?(a=a.ipAddress,r=a.$modelValue,_.isUndefined(o)||i.$setValidity(n.ADDRESS_INVALID,function(e){return e<=247||255===e}(o)),r=o&&r&&_.some(p.devices,{address:o,ipAddress:r,protocol:"TCP"}),i.$setValidity(n.ADDRESSES_IN_USE,!r),a.$setValidity(n.ADDRESSES_IN_USE,!r)):"RTU"===t&&(a=o&&_.some(p.devices,{address:o,protocol:"RTU"}),i.$setValidity(n.ADDRESS_IN_USE,!a)))):"CANopen"===t?(r=p[e].nodeId)&&(o=r.$modelValue)&&(i=function(e){return 1<=e&&e<=127}(o),a=function(t){return p.devices.find(function(e){return!(!e||!e.nodeId)&&e.nodeId===t})}(o),i?a?(r.$setValidity(n.NODE_OUT_OF_RANGE,!0),r.$setValidity(n.NODE_IN_USE,!1)):(r.$setValidity(n.NODE_OUT_OF_RANGE,!0),r.$setValidity(n.NODE_IN_USE,!0)):(r.$setValidity(n.NODE_OUT_OF_RANGE,!1),r.$setValidity(n.NODE_IN_USE,!0))):"SNMP"===t&&function(e){var t,n=p[e];e&&(t=function(e){return _.toNumber(e.replace("form",""))}(e));(function(e,t){var n=p.fieldErrors;{var r;e.snmpVersionEngineId&&(e=e.snmpVersionEngineId,r=e.$modelValue)&&e.$setValidity(n.ENGINEID_IN_USE,!function(t,n){if(n)return _.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.auth.engineId)&&e.engineId===t});return _.some(p.devices,function(e){return e.auth.engineId===t})}(r,t))}})(n,t),function(e,t){var n=p.fieldErrors,e=e.ipAddress,r=e.$modelValue;e.$setValidity(n.ADDRESS_IN_USE,!function(t,n){if(n)return _.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.ipAddress)&&e.ipAddress===t});return _.some(p.devices,{ipAddress:t})}(r,t))}(n,t),function(e){var t=p.fieldErrors,e=e.port,n=e.$modelValue;e.$setValidity(t.PORT_INVALID,!_.isNaN(_.toNumber(n)))}(n)}(e)}}(t),n.invalid(p,t,e)},getFieldValidationHints:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(p.mode,"DeviceForm"),t=_.get(p,"".concat(t,".").concat(e));if(t)return n.validationHints(t,p.fieldErrorsToMessages);return""},isFormInvalid:function(){return _.get(p,"".concat(e,".$invalid"))||_.get(p,"newDevice.adding")},startAddingNewDevice:function(){p.newDevice={name:null,deviceType:null,address:null},S()&&(p.newDevice=_.extend(p.newDevice,{version:null,port:null,auth:{}}),p.toggle("newDevice"))},addNewDevice:function(){return g.apply(this,arguments)},clearNewDevice:b,filterByMode:function(){if(w())return function(e){return _.get(e,"protocol")===p.mode};if(N())return function(e){return e.nodeId};return function(){return!0}},snmpVersions:t,snmpAuthPrivProtocols:v,snmpAuthProtocols:h,snmpSecurityLevels:y,updateDevice:function(e){return m.apply(this,arguments)},startEditDevice:function(e){var t=_.cloneDeep(e);t.adding=!1,_.isUndefined(t.deviceType)||(e=p.deviceConfigurationOptions,t.deviceType=_.find(e.types,function(e){return e.name===t.deviceType}));return t},isEditFormInvalid:function(e,t){return _.get(p,"".concat(e,".$invalid"))||_.get(t,"adding")},toggle:function(e){p.expandedId===e?p.expandedId="":p.expandedId=e},clearEditDevice:function(){p.expandedId=""},getSnmpVersionLabel:function(e){e=_.find(t,{value:e});return _.get(e,"label")},getFormName:function(e){if(e)return e=e.id,"vm.form".concat(_.toString(e));return"vm.form"},getDeviceFormName:function(e){return"form".concat(e.id)},expandedId:void 0})}e.$inject=["$rootScope","c8yBase","c8yAlert","c8yModbusDevice","c8yCanbusDevice","c8yOPCUADevice","c8yProfibusDevice","c8yCanopenDevice","c8ySNMPDevice","c8yDevices","gettext"],angular.module("c8y.modbusConfiguration4").component("c8yFieldbusDeviceList",{templateUrl:":::PLUGIN_PATH:::/fieldbus-device-list.html",bindings:{tab:"@",mode:"@",fieldErrors:"<",fieldErrorsToMessages:"<",deviceConfigurationOptions:"<",device:"<",devices:"<",reloadDevices:"<",onClickDelete:"<",navigateToDetail:"<"},controllerAs:"vm",controller:e})}();
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var u,a={},e=Object.prototype,s=e.hasOwnProperty,d=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(u){i=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var o,i,a,c,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),r=new S(r||[]);return d(t,"_invoke",{value:(o=e,i=n,a=r,c=f,function(e,t){if(c===v)throw new Error("Generator is already running");if(c===h){if("throw"===e)throw t;return{value:u,done:!0}}for(a.method=e,a.arg=t;;){var n=a.delegate;if(n){n=function e(t,n){var r=n.method,o=t.iterator[r];if(o===u)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=u,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;r=l(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,y;o=r.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=u),n.delegate=null,y):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}(n,a);if(n){if(n===y)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===f)throw c=h,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=v;n=l(o,i,a);if("normal"===n.type){if(c=a.done?h:p,n.arg===y)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(c=h,a.method="throw",a.arg=n.arg)}})}),t}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var f="suspendedStart",p="suspendedYield",v="executing",h="completed",y={};function m(){}function g(){}function _(){}var t={},b=(i(t,r,function(){return this}),Object.getPrototypeOf),b=b&&b(b(I([]))),w=(b&&b!==e&&s.call(b,r)&&(t=b),_.prototype=m.prototype=Object.create(t));function E(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function x(a,c){var t;d(this,"_invoke",{value:function(n,r){function e(){return new c(function(e,t){!function t(e,n,r,o){var i,e=l(a[e],a,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&s.call(n,"__await")?c.resolve(n.__await).then(function(e){t("next",e,r,o)},function(e){t("throw",e,r,o)}):c.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,o)});o(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function I(t){if(t||""===t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(s.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=u,e.done=!0,e}).next=e}throw new TypeError(_typeof(t)+" is not iterable")}return d(w,"constructor",{value:g.prototype=_,configurable:!0}),d(_,"constructor",{value:g,configurable:!0}),g.displayName=i(_,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,i(e,o,"GeneratorFunction")),e.prototype=Object.create(w),e},a.awrap=function(e){return{__await:e}},E(x.prototype),i(x.prototype,n,function(){return this}),a.AsyncIterator=x,a.async=function(e,t,n,r,o){void 0===o&&(o=Promise);var i=new x(c(e,t,n,r),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},E(w),i(w,o,"Generator"),i(w,r,function(){return this}),i(w,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=I,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(N),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),N(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(n=o.completion).type&&(r=n.arg,N(o)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=u),y}},a}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,n){var r=c.apply(e,a);function o(e){asyncGeneratorStep(r,t,n,o,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,o,i,"throw",e)}o(void 0)})}}!function(){function e(o,n,i,a,c,u,s,d,l,r,f){var e,p=this,t=l.snmpVersions,v=l.snmpAuthPrivProtocols,h=l.snmpAuthProtocols,y=l.snmpSecurityLevels;function m(){return(m=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=p.mode,r=p.device,t.adding=!0,t.protocol=n,e.prev=3,S())return e.next=7,l.update(r,t);e.next=7;break;case 7:p.expandedId="",p.reloadDevices(),i.success(f("Child device changes saved.")),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(3),t.adding=!1,i.danger(f("Failed to change child device."));case 13:o.$apply();case 14:case"end":return e.stop()}},e,null,[[3,10]])}))).apply(this,arguments)}function g(){return(g=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=p.mode,n=p.device,(r=p.newDevice).adding=!0,r.protocol=t,e.prev=3,w())return e.next=7,a.create(n,r);e.next=9;break;case 7:e.next=32;break;case 9:if(E())return e.next=12,c.create(n,r);e.next=14;break;case 12:e.next=32;break;case 14:if(x())return e.next=17,u.create(n,r);e.next=19;break;case 17:e.next=32;break;case 19:if(D())return e.next=22,s.create(n,r);e.next=24;break;case 22:e.next=32;break;case 24:if(N())return e.next=27,d.create(n,r);e.next=29;break;case 27:e.next=32;break;case 29:if(S())return e.next=32,l.create(n,r);e.next=32;break;case 32:b(),p.reloadDevices(),i.success(f("New child device added.")),e.next=38;break;case 35:e.prev=35,e.t0=e.catch(3),p.newDevice.adding=!1,i.danger(f("Failed to add new child device."));case 38:o.$apply();case 39:case"end":return e.stop()}},e,null,[[3,35]])}))).apply(this,arguments)}function b(){p.expandedId="",_.unset(p,"newDevice"),p[e].$setPristine(),document.getElementsByName("vm.".concat(e))[0].reset()}function w(){return"modbus"===p.tab}function E(){return"canbus"===p.tab}function x(){return"opcua"===p.tab}function D(){return"profibus"===p.tab}function N(){return"canopen"===p.tab}function S(){return"snmp"===p.tab}_.assign(p,{$onInit:function(){e="new".concat(p.mode,"DeviceForm"),p.expandedId=""},shouldShowSection:function(){var e=p.device,t=p.mode,n=!1;w()?"TCP"===t?n=r.supportsOperation(e,"c8y_ModbusDevice"):"RTU"===t&&(n=r.supportsOperation(e,"c8y_ModbusDevice")&&e.c8y_SerialConfiguration):E()&&"CAN"===t?n=r.supportsOperation(e,"c8y_CanDevice"):D()&&"Profibus"===t?n=r.supportsOperation(e,"c8y_ProfibusDevice"):N()&&"CANopen"===t&&(n=r.supportsOperation(e,"c8y_CANopenAddDevice"));return n},isModbusTab:w,isCanBusTab:E,isOPCUATab:x,isProfibusTab:D,isCanOpenTab:N,isSNMPTab:S,invalid:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(p.mode,"DeviceForm");return function(e){var t=p.mode,n=p.fieldErrors;{var r,o,i,a;"TCP"===t||"RTU"===t?(a=p[e],(i=a.address)&&(o=i.$modelValue,"TCP"===t?(a=a.ipAddress,r=a.$modelValue,_.isUndefined(o)||i.$setValidity(n.ADDRESS_INVALID,function(e){return e<=247||255===e}(o)),r=o&&r&&_.some(p.devices,{address:o,ipAddress:r,protocol:"TCP"}),i.$setValidity(n.ADDRESSES_IN_USE,!r),a.$setValidity(n.ADDRESSES_IN_USE,!r)):"RTU"===t&&(a=o&&_.some(p.devices,{address:o,protocol:"RTU"}),i.$setValidity(n.ADDRESS_IN_USE,!a)))):"CANopen"===t?(r=p[e].nodeId)&&(o=r.$modelValue)&&(i=function(e){return 1<=e&&e<=127}(o),a=function(t){return p.devices.find(function(e){return!(!e||!e.nodeId)&&e.nodeId===t})}(o),i?a?(r.$setValidity(n.NODE_OUT_OF_RANGE,!0),r.$setValidity(n.NODE_IN_USE,!1)):(r.$setValidity(n.NODE_OUT_OF_RANGE,!0),r.$setValidity(n.NODE_IN_USE,!0)):(r.$setValidity(n.NODE_OUT_OF_RANGE,!1),r.$setValidity(n.NODE_IN_USE,!0))):"SNMP"===t&&function(e){var t,n=p[e];e&&(t=function(e){return _.toNumber(e.replace("form",""))}(e));(function(e,t){var n=p.fieldErrors;{var r;e.snmpVersionEngineId&&(e=e.snmpVersionEngineId,r=e.$modelValue)&&e.$setValidity(n.ENGINEID_IN_USE,!function(t,n){if(n)return _.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.auth.engineId)&&e.engineId===t});return _.some(p.devices,function(e){return e.auth.engineId===t})}(r,t))}})(n,t),function(e,t){var n=p.fieldErrors,e=e.ipAddress,r=e.$modelValue;e.$setValidity(n.ADDRESS_IN_USE,!function(t,n){if(n)return _.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.ipAddress)&&e.ipAddress===t});return _.some(p.devices,{ipAddress:t})}(r,t))}(n,t),function(e){var t=p.fieldErrors,e=e.port,n=e.$modelValue;e.$setValidity(t.PORT_INVALID,!_.isNaN(_.toNumber(n)))}(n)}(e)}}(t),n.invalid(p,t,e)},getFieldValidationHints:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(p.mode,"DeviceForm"),t=_.get(p,"".concat(t,".").concat(e));if(t)return n.validationHints(t,p.fieldErrorsToMessages);return""},isFormInvalid:function(){return _.get(p,"".concat(e,".$invalid"))||_.get(p,"newDevice.adding")},startAddingNewDevice:function(){p.newDevice={name:null,deviceType:null,address:null},S()&&(p.newDevice=_.extend(p.newDevice,{version:null,port:null,auth:{}}),p.toggle("newDevice"))},addNewDevice:function(){return g.apply(this,arguments)},clearNewDevice:b,filterByMode:function(){if(w())return function(e){return _.get(e,"protocol")===p.mode};if(N())return function(e){return e.nodeId};return function(){return!0}},snmpVersions:t,snmpAuthPrivProtocols:v,snmpAuthProtocols:h,snmpSecurityLevels:y,updateDevice:function(e){return m.apply(this,arguments)},startEditDevice:function(e){var t=_.cloneDeep(e);t.adding=!1,_.isUndefined(t.deviceType)||(e=p.deviceConfigurationOptions,t.deviceType=_.find(e.types,function(e){return e.name===t.deviceType}));return t},isEditFormInvalid:function(e,t){return _.get(p,"".concat(e,".$invalid"))||_.get(t,"adding")},toggle:function(e){p.expandedId===e?p.expandedId="":p.expandedId=e},clearEditDevice:function(){p.expandedId=""},getSnmpVersionLabel:function(e){e=_.find(t,{value:e});return _.get(e,"label")},getFormName:function(e){if(e)return e=e.id,"vm.form".concat(_.toString(e));return"vm.form"},getDeviceFormName:function(e){return"form".concat(e.id)},expandedId:void 0})}e.$inject=["$rootScope","c8yBase","c8yAlert","c8yModbusDevice","c8yCanbusDevice","c8yOPCUADevice","c8yProfibusDevice","c8yCanopenDevice","c8ySNMPDevice","c8yDevices","gettext"],angular.module("c8y.modbusConfiguration4").component("c8yFieldbusDeviceList",{templateUrl:":::PLUGIN_PATH:::/fieldbus-device-list.html",bindings:{tab:"@",mode:"@",fieldErrors:"<",fieldErrorsToMessages:"<",deviceConfigurationOptions:"<",device:"<",devices:"<",reloadDevices:"<",onClickDelete:"<",navigateToDetail:"<"},controllerAs:"vm",controller:e})}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},e=Object.prototype,u=e.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof p?t:p,t=Object.create(t.prototype),n=new w(n||[]);return s(t,"_invoke",{value:(o=e,i=r,a=n,c="suspendedStart",function(e,t){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===e)throw t;return T()}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;n=l(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}(r,a);if(r){if(r===f)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";r=l(o,i,a);if("normal"===r.type){if(c=a.done?"completed":"suspendedYield",r.arg===f)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c="completed",a.method="throw",a.arg=r.arg)}})}),t}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var f={};function p(){}function y(){}function d(){}var t={},g=(i(t,n,function(){return this}),Object.getPrototypeOf),g=g&&g(g(E([]))),m=(g&&g!==e&&u.call(g,n)&&(t=g),d.prototype=p.prototype=Object.create(t));function h(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function v(a,c){var t;s(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=l(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function E(t){if(t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(u.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:T}}function T(){return{value:void 0,done:!0}}return s(m,"constructor",{value:y.prototype=d,configurable:!0}),s(d,"constructor",{value:y,configurable:!0}),y.displayName=i(d,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},a.awrap=function(e){return{__await:e}},h(v.prototype),i(v.prototype,r,function(){return this}),a.AsyncIterator=v,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new v(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},h(m),i(m,o,"Generator"),i(m,n,function(){return this}),i(m,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=E,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&u.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,_(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(c,e,t,u,s,l){var r=e.MODBUS_DEVICE_FRAGMENT,n=e.PROFIBUS_DEVICE_FRAGMENT;return{getConfigModel:function(e){return o.apply(this,arguments)},updateConfigModel:function(e,t){_.set(e,"categoriesConfig",_.map(t,function(e){return{name:e.name,label:e.label,elements:_.compact(_.map(e.elements,function(e){return e.show?_.pick(e,["refId","label","type"]):void 0}))}})),_.unset(e,"coils"),_.unset(e,"registers")},getWidgetModel:function(e){return g.apply(this,arguments)},isAtLeastOneElementSelected:function(e){return _.some(e,function(e){return _.some(e.elements,"show")})},isDiscreteIOSelectedInConfig:window.c8y_testing&&d,isRegisterSelectedInConfig:window.c8y_testing&&y};function o(){return(o=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=_.get(t,"device"))return e.next=4,b(r);e.next=6;break;case 4:return r=e.sent,e.abrupt("return",function(){return i.apply(this,arguments)}({fieldbusDevice:r,widgetConfig:t}));case 6:return e.abrupt("return",c.resolve([]));case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function i(){return(i=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.fieldbusDevice,n=t.widgetConfig,e.next=3,w(r);case 3:if(o=e.sent,i=h({fieldbusDevice:r,deviceType:o}),_.isEmpty(i))return e.abrupt("return",[]);e.next=7;break;case 7:return a=_.groupBy(i,E),e.abrupt("return",_(n).chain().get("categoriesConfig",[]).map(function(e){var t=_.get(a,e.name);_.defaults(e,{label:e.name||l("Uncategorized")});t=_.flow([f,p])({categoryConfigElements:e.elements,deviceType:o,elements:i,categoryElements:t,widgetConfig:n}).categoryConfigElements;return e.elements=t,e}).thru(function(e){return T({categoriesConfig:e,categories:a,deviceType:o,widgetConfig:n})}).value());case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(e){var t=e.categoryConfigElements,n=e.deviceType,o=e.elements,r=e.categoryElements,e=e.widgetConfig;return{categoryConfigElements:_.map(t,function(e){var t=e.refId,r=e.type,t=s.findElementBestMatchingRefId(o,t,r);if(t)return _.defaults(e,{name:t.name,type:t.meta.type.value,typeLabel:s.getElementTypeLabel(t,n),show:!0,label:t.name})}),deviceType:n,elements:o,categoryElements:r,widgetConfig:e}}function p(e){var t=e.categoryConfigElements,r=e.deviceType,n=e.elements,o=e.categoryElements,i=e.widgetConfig;return{categoryConfigElements:[].concat(_toConsumableArray(t),_toConsumableArray(_(o).filter(function(e){return!_.find(t,{refId:s.getElementRefId(e)})}).map(function(e){return{refId:s.getElementRefId(e),label:e.name,show:a(e,i),name:e.name,type:e.meta.type.value,typeLabel:s.getElementTypeLabel(e,r)}}).value())),deviceType:r,elements:n,categoryElements:o,widgetConfig:i}}function a(e,t){return(e.meta.type===s.ElementType.REGISTER?y:d)(e,t)}function y(e,t){var r=e.id,n=e.input,o=e.number,e=e.startBit,t=t.registers;return _.includes(t,r)||_.includes(t,[n,o,e].join(","))||_.includes(t,o)||!!_.find(t,{number:o,startBit:e})}function d(e,t){var r=e.id,n=e.input,e=e.number,t=t.coils;return _.includes(t,r)||_.includes(t,[n,e].join(","))||_.includes(t,e)}function g(){return(g=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=_.get(t,"device.id"),r=u.detailRealtime(o),n=r.then(w),o=function(){return m.apply(this,arguments)}(o,t).then(function(e){return _.get(t,"categoriesConfig",e)}),e.next=6,c.all({fieldbusDevice:r,deviceType:n,categoriesConfig:o});case 6:return r=e.sent,n=r.fieldbusDevice,o=r.deviceType,a=r.categoriesConfig,i=h({fieldbusDevice:n,deviceType:o}),a=_.map(a,function(e){return _.defaults(_objectSpread(_objectSpread({},e),{},{elements:_(e.elements).map(function(e){var t=s.findElementBestMatchingRefId(i,e.refId,e.type);return t?_.defaults(_objectSpread(_objectSpread({},e),t),{label:t.name,show:!0}):e}).filter("show").value()}),{label:e.name})}),e.abrupt("return",{device:n,categories:a});case 13:case"end":return e.stop()}},e)}))).apply(this,arguments)}function m(){return(m=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){var n,o,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b(t);case 2:return n=e.sent,e.next=5,w(n);case 5:return o=e.sent,i=h({fieldbusDevice:n,deviceType:o}),i=_.groupBy(i,E),e.abrupt("return",T({categoriesConfig:[],categories:i,deviceType:o,widgetConfig:r}));case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function h(e){var t=e.fieldbusDevice,e=e.deviceType,e=s.getElementsWithMeta(e);return _.has(t,r)||_.has(t,n)?e:_.filter(e,v)}function v(e){return e.meta.type===s.ElementType.REGISTER&&!e.input}function b(e){return s.isFieldbusDevice(e)?c.resolve(e):u.detail(t.getId(e)).then(t.getResData)}function w(e){return s.getDeviceTypeFromDevice(e)}function E(e){return _.get(e,"category","")}function T(e){var r=e.categoriesConfig,t=e.categories,n=e.deviceType,o=e.widgetConfig;return[].concat(_toConsumableArray(r),_toConsumableArray(_(t).pickBy(function(e,t){return!_.find(r,{name:t})}).map(function(e,t){return{name:t,label:t||l("Uncategorized"),elements:_.map(e,function(e){return{refId:s.getElementRefId(e),label:e.name,show:a(e,o),name:e.name,type:e.meta.type.value,typeLabel:s.getElementTypeLabel(e,n)}})}}).value()))}}e.$inject=["$q","fieldbusConstants","c8yBase","c8yDevices","c8yDeviceDatabase","gettext"],angular.module("c8y.modbusWidget4").factory("modbusWidgetSvc",e)}();
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var u,a={},e=Object.prototype,s=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(u){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),n=new j(n||[]);return l(t,"_invoke",{value:(o=e,i=r,a=n,c=p,function(e,t){if(c===g)throw new Error("Generator is already running");if(c===h){if("throw"===e)throw t;return{value:u,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=u,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;n=f(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,d;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}(r,a);if(r){if(r===d)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===p)throw c=h,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=g;r=f(o,i,a);if("normal"===r.type){if(c=a.done?h:y,r.arg===d)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c=h,a.method="throw",a.arg=r.arg)}})}),t}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var p="suspendedStart",y="suspendedYield",g="executing",h="completed",d={};function m(){}function v(){}function b(){}var t={},_=(i(t,n,function(){return this}),Object.getPrototypeOf),_=_&&_(_(O([]))),w=(_&&_!==e&&s.call(_,n)&&(t=_),b.prototype=m.prototype=Object.create(t));function E(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function T(a,c){var t;l(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=f(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==_typeof(r)&&s.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function O(t){if(t||""===t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(s.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=u,e.done=!0,e}).next=e}throw new TypeError(_typeof(t)+" is not iterable")}return l(w,"constructor",{value:v.prototype=b,configurable:!0}),l(b,"constructor",{value:v,configurable:!0}),v.displayName=i(b,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,i(e,o,"GeneratorFunction")),e.prototype=Object.create(w),e},a.awrap=function(e){return{__await:e}},E(T.prototype),i(T.prototype,r,function(){return this}),a.AsyncIterator=T,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new T(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},E(w),i(w,o,"Generator"),i(w,n,function(){return this}),i(w,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=O,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,S(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=u),d}},a}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){asyncGeneratorStep(n,t,r,o,i,"next",e)}function i(e){asyncGeneratorStep(n,t,r,o,i,"throw",e)}o(void 0)})}}!function(){function e(c,e,t,u,s,l){var r=e.MODBUS_DEVICE_FRAGMENT,n=e.PROFIBUS_DEVICE_FRAGMENT;return{getConfigModel:function(e){return o.apply(this,arguments)},updateConfigModel:function(e,t){_.set(e,"categoriesConfig",_.map(t,function(e){return{name:e.name,label:e.label,elements:_.compact(_.map(e.elements,function(e){return e.show?_.pick(e,["refId","label","type"]):void 0}))}})),_.unset(e,"coils"),_.unset(e,"registers")},getWidgetModel:function(e){return h.apply(this,arguments)},isAtLeastOneElementSelected:function(e){return _.some(e,function(e){return _.some(e.elements,"show")})},isDiscreteIOSelectedInConfig:window.c8y_testing&&g,isRegisterSelectedInConfig:window.c8y_testing&&y};function o(){return(o=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=_.get(t,"device"))return e.next=4,b(r);e.next=6;break;case 4:return r=e.sent,e.abrupt("return",function(){return i.apply(this,arguments)}({fieldbusDevice:r,widgetConfig:t}));case 6:return e.abrupt("return",c.resolve([]));case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function i(){return(i=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.fieldbusDevice,n=t.widgetConfig,e.next=3,w(r);case 3:if(o=e.sent,i=m({fieldbusDevice:r,deviceType:o}),_.isEmpty(i))return e.abrupt("return",[]);e.next=7;break;case 7:return a=_.groupBy(i,E),e.abrupt("return",_(n).chain().get("categoriesConfig",[]).map(function(e){var t=_.get(a,e.name);_.defaults(e,{label:e.name||l("Uncategorized")});t=_.flow([f,p])({categoryConfigElements:e.elements,deviceType:o,elements:i,categoryElements:t,widgetConfig:n}).categoryConfigElements;return e.elements=t,e}).thru(function(e){return T({categoriesConfig:e,categories:a,deviceType:o,widgetConfig:n})}).value());case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function f(e){var t=e.categoryConfigElements,n=e.deviceType,o=e.elements,r=e.categoryElements,e=e.widgetConfig;return{categoryConfigElements:_.map(t,function(e){var t=e.refId,r=e.type,t=s.findElementBestMatchingRefId(o,t,r);if(t)return _.defaults(e,{name:t.name,type:t.meta.type.value,typeLabel:s.getElementTypeLabel(t,n),show:!0,label:t.name})}),deviceType:n,elements:o,categoryElements:r,widgetConfig:e}}function p(e){var t=e.categoryConfigElements,r=e.deviceType,n=e.elements,o=e.categoryElements,i=e.widgetConfig;return{categoryConfigElements:[].concat(_toConsumableArray(t),_toConsumableArray(_(o).filter(function(e){return!_.find(t,{refId:s.getElementRefId(e)})}).map(function(e){return{refId:s.getElementRefId(e),label:e.name,show:a(e,i),name:e.name,type:e.meta.type.value,typeLabel:s.getElementTypeLabel(e,r)}}).value())),deviceType:r,elements:n,categoryElements:o,widgetConfig:i}}function a(e,t){return(e.meta.type===s.ElementType.REGISTER?y:g)(e,t)}function y(e,t){var r=e.id,n=e.input,o=e.number,e=e.startBit,t=t.registers;return _.includes(t,r)||_.includes(t,[n,o,e].join(","))||_.includes(t,o)||!!_.find(t,{number:o,startBit:e})}function g(e,t){var r=e.id,n=e.input,e=e.number,t=t.coils;return _.includes(t,r)||_.includes(t,[n,e].join(","))||_.includes(t,e)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=_.get(t,"device.id"),r=u.detailRealtime(o),n=r.then(w),o=function(){return d.apply(this,arguments)}(o,t).then(function(e){return _.get(t,"categoriesConfig",e)}),e.next=6,c.all({fieldbusDevice:r,deviceType:n,categoriesConfig:o});case 6:return r=e.sent,n=r.fieldbusDevice,o=r.deviceType,a=r.categoriesConfig,i=m({fieldbusDevice:n,deviceType:o}),a=_.map(a,function(e){return _.defaults(_objectSpread(_objectSpread({},e),{},{elements:_(e.elements).map(function(e){var t=s.findElementBestMatchingRefId(i,e.refId,e.type);return t?_.defaults(_objectSpread(_objectSpread({},e),t),{label:t.name,show:!0}):e}).filter("show").value()}),{label:e.name})}),e.abrupt("return",{device:n,categories:a});case 13:case"end":return e.stop()}},e)}))).apply(this,arguments)}function d(){return(d=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){var n,o,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b(t);case 2:return n=e.sent,e.next=5,w(n);case 5:return o=e.sent,i=m({fieldbusDevice:n,deviceType:o}),i=_.groupBy(i,E),e.abrupt("return",T({categoriesConfig:[],categories:i,deviceType:o,widgetConfig:r}));case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function m(e){var t=e.fieldbusDevice,e=e.deviceType,e=s.getElementsWithMeta(e);return _.has(t,r)||_.has(t,n)?e:_.filter(e,v)}function v(e){return e.meta.type===s.ElementType.REGISTER&&!e.input}function b(e){return s.isFieldbusDevice(e)?c.resolve(e):u.detail(t.getId(e)).then(t.getResData)}function w(e){return s.getDeviceTypeFromDevice(e)}function E(e){return _.get(e,"category","")}function T(e){var r=e.categoriesConfig,t=e.categories,n=e.deviceType,o=e.widgetConfig;return[].concat(_toConsumableArray(r),_toConsumableArray(_(t).pickBy(function(e,t){return!_.find(r,{name:t})}).map(function(e,t){return{name:t,label:t||l("Uncategorized"),elements:_.map(e,function(e){return{refId:s.getElementRefId(e),label:e.name,show:a(e,o),name:e.name,type:e.meta.type.value,typeLabel:s.getElementTypeLabel(e,n)}})}}).value()))}}e.$inject=["$q","fieldbusConstants","c8yBase","c8yDevices","c8yDeviceDatabase","gettext"],angular.module("c8y.modbusWidget4").factory("modbusWidgetSvc",e)}();
|
|
@@ -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 _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,
|
|
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 _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var u,a={},t=Object.prototype,f=t.hasOwnProperty,l=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(u){i=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o,i,a,c,e=e&&e.prototype instanceof v?e:v,e=Object.create(e.prototype),n=new O(n||[]);return l(e,"_invoke",{value:(o=t,i=r,a=n,c=h,function(t,e){if(c===y)throw new Error("Generator is already running");if(c===g){if("throw"===t)throw e;return{value:u,done:!0}}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=u,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;n=s(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,d;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}(r,a);if(r){if(r===d)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===h)throw c=g,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=y;r=s(o,i,a);if("normal"===r.type){if(c=a.done?g:p,r.arg===d)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c=g,a.method="throw",a.arg=r.arg)}})}),e}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var h="suspendedStart",p="suspendedYield",y="executing",g="completed",d={};function v(){}function m(){}function w(){}var e={},b=(i(e,n,function(){return this}),Object.getPrototypeOf),b=b&&b(b(j([]))),L=(b&&b!==t&&f.call(b,n)&&(e=b),w.prototype=v.prototype=Object.create(e));function _(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function x(a,c){var e;l(this,"_invoke",{value:function(r,n){function t(){return new c(function(t,e){!function e(t,r,n,o){var i,t=s(a[t],a,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&f.call(r,"__await")?c.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):c.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(e){if(e||""===e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(f.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=u,t.done=!0,t}).next=t}throw new TypeError(_typeof(e)+" is not iterable")}return l(L,"constructor",{value:m.prototype=w,configurable:!0}),l(w,"constructor",{value:m,configurable:!0}),m.displayName=i(w,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,i(t,o,"GeneratorFunction")),t.prototype=Object.create(L),t},a.awrap=function(t){return{__await:t}},_(x.prototype),i(x.prototype,r,function(){return this}),a.AsyncIterator=x,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new x(c(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},_(L),i(L,o,"Generator"),i(L,n,function(){return this}),i(L,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&f.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=f.call(o,"catchLoc"),c=f.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&f.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,S(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=u),d}},a}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=c.apply(t,a);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}!function(){function t(e,r){var t,n,o=this;function i(){return(i=_asyncToGenerator(_regeneratorRuntime().mark(function t(){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.getConfigModel(o.config);case 2:o.categoriesConfig=t.sent,e.$apply();case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}_.assign(o,{$doCheck:function(){_.isEqual(t,o.config.device)||(t=o.config.device,function(){i.apply(this,arguments)}());!_.isEqual(n,o.categoriesConfig)&&(n=_.cloneDeep(o.categoriesConfig),function(){{var t;if(n)return t=r.isAtLeastOneElementSelected(n),o.modbusWidgetConfigForm.modbusWidgetValidation.$setValidity("at-least-one-field-selected",t),o.atLeastOneElementSelected=t}return}())&&r.updateConfigModel(o.config,n)}})}t.$inject=["$rootScope","modbusWidgetSvc"],angular.module("c8y.modbusWidget4").component("c8yModbusWidgetConfig",{templateUrl:":::PLUGIN_PATH:::/widget-config.html",bindings:{config:"<"},controllerAs:"vm",controller:t})}();
|