From 2f369b1bdfeb592faab9e2fe27ca27d90ba2b325 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Tue, 10 Aug 2021 15:58:03 +0200 Subject: [PATCH 1/3] Namespace support + support to open more types of processes (and parameters) by default #178 --- README.md | 8 +- config.js | 3 + src/Page.vue | 36 ++----- src/components/DiscoveryToolbar.vue | 22 ++--- src/components/Editor.vue | 12 +-- src/components/IDE.vue | 11 +-- src/components/TextEditor.vue | 4 +- src/components/VisualEditor.vue | 53 +++++++++-- src/components/modals/ExpressionModal.vue | 21 ++--- src/components/modals/ProcessModal.vue | 3 +- src/events.md | 2 +- src/store/editor.js | 47 +++++++-- src/store/files.js | 3 - src/store/index.js | 110 ++++++++++++++++++---- src/store/jobs.js | 2 + src/store/userProcesses.js | 59 +----------- 16 files changed, 230 insertions(+), 166 deletions(-) diff --git a/README.md b/README.md index 1ce6f74d3..728134689 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,12 @@ You can also build the files yourself and deploy them to any web host: You can use some query parameters to set initial state to the Editor. * `server`: Set a openEO back-end to connect to by default, e.g. `https://earthengine.openeo.org` -* `discover`: If you want to skip authentication and just show the capabiltiies of the back-end, simply set to `1` -* `process`: Loads a process from a URL and shows it in the Model Builder. +* `discover`: If you want to skip authentication and just show the capabiltiies of the back-end, simply set to `1`. +* `process`: Loads a process from a URL and shows it in the Model Builder. You can also pass a single process name with an optional namespace to the parameter (format: `process@namespace`) to simply add a single process node for that process by default. +* `namespaces`: Loads a additional process namespaces. Multiple namespaces can be separated by a comma (e.g. `vector,sar`). +* `edit-node` Opens the parameter editor for a single process node on start-up. Must have the `process` parameter being set, otherwise will be ignored. You can set two types of values: + * `1`: If only a single node is being added, opens this node without explicitly naming it. + * Otherwise, the value must correspond to the node identifier without `#` at the beginning. Example: diff --git a/config.js b/config.js index d3fa20bbc..e96103f7b 100644 --- a/config.js +++ b/config.js @@ -34,6 +34,9 @@ export default { 'wmts' ], + // Additional process namespaces to load by default + processNamespaces: [], + // Key is the OIDC provider id, value is the client ID oidcClientIds: {}, diff --git a/src/Page.vue b/src/Page.vue index 9f92441db..da7b497f6 100644 --- a/src/Page.vue +++ b/src/Page.vue @@ -20,8 +20,6 @@ import EventBusMixin from './components/EventBusMixin.vue'; import Utils from './utils'; import ConnectForm from './components/ConnectForm.vue'; import axios from 'axios'; -import { UserProcess } from '@openeo/js-client'; -import { ProcessGraph } from '@openeo/js-processgraphs'; // Making axios available globally for the OpenEO JS client window.axios = axios; @@ -57,6 +55,10 @@ export default { }; }, created() { + this.addProcessNamespacesToRequest(Utils.param('namespaces')); + this.setInitialProcess(Utils.param('process')); + this.setInitialNode(Utils.param('edit-node')); + if (Utils.param('discover')) { this.skipLogin = true; } @@ -100,12 +102,11 @@ export default { ...Utils.mapState(['activeRequests']), ...Utils.mapGetters(['isDiscovered']), ...Utils.mapState('editor', ['hightestModalZIndex']), - ...Utils.mapGetters('userProcesses', {getProcessById: 'getAllById'}) }, methods: { - ...Utils.mapActions(['describeAccount', 'describeCollection']), - ...Utils.mapMutations(['startActiveRequest', 'endActiveRequest']), - ...Utils.mapActions('userProcesses', {readUserProcess: 'read'}), + ...Utils.mapActions(['describeAccount', 'describeCollection', 'loadProcess']), + ...Utils.mapMutations(['startActiveRequest', 'endActiveRequest', 'addProcessNamespacesToRequest']), + ...Utils.mapMutations('editor', ['setInitialProcess', 'setInitialNode']), setTitle(subtitle) { var title = `${this.$config.serviceName} ${this.$config.appName}`; if (subtitle) { @@ -144,26 +145,9 @@ export default { } }, async showProcess(process) { - // Convert process id into process - if (typeof process === 'string') { - process = this.getProcessById(process); - } - - if (!process.native) { - try { - let udp = await this.readUserProcess({data: process}); - process = udp.toJSON(); - } catch(error) { - Utils.exception(this, error, "Load Process Error: " + process.id); - return; - } - } - - if (process instanceof ProcessGraph || process instanceof UserProcess) { - process = process.toJSON(); - } - - this.showModal('ProcessModal', {process}); + this.showModal('ProcessModal', { + process: await this.loadProcess(process) + }); }, showProcessParameter(parameter, udp = true) { this.showModal('ProcessParameterModal', { diff --git a/src/components/DiscoveryToolbar.vue b/src/components/DiscoveryToolbar.vue index 5f41ef894..4e5ffbba9 100644 --- a/src/components/DiscoveryToolbar.vue +++ b/src/components/DiscoveryToolbar.vue @@ -15,11 +15,12 @@ - +