1
1
<template >
2
2
<DataTable ref =" table" :data =" data" :columns =" columns" class =" ServicePanel" >
3
3
<template slot="toolbar">
4
- <button title =" Add new service" @click =" createServiceFromScript()" v-show =" supportsCreate" :disabled =" !this.hasProcess" ><i class =" fas fa-plus" ></i > Create</button >
4
+ <button title =" Add new permanently stored web service" @click =" createServiceFromScript()" v-show =" supportsCreate" :disabled =" !this.hasProcess" ><i class =" fas fa-plus" ></i > Create</button >
5
+ <button title =" Quickly show the process on map without storing it permanently" @click =" quickViewServiceFromScript()" v-show =" supportsQuickView" :disabled =" !this.hasProcess" ><i class =" fas fa-map" ></i > Show on Map</button >
5
6
</template >
6
7
<template #actions =" p " >
7
8
<button title =" Details" @click =" serviceInfo(p.row)" v-show =" supportsRead" ><i class =" fas fa-info" ></i ></button >
@@ -69,6 +70,23 @@ export default {
69
70
},
70
71
supportsDebug () {
71
72
return this .supports (' debugService' );
73
+ },
74
+ supportsQuickView () {
75
+ return this .supportsCreate && this .supportsDelete && this .mapService !== null ;
76
+ },
77
+ mapService () {
78
+ for (let key in this .serviceTypes ) {
79
+ if (! Utils .isMapServiceSupported (key)) {
80
+ continue ;
81
+ }
82
+ let service = this .serviceTypes [key];
83
+ let hasRequiredParam = Object .values (service .configuration ).some (param => param .required === true );
84
+ if (hasRequiredParam) {
85
+ continue ;
86
+ }
87
+ return key;
88
+ }
89
+ return null ;
72
90
}
73
91
},
74
92
mounted () {
@@ -185,13 +203,17 @@ export default {
185
203
}
186
204
return data;
187
205
},
188
- async createService (script , data ) {
206
+ async createService (script , data , quiet = false ) {
189
207
data = this .normalizeToDefaultData (data);
190
208
try {
191
209
let service = await this .create ({parameters: [script, data .type , data .title , data .description , data .enabled , data .configuration , data .plan , data .budget ]});
192
- this .serviceCreated (service);
210
+ if (! quiet) {
211
+ this .serviceCreated (service);
212
+ }
213
+ return service;
193
214
} catch (error) {
194
215
Utils .exception (this , error, ' Create Service Error: ' + (data .title || ' ' ));
216
+ return null ;
195
217
}
196
218
},
197
219
createServiceFromScript () {
@@ -206,6 +228,19 @@ export default {
206
228
];
207
229
this .emit (' showDataForm' , " Create new web service" , fields, data => this .createService (this .process , data));
208
230
},
231
+ async quickViewServiceFromScript () {
232
+ try {
233
+ let settings = {
234
+ title: ' Quick view' ,
235
+ type: this .mapService ,
236
+ enabled: true
237
+ };
238
+ let service = await this .createService (this .process , settings, true );
239
+ this .viewService (service, () => this .deleteService (service, true ));
240
+ } catch (error) {
241
+ Utils .exception (this , error, " Show on Map Error" );
242
+ }
243
+ },
209
244
editMetadata (oldService ) {
210
245
this .refreshElement (oldService, service => {
211
246
var fields = [
@@ -243,19 +278,24 @@ export default {
243
278
Utils .exception (this , error, " Update Service Error: " + Utils .getResourceTitle (service));
244
279
}
245
280
},
246
- async deleteService (service ) {
247
- if (! confirm (` Do you really want to delete the service "${ Utils .getResourceTitle (service)} "?` )) {
281
+ async deleteService (service , quiet = false ) {
282
+ if (! quiet && ! confirm (` Do you really want to delete the service "${ Utils .getResourceTitle (service)} "?` )) {
248
283
return ;
249
284
}
250
285
try {
251
286
await this .delete ({data: service});
252
287
this .emit (' removeWebService' , service .id );
253
288
} catch (error) {
254
- Utils .exception (this , error, ' Delete Service Error: ' + Utils .getResourceTitle (service));
289
+ if (quiet) {
290
+ console .error (error);
291
+ }
292
+ else {
293
+ Utils .exception (this , error, ' Delete Service Error: ' + Utils .getResourceTitle (service));
294
+ }
255
295
}
256
296
},
257
- viewService (service ) {
258
- this .emit (' viewWebService' , service);
297
+ viewService (service , onClose = null ) {
298
+ this .emit (' viewWebService' , service, onClose );
259
299
},
260
300
async shareResults (service ) {
261
301
if (this .canShare ) {
0 commit comments