Skip to content

Commit

Permalink
Import from openeo-community-examples correctly and make it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Apr 11, 2023
1 parent 8fb0cf2 commit dfc5e70
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export default {
}
],

// Import processes from openeo-community-examples repo
importCommunityExamples: true,

// Additional process namespaces to load by default
processNamespaces: [],

Expand Down
28 changes: 18 additions & 10 deletions src/components/modals/ImportProcessModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,24 @@ export default {
};
},
async created() {
try {
let response = await axios('https://api.github.com/repos/Open-EO/openeo-community-examples/git/trees/2babd5d10e56f10d0a51569838227e93fdd934c5'); // the hash is the sha for the processes folder, see https://api.github.com/repos/Open-EO/openeo-community-examples/git/trees
this.gh = response.data.tree
.filter(file => file.path.endsWith('.json'))
.map(file => ({
name: file.path.substring(0, file.path.length-5),
url: `https://raw.githubusercontent.com/Open-EO/openeo-community-examples/main/processes/${file.path}`
}));
} catch(error) {
console.warn(error);
if (this.$config.importCommunityExamples) {
try {
// Get folders from repo and find the processes folder
let response = await axios('https://api.github.com/repos/Open-EO/openeo-community-examples/git/trees/main');
let folder = response.data.tree.find(file => file.path === 'processes');
if (folder) {
// Get files in the folder
let response2 = await axios(folder.url);
this.gh = response2.data.tree
.filter(file => file.path.endsWith('.json'))
.map(file => ({
name: file.path.substring(0, file.path.length-5),
url: `https://raw.githubusercontent.com/Open-EO/openeo-community-examples/main/processes/${file.path}`
}));
}
} catch(error) {
console.warn(error);
}
}
},
computed: {
Expand Down

0 comments on commit dfc5e70

Please sign in to comment.