@processmaker/modeler 1.43.3 → 1.43.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/modeler",
3
- "version": "1.43.3",
3
+ "version": "1.43.5",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve --mode development",
6
6
  "test:unit": "vue-cli-service test:unit",
@@ -1,6 +1,11 @@
1
1
  <template>
2
2
  <div class="customAlert mx-auto mt-2">
3
- <b-alert show dismissible variant="warning">
3
+ <b-alert
4
+ show
5
+ dismissible
6
+ variant="warning"
7
+ @dismissed="onDismiss()"
8
+ >
4
9
  {{ $t("Generation of assets was not able to complete. Try again") }}
5
10
  </b-alert>
6
11
  </div>
@@ -11,6 +16,11 @@ export default {
11
16
  data() {
12
17
  return {};
13
18
  },
19
+ methods: {
20
+ onDismiss() {
21
+ this.$emit('onDismiss');
22
+ },
23
+ },
14
24
  };
15
25
  </script>
16
26
  <style scoped>
@@ -11,7 +11,7 @@
11
11
  <div class="p-0">
12
12
  <button
13
13
  class="h-100 px-3 cancel-btn btn btn-secondary"
14
- @click="onClose()"
14
+ @click="onStop()"
15
15
  >
16
16
  {{ $t("STOP") }}
17
17
  </button>
@@ -34,7 +34,7 @@ export default {
34
34
  };
35
35
  },
