Skip to content

Commit

Permalink
chore: move endpoint config to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Nov 9, 2023
1 parent 509f234 commit d9b15b1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 49 deletions.
21 changes: 21 additions & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ export default {
},
},
},
processingEndpoints: [
{
id: "eoepca-staging-spaceapplications",
title: "Space Application Services",
auth: {
url: "https://auth.eoepca-staging.spaceapplications.com/realms/master/protocol/openid-connect/token",
params: {
scope: "openid user_name",
grant_type: "password",
username: "<user>",
password: "<pass>",
client_id: "<client>",
},
},
root: "https://eoepca-staging.spaceapplications.com/ades",
},
{
id: "terradue",
title: "Terradue",
},
],
},

// Target: https://go.nuxtjs.dev/config-target
Expand Down
7 changes: 2 additions & 5 deletions pages/new-process.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<v-stepper-content step="3">
<v-autocomplete
v-model="selectedEndpoint"
:items="processingEndpoints"
:items="$config.processingEndpoints"
item-text="title"
return-object
outlined
Expand Down Expand Up @@ -169,7 +169,7 @@
</template>

<script>
import { mapState, mapActions } from "vuex";
import { mapActions } from "vuex";
export default {
data: () => ({
Expand All @@ -190,9 +190,6 @@ export default {
title: "New process",
};
},
computed: {
...mapState("processing", ["processingEndpoints"]),
},
watch: {
selectedProcess(newProcess) {
this.getProcessDetails(newProcess);
Expand Down
13 changes: 5 additions & 8 deletions pages/processing-status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
color="primary"
plain
small
:href="`${processingEndpoints[0].root}${item.statusLink}`"
:href="`${$config.processingEndpoints[0].root}${item.statusLink}`"
target="_blank"
class="px-0"
>
Expand All @@ -64,7 +64,9 @@
target="_blank"
class="px-0"
@click="
fetchItem(`${processingEndpoints[0].root}${item.resultLink}`)
fetchItem(
`${$config.processingEndpoints[0].root}${item.resultLink}`
)
"
>
<v-icon small left> mdi-cloud-download-outline </v-icon>
Expand All @@ -84,8 +86,6 @@
</template>

<script>
import { mapState } from "vuex";
export default {
data: () => ({
jobs: null,
Expand Down Expand Up @@ -124,13 +124,10 @@ export default {
},
],
}),
computed: {
...mapState("processing", ["processingEndpoints"]),
},
async created() {
try {
const response = await this.$processingBackend.$get(
`/${this.processingEndpoints[0].id}/jobs`
`/${this.$config.processingEndpoints[0].id}/jobs`
);
this.jobs = response.jobs
.map((job) => ({
Expand Down
21 changes: 8 additions & 13 deletions plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default function (
staticBaseToReplace,
dynamicEndpoint,
backendEndpoint,
processingEndpoints,
},
store,
},
inject
) {
Expand Down Expand Up @@ -60,22 +60,17 @@ export default function (
return;
}
try {
const currentParams =
store.state.processing.processingEndpoints[0].auth.params;
const currentParams = processingEndpoints[0].auth.params;
const params = new URLSearchParams();
Object.keys(currentParams).forEach((param) => {
params.append(param, currentParams[param]);
});
const auth = await $axios.post(
store.state.processing.processingEndpoints[0].auth.url,
params,
{
headers: {
"Cache-Control": "no-cache",
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
const auth = await $axios.post(processingEndpoints[0].auth.url, params, {
headers: {
"Cache-Control": "no-cache",
"Content-Type": "application/x-www-form-urlencoded",
},
});
processingBackend.setHeader("Accept", "application/json");
processingBackend.setHeader("Content-Type", "application/json");
processingBackend.setHeader("X-User-Id", auth.data.id_token);
Expand Down
23 changes: 0 additions & 23 deletions store/processing.js

This file was deleted.

0 comments on commit d9b15b1

Please sign in to comment.