@c8y/ng1-modules 1021.75.4 → 1021.75.8

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.
@@ -1 +1 @@
1
- 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===h)throw Error("Generator is already running");if(c===v){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=v,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;n=l(o,i,a);if("normal"===n.type){if(c=a.done?v:p,n.arg===y)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(c=v,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",h="executing",v="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 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 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 e(o,n,i,a,c,u,s,d,l,r,f){var e,p=this,t=l.snmpVersions;function h(){return(h=_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,x())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 v(){return(v=_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,m())return e.next=7,a.create(n,r);e.next=9;break;case 7:e.next=32;break;case 9:if(g())return e.next=12,c.create(n,r);e.next=14;break;case 12:e.next=32;break;case 14:if(b())return e.next=17,u.create(n,r);e.next=19;break;case 17:e.next=32;break;case 19:if(w())return e.next=22,s.create(n,r);e.next=24;break;case 22:e.next=32;break;case 24:if(E())return e.next=27,d.create(n,r);e.next=29;break;case 27:e.next=32;break;case 29:if(x())return e.next=32,l.create(n,r);e.next=32;break;case 32:y(),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 y(){p.expandedId="",_.unset(p,"newDevice"),p[e].$setPristine(),document.getElementsByName("vm.".concat(e))[0].reset()}function m(){return"modbus"===p.tab}function g(){return"canbus"===p.tab}function b(){return"opcua"===p.tab}function w(){return"profibus"===p.tab}function E(){return"canopen"===p.tab}function x(){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;m()?"TCP"===t?n=r.supportsOperation(e,"c8y_ModbusDevice"):"RTU"===t&&(n=r.supportsOperation(e,"c8y_ModbusDevice")&&e.c8y_SerialConfiguration):g()&&"CAN"===t?n=r.supportsOperation(e,"c8y_CanDevice"):w()&&"Profibus"===t?n=r.supportsOperation(e,"c8y_ProfibusDevice"):E()&&"CANopen"===t&&(n=r.supportsOperation(e,"c8y_CANopenAddDevice"));return n},isModbusTab:m,isCanBusTab:g,isOPCUATab:b,isProfibusTab:w,isCanOpenTab:E,isSNMPTab:x,invalid:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(p.mode,"DeviceForm");return(e=>{var t,n,r,o,i,a=p.mode,c=p.fieldErrors;"TCP"===a||"RTU"===a?(n=p[e],(i=n.address)&&(o=i.$modelValue,"TCP"===a?(n=n.ipAddress,r=n.$modelValue,_.isUndefined(o)||i.$setValidity(c.ADDRESS_INVALID,(e=>e<=247||255===e)(o)),r=o&&r&&_.some(p.devices,{address:o,ipAddress:r,protocol:"TCP"}),i.$setValidity(c.ADDRESSES_IN_USE,!r),n.$setValidity(c.ADDRESSES_IN_USE,!r)):"RTU"===a&&(n=o&&_.some(p.devices,{address:o,protocol:"RTU"}),i.$setValidity(c.ADDRESS_IN_USE,!n)))):"CANopen"===a?(r=p[e].nodeId)&&(o=r.$modelValue)&&(i=(e=>1<=e&&e<=127)(o),n=(t=>p.devices.find(function(e){return!(!e||!e.nodeId)&&e.nodeId===t}))(o),i?n?(r.$setValidity(c.NODE_OUT_OF_RANGE,!0),r.$setValidity(c.NODE_IN_USE,!1)):(r.$setValidity(c.NODE_OUT_OF_RANGE,!0),r.$setValidity(c.NODE_IN_USE,!0)):(r.$setValidity(c.NODE_OUT_OF_RANGE,!1),r.$setValidity(c.NODE_IN_USE,!0))):"SNMP"===a&&(i=p[o=e],o&&(t=(e=>_.toNumber(e.replace("form","")))(o)),o=i,n=t,r=p.fieldErrors,o.snmpVersionEngineId&&(o=o.snmpVersionEngineId,c=o.$modelValue)&&o.$setValidity(r.ENGINEID_IN_USE,!((t,n)=>n?_.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.auth.engineId)&&e.engineId===t}):_.some(p.devices,function(e){return e.auth.engineId===t}))(c,n)),o=i,a=p.fieldErrors,e=(o=o.ipAddress).$modelValue,o.$setValidity(a.ADDRESS_IN_USE,!((t,n)=>n?_.some(p.devices,function(e){return(_.toNumber(e.id)!==n||t!==e.ipAddress)&&e.ipAddress===t}):_.some(p.devices,{ipAddress:t}))(e,t)),o=i,i=p.fieldErrors,c=(o=o.port).$modelValue,o.$setValidity(i.PORT_INVALID,!_.isNaN(_.toNumber(c))))})(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},x()&&(p.newDevice=_.extend(p.newDevice,{version:null,port:null,auth:{}}),p.toggle("newDevice"))},addNewDevice:function(){return v.apply(this,arguments)},clearNewDevice:y,filterByMode:function(){if(m())return function(e){return _.get(e,"protocol")===p.mode};if(E())return function(e){return e.nodeId};return function(){return!0}},snmpVersions:t,snmpAuthPrivProtocols:l.snmpAuthPrivProtocols,snmpAuthProtocols:l.snmpAuthProtocols,snmpSecurityLevels:l.snmpSecurityLevels,updateDevice:function(e){return h.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
+ 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 g?t:g,t=Object.create(t.prototype),r=new O(r||[]);return d(t,"_invoke",{value:(o=e,i=n,a=r,c=f,function(e,t){if(c===h)throw Error("Generator is already running");if(c===y){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")),v;r=l(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,v;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,v):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}(n,a);if(n){if(n===v)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===f)throw c=y,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;n=l(o,i,a);if("normal"===n.type){if(c=a.done?y:p,n.arg===v)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(c=y,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",h="executing",y="completed",v={};function g(){}function m(){}function _(){}var t={},b=(i(t,r,function(){return this}),Object.getPrototypeOf),b=b&&b(b(S([]))),w=(b&&b!==e&&s.call(b,r)&&(t=b),_.prototype=g.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 O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function S(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:m.prototype=_,configurable:!0}),d(_,"constructor",{value:m,configurable:!0}),m.displayName=i(_,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,_):(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=S,O.prototype={constructor:O,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 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,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 n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),N(n),v}},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 Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=u),v}},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 e(o,n,i,a,c,u,s,d,r,l){var e,f=this;function t(){return(t=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=f.mode,t.adding=!0,t.protocol=n;try{f.expandedId="",f.reloadDevices(),i.success(l("Child device changes saved."))}catch(e){t.adding=!1,i.danger(l("Failed to change child device."))}o.$apply();case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function p(){return(p=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=f.mode,n=f.device,(r=f.newDevice).adding=!0,r.protocol=t,e.prev=3,y())return e.next=7,a.create(n,r);e.next=9;break;case 7:e.next=27;break;case 9:if(v())return e.next=12,c.create(n,r);e.next=14;break;case 12:e.next=27;break;case 14:if(g())return e.next=17,u.create(n,r);e.next=19;break;case 17:e.next=27;break;case 19:if(m())return e.next=22,s.create(n,r);e.next=24;break;case 22:e.next=27;break;case 24:if(b())return e.next=27,d.create(n,r);e.next=27;break;case 27:h(),f.reloadDevices(),i.success(l("New child device added.")),e.next=33;break;case 30:e.prev=30,e.t0=e.catch(3),f.newDevice.adding=!1,i.danger(l("Failed to add new child device."));case 33:o.$apply();case 34:case"end":return e.stop()}},e,null,[[3,30]])}))).apply(this,arguments)}function h(){f.expandedId="",_.unset(f,"newDevice"),f[e].$setPristine(),document.getElementsByName("vm.".concat(e))[0].reset()}function y(){return"modbus"===f.tab}function v(){return"canbus"===f.tab}function g(){return"opcua"===f.tab}function m(){return"profibus"===f.tab}function b(){return"canopen"===f.tab}_.assign(f,{$onInit:function(){e="new".concat(f.mode,"DeviceForm"),f.expandedId=""},shouldShowSection:function(){var e=f.device,t=f.mode,n=!1;y()?"TCP"===t?n=r.supportsOperation(e,"c8y_ModbusDevice"):"RTU"===t&&(n=r.supportsOperation(e,"c8y_ModbusDevice")&&e.c8y_SerialConfiguration):v()&&"CAN"===t?n=r.supportsOperation(e,"c8y_CanDevice"):m()&&"Profibus"===t?n=r.supportsOperation(e,"c8y_ProfibusDevice"):b()&&"CANopen"===t&&(n=r.supportsOperation(e,"c8y_CANopenAddDevice"));return n},isModbusTab:y,isCanBusTab:v,isOPCUATab:g,isProfibusTab:m,isCanOpenTab:b,invalid:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(f.mode,"DeviceForm");return(e=>{var t,n,r,o,i=f.mode,a=f.fieldErrors;"TCP"===i||"RTU"===i?(o=f[e],(r=o.address)&&(n=r.$modelValue,"TCP"===i?(o=o.ipAddress,t=o.$modelValue,_.isUndefined(n)||r.$setValidity(a.ADDRESS_INVALID,(e=>e<=247||255===e)(n)),t=n&&t&&_.some(f.devices,{address:n,ipAddress:t,protocol:"TCP"}),r.$setValidity(a.ADDRESSES_IN_USE,!t),o.$setValidity(a.ADDRESSES_IN_USE,!t)):"RTU"===i&&(o=n&&_.some(f.devices,{address:n,protocol:"RTU"}),r.$setValidity(a.ADDRESS_IN_USE,!o)))):"CANopen"===i&&(t=f[e].nodeId)&&(n=t.$modelValue)&&(r=(e=>1<=e&&e<=127)(n),o=(t=>f.devices.find(function(e){return!(!e||!e.nodeId)&&e.nodeId===t}))(n),r?o?(t.$setValidity(a.NODE_OUT_OF_RANGE,!0),t.$setValidity(a.NODE_IN_USE,!1)):(t.$setValidity(a.NODE_OUT_OF_RANGE,!0),t.$setValidity(a.NODE_IN_USE,!0)):(t.$setValidity(a.NODE_OUT_OF_RANGE,!1),t.$setValidity(a.NODE_IN_USE,!0)))})(t),n.invalid(f,t,e)},getFieldValidationHints:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"new".concat(f.mode,"DeviceForm"),t=_.get(f,"".concat(t,".").concat(e));if(t)return n.validationHints(t,f.fieldErrorsToMessages);return""},isFormInvalid:function(){return _.get(f,"".concat(e,".$invalid"))||_.get(f,"newDevice.adding")},startAddingNewDevice:function(){f.newDevice={name:null,deviceType:null,address:null}},addNewDevice:function(){return p.apply(this,arguments)},clearNewDevice:h,filterByMode:function(){if(y())return function(e){return _.get(e,"protocol")===f.mode};if(b())return function(e){return e.nodeId};return function(){return!0}},updateDevice:function(e){return t.apply(this,arguments)},startEditDevice:function(e){var t=_.cloneDeep(e);t.adding=!1,_.isUndefined(t.deviceType)||(e=f.deviceConfigurationOptions,t.deviceType=_.find(e.types,function(e){return e.name===t.deviceType}));return t},isEditFormInvalid:function(e,t){return _.get(f,"".concat(e,".$invalid"))||_.get(t,"adding")},toggle:function(e){f.expandedId===e?f.expandedId="":f.expandedId=e},clearEditDevice:function(){f.expandedId=""},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","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})})();