36
36
  methods: {
37
- onClose() {
37
+ onStop() {
38
38
  this.$emit('stopAssetGeneration');
39
39
  },
40
40
  },
@@ -25,6 +25,7 @@
25
25
  @clearSelection="clearSelection"
26
26
  :players="filteredPlayers"
27
27
  @action="handleToolbarAction"
28
+ @onGenerateAssets="generateAssets()"
28
29
  />
29
30
  <b-row class="modeler h-100">
30
31
  <b-tooltip
@@ -60,23 +61,25 @@
60
61
  ref="createAssetsCard"
61
62
  v-if="isAiGenerated"
62
63
  @onGenerateAssets="generateAssets()"
63
- @closeCreateAssets="onCloseCreateAssets()"
64
+ @closeCreateAssets="isAiGenerated = false"
64
65
  />
65
66
 
66
67
  <GeneratingAssetsCard
67
68
  ref="generatingAssetsCard"
68
- v-if="generatingAi"
69
+ v-if="loadingAI"
70
+ @stopAssetGeneration="onStopAssetGeneration()"
69
71
  />
70
72
 
71
73
  <AssetsCreatedCard
72
74
  ref="assetsCreatedCard"
73
75
  v-if="assetsCreated"
74
- @closeAssetsCreated="onCloseAssetsCreated()"
76
+ @closeAssetsCreated="assetsCreated = false"
75
77
  />
76
78
 
77
79
  <CreateAssetsFailCard
78
80
  ref="createAssetsFailCard"
79
- v-if="false"
81
+ v-if="assetFail"
82
+ @onDismiss="assetFail = false"
80
83
  />
81
84
 
82
85
  <InspectorButton
@@ -166,7 +169,7 @@
166
169
  />
167
170
 
168
171
  <RailBottom
169
- v-if="!generatingAi"
172
+ v-if="!loadingAI"
170
173
  :nodeTypes="nodeTypes"
171
174
  :paper-manager="paperManager"
172
175
  :graph="graph"
@@ -199,9 +202,7 @@
199
202
  </template>
200
203
 
201
204
  <script>
202
-
203
205
  import Vue from 'vue';
204
-
205
206
  import _ from 'lodash';
206
207
  import { dia } from 'jointjs';
207
208
  import boundaryEventConfig from '../nodes/boundaryEvent';
@@ -387,11 +388,12 @@ export default {
387
388
  currentCursorPosition: 0,
388
389
  previewPanelWidth: 600,
389
390
  isAiGenerated: window.ProcessMaker?.modeler?.isAiGenerated,
390
- generatingAi: false,
391
391
  assetsCreated: false,
392
- // ^ TODO: To be changed depending on microservice response
392
+ assetFail: false,
393
393
  currentNonce: null,
394
394
  promptSessionId: '',
395
+ loadingAI: false,
396
+ cancelledJobs: [],
395
397
  flowTypes: [
396
398
  'processmaker-modeler-sequence-flow',
397
399
  'processmaker-modeler-message-flow',
@@ -1845,7 +1847,7 @@ export default {
1845
1847
 
1846
1848
  let params = {
1847
1849
  server: window.location.host,
1848
- processId: this.processId,
1850
+ processId: window.ProcessMaker?.modeler?.process?.id,
1849
1851
  };
1850
1852
 
1851
1853
  if (this.promptSessionId && this.promptSessionId !== null && this.promptSessionId !== '') {
@@ -1860,9 +1862,8 @@ export default {
1860
1862
  this.promptSessionId = (response.data.promptSessionId);
1861
1863
  localStorage.promptSessionId = (response.data.promptSessionId);
1862
1864
  }).catch((error) => {
1863
- const errorMsg = error.response?.data?.message || error.message;
1864
-
1865
- if (error.response.status === 404) {
1865
+ const errorMsg = error.message;
1866
+ if (error === 404) {
1866
1867
  this.removePromptSessionForUser();
1867
1868
  localStorage.promptSessionId = '';
1868
1869
  this.promptSessionId = '';
@@ -1874,7 +1875,7 @@ export default {
1874
1875
  generateAssets() {
1875
1876
  this.getNonce();
1876
1877
 
1877
- // TODO: Add endpoint to get the promprSessionId
1878
+ this.fetchHistory();
1878
1879
 
1879
1880
  const params = {
1880
1881
  promptSessionId: this.promptSessionId,
@@ -1886,17 +1887,87 @@ export default {
1886
1887
 
1887
1888
  window.ProcessMaker.apiClient.post(url, params)
1888
1889
  .then(() => {
1890
+ // Response
1889
1891
  })
1890
1892
  .catch((error) => {
1891
1893
  const errorMsg = error.response?.data?.message || error.message;
1892
1894
  window.ProcessMaker.alert(errorMsg, 'danger');
1895
+ this.assetFail = true;
1893
1896
  });
1894
1897
  },
1895
- onCloseCreateAssets() {
1896
- this.isAiGenerated = false;
1898
+ highlightTaskArrays(data) {
1899
+ if (data) {
1900
+ this.addAiHighlights(data.tasks);
1901
+ this.addAiHighlights(data.serviceTasks);
1902
+ this.addAiHighlights(data.scriptTasks);
1903
+ }
1897
1904
  },
1898
- onCloseAssetsCreated() {
1899
- this.assetsCreated = false;
1905
+ unhighlightTaskArrays(data) {
1906
+ if (data) {
1907
+ this.removeAiHighlights(data.tasks);
1908
+ this.removeAiHighlights(data.serviceTasks);
1909
+ this.removeAiHighlights(data.scriptTasks);
1910
+ }
1911
+ },
1912
+ addAiHighlights(taskArray) {
1913
+ let self = this;
1914
+ taskArray.forEach(task => {
1915
+ const taskNode = self.getElementByNodeId(task.id);
1916
+ taskNode.component.setAiStatusHighlight(task.status);
1917
+ });
1918
+ },
1919
+ removeAiHighlights(taskArray) {
1920
+ let self = this;
1921
+ taskArray.forEach(task => {
1922
+ const taskNode = self.getElementByNodeId(task.id);
1923
+ taskNode.component.unsetHighlights();
1924
+ });
1925
+ },
1926
+ subscribeToProgress() {
1927
+ const channel = `ProcessMaker.Models.User.${window.ProcessMaker?.modeler?.process?.user_id}`;
1928
+ const streamProgressEvent = '.ProcessMaker\\Package\\PackageAi\\Events\\GenerateArtifactsProgressEvent';
1929
+ window.Echo.private(channel).listen(
1930
+ streamProgressEvent,
1931
+ (response) => {
1932
+ if (response.data.promptSessionId !== this.promptSessionId) {
1933
+ this.unhighlightTaskArrays(response.data);
1934
+ return;
1935
+ }
1936
+
1937
+ if (this.cancelledJobs.some((element) => element === response.data.nonce)) {
1938
+ this.unhighlightTaskArrays(response.data);
1939
+ return;
1940
+ }
1941
+
1942
+ if (response.data) {
1943
+ if (response.data.progress.status === 'running') {
1944
+ this.loadingAI = true;
1945
+ this.highlightTaskArrays(response.data);
1946
+ } else if (response.data.progress.status === 'error') {
1947
+ this.loadingAI = false;
1948
+ window.ProcessMaker.alert(response.data.message, 'danger');
1949
+ // Stop and show error
1950
+ this.assetFail = true;
1951
+ } else {
1952
+ this.setPromptSessions(response.data.promptSessionId);
1953
+ // Successful generation
1954
+ this.assetsCreated = true;
1955
+ this.unhighlightTaskArrays(response.data);
1956
+ this.fetchHistory();
1957
+ setTimeout(() => {
1958
+ this.loadingAI = false;
1959
+ }, 500);
1960
+ }
1961
+ }
1962
+ },
1963
+ );
1964
+ },
1965
+ onStopAssetGeneration() {
1966
+ if (this.currentNonce) {
1967
+ this.cancelledJobs.push(this.currentNonce);
1968
+ localStorage.setItem('cancelledJobs', JSON.stringify(this.cancelledJobs));
1969
+ this.loadingAI = false;
1970
+ }
1900
1971
  },
1901
1972
  },
1902
1973
  created() {
@@ -2092,8 +2163,14 @@ export default {
2092
2163
  if (!localStorage.getItem('promptSessions') || localStorage.getItem('promptSessions') === 'null') {
2093
2164
  localStorage.setItem('promptSessions', JSON.stringify([]));
2094
2165
  }
2166
+ if (!localStorage.getItem('cancelledJobs') || localStorage.getItem('cancelledJobs') === 'null') {
2167
+ this.cancelledJobs = [];
2168
+ } else {
2169
+ this.cancelledJobs = JSON.parse(localStorage.getItem('cancelledJobs'));
2170
+ }
2095
2171
  this.promptSessionId = this.getPromptSessionForUser();
2096
2172
  this.fetchHistory();
2173
+ this.subscribeToProgress();
2097
2174
  },
2098
2175
  };
2099
2176
  </script>
@@ -9,6 +9,7 @@
9
9
  :validation-errors="validationErrors"
10
10
  :warnings="warnings"
11
11
  :players="players"
12
+ v-on="$listeners"
12
13
  >
13
14
  <component
14
15
  :is="component.button"
@@ -7,7 +7,9 @@
7
7
  @openPanel="handleOpenPanel"
8
8
  />
9
9
 
10
- <AiGenerateButton/>
10
+ <AiGenerateButton
11
+ v-on="$listeners"
12
+ />
11
13
 
12
14
  <ValidateButton @openIssue="handleOpenIssue" />
13
15
 
@@ -143,7 +143,29 @@ export default {
143
143
  } else {
144
144
  this.shapeView.unhighlight(this.shapeBody, this.prepareCustomColorHighlighter(color));
145
145
  }
146
-
146
+ },
147
+ setAiStatusHighlight(status) {
148
+ this.shapeView.unhighlight(this.shapeBody, completedHighlighter);
149
+ if (status === 'generated') {
150
+ this.shape.attr('body/fill', COLOR_COMPLETED_FILL);
151
+ this.shapeView.highlight(this.shapeBody, completedHighlighter);
152
+ }
153
+ this.shapeView.unhighlight(this.shapeBody, inProgressHighlighter);
154
+ if (status === 'generating') {
155
+ this.shape.attr('body/fill', COLOR_IN_PROGRESS_FILL);
156
+ this.shapeView.highlight(this.shapeBody, inProgressHighlighter);
157
+ }
158
+ this.shapeView.unhighlight(this.shapeBody, idleHighlighter);
159
+ if (status === 'previously generated') {
160
+ this.shape.attr('body/fill', COLOR_IDLE_FILL);
161
+ this.shapeView.highlight(this.shapeBody, idleHighlighter);
162
+ }
163
+ },
164
+ unsetHighlights() {
165
+ this.shape.attr('body/fill', '#FFFFFF');
166
+ this.shapeView.unhighlight(this.shapeBody, inProgressHighlighter);
167
+ this.shapeView.unhighlight(this.shapeBody, completedHighlighter);
168
+ this.shapeView.unhighlight(this.shapeBody, idleHighlighter);
147
169
  },
148
170
  setShapeHighlightForReadOnly() {
149
171
  if (!this.shapeView) {