g3w-admin-processing 1.2.1b1.dev1__py3-none-any.whl

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.
Files changed (80) hide show
  1. g3w_admin_processing-1.2.1b1.dev1.dist-info/METADATA +258 -0
  2. g3w_admin_processing-1.2.1b1.dev1.dist-info/RECORD +80 -0
  3. g3w_admin_processing-1.2.1b1.dev1.dist-info/WHEEL +5 -0
  4. g3w_admin_processing-1.2.1b1.dev1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_processing-1.2.1b1.dev1.dist-info/top_level.txt +1 -0
  6. qprocessing/__init__.py +7 -0
  7. qprocessing/admin.py +21 -0
  8. qprocessing/api/__init__.py +0 -0
  9. qprocessing/api/permissions.py +41 -0
  10. qprocessing/api/views/__init__.py +4 -0
  11. qprocessing/api/views/actions.py +84 -0
  12. qprocessing/api/views/admin.py +76 -0
  13. qprocessing/api/views/models.py +219 -0
  14. qprocessing/api/views/upload.py +177 -0
  15. qprocessing/apiurls.py +64 -0
  16. qprocessing/apps.py +38 -0
  17. qprocessing/configs.py +131 -0
  18. qprocessing/forms.py +133 -0
  19. qprocessing/migrations/0001_initial.py +24 -0
  20. qprocessing/migrations/0002_auto_20230615_1609.py +23 -0
  21. qprocessing/migrations/0003_qprocessinginputupload.py +32 -0
  22. qprocessing/migrations/0004_auto_20230809_0920.py +26 -0
  23. qprocessing/migrations/0005_alter_qprocessinginputupload_user.py +21 -0
  24. qprocessing/migrations/__init__.py +0 -0
  25. qprocessing/models.py +143 -0
  26. qprocessing/receivers.py +100 -0
  27. qprocessing/sitetrees.py +31 -0
  28. qprocessing/static/qprocessing/js/components/DrawInputVectorFeatures.js +180 -0
  29. qprocessing/static/qprocessing/js/components/InputFieldChooser.js +226 -0
  30. qprocessing/static/qprocessing/js/components/InputPrjRasterLayer.js +135 -0
  31. qprocessing/static/qprocessing/js/components/InputPrjVectorLayer.js +415 -0
  32. qprocessing/static/qprocessing/js/components/ModelPanel.js +496 -0
  33. qprocessing/static/qprocessing/js/components/ModelResults.js +73 -0
  34. qprocessing/static/qprocessing/js/components/OutputFile.js +63 -0
  35. qprocessing/static/qprocessing/js/components/OutputRasterLayer.js +63 -0
  36. qprocessing/static/qprocessing/js/components/OutputVectorLayer.js +115 -0
  37. qprocessing/static/qprocessing/js/components/UploadVectorFile.js +53 -0
  38. qprocessing/static/qprocessing/js/i18n/en.js +33 -0
  39. qprocessing/static/qprocessing/js/i18n/index.js +7 -0
  40. qprocessing/static/qprocessing/js/i18n/it.js +33 -0
  41. qprocessing/static/qprocessing/js/plugin.js +122 -0
  42. qprocessing/tasks.py +136 -0
  43. qprocessing/templates/qprocessing/project_form.html +70 -0
  44. qprocessing/templates/qprocessing/projects_list.html +72 -0
  45. qprocessing/tests/__init__.py +0 -0
  46. qprocessing/tests/base.py +104 -0
  47. qprocessing/tests/data/models/qbuffer.model3 +233 -0
  48. qprocessing/tests/data/models/qintersection.model3 +288 -0
  49. qprocessing/tests/data/models/qpointspolygons.model3 +222 -0
  50. qprocessing/tests/data/models/test.model3 +321 -0
  51. qprocessing/tests/data/models/test_buffer_all_inputs.model3 +269 -0
  52. qprocessing/tests/data/models/test_buffer_layer1.model3 +201 -0
  53. qprocessing/tests/data/project_data/buildings.geojson +15 -0
  54. qprocessing/tests/data/project_data/qprocessing.gpkg +0 -0
  55. qprocessing/tests/data/qprocessing_qprocessing.qgs +2813 -0
  56. qprocessing/tests/data/qprocessing_qprocessing_attachments.zip +0 -0
  57. qprocessing/tests/data/test_qgis_328.qgs +954 -0
  58. qprocessing/tests/data/test_qgis_328_attachments.zip +0 -0
  59. qprocessing/tests/data/upload/fail_shp_to_upload.zip +0 -0
  60. qprocessing/tests/data/upload/linestring_to_upload.geojson +9 -0
  61. qprocessing/tests/data/upload/point_to_upload.geojson +10 -0
  62. qprocessing/tests/data/upload/point_to_upload_espg4326.geojson +10 -0
  63. qprocessing/tests/data/upload/point_to_upload_espg4326.qmd +26 -0
  64. qprocessing/tests/data/upload/polygon_to_upload.geojson +9 -0
  65. qprocessing/tests/data/upload/shp_to_upload.cpg +1 -0
  66. qprocessing/tests/data/upload/shp_to_upload.dbf +0 -0
  67. qprocessing/tests/data/upload/shp_to_upload.prj +1 -0
  68. qprocessing/tests/data/upload/shp_to_upload.qix +0 -0
  69. qprocessing/tests/data/upload/shp_to_upload.shp +0 -0
  70. qprocessing/tests/data/upload/shp_to_upload.shx +0 -0
  71. qprocessing/tests/data/upload/shp_to_upload.zip +0 -0
  72. qprocessing/tests/test_algorithm.py +52 -0
  73. qprocessing/tests/test_api.py +173 -0
  74. qprocessing/tests/test_api_models.py +459 -0
  75. qprocessing/urls.py +33 -0
  76. qprocessing/utils/__init__.py +0 -0
  77. qprocessing/utils/data.py +283 -0
  78. qprocessing/utils/exceptions.py +20 -0
  79. qprocessing/utils/formtypes.py +521 -0
  80. qprocessing/views.py +96 -0
