diff --git a/config.js b/config.js index 64a548d9..855bd19e 100644 --- a/config.js +++ b/config.js @@ -53,6 +53,7 @@ export default { // List of supported web service sharing services supportedWebServiceSharingServices: [ + 'ShareEditor', 'CopyUrl', 'TwitterShare' ], diff --git a/src/Page.vue b/src/Page.vue index 6c742b58..cebe4aa5 100644 --- a/src/Page.vue +++ b/src/Page.vue @@ -72,10 +72,12 @@ export default { }); this.setCollectionPreview(Utils.param('preview-collection')); - let resultUrl = Utils.param('result'); + const resultUrl = Utils.param('result'); + const resultType = Utils.param('result-type') || 'job'; if (resultUrl) { this.setAppMode({ resultUrl, + resultType, ...Utils.paramsForPrefix('app') }); } diff --git a/src/components/Viewer.vue b/src/components/Viewer.vue index 3a0a9a75..68e205d8 100644 --- a/src/components/Viewer.vue +++ b/src/components/Viewer.vue @@ -48,11 +48,7 @@ export default { this.listen('addToMapChooser', this.addToMapChooser); if (this.appMode) { - this.showJobResults(this.appMode.data, null, this.appMode.title); - if (typeof this.appMode.expires === 'string') { - const expires = Formatters.formatTimestamp(this.appMode.expires); - Utils.info(this, `The shared data is available until ${expires}`); - } + this.showAppMode(); } }, data() { @@ -78,6 +74,25 @@ export default { methods: { ...Utils.mapActions(['describeCollection']), ...Utils.mapMutations('editor', ['setViewerOptions', 'setModelDnD']), + showAppMode() { + if (this.appMode.resultType === 'service') { + console.log(this.appMode); + const service = new Service(this.connection, 'app'); + service.title = this.appMode.title; + service.url = this.appMode.resultUrl; + service.type = this.appMode.service; + service.enabled = true; + console.log(service); + this.showWebService(service); + } + else { + this.showJobResults(this.appMode.data, null, this.appMode.title); + if (typeof this.appMode.expires === 'string') { + const expires = Formatters.formatTimestamp(this.appMode.expires); + Utils.info(this, `The shared data is available until ${expires}`); + } + } + }, isCollectionPreview(data) { return (data instanceof Service && Utils.isObject(data.attributes) && data.attributes.preview === true); }, diff --git a/src/components/share/CopyUrl.vue b/src/components/share/CopyUrl.vue index 90545817..1b1ecb6f 100644 --- a/src/components/share/CopyUrl.vue +++ b/src/components/share/CopyUrl.vue @@ -1,7 +1,7 @@ @@ -24,6 +24,9 @@ export default { }; }, computed: { + name() { + return this.type === 'service' ? 'Web Service' : 'STAC metadata'; + }, description() { if (this.state === 'error') { return 'Copying to clipboard failed'; @@ -32,11 +35,14 @@ export default { return 'Copied to clipboard'; } else { - return 'Copy the public URL of the STAC metadata to your clipboard'; + return `Copy the public URL of the ${this.name} to your clipboard`; } } }, methods: { + updateState(state) { + this.state = state; + }, copy() { return this.$clipboard(this.url); } diff --git a/src/components/share/ShareEditor.vue b/src/components/share/ShareEditor.vue index c335726a..9e942f7b 100644 --- a/src/components/share/ShareEditor.vue +++ b/src/components/share/ShareEditor.vue @@ -43,7 +43,11 @@ export default { editorUrl() { const url = new URL(window.location.href); const query = new URLSearchParams(url.search); + query.set('result-type', this.type); query.set('result', this.url); // Pass canonical link, implies discover = 1 + if (this.type === 'service') { + query.set('app~service', this.context.type); + } url.search = query; return url.toString(); } diff --git a/src/events.md b/src/events.md index bebebc5c..e73340ef 100644 --- a/src/events.md +++ b/src/events.md @@ -15,7 +15,7 @@ Sends the current custom process and inserts it into the currently active editor Shows a list in a modal. ### showWebEditorInfo() -Showa information about the web editor in a modal. +Shows information about the web editor in a modal. ### showCollection(id) Shows collection information in a modal. diff --git a/src/store/editor.js b/src/store/editor.js index 885462f9..fe017226 100644 --- a/src/store/editor.js +++ b/src/store/editor.js @@ -122,14 +122,16 @@ export default { return; } - try { - let response = await axios(cx.state.appMode.resultUrl); - if (Utils.isObject(response.data)) { - cx.commit('setAppModeData', response.data); + if (cx.state.appMode.resultType !== 'service') { + try { + let response = await axios(cx.state.appMode.resultUrl); + if (Utils.isObject(response.data)) { + cx.commit('setAppModeData', response.data); + } + } catch (error) { + console.error(error); + throw new Error("Sorry, the shared data is not available anymore!"); } - } catch (error) { - console.error(error); - throw new Error("Sorry, the shared data is not available anymore!"); } } }, diff --git a/src/store/index.js b/src/store/index.js index d9640163..15b026b0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -244,7 +244,7 @@ export default new Vuex.Store({ } } - // Request batch job result for app mode + // Request results for app mode if (!refresh) { try { await cx.dispatch('editor/loadForAppMode');