@gudhub/core 1.2.4-beta.6 → 1.2.4-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.parcel-cache/83e7562660f7cc15-BundleGraph +0 -0
- package/.parcel-cache/9a0d07555444f4da-AssetGraph +0 -0
- package/.parcel-cache/d3a1b9507cb44047-AssetGraph +0 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/dc1da35000e13623-RequestGraph +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/.parcel-cache/snapshot-dc1da35000e13623.txt +29402 -0
- package/.parcelrc.appRequestWorker +4 -0
- package/GUDHUB/AppProcessor/AppProcessor.js +58 -26
- package/GUDHUB/ChunksManager/ChunksManager.test.js +11 -4
- package/GUDHUB/DataService/AppDataService.js +36 -1
- package/GUDHUB/DataService/ChunkDataService.js +7 -1
- package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +773 -43
- package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +118 -85
- package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +171 -7
- package/GUDHUB/DataService/IndexedDB/StoreManager/BaseStoreManager.js +97 -0
- package/GUDHUB/DataService/IndexedDB/StoreManager/managers.js +77 -0
- package/GUDHUB/DataService/IndexedDB/appDataConf.js +6 -3
- package/GUDHUB/DataService/IndexedDB/appRequestWorker.js +163 -0
- package/GUDHUB/DataService/IndexedDB/chunkDataConf.js +3 -3
- package/GUDHUB/DataService/IndexedDB/consts.js +1 -1
- package/GUDHUB/DataService/IndexedDB/init.js +18 -17
- package/GUDHUB/DataService/IndexedDB/storeManagerConf/chunkCacheStoreManagerConf.js +11 -0
- package/GUDHUB/DataService/IndexedDB/storeManagerConf/init.js +1 -0
- package/GUDHUB/DataService/export.js +69 -14
- package/GUDHUB/DataService/httpService/AppHttpService.js +13 -5
- package/GUDHUB/DataService/httpService/ChunkHttpService.js +41 -26
- package/GUDHUB/DataService/utils.js +27 -27
- package/GUDHUB/FileManager/FileManager.js +7 -3
- package/GUDHUB/GHConstructor/createAngularModuleInstance.js +63 -42
- package/GUDHUB/GHConstructor/createClassInstance.js +8 -3
- package/GUDHUB/ItemProcessor/ItemProcessor.js +14 -6
- package/GUDHUB/Storage/ModulesList.js +66 -3
- package/GUDHUB/Utils/AppsTemplateService/AppsTemplateService.js +48 -5
- package/GUDHUB/Utils/Utils.js +29 -1
- package/GUDHUB/Utils/filter/filter.js +32 -1
- package/GUDHUB/Utils/get_date/get_date.test.js +3 -12
- package/GUDHUB/Utils/merge_chunks/merge_chunks.js +36 -28
- package/GUDHUB/Utils/merge_chunks/merge_chunks.worker.js +78 -0
- package/GUDHUB/Utils/merge_compare_items/merge_compare_items.js +40 -9
- package/GUDHUB/Utils/nested_list/nested_list.js +53 -50
- package/GUDHUB/Utils/nested_list/nested_list.test.js +140 -2
- package/GUDHUB/WebSocket/WebSocket.js +2 -1
- package/GUDHUB/api/AppApi.js +13 -13
- package/GUDHUB/api/ChunkApi.js +6 -6
- package/GUDHUB/config.js +11 -2
- package/GUDHUB/consts.js +15 -1
- package/GUDHUB/gudhub.js +48 -26
- package/GUDHUB/gudhubAppRequestWorker.js +18 -0
- package/build.sh +127 -0
- package/diff.txt +1221 -0
- package/dist/gudhub.es.js +13455 -0
- package/dist/gudhub.umd.js +197 -0
- package/index.js +3 -1
- package/indexUMD.js +0 -2
- package/package.json +38 -22
- package/umd/library.min.js +285 -2
- package/umd/library.min.js.map +1 -1
- package/vite.config.esm.js +72 -0
- package/vite.config.umd.js +68 -0
- package/GUDHUB/ChunksManager/ChunksManager.js +0 -68
- package/umd/library.min.js.LICENSE.txt +0 -13
- package/webpack.config.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { IS_BROWSER_MAIN_THREAD } from './../consts.js';
|
|
3
3
|
|
|
4
4
|
/*************** FAKE ANGULAR $Q ***************/
|
|
5
5
|
// It's needed when we import angular code.
|
|
@@ -17,13 +17,14 @@ let $q = {
|
|
|
17
17
|
|
|
18
18
|
let factoryReturns = {};
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
// required for building project to single file. Bundlers mangle angular variable, therefore class required for context only. Search it across project for details
|
|
21
|
+
class AngularClass {
|
|
21
22
|
module() {
|
|
22
23
|
return angular;
|
|
23
|
-
}
|
|
24
|
+
}
|
|
24
25
|
directive() {
|
|
25
26
|
return angular;
|
|
26
|
-
}
|
|
27
|
+
}
|
|
27
28
|
factory(name, args) {
|
|
28
29
|
try {
|
|
29
30
|
if (typeof args === 'object') {
|
|
@@ -36,33 +37,37 @@ let angular = {
|
|
|
36
37
|
console.log(error);
|
|
37
38
|
}
|
|
38
39
|
return angular;
|
|
39
|
-
}
|
|
40
|
+
}
|
|
40
41
|
service() {
|
|
41
42
|
return angular;
|
|
42
|
-
}
|
|
43
|
+
}
|
|
43
44
|
run() {
|
|
44
45
|
return angular;
|
|
45
|
-
}
|
|
46
|
+
}
|
|
46
47
|
filter() {
|
|
47
48
|
return angular;
|
|
48
|
-
}
|
|
49
|
+
}
|
|
49
50
|
controller() {
|
|
50
51
|
return angular;
|
|
51
|
-
}
|
|
52
|
+
}
|
|
52
53
|
value() {
|
|
53
54
|
return angular;
|
|
54
|
-
}
|
|
55
|
+
}
|
|
55
56
|
element() {
|
|
56
57
|
return angular;
|
|
57
|
-
}
|
|
58
|
+
}
|
|
58
59
|
injector() {
|
|
59
60
|
return angular;
|
|
60
|
-
}
|
|
61
|
+
}
|
|
61
62
|
invoke() {
|
|
62
63
|
return angular;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
|
|
68
|
+
let angular = new AngularClass();
|
|
69
|
+
|
|
70
|
+
|
|
66
71
|
/*************** CREATE INSTANCE ***************/
|
|
67
72
|
// Here we are importing modules using dynamic import.
|
|
68
73
|
// For browser: just do dynamic import with url as parameter.
|
|
@@ -80,7 +85,9 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
80
85
|
let angularModule;
|
|
81
86
|
let importedClass;
|
|
82
87
|
|
|
83
|
-
if (
|
|
88
|
+
if (
|
|
89
|
+
IS_BROWSER_MAIN_THREAD
|
|
90
|
+
) {
|
|
84
91
|
|
|
85
92
|
if(window.angular) {
|
|
86
93
|
|
|
@@ -125,19 +132,24 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
} else {
|
|
128
|
-
|
|
129
135
|
const proxy = new Proxy(nodeWindow, {
|
|
130
136
|
get: (target, property) => {
|
|
131
|
-
|
|
137
|
+
const value = target[property];
|
|
138
|
+
if (typeof value === 'symbol') {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return value;
|
|
132
142
|
},
|
|
133
143
|
set: (target, property, value) => {
|
|
144
|
+
if (typeof value === 'symbol') {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
134
147
|
target[property] = value;
|
|
135
148
|
global[property] = value;
|
|
136
149
|
return true;
|
|
137
150
|
}
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// If node's global object don't have window and it's methods yet - set it.
|
|
151
|
+
});
|
|
152
|
+
|
|
141
153
|
if (!global.hasOwnProperty('window')) {
|
|
142
154
|
global.window = proxy;
|
|
143
155
|
global.document = nodeWindow.document;
|
|
@@ -153,35 +165,42 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
153
165
|
global.WebSocket = nodeWindow.WebSocket;
|
|
154
166
|
global.crypto = nodeWindow.crypto;
|
|
155
167
|
global.DOMParser = nodeWindow.DOMParser;
|
|
156
|
-
|
|
168
|
+
|
|
157
169
|
global.document.queryCommandSupported = (command) => {
|
|
158
170
|
return false;
|
|
159
|
-
}
|
|
171
|
+
};
|
|
160
172
|
global.angular = angular;
|
|
161
173
|
}
|
|
162
|
-
|
|
163
|
-
// Downloading module's code and
|
|
164
|
-
|
|
165
|
-
let response = await axios.get(module_url);
|
|
166
|
-
let code = response.data;
|
|
167
|
-
let encodedCode = encodeURIComponent(code);
|
|
168
|
-
encodedCode = 'data:text/javascript;charset=utf-8,' + encodedCode;
|
|
169
|
-
|
|
170
|
-
let module;
|
|
171
|
-
|
|
172
|
-
// Then, dynamically import modules from data url.
|
|
173
|
-
|
|
174
|
+
|
|
175
|
+
// Downloading module's code and transforming it to a data URL.
|
|
174
176
|
try {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
let response = await axios.get(module_url);
|
|
178
|
+
let code = response.data;
|
|
179
|
+
|
|
180
|
+
// Ensure code is properly encoded, excluding any symbols
|
|
181
|
+
let encodedCode = encodeURIComponent(code);
|
|
182
|
+
|
|
183
|
+
// Creating a data URL
|
|
184
|
+
encodedCode = 'data:text/javascript;charset=utf-8,' + encodedCode;
|
|
185
|
+
|
|
186
|
+
let module;
|
|
187
|
+
|
|
188
|
+
// Dynamically import the module from the data URL.
|
|
189
|
+
try {
|
|
190
|
+
module = await import(/* webpackIgnore: true */ encodedCode);
|
|
191
|
+
} catch (err) {
|
|
192
|
+
console.log(`Error while importing module: ${module_id}`);
|
|
193
|
+
console.log(err);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (module && module.default) {
|
|
197
|
+
importedClass = new module.default();
|
|
198
|
+
} else {
|
|
199
|
+
console.error(`Module ${module_id} didn't export a default class`);
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error("Error fetching module code:", error);
|
|
179
203
|
}
|
|
180
|
-
|
|
181
|
-
// Modules always exports classes as default, so we create new class instance.
|
|
182
|
-
|
|
183
|
-
importedClass = new module.default();
|
|
184
|
-
|
|
185
204
|
}
|
|
186
205
|
|
|
187
206
|
let result = {
|
|
@@ -290,7 +309,9 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
290
309
|
|
|
291
310
|
// We need these methods in browser environment only
|
|
292
311
|
|
|
293
|
-
if (
|
|
312
|
+
if (
|
|
313
|
+
IS_BROWSER_MAIN_THREAD
|
|
314
|
+
) {
|
|
294
315
|
|
|
295
316
|
//*************** EXTEND CONTROLLER ****************//
|
|
296
317
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { IS_BROWSER, IS_BROWSER_MAIN_THREAD } from './../consts.js';
|
|
3
3
|
|
|
4
4
|
export default async function createClassInstance(gudhub, module_id, js_url, css_url, nodeWindow) {
|
|
5
5
|
|
|
@@ -14,7 +14,9 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
|
|
|
14
14
|
// Import module using dynamic import
|
|
15
15
|
|
|
16
16
|
let downloadModule = (url) => {
|
|
17
|
-
if (
|
|
17
|
+
if (
|
|
18
|
+
!IS_BROWSER_MAIN_THREAD
|
|
19
|
+
) {
|
|
18
20
|
global.window = proxy;
|
|
19
21
|
global.document = nodeWindow.document;
|
|
20
22
|
global.Element = nodeWindow.Element;
|
|
@@ -67,7 +69,10 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
|
|
|
67
69
|
// Check if there is url to css file of module
|
|
68
70
|
// If true, and there is no css for this data type, than create link tag to this css in head
|
|
69
71
|
|
|
70
|
-
if (
|
|
72
|
+
if (
|
|
73
|
+
css_url &&
|
|
74
|
+
IS_BROWSER
|
|
75
|
+
) {
|
|
71
76
|
const linkTag = document.createElement('link');
|
|
72
77
|
linkTag.href = css_url;
|
|
73
78
|
linkTag.setAttribute('data-module', module_id);
|
|
@@ -118,11 +118,10 @@ export class ItemProcessor {
|
|
|
118
118
|
return items;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.
|
|
125
|
-
this.addItemsToStorage(v1.app_id, compareRes.new_src_items);
|
|
121
|
+
handleDiff(id, compare) {
|
|
122
|
+
this.updateItemsInStorage(id, compare.diff_src_items);
|
|
123
|
+
this.addItemsToStorage(id, compare.new_src_items);
|
|
124
|
+
this.deleteItemsFromStorage(id, compare.trash_src_items);
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
async deleteItemsFromStorage(app_id, itemsForDelete = []) {
|
|
@@ -141,7 +140,7 @@ export class ItemProcessor {
|
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
async getItems(app_id, trash = false) {
|
|
144
|
-
const app = await this.appProcessor.getApp(app_id
|
|
143
|
+
const app = await this.appProcessor.getApp(app_id);
|
|
145
144
|
if(!app) return null;
|
|
146
145
|
return app.items_list;
|
|
147
146
|
}
|
|
@@ -172,6 +171,15 @@ export class ItemProcessor {
|
|
|
172
171
|
);
|
|
173
172
|
}
|
|
174
173
|
|
|
174
|
+
async restoreItems(app_id, itemsIds) {
|
|
175
|
+
const preparedItemsList = itemsIds.map((id) => ({
|
|
176
|
+
item_id: id,
|
|
177
|
+
trash: false
|
|
178
|
+
}));
|
|
179
|
+
const updatedItems = await this.updateItemsApi(app_id, preparedItemsList);
|
|
180
|
+
return await this.updateItemsInStorage(app_id, updatedItems);
|
|
181
|
+
}
|
|
182
|
+
|
|
175
183
|
itemListeners() {
|
|
176
184
|
this.pipeService.onRoot("gh_items_get", {}, async (event, data) => {
|
|
177
185
|
if(data && data.app_id) {
|
|
@@ -142,7 +142,7 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
142
142
|
data_type: "calendar",
|
|
143
143
|
name: 'Calendar',
|
|
144
144
|
icon: 'calendar',
|
|
145
|
-
js: 'https://gudhub.com/modules/FullCalendar-Gh-Element/dist/main.js?t=
|
|
145
|
+
js: 'https://gudhub.com/modules/FullCalendar-Gh-Element/dist/main.js?t=6',
|
|
146
146
|
css: 'https://gudhub.com/modules/FullCalendar-Gh-Element/dist/style.css?t=1',
|
|
147
147
|
type: 'gh_element',
|
|
148
148
|
technology: "class"
|
|
@@ -931,7 +931,7 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
931
931
|
data_type: 'study_journal',
|
|
932
932
|
name: 'Study Journal',
|
|
933
933
|
icon: 'timeline',
|
|
934
|
-
js: 'https://gudhub.com/modules/Study-Journal/dist/main.js',
|
|
934
|
+
js: 'https://gudhub.com/modules/Study-Journal/dist/main.js?t=1',
|
|
935
935
|
css: 'https://gudhub.com/modules/Study-Journal/dist/style.css',
|
|
936
936
|
type: 'gh_element',
|
|
937
937
|
technology: 'class'
|
|
@@ -958,11 +958,53 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
958
958
|
data_type: "text_area",
|
|
959
959
|
name: "Text Area",
|
|
960
960
|
icon: "text_icon",
|
|
961
|
-
js: "https://gudhub.com/modules/text-area-ghe/dist/main.js?t=
|
|
961
|
+
js: "https://gudhub.com/modules/text-area-ghe/dist/main.js?t=3",
|
|
962
962
|
css: "https://gudhub.com/modules/text-area-ghe/dist/style.css",
|
|
963
963
|
type: "gh_element",
|
|
964
964
|
technology: "class",
|
|
965
965
|
},
|
|
966
|
+
{
|
|
967
|
+
data_type: "resource_calendar",
|
|
968
|
+
name: "Resource Сalendar",
|
|
969
|
+
icon: "calendar",
|
|
970
|
+
url: file_server_url + '/' + async_modules_path + "resource_calendar_data.js",
|
|
971
|
+
type: 'gh_element',
|
|
972
|
+
technology: 'angular'
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
data_type: "visualizer_with_control_panel",
|
|
976
|
+
name: "Visualizer With Control Panel",
|
|
977
|
+
icon: 'visualizer',
|
|
978
|
+
url: file_server_url + '/' + async_modules_path + "visualizer_with_control_panel_data.js",
|
|
979
|
+
type: 'gh_element',
|
|
980
|
+
technology: 'angular'
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
data_type: "svg_to_pdf",
|
|
984
|
+
name: "SVG To PDF",
|
|
985
|
+
icon: "box",
|
|
986
|
+
js: "https://gudhub.com/modules/SVG-to-PDF-Gh-Element/dist/main.js",
|
|
987
|
+
css: "https://gudhub.com/modules/SVG-to-PDF-Gh-Element/dist/style.css",
|
|
988
|
+
type: "gh_element",
|
|
989
|
+
technology: "class",
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
data_type: "recycle_bin",
|
|
993
|
+
name: "Recycle Bin",
|
|
994
|
+
icon: 'recycle_bin',
|
|
995
|
+
url: file_server_url + '/' + async_modules_path + "recycle_bin_data.js",
|
|
996
|
+
type: 'gh_element',
|
|
997
|
+
technology: "angular",
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
data_type: "assessment_journual",
|
|
1001
|
+
name: "Assessment Journual",
|
|
1002
|
+
icon: "text_icon",
|
|
1003
|
+
js: "https://gudhub.com/modules/Assessment-Journal/dist/main.js",
|
|
1004
|
+
css: "https://gudhub.com/modules/Assessment-Journal/dist/style.css",
|
|
1005
|
+
type: "gh_element",
|
|
1006
|
+
technology: "class",
|
|
1007
|
+
},
|
|
966
1008
|
/* AUTOMATION MODULES */
|
|
967
1009
|
/*
|
|
968
1010
|
We have next types for automations:
|
|
@@ -1340,6 +1382,27 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
1340
1382
|
url: file_server_url + '/' + automation_modules_path + 'turbo_sms.js',
|
|
1341
1383
|
type: 'automation',
|
|
1342
1384
|
icon: 'email'
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
data_type: 'JsCode',
|
|
1388
|
+
name: 'Js Code',
|
|
1389
|
+
url: file_server_url + '/' + automation_modules_path + 'js_code.js',
|
|
1390
|
+
type: 'automation',
|
|
1391
|
+
icon: 'code_editor'
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
data_type: 'AskChatGPT',
|
|
1395
|
+
name: 'Ask ChatGPT',
|
|
1396
|
+
url: file_server_url + '/' + automation_modules_path + 'ask_chat_gpt.js',
|
|
1397
|
+
type: 'automation',
|
|
1398
|
+
icon: 'ask_chat_gpt'
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
data_type: 'TeachChatGPT',
|
|
1402
|
+
name: 'Teach ChatGPT',
|
|
1403
|
+
url: file_server_url + '/' + automation_modules_path + 'teach_chat_gpt.js',
|
|
1404
|
+
type: 'automation',
|
|
1405
|
+
icon: 'teach_chat_gpt'
|
|
1343
1406
|
}
|
|
1344
1407
|
]
|
|
1345
1408
|
}
|
|
@@ -195,6 +195,8 @@ export default class AppsTemplateService {
|
|
|
195
195
|
|
|
196
196
|
documentInstallerHelper(appId, items, elementId) {
|
|
197
197
|
const self = this;
|
|
198
|
+
const itemsWithClonedDocument = [];
|
|
199
|
+
|
|
198
200
|
return new Promise(async (resolve) => {
|
|
199
201
|
for(const item of items) {
|
|
200
202
|
const itemId = item.item_id;
|
|
@@ -216,10 +218,11 @@ export default class AppsTemplateService {
|
|
|
216
218
|
|
|
217
219
|
field.field_value = newDocument._id;
|
|
218
220
|
|
|
221
|
+
itemsWithClonedDocument.push(item);
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
|
-
resolve();
|
|
225
|
+
resolve(itemsWithClonedDocument);
|
|
223
226
|
});
|
|
224
227
|
}
|
|
225
228
|
|
|
@@ -440,7 +443,14 @@ export default class AppsTemplateService {
|
|
|
440
443
|
});
|
|
441
444
|
|
|
442
445
|
self.crawling(app.field_list, function (prop, value, parent) {
|
|
443
|
-
|
|
446
|
+
const fieldProps = ["field_id", "FieldId", "destination_field", "element_id"];
|
|
447
|
+
const appProps = ["app_id", "AppId", "destination_app"];
|
|
448
|
+
const viewProps = ["view_id"];
|
|
449
|
+
const srcProps = ["src"];
|
|
450
|
+
|
|
451
|
+
const hasProp = (prop, propArray) => propArray.some(key => prop.indexOf(key) !== -1);
|
|
452
|
+
|
|
453
|
+
if (hasProp(prop, fieldProps)) {
|
|
444
454
|
let fieldsArr = String(value).split(','), newFieldsArr = [];
|
|
445
455
|
|
|
446
456
|
appsConnectingMap.fields.forEach(field => {
|
|
@@ -456,7 +466,7 @@ export default class AppsTemplateService {
|
|
|
456
466
|
}
|
|
457
467
|
}
|
|
458
468
|
|
|
459
|
-
if (
|
|
469
|
+
if (hasProp(prop, appProps)) {
|
|
460
470
|
appsConnectingMap.apps.forEach(app => {
|
|
461
471
|
if (value == app.old_app_id) {
|
|
462
472
|
parent[prop] = app.new_app_id;
|
|
@@ -464,7 +474,7 @@ export default class AppsTemplateService {
|
|
|
464
474
|
})
|
|
465
475
|
}
|
|
466
476
|
|
|
467
|
-
if (prop
|
|
477
|
+
if (hasProp(prop, viewProps)) {
|
|
468
478
|
appsConnectingMap.views.forEach(view => {
|
|
469
479
|
if (value == view.old_view_id) {
|
|
470
480
|
parent[prop] = view.new_view_id;
|
|
@@ -472,7 +482,7 @@ export default class AppsTemplateService {
|
|
|
472
482
|
})
|
|
473
483
|
}
|
|
474
484
|
|
|
475
|
-
if (prop
|
|
485
|
+
if (hasProp(prop, srcProps) && isFinite(value)) {
|
|
476
486
|
const pron_name = 'container_id';
|
|
477
487
|
const old_app_id = appsConnectingMap.apps.find(appMap => appMap.new_app_id === app.app_id).old_app_id;
|
|
478
488
|
const path = self.findPath(source_apps[old_app_id].views_list, pron_name, value);
|
|
@@ -480,6 +490,39 @@ export default class AppsTemplateService {
|
|
|
480
490
|
parent[prop] = `${self.getValueByPath(app.views_list, path, pron_name)}`;
|
|
481
491
|
}
|
|
482
492
|
|
|
493
|
+
if (prop.indexOf("trigger") !== -1 && value.model && value.model.nodes) {
|
|
494
|
+
const nodes = value.model.nodes;
|
|
495
|
+
const nodeProperties = ["inputs", "outputs"];
|
|
496
|
+
|
|
497
|
+
for (const index in nodes) {
|
|
498
|
+
nodeProperties.forEach((property) => {
|
|
499
|
+
const node = nodes[index];
|
|
500
|
+
const numericProperties = Object.keys(node[property]).filter(prop => prop !== '' && !isNaN(prop)); // field_id as keys
|
|
501
|
+
|
|
502
|
+
numericProperties.forEach((old_field_id) => {
|
|
503
|
+
const correspondFieldOfConnectingMap = appsConnectingMap.fields.filter((field) => field.old_field_id == old_field_id);
|
|
504
|
+
|
|
505
|
+
if (correspondFieldOfConnectingMap.length !== 0 && correspondFieldOfConnectingMap[0].new_field_id) {
|
|
506
|
+
const new_field_id = correspondFieldOfConnectingMap[0].new_field_id.toString();
|
|
507
|
+
|
|
508
|
+
const connectionObjectCopy = node[property][old_field_id];
|
|
509
|
+
connectionObjectCopy.connections.forEach((connection) => {
|
|
510
|
+
if (connection.input == old_field_id) {
|
|
511
|
+
connection.input = new_field_id;
|
|
512
|
+
}
|
|
513
|
+
if (connection.output == old_field_id) {
|
|
514
|
+
connection.output = new_field_id;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
delete node[property][old_field_id];
|
|
519
|
+
|
|
520
|
+
node[property][new_field_id] = connectionObjectCopy;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
}
|
|
483
526
|
})
|
|
484
527
|
})
|
|
485
528
|
|
package/GUDHUB/Utils/Utils.js
CHANGED
|
@@ -24,6 +24,7 @@ import { FileHelper } from "./FIleHelper/FileHelper.js";
|
|
|
24
24
|
import { compareObjects } from "./compareObjects/compareObjects.js";
|
|
25
25
|
import { dynamicPromiseAll } from "./dynamicPromiseAll/dynamicPromiseAll.js";
|
|
26
26
|
import { sortItems } from './filter/sortItems.js';
|
|
27
|
+
import { mergeChunksWorker } from "./merge_chunks/merge_chunks.worker.js";
|
|
27
28
|
|
|
28
29
|
export class Utils {
|
|
29
30
|
constructor(gudhub) {
|
|
@@ -126,6 +127,7 @@ export class Utils {
|
|
|
126
127
|
);
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
//here
|
|
129
131
|
compareItems(sourceItems, destinationItems, fieldToCompare) {
|
|
130
132
|
return compareItems(sourceItems, destinationItems, fieldToCompare);
|
|
131
133
|
}
|
|
@@ -142,8 +144,19 @@ export class Utils {
|
|
|
142
144
|
return makeNestedList(arr, id, parent_id, children_property, priority_property);
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
mergeChunks(chunks) {
|
|
147
|
+
async mergeChunks(chunks) {
|
|
146
148
|
return mergeChunks(chunks);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
// const chunkWorkerBlob = new Blob([mergeChunksWorker()], {
|
|
152
|
+
// type: "application/javascript",
|
|
153
|
+
// });
|
|
154
|
+
// this.worker = new Worker(URL.createObjectURL(chunkWorkerBlob));
|
|
155
|
+
// this.worker.postMessage(chunks);
|
|
156
|
+
// this.worker.addEventListener("message", (event) => {
|
|
157
|
+
// const { diff } = event.data;
|
|
158
|
+
// callback(event.data);
|
|
159
|
+
// });
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
mergeFieldLists(fieldsToView, fieldList) {
|
|
@@ -194,10 +207,25 @@ export class Utils {
|
|
|
194
207
|
return this.AppsTemplateService.createItems(create_apps, maxNumberOfInsstalledItems);
|
|
195
208
|
}
|
|
196
209
|
|
|
210
|
+
areViewListsEqual(list1, list2) {
|
|
211
|
+
let sortedList1 = list1.sort((e1, e2) => e1.view_id - e2.view_id);
|
|
212
|
+
let sortedList2 = list2.sort((e1, e2) => e1.view_id - e2.view_id);
|
|
213
|
+
|
|
214
|
+
return this.compareObjects(sortedList1, sortedList2);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
areFieldListsEqual(list1, list2) {
|
|
218
|
+
let sortedList1 = list1.sort((e1, e2) => e1.field_id - e2.field_id);
|
|
219
|
+
let sortedList2 = list2.sort((e1, e2) => e1.field_id - e2.field_id);
|
|
220
|
+
|
|
221
|
+
return this.compareObjects(sortedList1, sortedList2);
|
|
222
|
+
}
|
|
223
|
+
|
|
197
224
|
compareObjects(obj1, obj2) {
|
|
198
225
|
return compareObjects(obj1, obj2);
|
|
199
226
|
}
|
|
200
227
|
|
|
228
|
+
//
|
|
201
229
|
compareAppsItemsLists(items_list1, items_list2, callback) {
|
|
202
230
|
const chunkWorkerBlob = new Blob([compare_items_lists_Worker()], {
|
|
203
231
|
type: "application/javascript",
|
|
@@ -157,6 +157,24 @@ class Checker {
|
|
|
157
157
|
);
|
|
158
158
|
};
|
|
159
159
|
break;
|
|
160
|
+
|
|
161
|
+
case 'month_before_date':
|
|
162
|
+
this._checkFn = function (data, filtersValues) {
|
|
163
|
+
return filtersValues.some((_filter) =>
|
|
164
|
+
data.some((_dataItem) => {
|
|
165
|
+
const itemDate = new Date(_dataItem);
|
|
166
|
+
const endDate = new Date(_filter);
|
|
167
|
+
const startDate = new Date(endDate);
|
|
168
|
+
|
|
169
|
+
startDate.setMonth(startDate.getMonth() - 1);
|
|
170
|
+
|
|
171
|
+
if (isNaN(itemDate) || isNaN(startDate) || isNaN(endDate)) return false;
|
|
172
|
+
|
|
173
|
+
return itemDate >= startDate && itemDate <= endDate;
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
break;
|
|
160
178
|
}
|
|
161
179
|
return this;
|
|
162
180
|
}
|
|
@@ -232,6 +250,16 @@ class RecurringDateStrategy {
|
|
|
232
250
|
}
|
|
233
251
|
}
|
|
234
252
|
|
|
253
|
+
class MonthBeforeDateStrategy {
|
|
254
|
+
convert(val) {
|
|
255
|
+
return [Number(val)];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
convertFilterValue(val) {
|
|
259
|
+
return Number(val);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
235
263
|
class Aggregate {
|
|
236
264
|
constructor() {
|
|
237
265
|
this._strategies = {
|
|
@@ -240,7 +268,8 @@ class Aggregate {
|
|
|
240
268
|
booleanStrategy: new BooleanFetchStrategy(),
|
|
241
269
|
rangeStrategy: new RangeFetchStrategy(),
|
|
242
270
|
dateStrategy: new dateFetchStrategy(),
|
|
243
|
-
recurringDateStrategy: new RecurringDateStrategy()
|
|
271
|
+
recurringDateStrategy: new RecurringDateStrategy(),
|
|
272
|
+
monthBeforeDate: new MonthBeforeDateStrategy()
|
|
244
273
|
};
|
|
245
274
|
}
|
|
246
275
|
|
|
@@ -276,6 +305,8 @@ class Aggregate {
|
|
|
276
305
|
break;
|
|
277
306
|
case "recurring_date":
|
|
278
307
|
this._currentStrategy = this._strategies.recurringDateStrategy
|
|
308
|
+
case "month_before_date":
|
|
309
|
+
this._currentStrategy = this._strategies.monthBeforeDate
|
|
279
310
|
}
|
|
280
311
|
return this;
|
|
281
312
|
}
|
|
@@ -53,7 +53,7 @@ describe("GET DATE", function () {
|
|
|
53
53
|
day.getDay().should.equal(6);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("CHECK
|
|
56
|
+
it("CHECK RECURRING DATE / today", function() {
|
|
57
57
|
let today = new Date();
|
|
58
58
|
let result = gudhub.checkRecurringDate(today, 'day');
|
|
59
59
|
result.should.equal(true);
|
|
@@ -64,7 +64,7 @@ describe("GET DATE", function () {
|
|
|
64
64
|
result.should.equal(false);
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
it("CHECK
|
|
67
|
+
it("CHECK RECURRING DATE / week", function() {
|
|
68
68
|
let today = new Date();
|
|
69
69
|
let result = gudhub.checkRecurringDate(today, 'week');
|
|
70
70
|
result.should.equal(true);
|
|
@@ -75,16 +75,7 @@ describe("GET DATE", function () {
|
|
|
75
75
|
result.should.equal(false);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
it(
|
|
79
|
-
let day = gudhub.getDate('this_wednesday');
|
|
80
|
-
let dayTwoYearsBefore = subYears(day, 2);
|
|
81
|
-
|
|
82
|
-
// console.log(dayTwoYearsBefore);
|
|
83
|
-
let result = gudhub.checkRecurringDate(dayTwoYearsBefore, 'week');
|
|
84
|
-
result.should.equal(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("CHECK IF DATE IN THIS MONTH", function() {
|
|
78
|
+
it("CHECK RECURRING DATE / month", function() {
|
|
88
79
|
let today = new Date();
|
|
89
80
|
let result = gudhub.checkRecurringDate(today, 'month');
|
|
90
81
|
result.should.equal(true);
|