@@ -0,0 +1,496 @@
1
+ import prjvectorlayer_input from '../components/InputPrjVectorLayer.js';
2
+ import prjrasterlayer_input from '../components/InputPrjRasterLayer.js';
3
+ import fieldchooser_input from '../components/InputFieldChooser.js';
4
+ import outputvectorlayer from '../components/OutputVectorLayer.js';
5
+ import outputrasterlayer from '../components/OutputRasterLayer.js';
6
+ import outputfile from '../components/OutputFile.js';
7
+
8
+ const { Panel } = g3wsdk.gui;
9
+ const { formInputsMixins } = g3wsdk.gui.vue.Mixins;
10
+ const { XHR } = g3wsdk.core.utils;
11
+ const { ProjectsRegistry } = g3wsdk.core.project;
12
+ const { TaskService } = g3wsdk.core.task;
13
+ const { GUI } = g3wsdk.gui;
14
+
15
+ export default ({
16
+
17
+ // language=html
18
+ template: /* html */ `
19
+ <div class="qprocessing-model">
20
+
21
+ <section class="qprocessing-model-header">
22
+ <div class="skin-color">{{model.display_name.toUpperCase()}}</div>
23
+ </section>
24
+
25
+ <!-- INPUTS -->
26
+ <section class="qprocessing-model-inputs">
27
+ <div class="title" >INPUTS</div>
28
+ <divider/>
29
+ <form class="form-horizontal g3w-form">
30
+ <div class="box-primary">
31
+ <div class="box-body">
32
+ <component
33
+ v-for = "input in model.inputs"
34
+ :key = "input.name"
35
+ :modelId = "model.id"
36
+ @register-change-input = "registerChangeInputEvent"
37
+ @addinput = "addToValidate"
38
+ @changeinput = "_changeInput(input)"
39
+ :state = "input"
40
+ :is = "input.input.type + '_input'"
41
+ />
42
+ </div>
43
+ </div>
44
+ </form>
45
+
46
+ </section>
47
+
48
+ <!-- OUTPUTS -->
49
+ <section class="qprocessing-model-outputs">
50
+ <div class="title">OUTPUTS</div>
51
+ <divider/>
52
+ <form class="form-horizontal g3w-form">
53
+ <div class="box-primary">
54
+ <div class="box-body">
55
+ <component
56
+ v-for = "output in model.outputs"
57
+ :key = "output.name"
58
+ @add-result-to-model-results = "addResultToModel"
59
+ :state = "output"
60
+ :task = "task"
61
+ :is = "output.input.type + ''"
62
+ />
63
+ </div>
64
+ </div>
65
+ </form>
66
+ </section>
67
+
68
+ <!-- MODEL RESULTS -->
69
+ <section class="qprocessing-model-results">
70
+ <section style="display: flex; justify-content: space-between; align-items: center">
71
+ <div class="title">RESULTS</div>
72
+ <span
73
+ v-disabled = "model.results.length === 0"
74
+ class = "icon skin-color skin-border-color"
75
+ :class = "[ g3wtemplate.getFontClass('list'), {'pulse': newResults}]"
76
+ @click.stop.prevent = "showModelResults">
77
+ </span>
78
+ </section>
79
+ <divider/>
80
+ </section>
81
+
82
+ <!-- FOOTER -->
83
+ <section class="qprocess-model-footer">
84
+ <div>
85
+ <progressbar v-if="state.progress" :progress="state.progress" />
86
+ <bar-loader v-else :loading="state.loading" />
87
+ <button
88
+ class = "btn skin-background-color run"
89
+ @click.stop = "run"
90
+ :disabled = "!valid || state.loading">
91
+ <i :class="g3wtemplate.font['run']"></i>
92
+ </button>
93
+ <div v-if="state.message.show">
94
+ <span
95
+ class ="message"
96
+ :style = "{color: getMessageColor()}"
97
+ v-t-plugin = "'qprocessing.run.messages.'+ state.message.type"
98
+ ></span>
99
+ </div>
100
+ </div>
101
+ </section>
102
+
103
+ </div>
104
+ `,
105
+
106
+ name: "modelPanel",
107
+ mixins: [formInputsMixins],
108
+ components: {
109
+ // inputs
110
+ ...g3wsdk.gui.vue.Inputs.InputsComponents,
111
+ prjvectorlayer_input,
112
+ prjrasterlayer_input,
113
+ prjvectorlayerfeature_input: prjvectorlayer_input,
114
+ fieldchooser_input,
115
+ // outputs
116
+ outputvectorlayer,
117
+ outputrasterlayer,
118
+ outputfile,
119
+ outputhtml: outputfile,
120
+ },
121
+ props: {
122
+ model: {
123
+ required: true
124
+ }
125
+ },
126
+ data(){
127
+ return {
128
+ state: {
129
+ loading: false,
130
+ progress: null,
131
+ message: {
132
+ type: 'success', // error info
133
+ show: false
134
+ }
135
+ },
136
+ tovalidate: [],
137
+ task: null,
138
+ newResults: false, // set true if new results are add to models
139
+ }
140
+ },
141
+ methods: {
142
+ //add model result to results
143
+ addResultToModel(data={}) {
144
+ const {output, result} = data;
145
+ if (undefined !== result) {
146
+ const id = output.name;
147
+ //check if output contain already result
148
+ const findResultOutput = this.model.results.find(result => result.id === id);
149
+ if (findResultOutput) {
150
+ findResultOutput.urls.push(result[output.name])
151
+ } else {
152
+ this.model.results.push({
153
+ id: output.name,
154
+ label: output.label,
155
+ urls: [result[output.name]]
156
+ })
157
+ }
158
+ this.newResults = true; // set new result to true
159
+ }
160
+ },
161
+ //return message color
162
+ getMessageColor() {
163
+ switch(this.state.message.type){
164
+ case 'success':
165
+ return 'green';
166
+ case 'error':
167
+ return 'red';
168
+ }
169
+ },
170
+
171
+ /**
172
+ * Method to register by every inputs change of other input with dependence
173
+ * @param inputName
174
+ * @param handler
175
+ */
176
+ registerChangeInputEvent({inputName, handler}={}) {
177
+
178
+ if (undefined === this.subscribe_change_input[inputName]) {
179
+ this.subscribe_change_input[inputName] = []
180
+ }
181
+
182
+ this.subscribe_change_input[inputName].push(handler)
183
+ },
184
+ /**
185
+ * Method to handle change input
186
+ * @param input
187
+ */
188
+ async _changeInput(input) {
189
+ //need to wait change value dom
190
+ await this.$nextTick();
191
+ if (Array.isArray(this.subscribe_change_input[input.name])) {
192
+ this.subscribe_change_input[input.name].forEach(handler => handler(input.value))
193
+ }
194
+ //call base changeInput method
195
+ this.changeInput(input);
196
+ },
197
+ /**
198
+ * Run model method
199
+ * @returns {Promise<void>}
200
+ */
201
+ async run() {
202
+ this.state.loading = true;
203
+ this.state.message.show = false;
204
+ await this.$nextTick();
205
+ try {
206
+ //Run task
207
+ this.task = await this.runModel({
208
+ model: this.model,
209
+ state: this.state
210
+ });
211
+ this.state.message.type = 'success';
212
+ } catch(err) {
213
+ this.state.message.type = 'error';
214
+ }
215
+
216
+ this.state.loading = false;
217
+ this.state.message.show = true;
218
+ },
219
+
220
+ /**
221
+ * Method to run model
222
+ * @param model
223
+ * @param state
224
+ * @returns {Promise<unknown>}
225
+ */
226
+ runModel({ model, state } = {}) {
227
+ const qprocessing = g3wsdk.core.plugin.PluginsRegistry.getPlugin('qprocessing');
228
+
229
+ return new Promise(async (resolve, reject) => {
230
+ let timeoutprogressintervall;
231
+ /**
232
+ * listener method to handle task request
233
+ * @param task_id
234
+ * @param timeout
235
+ * @param response
236
+ */
237
+ const listener = ({task_id, timeout, response}) => {
238
+ const {progress, status} = response;
239
+ // in case of complete
240
+ if (status === 'complete') {
241
+ //stop current task
242
+ TaskService.stopTask({task_id});
243
+ timeoutprogressintervall = null;
244
+ _handleCompleteModelResponse(response, { resolve, reject })
245
+ } else if (status === 'executing') {
246
+ if (state.progress === null || state.progress === undefined) {
247
+ timeoutprogressintervall = Date.now();
248
+ } else {
249
+ if (progress > state.progress) {
250
+ timeoutprogressintervall = Date.now();
251
+ } else {
252
+ if ((Date.now() - timeoutprogressintervall) > 600000){
253
+ TaskService.stopTask({task_id});
254
+ GUI.showUserMessage({
255
+ type: 'warning',
256
+ message: 'Timeout',
257
+ autoclose: true
258
+ });
259
+ state.progress = null;
260
+ timeoutprogressintervall = null;
261
+ reject({
262
+ timeout: true
263
+ })
264
+ }
265
+ }
266
+ }
267
+ state.progress = progress;
268
+ }
269
+ else {
270
+ const statusError = _handleErrorModelResponse(response, {
271
+ reject,
272
+ });
273
+
274
+ if (statusError) {
275
+ state.progress = null;
276
+ timeoutprogressintervall = null;
277
+
278
+ //stop task
279
+ TaskService.stopTask({task_id});
280
+ }
281
+ }
282
+ };
283
+
284
+ //create inputs parmeters
285
+ const inputs = {};
286
+
287
+ //Loop through input model
288
+ for (const input of model.inputs) {
289
+ if (input.value) {
290
+ if (
291
+ (input.input.type === 'prjvectorlayer') &&
292
+ input.value.startsWith(`__g3w__external__:`)
293
+ ) {
294
+ //extract layer id form input.value
295
+ const [,layerExternalId] = input.value.split(`__g3w__external__:`);
296
+ //get external layer from catalog service
297
+ const {crs, name} = GUI.getService('catalog').getExternalLayers({type: 'vector'}).find(layer => layer.id === layerExternalId);
298
+ //get map ol layer from map
299
+ const OLlayer = GUI.getService('map').getLayerById(layerExternalId);
300
+ //create a geojson file from freatures
301
+ const file = qprocessing.createGeoJSONFile({
302
+ name,
303
+ features: OLlayer.getSource().getFeatures(),
304
+ crs
305
+ });
306
+ //upload file to server
307
+ try {
308
+ const {value} = await qprocessing.uploadFile({
309
+ modelId: model.id,
310
+ inputName: input.name,
311
+ file
312
+ });
313
+ //change input value value from new value
314
+ input.value = value;
315
+ } catch(err) {
316
+ //reject
317
+ reject(err);
318
+ }
319
+ }
320
+ inputs[input.name] = input.value;
321
+ }
322
+ }
323
+
324
+ //create outputs paramter
325
+ const outputs = model.outputs.reduce((accumulator, output) => {
326
+ if (output.value) {
327
+ accumulator[output.name] = output.value;
328
+ }
329
+ return accumulator;
330
+ }, {});
331
+
332
+ const data = {
333
+ inputs,
334
+ outputs,
335
+ }
336
+
337
+ const url = `${qprocessing.config.urls.run}${model.id}/${ProjectsRegistry.getCurrentProject().getId()}/` // url model
338
+
339
+ //Check if configured in async mode
340
+ if (qprocessing.config.async) {
341
+ // start to run Task
342
+ TaskService.runTask({
343
+ url,
344
+ taskUrl: qprocessing.config.urls.taskinfo, // url to ask task is end
345
+ params: {
346
+ data: JSON.stringify(data)
347
+ }, // request params
348
+ method: 'POST',
349
+ listener
350
+ })
351
+ } else { //get result directly
352
+ XHR.post({
353
+ url,
354
+ data: JSON.stringify(data),
355
+ contentType: 'application/json'
356
+ })
357
+ .then((response) => { _handleCompleteModelResponse(response, { resolve, reject }) })
358
+ .catch((response) => {
359
+ response.status = 500;
360
+ _handleErrorModelResponse(response, { reject });
361
+ })
362
+ }
363
+ })
364
+ },
365
+
366
+ /**
367
+ * Show Model results Panel
368
+ */
369
+ async showModelResults() {
370
+ const ModelResults = (await import('./ModelResults.js')).default;
371
+
372
+ new Panel({
373
+ id: `qprocessing-panel-results`,
374
+ title: `${this.model.display_name.toUpperCase()}`,
375
+ internalPanel: new (Vue.extend(ModelResults))({
376
+ propsData: {
377
+ model: this.model,
378
+ }
379
+ }),
380
+ show: true,
381
+ });
382
+ this.newResults = false;
383
+ }
384
+ },
385
+ created() {
386
+ //Object contains subscribers of change parent input
387
+ this.subscribe_change_input = {};
388
+ },
389
+ async mounted() {
390
+ await this.$nextTick();
391
+ //@TODO
392
+ $('.qprocessing-model-inputs input')
393
+ .keypress((event) => {
394
+ if (event.which === 13) {
395
+ event.preventDefault();
396
+ }
397
+ });
398
+ },
399
+ });
400
+
401
+ /**
402
+ * Handel Async or Sync response error
403
+ * @param response
404
+ * @param reject
405
+ * @private
406
+ */
407
+ function _handleErrorModelResponse(response, {
408
+ reject,
409
+ }) {
410
+ const {status, exception} = response;
411
+ let statusError = false;
412
+ let textMessage = false;
413
+ let message;
414
+
415
+ switch(status) {
416
+ case '500':
417
+ case 500:
418
+ message = (
419
+ response.responseJSON ?
420
+ (response.responseJSON.exception || response.responseJSON.error.message) :
421
+ 'server_error'
422
+ );
423
+ textMessage = undefined !== exception;
424
+ statusError = true;
425
+ break;
426
+ case 'error':
427
+ message = exception;
428
+ textMessage = true;
429
+ statusError = true;
430
+ break;
431
+ }
432
+
433
+ // in case of status error
434
+ if (statusError) {
435
+ //show a user message with error
436
+ GUI.showUserMessage({
437
+ type: 'alert',
438
+ message,
439
+ textMessage
440
+ });
441
+
442
+ reject({
443
+ statusError:true,
444
+ timeout: false
445
+ })
446
+ }
447
+
448
+ return statusError;
449
+ }
450
+
451
+ /**
452
+ * TO handle complete task ot sync request model
453
+ * @since v3.7.0
454
+ * @param response server response
455
+ * @param resolve resolve method of a Promise
456
+ * @param reject reject method of a Promise
457
+ * @private
458
+ */
459
+ function _handleCompleteModelResponse(response, {
460
+ resolve,
461
+ reject,
462
+ }) {
463
+ let {result, task_result, data} = response;
464
+ //case sync request model return data instead of task_result
465
+ if (data) {
466
+ task_result = data;
467
+ }
468
+ //in case of task_result null
469
+ if (null === task_result || false === result) {
470
+ reject({});
471
+ } else {
472
+ resolve({result, task_result});
473
+ }
474
+ }
475
+
476
+ document.head.insertAdjacentHTML(
477
+ 'beforeend',
478
+ /* css */`
479
+ <style>
480
+ .qprocessing-model { padding-bottom: 10px; }
481
+ .qprocessing-model-header { font-size: 1.3em; font-weight: bold; }
482
+ .qprocessing-model .title { font-weight: bold; margin-bottom: 5px; }
483
+ .qprocessing-model-results .icon { cursor: pointer; border: 2px solid transparent; margin-bottom: 8px; padding: 3px; border-radius: 5px; }
484
+ .qprocessing-model-results .icon.pulse { transform: scale(1); animation: pulse 2s infinite; }
485
+ .qprocess-model-footer button.run { width: 100%; }
486
+ .qprocessing-model-inputs { margin-bottom: 5px; }
487
+ :is(.qprocessing-model-inputs, .qprocessing-model-outputs) .g3w-form { background-color: transparent !important; }
488
+ .qprocess-model-footer { margin-top: 10px; }
489
+ .qprocess-model-footer .message { font-weight: bold; }
490
+ @keyframes pulse {
491
+ 0% { transform: scale(0.75); }
492
+ 70% { transform: scale(1); }
493
+ 100% { transform: scale(0.75); }
494
+ }
495
+ </style>`,
496
+ );
@@ -0,0 +1,73 @@
1
+ const { ApplicationState } = g3wsdk.core;
2
+
3
+ export default ({
4
+
5
+ // language=html
6
+ template: /* html */ `
7
+ <div class="qprocessing-model-results">
8
+ <div
9
+ v-for = "result in model.results"
10
+ v-if ="result.urls.length"
11
+ :key="result.id"
12
+ >
13
+ <h4 style="font-weight: bold">{{result.label}}</h4>
14
+ <divider/>
15
+ <ul
16
+ class = "treeview-menu menu-items"
17
+ style = "background-color: #2c3b41"
18
+ >
19
+ <li
20
+ v-for = "(url, index) in result.urls" :key="url"
21
+ class = "menu-item"
22
+ style = "display: flex; justify-content: space-between; padding: 5px;"
23
+ >
24
+ <span>{{result.id}}_{{index}}</span>
25
+ <section style="padding: 3px; cursor: pointer; font-weight: bold;">
26
+ <i
27
+ :class = "g3wtemplate.font['download']"
28
+ @click.stop.prevent = "downloadFile(url)"
29
+ ></i>
30
+ <i
31
+ :class = "g3wtemplate.font['trash']"
32
+ style = "color: red"
33
+ @click.stop.prevent = "removeResult(result, index)"
34
+ ></i>
35
+ </section>
36
+ </li>
37
+ </ul>
38
+ </div>
39
+ </div>`,
40
+
41
+ name: "ModelResults",
42
+ props: {
43
+ model: {
44
+ type: Object,
45
+ }
46
+ },
47
+ methods: {
48
+ //@since v3.7.0
49
+ removeResult(result, index) {
50
+ result.urls.splice(index, 1);
51
+ },
52
+ async downloadFile(url) {
53
+ try {
54
+ ApplicationState.download = true;
55
+ const response = url && await fetch(url, {
56
+ headers: { 'Access-Control-Expose-Headers': 'Content-Disposition' }, // get filename from server
57
+ signal: AbortSignal.timeout(60000),
58
+ });
59
+ if (!response?.ok) {
60
+ throw (await response.json()).message;
61
+ }
62
+ const blob = await response.blob();
63
+ Object.assign(document.createElement('a'), {
64
+ href: URL.createObjectURL(blob),
65
+ download: (response.headers.get('content-disposition') || 'filename=g3w_download_file').split('filename=').at(-1).split('filename=').at(-1)
66
+ }).click();
67
+ URL.revokeObjectURL(blob);
68
+ } finally {
69
+ ApplicationState.download = false;
70
+ }
71
+ }
72
+ }
73
+ });
@@ -0,0 +1,63 @@
1
+ export default ({
2
+
3
+ // language=html
4
+ template: /* html */ `
5
+ <div
6
+ class = "form-group"
7
+ v-t-tooltip:top.create = "state.description"
8
+ >
9
+ <label
10
+ style = "color:#fff !important;"
11
+ :for = "state.name"
12
+ class = "col-sm-12"
13
+ >{{state.label}}</label>
14
+ <div class="col-sm-12">
15
+ <select
16
+ :id = "state.name"
17
+ v-select2 = "'type'"
18
+ ref = "select2"
19
+ class = "form-control qprocessing-output-vectorlayer-select"
20
+ >
21
+ <option
22
+ v-for = "({key, value}) in state.input.options.values"
23
+ :key = "key"
24
+ :value = "value"
25
+ >{{key}}</option>
26
+ </select>
27
+ </div>
28
+ </div>`,
29
+
30
+ name: "OutputFile",
31
+ props: {
32
+ state: {
33
+ type: Object,
34
+ required: true
35
+ },
36
+ task: {
37
+ required: true
38
+ }
39
+ },
40
+ data() {
41
+ this.state.value = this.state.input.options.values[0].value;
42
+ return {
43
+ type: this.state.value,
44
+ }
45
+ },
46
+ methods: {
47
+ changeSelect(value) {
48
+ this.state.value = value;
49
+ }
50
+ },
51
+ watch: {
52
+ type(value) {
53
+ this.changeSelect(value)
54
+ },
55
+ async task(response={}) {
56
+ const {task_result={}} = response;
57
+ this.$emit('add-result-to-model-results', {
58
+ output: this.state,
59
+ result: task_result
60
+ })
61
+ }
62
+ },
63
+ });
@@ -0,0 +1,63 @@
1
+ export default ({
2
+
3
+ // language=html
4
+ template: /* html */ `
5
+ <div
6
+ class = "form-group"
7
+ v-t-tooltip:top.create = "state.description"
8
+ >
9
+ <label
10
+ style = "color:#fff !important;"
11
+ :for = "state.name"
12
+ class = "col-sm-12"
13
+ >{{state.label}}</label>
14
+ <div class="col-sm-12">
15
+ <select
16
+ :id = "state.name"
17
+ v-select2 = "'type'"
18
+ ref = "select2"
19
+ class = "form-control qprocessing-output-vectorlayer-select"
20
+ >
21
+ <option
22
+ v-for = "({key, value}) in state.input.options.values"
23
+ :key = "key"
24
+ :value = "value"
25
+ >{{key}}</option>
26
+ </select>
27
+ </div>
28
+ </div>`,
29
+
30
+ name: "OutputRasterLayer",
31
+ props: {
32
+ state: {
33
+ type: Object,
34
+ required: true
35
+ },
36
+ task: {
37
+ required: true
38
+ }
39
+ },
40
+ data() {
41
+ this.state.value = this.state.input.options.values[0].value;
42
+ return {
43
+ type: this.state.value,
44
+ }
45
+ },
46
+ methods: {
47
+ changeSelect(value) {
48
+ this.state.value = value;
49
+ }
50
+ },
51
+ watch: {
52
+ type(value){
53
+ this.changeSelect(value);
54
+ },
55
+ async task(response={}){
56
+ const {task_result={}} = response;
57
+ const fileUrl = task_result[this.state.name];
58
+ this.$emit('add-result-to-model-results', {
59
+ url: fileUrl
60
+ })
61
+ }
62
+ },
63
+ });