Skip to content

Commit d2ecfa2

Browse files
committed
Quick view mode for web services #277
1 parent 5a93c4c commit d2ecfa2

File tree

4 files changed

+55
-14
lines changed

4 files changed

+55
-14
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@openeo/js-client": "^2.5.1",
4646
"@openeo/js-commons": "^1.4.1",
4747
"@openeo/js-processgraphs": "^1.3.0",
48-
"@openeo/vue-components": "^2.10.1",
48+
"@openeo/vue-components": "^2.10.3",
4949
"ajv": "^6.12.6",
5050
"axios": "^0.24.0",
5151
"chart.js": "^3.7.1",

src/components/ServicePanel.vue

+48-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<DataTable ref="table" :data="data" :columns="columns" class="ServicePanel">
33
<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>
56
</template>
67
<template #actions="p">
78
<button title="Details" @click="serviceInfo(p.row)" v-show="supportsRead"><i class="fas fa-info"></i></button>
@@ -69,6 +70,23 @@ export default {
6970
},
7071
supportsDebug() {
7172
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;
7290
}
7391
},
7492
mounted() {
@@ -185,13 +203,17 @@ export default {
185203
}
186204
return data;
187205
},
188-
async createService(script, data) {
206+
async createService(script, data, quiet = false) {
189207
data = this.normalizeToDefaultData(data);
190208
try {
191209
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;
193214
} catch(error) {
194215
Utils.exception(this, error, 'Create Service Error: ' + (data.title || ''));
216+
return null;
195217
}
196218
},
197219
createServiceFromScript() {
@@ -206,6 +228,19 @@ export default {
206228
];
207229
this.emit('showDataForm', "Create new web service", fields, data => this.createService(this.process, data));
208230
},
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+
},
209244
editMetadata(oldService) {
210245
this.refreshElement(oldService, service => {
211246
var fields = [
@@ -243,19 +278,24 @@ export default {
243278
Utils.exception(this, error, "Update Service Error: " + Utils.getResourceTitle(service));
244279
}
245280
},
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)}"?`)) {
248283
return;
249284
}
250285
try {
251286
await this.delete({data: service});
252287
this.emit('removeWebService', service.id);
253288
} 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+
}
255295
}
256296
},
257-
viewService(service) {
258-
this.emit('viewWebService', service);
297+
viewService(service, onClose = null) {
298+
this.emit('viewWebService', service, onClose);
259299
},
260300
async shareResults(service) {
261301
if (this.canShare) {

src/components/Viewer.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ export default {
109109
let title = Utils.getResourceTitle(collection, true);
110110
this.showMapViewer(service, service.id, title, true);
111111
},
112-
showWebService(service) {
113-
this.showMapViewer(service, service.id, null, true);
112+
showWebService(service, onClose = null) {
113+
this.showMapViewer(service, service.id, null, true, onClose);
114114
},
115115
showLogs(resource, defaultTitle = 'Logs', selectTab = true, faIcon = 'fa-bug') {
116116
let title = Array.isArray(resource) ? defaultTitle : Utils.getResourceTitle(resource, "Logs");
@@ -169,7 +169,7 @@ export default {
169169
this.showViewer(files, title, file => `${job.id}-${file.getUrl()}`, true)
170170
.catch(error => Utils.exception(this, error));
171171
},
172-
showMapViewer(resource, id = null, title = null, reUseExistingTab = false) {
172+
showMapViewer(resource, id = null, title = null, reUseExistingTab = false, onClose = null) {
173173
if (!title) {
174174
title = Utils.getResourceTitle(resource, true);
175175
}
@@ -189,7 +189,8 @@ export default {
189189
this.$refs.tabs.addTab(
190190
title, "fa-map", resource, id, true, true,
191191
tab => this.onShow(tab),
192-
tab => this.onHide(tab)
192+
tab => this.onHide(tab),
193+
onClose
193194
);
194195
},
195196
async showViewer(files, title = null, id = null, reUseExistingTab = false) {

src/events.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Shows the result of a synchronous job.
3131
### viewJobResults(object $jobResult, object $job = null)
3232
Shows data from a job result document.
3333

34-
### viewWebService(object $service)
34+
### viewWebService(object $service, function $onClose = null)
3535
Shows a web service on the map.
3636

3737
### removeWebService(string $id)

0 commit comments

Comments
 (0)