Skip to content

Commit

Permalink
Show default workflow config after server creation + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrahn committed Nov 3, 2023
1 parent 3e2314b commit c6dc43c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 29 deletions.
56 changes: 43 additions & 13 deletions vueapp/components/Config/EditServer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
@updateValue="updateValue" />
</fieldset>

<WorkflowOptions v-if="id != 'new'"/>
<WorkflowOptions :disabled="currentId === 'new'" ref="workflow-form"/>
</form>

<MessageList :float="true"/>
<Error :float="true"/>
</template>

<template v-slot:dialogButtons>
<button v-if="config !== null"
<button v-if="currentId !== 'new'"
class="button trash"
type="button"
@click="deleteConfig"
Expand Down Expand Up @@ -86,7 +86,8 @@ export default {
data() {
return {
currentConfig: {},
disabled: false
disabled: false,
newId: null
}
},
Expand All @@ -96,6 +97,10 @@ export default {
simple_config_list: 'simple_config_list'
}),
currentId() {
return this.newId ? this.newId : this.id;
},
settings() {
return [
{
Expand Down Expand Up @@ -171,7 +176,7 @@ export default {
this.currentConfig.checked = false;
if (this.id == 'new') {
if (this.currentId == 'new') {
this.$store.dispatch('configCreate', this.currentConfig)
.then(({ data }) => {
this.disabled = false;
Expand All @@ -193,10 +198,10 @@ export default {
deleteConfig() {
if (confirm(this.$gettext('Sind Sie sicher, dass Sie die Serverkonfiguration löschen möchten? Die damit verbundenen Videos werden danach nicht mehr in Stud.IP zur Verfügung stehen!'))) {
if (this.id == 'new') {
if (this.currentId == 'new') {
this.currentConfig = {}
} else {
this.$store.dispatch('configDelete', this.id)
this.$store.dispatch('configDelete', this.currentId)
.then(() => {
this.$store.dispatch('configListRead');
this.$store.dispatch('addMessage', {
Expand All @@ -221,22 +226,47 @@ export default {
return;
}
else if (data.message.type === 'success') {
// Check if LTI connection is available
let lti_checked = false;
this.checkLti(data.lti).then((result) => {
lti_checked = result;
});
this.$store.dispatch('addMessage', {
type: data.message.type,
text: data.message.text
});
if (this.currentId !== 'new') {
// Just show success message if server was edited
this.$store.dispatch('addMessage', {
type: data.message.type,
text: data.message.text
});
}
else {
// On create, scroll to the default workflow configuration
this.$store.dispatch('addMessage', {
type: data.message.type,
text: data.message.text + ' Sie können nun die Standardworkflows einstellen oder die Konfiguration abschließen.'
});
this.newId = data.config.id;
this.$store.dispatch('simpleConfigListRead');
let view = this;
// We need to wait for a short time so the component is actually visible
setTimeout(() => {
view.$refs['workflow-form'].$el.scrollIntoView({
behavior: 'smooth'
});
}, 10);
}
if (!lti_checked) {
// Show LTI error
this.postLtiCheckFailedMessage();
}
else {
else if (this.currentId !== 'new') {
// Only close dialog, if lti successfull and no new server was created
this.$emit('close');
}
return;
}
}
Expand Down Expand Up @@ -292,9 +322,9 @@ export default {
mounted() {
this.$store.dispatch('clearMessages');
if (this.id !== 'new') {
if (this.currentId !== 'new') {
if (!this.config) {
this.$store.dispatch('configRead', this.id)
this.$store.dispatch('configRead', this.currentId)
.then(() => {
this.currentConfig = this.configStore;
});
Expand Down
33 changes: 19 additions & 14 deletions vueapp/components/Config/ServerCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export default {
return {
isShow: false,
checkFailed: false,
interval: null,
interval_counter: 0,
error_msg: this.$gettext('Überprüfung der LTI Verbindung fehlgeschlagen! '
+ 'Kontrollieren Sie die eingetragenen Daten und stellen Sie sicher, '
+ 'dass Cross-Origin Aufrufe von dieser Domain aus möglich sind! '
Expand All @@ -86,7 +88,7 @@ export default {
showEditServer() {
this.isShow = true;
if (!this.errors.find((e) => e === this.error_msg)) {
if (this.checkFailed && !this.errors.find((e) => e === this.error_msg)) {
this.$store.dispatch('errorCommit', this.error_msg);
}
},
Expand All @@ -100,20 +102,23 @@ export default {
let view = this;
// periodically check, if lti is authenticated
view.interval = setInterval(async () => {
await view.$store.dispatch('checkLTIAuthentication', {id: view.config.id, name: view.config.service_url});
// Make sure error is removed when authenticated
if (view.isLTIAuthenticated[view.config.id]) {
view.$store.dispatch('errorRemove', this.error_msg);
clearInterval(view.interval);
} else {
view.checkFailed = true;
}
view.interval = setInterval(() => {
view.$store.dispatch('checkLTIAuthentication', {id: view.config.id, name: view.config.service_url})
.then(() => {
// Make sure error is removed when authenticated
if (view.isLTIAuthenticated[view.config.id]) {
view.$store.dispatch('errorRemove', this.error_msg);
view.checkFailed = false;
clearInterval(view.interval);
} else {
view.checkFailed = true;
}
view.interval_counter++;
if (view.interval_counter > 10) {
clearInterval(view.interval);
}
view.interval_counter++;
if (view.interval_counter > 10) {
clearInterval(view.interval);
}
});
}, 2000);
}
},
Expand Down
8 changes: 6 additions & 2 deletions vueapp/components/Config/WorkflowOptions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="oc--admin--section">
<fieldset class="collapsable">
<fieldset class="collapsable" v-if="!disabled">
<legend>
{{ $gettext('Standardworkflows') }}
</legend>
Expand Down Expand Up @@ -34,8 +34,12 @@ export default {
I18NText
},
props: {
disabled: true
},
computed: {
...mapGetters(['config', 'simple_config_list']),
...mapGetters(['simple_config_list']),
workflow_definitions() {
let wf_defs = [];
Expand Down
11 changes: 11 additions & 0 deletions vueapp/store/error.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const actions = {
context.commit('errorsAdd', error);
},

errorRemove(context, error) {
context.commit('errorsRemove', error);
},

errorClear(context) {
context.commit('errorsClear');
}
Expand All @@ -23,6 +27,13 @@ const mutations = {
state.errors.push(data);
},

errorsRemove(state, data) {
let idx = state.errors.indexOf(data);
if (idx !== -1) {
state.errors.splice(idx, 1);
}
},

errorsClear(state) {
state.errors = [];
}
Expand Down

0 comments on commit c6dc43c

Please sign in to comment.