@gudhub/core 1.1.6 → 1.1.7
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.
|
@@ -258,10 +258,18 @@ export class AppProcessor {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
async updateApp(app) {
|
|
261
|
-
if (!app.
|
|
261
|
+
if (!app.views_list || !app.views_list.length || !app.show) {
|
|
262
262
|
const storageApp = await this.getApp(app.app_id);
|
|
263
|
-
|
|
263
|
+
|
|
264
|
+
if(!app.views_list || !app.views_list.length) {
|
|
265
|
+
app.views_list = storageApp.views_list;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if(typeof app.show === 'undefined') {
|
|
269
|
+
app.show = storageApp.show;
|
|
270
|
+
}
|
|
264
271
|
}
|
|
272
|
+
|
|
265
273
|
const updatedApp = await this.updateAppApi(app);
|
|
266
274
|
this.updatingAppInStorage(updatedApp);
|
|
267
275
|
return updatedApp;
|
|
@@ -39,7 +39,15 @@ export function compiler(scheme, item, util, variables) {
|
|
|
39
39
|
item
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const sortedItems = filteredItems.sort((a, b) => {
|
|
43
|
+
if(scheme.sortType == 'desc') {
|
|
44
|
+
return b.fields.find(field => field.field_id == scheme.field_id_to_sort).field_value - a.fields.find(field => field.field_id == scheme.field_id_to_sort).field_value;
|
|
45
|
+
} else {
|
|
46
|
+
return a.fields.find(field => field.field_id == scheme.field_id_to_sort).field_value - b.fields.find(field => field.field_id == scheme.field_id_to_sort).field_value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const arrayOfItemsWithProperties = sortedItems.map(async (item) => {
|
|
43
51
|
return getChildsPropertiesObject(scheme.childs, item, app);
|
|
44
52
|
});
|
|
45
53
|
return Promise.all(arrayOfItemsWithProperties);
|
package/package.json
CHANGED
package/umd/library.min.js
CHANGED
|
@@ -169,7 +169,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
|
|
|
169
169
|
},{}],"xR4c":[function(require,module,exports) {
|
|
170
170
|
"use strict";function e(){return'function createList(items) {\n return items.reduce(\n (acc, item) => {\n acc.list[item.item_id] = item;\n acc.ids.push(item.item_id);\n return acc;\n },\n { ids: [], list: {} }\n );\n };\n function compareItemsLists(oldItems, newItems) {\n const { ids: oldIds, list: oldList } = createList(oldItems);\n const { ids: newIds, list: newList } = createList(newItems);\n\n const deletedItemsIds = oldIds.filter((id) => !newIds.includes(id));\n const recentItemsIds = oldIds.filter((id) => !deletedItemsIds.includes(id));\n const newItemsIds = newIds.filter((id) => !oldIds.includes(id));\n\n const diff_fields_items = {};\n const diff_fields_items_Ids = [];\n \n recentItemsIds.forEach((id) => {\n const newItem = newList[id];\n const oldItem = oldList[id];\n\n oldItem.fields.forEach((field1) => {\n const sameField = newItem.fields.find(\n (field2) => Number(field2.field_id) === Number(field1.field_id)\n );\n\n if (!sameField) {\n if (!diff_fields_items[newItem.item_id]) {\n diff_fields_items[newItem.item_id] = [];\n diff_fields_items_Ids.push(newItem.item_id);\n }\n\n return diff_fields_items[newItem.item_id].push(field1);\n }\n\n if (field1.field_value != sameField.field_value) {\n if (!diff_fields_items[newItem.item_id]) {\n diff_fields_items[newItem.item_id] = [];\n diff_fields_items_Ids.push(newItem.item_id);\n }\n return diff_fields_items[newItem.item_id].push(field1);\n }\n });\n });\n\n return {\n newItems: newItemsIds.reduce((acc, id) => {\n acc.push(newList[id]);\n return acc;\n }, []),\n deletedItems: deletedItemsIds.reduce((acc, id) => {\n acc.push(oldList[id]);\n return acc;\n }, []),\n diff_fields_items_Ids,\n diff_fields_items,\n diff_items: diff_fields_items_Ids.reduce((acc, id) => {\n acc.push(oldList[id]);\n return acc;\n }, []),\n };\n }\n\n self.addEventListener("message", (event) => {\n const { items_list1, items_list2 } = event.data;\n\n const diff = compareItemsLists(items_list1, items_list2);\n self.postMessage({ diff });\n });'}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compare_items_lists_Worker=e;
|
|
171
171
|
},{}],"nKaW":[function(require,module,exports) {
|
|
172
|
-
"use strict";function e(e){return u(e)||n(e)||t(e)||r()}function r(){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 t(e,r){if(e){if("string"==typeof e)return
|
|
172
|
+
"use strict";function e(e){return u(e)||n(e)||t(e)||r()}function r(){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 t(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function u(e){if(Array.isArray(e))return i(e)}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach(function(r){c(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e,r,t,n,u,i,a){try{var o=e[i](a),c=o.value}catch(s){return void t(s)}o.done?r(c):Promise.resolve(c).then(n,u)}function p(e){return function(){var r=this,t=arguments;return new Promise(function(n,u){var i=e.apply(r,t);function a(e){s(i,n,u,a,o,"next",e)}function o(e){s(i,n,u,a,o,"throw",e)}a(void 0)})}}function f(r,t,n,u){function i(e,r,t){return a.apply(this,arguments)}function a(){return(a=p(regeneratorRuntime.mark(function e(r,t,n){var u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(u=null,"array"!==r.type){e.next=13;break}if(!Number(r.is_static)){e.next=10;break}return e.t0=Array,e.next=6,b(r.childs,t,n);case 6:e.t1=e.sent,u=new e.t0(e.t1),e.next=13;break;case 10:return e.next=12,s(r,t,n);case 12:u=e.sent;case 13:if("object"!==r.type){e.next=23;break}if(!Number(r.current_item)){e.next=20;break}return e.next=17,l(r,t);case 17:u=e.sent,e.next=23;break;case 20:return e.next=22,b(r.childs,t,n);case 22:u=e.sent;case 23:if("property"!==r.type){e.next=27;break}return e.next=26,y(r,t,n);case 26:u=e.sent;case 27:return e.abrupt("return",c({},r.property_name,u));case 28:case"end":return e.stop()}},e)}))).apply(this,arguments)}function s(e,r,t){return f.apply(this,arguments)}function f(){return(f=p(regeneratorRuntime.mark(function e(r,t,u){var i,a,o,c;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.gudhub.getApp(Number(r.app_id));case 2:return i=e.sent,e.next=5,_(r.filter,i.items_list,u,t);case 5:return a=e.sent,o=a.sort(function(e,t){return"desc"==r.sortType?t.fields.find(function(e){return e.field_id==r.field_id_to_sort}).field_value-e.fields.find(function(e){return e.field_id==r.field_id_to_sort}).field_value:e.fields.find(function(e){return e.field_id==r.field_id_to_sort}).field_value-t.fields.find(function(e){return e.field_id==r.field_id_to_sort}).field_value}),c=o.map(function(){var e=p(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",b(r.childs,t,i));case 1:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}()),e.abrupt("return",Promise.all(c));case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function l(e,r){return d.apply(this,arguments)}function d(){return(d=p(regeneratorRuntime.mark(function e(r,t){var u,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.gudhub.getApp(r.app_id);case 2:return u=e.sent,i=u.items_list||[],e.abrupt("return",b(r.childs,t||i[0],u));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e,r,t){return m.apply(this,arguments)}function m(){return(m=p(regeneratorRuntime.mark(function e(r,t,n){var u,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.map(function(){var e=p(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",i(r,t,n));case 1:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}());case 2:return u=e.sent,e.next=5,Promise.all(u);case 5:return a=e.sent,e.abrupt("return",a.reduce(function(e,r){return o(o({},e),r)},{}));case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function y(e,r,t){return h.apply(this,arguments)}function h(){return(h=p(regeneratorRuntime.mark(function r(t,u,i){var a,o,c;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=t.property_type,r.next="static"===r.t0?3:"variable"===r.t0?4:"field_id"===r.t0?9:"function"===r.t0?10:(r.t0,20);break;case 3:return r.abrupt("return",t.static_field_value);case 4:r.t1=t.variable_type,r.next="app_id"===r.t1?7:(r.t1,8);break;case 7:return r.abrupt("return",i.app_id);case 8:return r.abrupt("return","".concat(i.app_id,".").concat(u.item_id));case 9:return r.abrupt("return",t.field_id);case 10:if("function"!=typeof t.function){r.next=15;break}return a=t.function.apply(t,[u,i].concat(e(t.args))),r.abrupt("return",a);case 15:return o=new Function("item, app","return (async "+t.function+")(item, app)"),r.next=18,o(u,i);case 18:return c=r.sent,r.abrupt("return",c);case 20:if(!Boolean(Number(t.interpretation))){r.next=24;break}return r.abrupt("return",n.gudhub.getInterpretedValue(Number(i.app_id),Number(u.item_id),Number(t.field_id)));case 24:return r.abrupt("return",n.gudhub.getFieldValue(Number(i.app_id),Number(u.item_id),Number(t.field_id)));case 25:case"end":return r.stop()}},r)}))).apply(this,arguments)}function g(e,r,t,n){return v.apply(this,arguments)}function v(){return(v=p(regeneratorRuntime.mark(function r(t,i,a,o){var c;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,n.gudhub.prefilter(t,i,a,u);case 2:return c=r.sent,r.abrupt("return",n.gudhub.filter(o,[].concat(e(c),e(t))));case 4:case"end":return r.stop()}},r)}))).apply(this,arguments)}function _(){return x.apply(this,arguments)}function x(){return(x=p(regeneratorRuntime.mark(function r(){var t,n,u,i,a=arguments;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:[],n=a.length>1&&void 0!==a[1]?a[1]:[],u=a.length>2&&void 0!==a[2]?a[2]:{},i=a.length>3&&void 0!==a[3]?a[3]:{},r.abrupt("return",t.length?g(t,u.app_id,i.item_id,n):e(n));case 5:case"end":return r.stop()}},r)}))).apply(this,arguments)}return i(r,t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=f;
|
|
173
173
|
},{}],"zqOZ":[function(require,module,exports) {
|
|
174
174
|
"use strict";function e(e,n,i,t,a,r,o){try{var c=e[r](o),p=c.value}catch(u){return void i(u)}c.done?n(p):Promise.resolve(p).then(t,a)}function n(n){return function(){var i=this,t=arguments;return new Promise(function(a,r){var o=n.apply(i,t);function c(n){e(o,a,r,c,p,"next",n)}function p(n){e(o,a,r,c,p,"throw",n)}c(void 0)})}}function i(e){return(i="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 t(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function a(e,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function r(e,n,i){return n&&a(e.prototype,n),i&&a(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var o=function(){function e(n){t(this,e),this.gudhub=n,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}}return r(e,[{key:"createAppsFromTemplate",value:function(e,n,t){var a=this,r=this;return new Promise(function(o){var c=100/(6*e.apps.length),p=0;r.createApps(e,function(e){p+=1,t.call(a,{percent:p*c,status:e})}).then(function(e){r.createItems(e,n,function(e){"string"==typeof e?(p+=1,t.call(a,{percent:p*c,status:e})):"object"===i(e)&&t.call(a,{status:"Done",apps:e})}).then(function(){o()})})})}},{key:"createItems",value:function(e,n,i){var t=this;return new Promise(function(a){var r=n||1e5,o=t,c=[],p=[];e.forEach(function(e){p.push(new Promise(function(n){o.gudhub.getApp(o._searchOldAppId(e.app_id,o.appsConnectingMap.apps)).then(function(a){i&&i.call(t,"GET APP: ".concat(a.app_name," (Items steps)"));var p=JSON.parse(JSON.stringify(a)),u=p.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,n){return n<=r});o.gudhub.addNewItems(e.app_id,u).then(function(r){i&&i.call(t,"ADD NEW ITEMS: ".concat(a.app_name," (Items steps)")),0===r.length&&(i&&i.call(t,"NO ITEMS TO REPLACE VALUE: ".concat(a.app_name," (Items steps)")),n()),e.items_list=r,o._updateMap(e.items_list,p.items_list),o._addFieldValue(p.items_list,e.items_list,o.appsConnectingMap),c.push(e),o.appsConnectingMap.apps.length===c.length&&(c.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){o.appsConnectingMap.fields.forEach(function(n){e.field_id===n.old_field_id&&(e.field_id=n.new_field_id,e.element_id=n.new_field_id)})})})}),o.deleteField(c),o.replaceValue(c,o.appsConnectingMap).then(function(){i&&i.call(t,"REPLACE VALUE: ".concat(a.app_name," (Items steps)")),c.forEach(function(e){var i=e.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e});o.gudhub.updateItems(e.app_id,i).then(function(){n()})})}))})})}))}),Promise.all(p).then(function(){var n=e.map(function(e){return e.app_id});i.call(t,n),a()})})}},{key:"deleteField",value:function(e){e.forEach(function(e){e.items_list.forEach(function(n){n.fields=n.fields.filter(function(n){return e.field_list.findIndex(function(e){return e.field_id==n.field_id})>-1})})})}},{key:"replaceValue",value:function(e,i){var t=this;return new Promise(function(){var a=n(regeneratorRuntime.mark(function n(a){var r,o;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:r=[],o=t,e.forEach(function(e){e.field_list.forEach(function(n){"item_ref"===n.data_type&&o._replaceValueItemRef(e,n,i),r.push(o.gudhub.ghconstructor.getInstance(n.data_type).then(function(i){return"file"==i.getTemplate().constructor?o.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){return e}):"document"!=i.getTemplate().constructor?i:void o.documentInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){return i})}))})}),r.length>0?Promise.all(r).then(function(e){a(e)}):a(result);case 4:case"end":return n.stop()}},n)}));return function(e){return a.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(e,i,t){var a=this;return new Promise(function(){var r=n(regeneratorRuntime.mark(function n(r){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:i.forEach(function(n){var i=n.item_id,o=n.fields.find(function(e){return e.element_id===t});o&&o.field_value&&o.field_value.length>0&&a.gudhub.getDocument({_id:o.field_value}).then(function(n){a.gudhub.createDocument({app_id:e,item_id:i,element_id:t,data:n.data}).then(function(e){o.field_value=e._id,r()})})});case 1:case"end":return n.stop()}},n)}));return function(e){return r.apply(this,arguments)}}())}},{key:"_replaceValueItemRef",value:function(e,n,i){e.items_list.forEach(function(e){e.fields.forEach(function(e){if(e.field_id===n.field_id&&e.field_value){var t=e.field_value.split(",");t.forEach(function(e,n){var a=e.split(".");i.apps.forEach(function(e){a[0]==e.old_app_id&&(a[0]=e.new_app_id)}),i.items.forEach(function(e){a[1]==e.old_item_id&&(a[1]=e.new_item_id)}),t[n]=a.join(".")}),e.field_value=t.join(",")}})})}},{key:"_addFieldValue",value:function(e,n,i){n.forEach(function(n){i.items.forEach(function(i){n.item_id===i.new_item_id&&e.forEach(function(e){i.old_item_id===e.item_id&&(n.fields=e.fields)})})})}},{key:"_updateMap",value:function(e,n){var i=this;n.forEach(function(n){e.forEach(function(e){n.index_number===e.index_number&&i.appsConnectingMap.items.push({old_item_id:n.item_id,new_item_id:e.item_id})})})}},{key:"_searchOldAppId",value:function(e,n){var i=0;return n.forEach(function(n){n.new_app_id===e&&(i=n.old_app_id)}),i}},{key:"createApps",value:function(e,n){var i=this,t=this,a={step_size:100/(3*e.apps.length),apps:[]};return new Promise(function(r){var o={},c=[],p=[];e.apps.forEach(function(u){t.gudhub.getApp(u).then(function(u){n&&n.call(i,"GET APP: ".concat(u.app_name," (App steps)"));var f=JSON.parse(JSON.stringify(u));o[f.app_id]=f,a.apps.push(f.icon);var l=t.prepareAppTemplate(f);l.app_name=l.app_name+" New",l.privacy=1,t.resetViewsIds(l),t.gudhub.createNewApp(l).then(function(a){n&&n.call(i,"CREATE NEW APP: ".concat(u.app_name," (App steps)")),c.push(a),t.mapApp(f,a,t.appsConnectingMap),e.apps.length==c.length&&(t.connectApps(c,t.appsConnectingMap,o),c.forEach(function(a){t.gudhub.updateApp(a).then(function(t){n&&n.call(i,"UPDATE APP: ".concat(u.app_name," (App steps)")),p.push(t),e.apps.length==p.length&&r(p)})}))})})})})}},{key:"mapApp",value:function(e,n,i){i.apps.push({old_app_id:e.app_id,new_app_id:n.app_id,old_view_init:e.view_init,new_view_init:n.view_init}),e.field_list.forEach(function(e){n.field_list.forEach(function(n){e.name_space==n.name_space&&i.fields.push({name_space:e.name_space,old_field_id:e.field_id,new_field_id:n.field_id})})}),e.views_list.forEach(function(e){n.views_list.forEach(function(n){e.name==n.name&&i.views.push({name:e.name,old_view_id:e.view_id,new_view_id:n.view_id})})})}},{key:"crawling",value:function(e,n){var i=null===e?[]:Object.keys(e),t=this;i.length>0&&i.forEach(function(i){var a=e[i];void 0!==a&&"string"!=typeof e&&(n(i,a,e),t.crawling(a,n))})}},{key:"resetViewsIds",value:function(e){e.view_init=0,this.crawling(e.views_list,function(e,n,i){"view_id"!=e&&"container_id"!=e||(i[e]=0)})}},{key:"connectApps",value:function(e,n,i){var t=this;return e.forEach(function(e){n.apps.forEach(function(i){e.view_init===i.new_view_init&&n.views.forEach(function(n){i.old_view_init===n.old_view_id&&(e.view_init=n.new_view_id)})}),t.crawling(e.field_list,function(a,r,o){if(-1!==a.indexOf("field_id")||-1!==a.indexOf("FieldId")||-1!==a.indexOf("destination_field")){var c=String(r).split(","),p=[];n.fields.forEach(function(e){c.forEach(function(n){n==e.old_field_id&&p.push(e.new_field_id)})}),p.length&&(o[a]=p.join(","))}if(-1==a.indexOf("app_id")&&-1==a.indexOf("AppId")&&-1==a.indexOf("destination_app")||n.apps.forEach(function(e){r==e.old_app_id&&(o[a]=e.new_app_id)}),-1!==a.indexOf("view_id")&&n.views.forEach(function(e){r==e.old_view_id&&(o[a]=e.new_view_id)}),-1!==a.indexOf("src")&&isFinite(r)){var u=n.apps.find(function(n){return n.new_app_id===e.app_id}).old_app_id,f=t.findPath(i[u].views_list,"container_id",r);o[a]="".concat(t.getValueByPath(e.views_list,f,"container_id"))}})}),e}},{key:"getValueByPath",value:function(e,n,i){var t=e;return n.split(".").forEach(function(e){t=t[e]}),t[i]}},{key:"findPath",value:function(e,n,t){var a=!1,r=!1,o=[];return this.crawling(e,function(e,c,p){r&&o.reverse().forEach(function(e){r&&(e.delete=!0,e.parent===p&&(r=!1,(o=o.filter(function(e){return!e.delete})).reverse()))}),a||("object"===i(p[e])&&o.push({prop:e,parent:p}),c==t&&n===e?a=!0:Object.keys(p).pop()===e&&"object"!==i(p[e])&&(r=!0))}),o.map(function(e){return e.prop}).join(".")}},{key:"prepareAppTemplate",value:function(e){var n=JSON.parse(JSON.stringify(e));return this.crawling(n.views_list,function(e,n,i){"element_id"==e&&(i.element_id=-Number(n),i.create_element=-Number(n))}),n.field_list.forEach(function(e){e.create_field=-Number(e.field_id),e.element_id=-Number(e.field_id),e.field_id=-Number(e.field_id),e.field_value=""}),n.items_list=[],delete n.app_id,delete n.icon.id,delete n.group_id,delete n.trash,delete n.last_update,delete n.file_list,n}}]),e}();exports.default=o;
|
|
175
175
|
},{}],"E7yc":[function(require,module,exports) {
|
|
@@ -189,7 +189,7 @@ var e=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),export
|
|
|
189
189
|
},{"axios":"O4Aa","./../consts.js":"UV2u"}],"Htuh":[function(require,module,exports) {
|
|
190
190
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GHConstructor=void 0;var e=t(require("./createAngularModuleInstance.js")),n=t(require("./createClassInstance.js"));function t(e){return e&&e.__esModule?e:{default:e}}function r(e,n,t,r,u,a,o){try{var i=e[a](o),c=i.value}catch(s){return void t(s)}i.done?n(c):Promise.resolve(c).then(r,u)}function u(e){return function(){var n=this,t=arguments;return new Promise(function(u,a){var o=e.apply(n,t);function i(e){r(o,u,a,i,c,"next",e)}function c(e){r(o,u,a,i,c,"throw",e)}i(void 0)})}}function a(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,n,t){return n&&o(e.prototype,n),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var c=function(){function t(e){a(this,t),this.gudhub=e,this.cache=[],this.modulesQueue={},this.angularInjector,this.nodeWindow}return i(t,[{key:"getInstance",value:function(){var e=u(regeneratorRuntime.mark(function e(n){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=u(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.modulesQueue[n]){e.next=4;break}return e.abrupt("return",t.modulesQueue[n].then(function(){r(t.getCached(n))}));case 4:t.cache.find(function(e){return e.type===n})?r(t.getCached(n)):(t.modulesQueue[n]=t.createInstance(n),t.modulesQueue[n].then(function(){r(t.getCached(n))}));case 5:case"end":return e.stop()}},e)}));return function(n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e)}));return function(n){return e.apply(this,arguments)}}()},{key:"pupToCache",value:function(e){this.cache.push(e)}},{key:"getCached",value:function(e){return this.cache.find(function(n){return n.type===e})}},{key:"initAngularInjector",value:function(e){this.angularInjector=e}},{key:"initJsdomWindow",value:function(e){this.nodeWindow=e}},{key:"createInstance",value:function(){var t=u(regeneratorRuntime.mark(function t(r){var u,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("angular"!==(u=this.gudhub.storage.getModuleUrl(r)).type){t.next=7;break}return t.next=4,(0,e.default)(r,u.url,this.angularInjector,this.nodeWindow);case 4:a=t.sent,t.next=11;break;case 7:if("class"!==u.type){t.next=11;break}return t.next=10,(0,n.default)(r,u.js,u.css,this.nodeWindow);case 10:a=t.sent;case 11:return this.pupToCache(a),t.abrupt("return",a);case 13:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()}]),t}();exports.GHConstructor=c;
|
|
191
191
|
},{"./createAngularModuleInstance.js":"osSN","./createClassInstance.js":"DsUm"}],"q0my":[function(require,module,exports) {
|
|
192
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppProcessor=void 0;var e=require("../consts.js");function t(e){return i(e)||n(e)||o(e)||r()}function r(){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 n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return c(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=o(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,p=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return p=e.done,e},e:function(e){s=!0,a=e},f:function(){try{p||null==r.return||r.return()}finally{if(s)throw a}}}}function o(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(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 f(e,t,r,n,i,a,p){try{var s=e[a](p),u=s.value}catch(o){return void r(o)}s.done?t(u):Promise.resolve(u).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function p(e){f(a,n,i,p,s,"next",e)}function s(e){f(a,n,i,p,s,"throw",e)}p(void 0)})}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var d=function(){function r(e,t,n,i,a,p,s){h(this,r),this.storage=e,this.pipeService=t,this.req=n,this.ws=i,this.applistReceived=!1,this.activateSW=s,this.chunksManager=a,this.util=p,this.appListeners()}return g(r,[{key:"createNewAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/create",form:{app:JSON.stringify(t)}});case 3:return(r=e.sent).from_apps_list=!0,e.abrupt("return",r);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/update",form:{app:JSON.stringify(t)}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/delete",form:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListApi",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/applist/get"});case 3:return t=e.sent,e.abrupt("return",t.apps_list.map(function(e){return e.from_apps_list=!0,e}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(){return e.apply(this,arguments)}}()},{key:"getAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/app/get",params:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListFromStorage",value:function(){return this.storage.getAppsList()}},{key:"getAppFromStorage",value:function(e){var t=this.storage.getApp(e);return t&&t.field_list.length?t:null}},{key:"addNewAppToStorage",value:function(e){return this.storage.getAppsList().push(e)}},{key:"saveAppInStorage",value:function(e){var t=this.storage.getApp(e.app_id);return t?(e.from_apps_list=t.from_apps_list,e.permission=t.permission,this.storage.updateApp(e)):(e.from_apps_list=!1,this.addNewAppToStorage(e)),this.getAppFromStorage(e.app_id)}},{key:"updatingAppInStorage",value:function(e){var t=this,r=this.getAppFromStorage(e.app_id);e.items_list=r.items_list,e.file_list=r.file_list,e.from_apps_list=r.from_apps_list,this.storage.updateApp(e),this.pipeService.emit("gh_app_views_update",{app_id:e.app_id},e.views_list),e.field_list.forEach(function(r){t.pipeService.emit("gh_model_update",{app_id:e.app_id,field_id:r.field_id},r)})}},{key:"deletingAppFromStorage",value:function(e){var t=this.storage.getAppsList();return t.forEach(function(r,n){r.app_id==e&&t.splice(n)}),t}},{key:"updateAppsListInStorage",value:function(){var e,t=u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(t.s();!(e=t.n()).done;){var r=e.value,n=this.storage.getApp(r.app_id);n?(n.from_apps_list=r.from_apps_list,n.permission=r.permission):this.addNewAppToStorage(r)}}catch(i){t.e(i)}finally{t.f()}}},{key:"refreshApps",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n,i,a,p=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=p.length>0&&void 0!==p[0]?p[0]:[],r=u(t),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=19;break}if(null==(i=n.value)||!this.storage.getApp(i)){e.next=17;break}return e.prev=7,e.next=10,this.getAppApi(i);case 10:(a=e.sent)&&this.storage.updateApp(a),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.log(e.t0);case 17:e.next=4;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(2),r.e(e.t1);case 24:return e.prev=24,r.f(),e.finish(24);case 27:console.log("Apps refreshed: ",JSON.stringify(t));case 28:case"end":return e.stop()}},e,this,[[2,21,24,27],[7,14]])}));return function(){return e.apply(this,arguments)}}()},{key:"refreshAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getAppListFromStorage(),e.next=3,this.getAppListApi();case 3:r=e.sent,n=r.map(function(e){return p(p({},e),t.find(function(t){return t.app_id===e.app_id}))}),this.updateAppsListInStorage(n),this.pipeService.emit("gh_apps_list_refreshed",{});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getAppListFromStorage(),this.applistReceived){e.next=10;break}return e.next=4,this.getAppListApi();case 4:if(r=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:this.updateAppsListInStorage(r),this.applistReceived=!0,t=r;case 10:return e.abrupt("return",t);case 11:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAppsList();case 2:return r=e.sent,e.abrupt("return",r?r.find(function(e){return e.app_id==t}):null);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteAppApi(t);case 2:return e.abrupt("return",this.deletingAppFromStorage(t));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getApp",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var n,i,a,s=this,u=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>1&&void 0!==u[1]&&u[1],r){e.next=3;break}return e.abrupt("return",null);case 3:if(i=this.getAppFromStorage(r)){e.next=11;break}return e.next=7,this.getAppApi(r);case 7:if(a=e.sent){e.next=10;break}return e.abrupt("return",null);case 10:a.chunks&&a.chunks.length?(this.chunksManager.getChunks(r,a.chunks).then(function(e){a.items_list=s.util.mergeChunks([].concat(t(e),[a])),s.saveAppInStorage(a),s.pipeService.emit("gh_items_update",{app_id:r},a.items_list)}),i=a,this.saveAppInStorage(a)):(i=this.getAppFromStorage(r))||(i=a,this.saveAppInStorage(a),this.ws.addSubscription(r));case 11:return e.abrupt("return",n?i:p(p({},i),{},{items_list:i.items_list.filter(function(e){return!e.trash})}));case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.view_list&&t.view_list.length){e.next=5;break}return e.next=3,this.getApp(t.app_id);case 3:r=e.sent,t.view_list=r.view_list;case 5:return e.next=7,this.updateAppApi(t);case 7:return n=e.sent,this.updatingAppInStorage(n),e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=this.getAppFromStorage(t.app_id),e.abrupt("return",this.updateApp(p(p({},r),t)));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"createNewApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createNewAppApi(t);case 2:return r=e.sent,this.addNewAppToStorage(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearAppProcessor",value:function(){this.getAppListPromises=null,this.getAppPromises={},this.applistReceived=!1}},{key:"appListeners",value:function(){var t=this;this.pipeService.onRoot("gh_app_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_get",n,i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_apps_list_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppsList();case 2:i=e.sent,t.pipeService.emit("gh_apps_list_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_delete_app",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.deleteApp(n.app_id);case 2:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.app.items_list=[],n.app.file_list=[],e.next=4,t.updateApp(n.app);case 4:return i=e.sent,t.pipeService.emit("gh_app_views_update",{app_id:i.app_id},i.views_list),e.next=8,t.getAppsList();case 8:a=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},a),i.field_list.forEach(function(e){t.pipeService.emit("gh_model_update",{app_id:i.app_id,field_id:e.field_id},e)});case 11:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_view_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:(i=e.sent).views_list.forEach(function(e,r){e.view_id==n.view_id&&t.pipeService.emit("gh_app_view_get",n,i.views_list[r])});case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_views_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_views_get",n,i.views_list);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppInfo(n.app_id);case 2:(i=e.sent)&&t.pipeService.emit("gh_app_info_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app){e.next=5;break}return e.next=3,t.updateAppInfo(n.app);case 3:i=e.sent,t.pipeService.emit("gh_app_info_update",{app_id:n.app.app_id},i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_create",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createNewApp(n.app);case 2:return e.next=4,t.getAppsList();case 4:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),e.IS_WEB&&this.activateSW&&navigator.serviceWorker.addEventListener("message",function(){var e=l(regeneratorRuntime.mark(function e(r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("refresh app"!==r.data.type){e.next=7;break}return e.next=3,t.getApp(r.data.payload.app_id);case 3:(n=e.sent)&&t.util.compareAppsItemsLists(n.items_list,r.data.payload.items_list.filter(function(e){return!e.trash}),function(e){var n=e.diff_fields_items,i=e.diff_fields_items_Ids,a=e.diff_items,p=e.newItems,s=e.deletedItems;(a.length||p.length||s.length)&&(t.pipeService.emit("gh_items_update",{app_id:r.data.payload.app_id},r.data.payload.items_list.filter(function(e){return!e.trash})),a.forEach(function(e){return t.pipeService.emit("gh_item_update",{app_id:r.data.payload.app_id,item_id:e.item_id},e)})),i.forEach(function(e){var i=n[e];i&&i.forEach(function(n){t.pipeService.emit("gh_value_update",{app_id:r.data.payload.app_id,item_id:e,field_id:n.field_id},n.field_value)})})}),r.data.payload.items_list=t.util.mergeChunks([n,r.data.payload]),t.saveAppInStorage(r.data.payload);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}}]),r}();exports.AppProcessor=d;
|
|
192
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppProcessor=void 0;var e=require("../consts.js");function t(e){return i(e)||n(e)||o(e)||r()}function r(){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 n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return c(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=o(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,p=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return p=e.done,e},e:function(e){s=!0,a=e},f:function(){try{p||null==r.return||r.return()}finally{if(s)throw a}}}}function o(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(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 f(e,t,r,n,i,a,p){try{var s=e[a](p),u=s.value}catch(o){return void r(o)}s.done?t(u):Promise.resolve(u).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function p(e){f(a,n,i,p,s,"next",e)}function s(e){f(a,n,i,p,s,"throw",e)}p(void 0)})}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var d=function(){function r(e,t,n,i,a,p,s){h(this,r),this.storage=e,this.pipeService=t,this.req=n,this.ws=i,this.applistReceived=!1,this.activateSW=s,this.chunksManager=a,this.util=p,this.appListeners()}return g(r,[{key:"createNewAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/create",form:{app:JSON.stringify(t)}});case 3:return(r=e.sent).from_apps_list=!0,e.abrupt("return",r);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/update",form:{app:JSON.stringify(t)}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/delete",form:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListApi",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/applist/get"});case 3:return t=e.sent,e.abrupt("return",t.apps_list.map(function(e){return e.from_apps_list=!0,e}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(){return e.apply(this,arguments)}}()},{key:"getAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/app/get",params:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListFromStorage",value:function(){return this.storage.getAppsList()}},{key:"getAppFromStorage",value:function(e){var t=this.storage.getApp(e);return t&&t.field_list.length?t:null}},{key:"addNewAppToStorage",value:function(e){return this.storage.getAppsList().push(e)}},{key:"saveAppInStorage",value:function(e){var t=this.storage.getApp(e.app_id);return t?(e.from_apps_list=t.from_apps_list,e.permission=t.permission,this.storage.updateApp(e)):(e.from_apps_list=!1,this.addNewAppToStorage(e)),this.getAppFromStorage(e.app_id)}},{key:"updatingAppInStorage",value:function(e){var t=this,r=this.getAppFromStorage(e.app_id);e.items_list=r.items_list,e.file_list=r.file_list,e.from_apps_list=r.from_apps_list,this.storage.updateApp(e),this.pipeService.emit("gh_app_views_update",{app_id:e.app_id},e.views_list),e.field_list.forEach(function(r){t.pipeService.emit("gh_model_update",{app_id:e.app_id,field_id:r.field_id},r)})}},{key:"deletingAppFromStorage",value:function(e){var t=this.storage.getAppsList();return t.forEach(function(r,n){r.app_id==e&&t.splice(n)}),t}},{key:"updateAppsListInStorage",value:function(){var e,t=u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(t.s();!(e=t.n()).done;){var r=e.value,n=this.storage.getApp(r.app_id);n?(n.from_apps_list=r.from_apps_list,n.permission=r.permission):this.addNewAppToStorage(r)}}catch(i){t.e(i)}finally{t.f()}}},{key:"refreshApps",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n,i,a,p=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=p.length>0&&void 0!==p[0]?p[0]:[],r=u(t),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=19;break}if(null==(i=n.value)||!this.storage.getApp(i)){e.next=17;break}return e.prev=7,e.next=10,this.getAppApi(i);case 10:(a=e.sent)&&this.storage.updateApp(a),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.log(e.t0);case 17:e.next=4;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(2),r.e(e.t1);case 24:return e.prev=24,r.f(),e.finish(24);case 27:console.log("Apps refreshed: ",JSON.stringify(t));case 28:case"end":return e.stop()}},e,this,[[2,21,24,27],[7,14]])}));return function(){return e.apply(this,arguments)}}()},{key:"refreshAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getAppListFromStorage(),e.next=3,this.getAppListApi();case 3:r=e.sent,n=r.map(function(e){return p(p({},e),t.find(function(t){return t.app_id===e.app_id}))}),this.updateAppsListInStorage(n),this.pipeService.emit("gh_apps_list_refreshed",{});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getAppListFromStorage(),this.applistReceived){e.next=10;break}return e.next=4,this.getAppListApi();case 4:if(r=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:this.updateAppsListInStorage(r),this.applistReceived=!0,t=r;case 10:return e.abrupt("return",t);case 11:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAppsList();case 2:return r=e.sent,e.abrupt("return",r?r.find(function(e){return e.app_id==t}):null);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteAppApi(t);case 2:return e.abrupt("return",this.deletingAppFromStorage(t));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getApp",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var n,i,a,s=this,u=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>1&&void 0!==u[1]&&u[1],r){e.next=3;break}return e.abrupt("return",null);case 3:if(i=this.getAppFromStorage(r)){e.next=11;break}return e.next=7,this.getAppApi(r);case 7:if(a=e.sent){e.next=10;break}return e.abrupt("return",null);case 10:a.chunks&&a.chunks.length?(this.chunksManager.getChunks(r,a.chunks).then(function(e){a.items_list=s.util.mergeChunks([].concat(t(e),[a])),s.saveAppInStorage(a),s.pipeService.emit("gh_items_update",{app_id:r},a.items_list)}),i=a,this.saveAppInStorage(a)):(i=this.getAppFromStorage(r))||(i=a,this.saveAppInStorage(a),this.ws.addSubscription(r));case 11:return e.abrupt("return",n?i:p(p({},i),{},{items_list:i.items_list.filter(function(e){return!e.trash})}));case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.views_list&&t.views_list.length&&t.show){e.next=6;break}return e.next=3,this.getApp(t.app_id);case 3:r=e.sent,t.views_list&&t.views_list.length||(t.views_list=r.views_list),void 0===t.show&&(t.show=r.show);case 6:return e.next=8,this.updateAppApi(t);case 8:return n=e.sent,this.updatingAppInStorage(n),e.abrupt("return",n);case 11:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=this.getAppFromStorage(t.app_id),e.abrupt("return",this.updateApp(p(p({},r),t)));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"createNewApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createNewAppApi(t);case 2:return r=e.sent,this.addNewAppToStorage(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearAppProcessor",value:function(){this.getAppListPromises=null,this.getAppPromises={},this.applistReceived=!1}},{key:"appListeners",value:function(){var t=this;this.pipeService.onRoot("gh_app_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_get",n,i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_apps_list_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppsList();case 2:i=e.sent,t.pipeService.emit("gh_apps_list_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_delete_app",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.deleteApp(n.app_id);case 2:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.app.items_list=[],n.app.file_list=[],e.next=4,t.updateApp(n.app);case 4:return i=e.sent,t.pipeService.emit("gh_app_views_update",{app_id:i.app_id},i.views_list),e.next=8,t.getAppsList();case 8:a=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},a),i.field_list.forEach(function(e){t.pipeService.emit("gh_model_update",{app_id:i.app_id,field_id:e.field_id},e)});case 11:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_view_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:(i=e.sent).views_list.forEach(function(e,r){e.view_id==n.view_id&&t.pipeService.emit("gh_app_view_get",n,i.views_list[r])});case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_views_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_views_get",n,i.views_list);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppInfo(n.app_id);case 2:(i=e.sent)&&t.pipeService.emit("gh_app_info_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app){e.next=5;break}return e.next=3,t.updateAppInfo(n.app);case 3:i=e.sent,t.pipeService.emit("gh_app_info_update",{app_id:n.app.app_id},i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_create",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createNewApp(n.app);case 2:return e.next=4,t.getAppsList();case 4:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),e.IS_WEB&&this.activateSW&&navigator.serviceWorker.addEventListener("message",function(){var e=l(regeneratorRuntime.mark(function e(r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("refresh app"!==r.data.type){e.next=7;break}return e.next=3,t.getApp(r.data.payload.app_id);case 3:(n=e.sent)&&t.util.compareAppsItemsLists(n.items_list,r.data.payload.items_list.filter(function(e){return!e.trash}),function(e){var n=e.diff_fields_items,i=e.diff_fields_items_Ids,a=e.diff_items,p=e.newItems,s=e.deletedItems;(a.length||p.length||s.length)&&(t.pipeService.emit("gh_items_update",{app_id:r.data.payload.app_id},r.data.payload.items_list.filter(function(e){return!e.trash})),a.forEach(function(e){return t.pipeService.emit("gh_item_update",{app_id:r.data.payload.app_id,item_id:e.item_id},e)})),i.forEach(function(e){var i=n[e];i&&i.forEach(function(n){t.pipeService.emit("gh_value_update",{app_id:r.data.payload.app_id,item_id:e,field_id:n.field_id},n.field_value)})})}),r.data.payload.items_list=t.util.mergeChunks([n,r.data.payload]),t.saveAppInStorage(r.data.payload);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}}]),r}();exports.AppProcessor=d;
|
|
193
193
|
},{"../consts.js":"UV2u"}],"UUd3":[function(require,module,exports) {
|
|
194
194
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemProcessor=void 0;var e=require("../utils.js");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function r(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t,r,i,n,a,s){try{var u=e[a](s),p=u.value}catch(o){return void r(o)}u.done?t(p):Promise.resolve(p).then(i,n)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var s=e.apply(t,r);function u(e){n(s,i,a,u,p,"next",e)}function p(e){n(s,i,a,u,p,"throw",e)}u(void 0)})}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var o=function(){function t(e,r,i,n,a){s(this,t),this.storage=e,this.pipeService=r,this.req=i,this.appProcessor=n,this.util=a,this.itemListeners()}return p(t,[{key:"addItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/add",form:{items:JSON.stringify(r),app_id:t}});case 3:return i=e.sent,e.abrupt("return",i);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/update",form:{items:JSON.stringify(r),app_id:t}});case 3:return i=e.sent,e.abrupt("return",i);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsApi",value:function(e){try{var t=this.req.post({url:"/api/items/delete",form:{items_ids:JSON.stringify(e)}});return t.from_apps_list=!0,t}catch(r){return console.log(r),null}}},{key:"addItemsToStorage",value:function(e,t){var r=this,i=this.storage.getApp(e);return i&&(t.forEach(function(t){i.items_list.push(t),r.pipeService.emit("gh_item_update",{app_id:e},[t])}),this.pipeService.emit("gh_items_update",{app_id:e},i.items_list),this.storage.updateApp(i)),i}},{key:"updateItemsInStorage",value:function(e,t){var r=this;this.pipeService.emit("gh_items_update",{app_id:e},t);var i=this.storage.getApp(e);return i&&t&&t.forEach(function(t){var n={app_id:e};r.pipeService.emit("gh_item_update",n,[t]),n.item_id=t.item_id,r.pipeService.emit("gh_item_update",n,t);var a=i.items_list.find(function(e){return e.item_id==t.item_id});a&&t.fields.forEach(function(e){var t=a.fields.find(function(t){return t.field_id==e.field_id});n.field_id=e.field_id,t?t.field_value!=e.field_value&&(t.field_value=e.field_value,r.pipeService.emit("gh_value_update",n,e.field_value)):(a.fields.push(e),r.pipeService.emit("gh_value_update",n,e.field_value))})}),t}},{key:"deleteItemsFromStorage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.storage.getApp(e);r&&(r.items_list=r.items_list.filter(function(e){return!t.includes(e.item_id)}),this.pipeService.emit("gh_items_update",{app_id:e},r.items_list),this.storage.updateApp(r))}},{key:"getItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t){var r,i,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]&&n[1],e.next=3,this.appProcessor.getApp(t,r);case 3:if(i=e.sent){e.next=6;break}return e.abrupt("return",null);case 6:return e.abrupt("return",i.items_list);case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(){var t=a(regeneratorRuntime.mark(function t(i,n){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=n.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.addItemsApi(i,a);case 3:return s=t.sent,this.addItemsToStorage(i,s),this.pipeService.emit("gh_items_add",{app_id:i},s),t.abrupt("return",s);case 7:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"updateItems",value:function(){var t=a(regeneratorRuntime.mark(function t(i,n){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=n.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.updateItemsApi(i,a);case 3:return s=t.sent,t.abrupt("return",this.updateItemsInStorage(i,s));case 5:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"deleteItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deleteItemsApi(r).then(function(){return i.deleteItemsFromStorage(t,r)}));case 1:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){var e=this;this.pipeService.onRoot("gh_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.app_id){t.next=5;break}return t.next=3,e.getItems(i.app_id);case 3:(n=t.sent)?e.pipeService.emit("gh_items_get",i,n):e.pipeService.emit("gh_items_get",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_add",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i&&i.app_id&&i.items)){t.next=5;break}return t.next=3,e.addNewItems(i.app_id,i.items);case 3:(n=t.sent)?e.pipeService.emit("gh_items_add",i,n):e.pipeService.emit("gh_items_add",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_update",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i&&i.app_id&&i.items)){t.next=5;break}return t.next=3,e.updateItems(i.app_id,i.items);case 3:(n=t.sent)?e.pipeService.emit("gh_items_update",i,n):e.pipeService.emit("gh_items_update",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_item_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.app_id){t.next=6;break}return t.next=3,e.getItems(i.app_id);case 3:n=t.sent,a=n.find(function(e){return e.item_id==i.item_id}),e.pipeService.emit("gh_item_get",i,a);case 6:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filtered_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.element_app_id){t.next=8;break}return t.next=3,e.getItems(i.element_app_id);case 3:return n=t.sent,t.next=6,e.util.getFilteredItems(n,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 6:a=t.sent,e.pipeService.emit("gh_filtered_items_get",i,a);case 8:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filter_items",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.items){t.next=5;break}return t.next=3,e.util.getFilteredItems(i.items,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 3:n=t.sent,e.pipeService.emit("gh_filter_items",i,n);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}]),t}();exports.ItemProcessor=o;
|
|
195
195
|
},{"../utils.js":"EgeI"}],"PoPF":[function(require,module,exports) {
|