Skip to content

Commit

Permalink
Merge pull request #52 from openzim/fix_offliner_flags
Browse files Browse the repository at this point in the history
Zimfarm endpoint now contains flags as subkey in dictionary
  • Loading branch information
benoit74 authored Apr 8, 2024
2 parents f054dbe + 6a292a7 commit 2de33a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 5 additions & 6 deletions ui/src/components/NewRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
},
computed: {
editorReady() {
return this.form && this.offliner_def !== null; },
return this.form && this.offliner_flags !== null; },
form_fields() {
let fields = [];
for (var i=0;i<this.offliner_def.length;i++) {
let field = this.offliner_def[i];
for (var i=0;i<this.offliner_flags.length;i++) {
let field = this.offliner_flags[i];
let component = "b-form-input";
let options = null;
let component_type = null;
Expand Down Expand Up @@ -195,7 +195,7 @@
},
methods: {
loadRecipeDefinition(force_reload, on_success, on_error) {
if (!force_reload && this.$store.getters.offliner_def.length){
if (!force_reload && this.$store.getters.offliner_flags.length){
if (on_success) { on_success(); }
return;
}
Expand All @@ -205,8 +205,7 @@
parent.toggleLoader("fetching definition…");
parent.queryAPI('get', Constants.zimfarm_webapi + '/offliners/zimit')
.then(function (response) {
let definition = response.data.filter(field => Constants.zimit_fields.indexOf(field.key) > -1);
parent.$store.dispatch('setOfflinerDef', definition);
parent.$store.dispatch('setOfflinerDef', response.data);
if (on_success) { on_success(); }
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
},
computed: {
publicPath() { return process.env.BASE_URL; }, // for static files linking
offliner_def() { return this.$store.getters.offliner_def; }, // offliner def for requests
offliner_flags() { return this.$store.getters.offliner_flags; }, // offliner flags for requests
},
methods: {
toggleLoader(text) { // shortcut to store's loader status changer
Expand Down
9 changes: 8 additions & 1 deletion ui/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import Vue from 'vue'
import Vuex from 'vuex'
import Constants from './constants.js'

Vue.use(Vuex);

Expand All @@ -9,7 +10,7 @@ const store = new Vuex.Store({
loading: false,
loading_text: "",

offliner_def: [],
offliner_def: null,
},
mutations: {
setLoading (state, payload) { // toggle GUI loader
Expand All @@ -31,6 +32,12 @@ const store = new Vuex.Store({
getters: {
loadingStatus(state) { return {should_display: state.loading, text: state.loading_text};},
offliner_def(state) { return state.offliner_def; },
offliner_flags(state) {
if (!state.offliner_def) {
return []
}
return state.offliner_def.flags.filter(field => Constants.zimit_fields.indexOf(field.key) > -1);
},
}
})

Expand Down

0 comments on commit 2de33a5

Please sign in to comment.