Skip to content

Commit

Permalink
Run workflow on caption upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrahn authored and tgloeggl committed May 22, 2024
1 parent 0464898 commit b5162be
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
23 changes: 21 additions & 2 deletions vueapp/common/upload.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class UploadService {
}, Promise.resolve(mediaPackage))
}

async uploadCaptions(files, episode_id, options) {
async uploadCaptions(files, episode_id, workflowId, options) {
this.fixFilenames(files);
let onProgress = options.uploadProgress;
let uploadDone = options.uploadDone;
Expand All @@ -261,14 +261,33 @@ class UploadService {
});
}, Promise.resolve())
.then(() => {
uploadDone();
return this.runWorkflow(episode_id, workflowId)
.then(function ({ data }) {
uploadDone();
})
}).catch(function (error) {
if (error.code === 'ERR_NETWORK') {
onError();
}
});
}

runWorkflow(episode_id, workflowId) {
console.log("hi");
return axios({
url: this.service_url + "/api/workflows",
method: "POST",
data: new URLSearchParams({
event_identifier: episode_id,
workflow_definition_identifier: workflowId
}),
withCredentials: true,
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
})
}

addTrack(data, url_path, track, onProgress, onError) {
var fnOnProgress = function (event) {
onProgress(track, event.loaded, event.total);
Expand Down
38 changes: 34 additions & 4 deletions vueapp/components/Videos/Actions/CaptionUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@
</div>
</fieldset>

<fieldset>
<legend >
{{ $gettext('Workflow') }}
</legend>

<select v-model="selectedWorkflow" required>
<option v-for="workflow in upload_workflows"
v-bind:key="workflow.id"
:value="workflow">
{{ workflow.displayname }}
</option>
</select>
</fieldset>

<ProgressBar v-if="uploadProgress && uploadProgress.flavor == language.flavor" :progress="uploadProgress.progress" />
</div>
</fieldset>
Expand Down Expand Up @@ -136,15 +150,17 @@ export default {
fileUploadError: false,
files: {},
uploadProgress: null,
languages: []
languages: [],
selectedWorkflow: false
}
},
computed: {
...mapGetters({
'config' : 'simple_config_list',
'course_config': 'course_config',
'videoCaptions': 'videoCaptions'
'videoCaptions': 'videoCaptions',
'config' : 'simple_config_list',
}),
uploadButtonClasses() {
Expand All @@ -162,7 +178,20 @@ export default {
if (redirectUrl && this.event.publication.annotation_tool) {
return redirectUrl + action;
}
}
},
defaultWorkflow() {
let wf_id = this.config['workflow_configs'].find(wf_config =>
wf_config['config_id'] == this.config.settings['OPENCAST_DEFAULT_SERVER']
&& wf_config['used_for'] === 'upload'
)['workflow_id'];
return this.config['workflows'].find(wf => wf['id'] == wf_id);
},
upload_workflows() {
return this.config['workflows'].filter(wf => wf['config_id'] == this.config.settings['OPENCAST_DEFAULT_SERVER'] && wf['tag'] === 'upload');
},
},
methods: {
Expand Down Expand Up @@ -252,7 +281,7 @@ export default {
let view = this;
this.uploadService.uploadCaptions(files, this.event.episode, {
this.uploadService.uploadCaptions(files, this.event.episode, this.selectedWorkflow.name, {
uploadProgress: (track, loaded, total) => {
view.uploadProgress = {
flavor: track.flavor,
Expand Down Expand Up @@ -301,6 +330,7 @@ export default {
this.$store.dispatch('authenticateLti');
this.$store.dispatch('simpleConfigListRead').then(() => {
this.selectedServer = this.config['server'][this.config.settings['OPENCAST_DEFAULT_SERVER']];
this.selectedWorkflow = this.defaultWorkflow;
});
this.$store.dispatch('loadCaption', this.event.token);
Expand Down

0 comments on commit b5162be

Please sign in to comment.