Skip to content

Commit

Permalink
Make uploading and downloading JSON processes simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Nov 4, 2024
1 parent 0b5b6c3 commit be63d8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/components/IDE.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<template #file-toolbar>
<button type="button" @click="importProcess" title="Import process from external source"><i class="fas fa-cloud-download-alt"></i></button>
<button type="button" v-show="saveSupported" :disabled="!hasProcess" @click="saveProcess" :title="'Save to ' + contextTitle"><i class="fas fa-save"></i></button>
<button type="button" @click="exportJSON" :disabled="!hasProcess" title="Download as JSON file"><i class="fas fa-file-download"></i></button>
<button type="button" @click="exportCode" :disabled="!hasProcess" title="Export into another programming language"><i class="fas fa-file-export"></i></button>
<button type="button" v-show="validateSupported" :disabled="!hasProcess" @click="validateProcess" title="Validate process on server-side"><i class="fas fa-tasks"></i></button>
</template>
Expand Down Expand Up @@ -55,6 +56,7 @@ import DiscoveryToolbar from './DiscoveryToolbar.vue';
import { ProcessParameter } from '@openeo/js-commons';
import { Job, Service, UserProcess } from '@openeo/js-client';
import { Splitpanes, Pane } from 'splitpanes';
import { OpenEO } from '@openeo/js-client';
export default {
name: 'IDE',
Expand Down Expand Up @@ -186,6 +188,11 @@ export default {
this.broadcast('replaceProcess', this.context, this.process);
},
exportJSON() {
const filename = (this.contextTitle || "openeo-process") + '.json';
OpenEO.Environment.saveToFile(JSON.stringify(this.process, null, 2), filename);
},
async exportCode() {
this.broadcast('showModal', 'ExportCodeModal');
},
Expand Down
3 changes: 0 additions & 3 deletions src/components/modals/ImportProcessModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ export default {
if (!Utils.isObject(data)) {
throw new Error('Process does not contain any data');
}
if (!Utils.hasText(data.id)) {
throw new Error('Process does not contain an id');
}
if (!Utils.isObject(data.process_graph)) {
throw new Error('Process does not contain a process graph');
}
Expand Down

0 comments on commit be63d8f

Please sign in to comment.