20
20
type =" radio"
21
21
value =" presenter"
22
22
v-model =" selectedSource"
23
- :disabled =" !hasPresenterVideo || downloadInProgress "
23
+ :disabled =" !hasPresenterVideo"
24
24
/>
25
25
{{ $gettext('Aufzeichnung der vortragenden Person') }}</label
26
26
>
29
29
type =" radio"
30
30
value =" presentation"
31
31
v-model =" selectedSource"
32
- :disabled =" !hasPresentationVideo || downloadInProgress "
32
+ :disabled =" !hasPresentationVideo"
33
33
/>
34
34
{{ $gettext('Aufzeichnung des Bildschirms') }}</label
35
35
>
36
36
<label >
37
37
{{ $gettext('Videoqualität') }}
38
- <select v-model =" selectedMedia" :disabled = " downloadInProgress " >
38
+ <select v-model =" selectedMedia" >
39
39
<template v-if =" selectedSource === ' presenter' " >
40
- <option v-for =" (media, index) in tuned_presenters " :key =" index" :value =" media" >
40
+ <option v-for =" (media, index) in presenters " :key =" index" :value =" media" >
41
41
{{ getMediaText(media) }}
42
42
</option >
43
43
</template >
44
44
<template v-else >
45
45
<option
46
- v-for =" (media, index) in tuned_presentations "
46
+ v-for =" (media, index) in presentations "
47
47
:key =" index"
48
48
:value =" media"
49
49
>
53
53
</select >
54
54
</label >
55
55
</form >
56
- <template v-if =" downloadInProgress " >
57
- <span >{{ $gettext('Video wird heruntergeladen') }}</span >
58
- <ProgressBar :progress =" selectedMedia.progress" />
59
- </template >
60
56
</div >
61
57
<div class =" oc--download-messages" >
62
58
<MessageList :float =" true" :dialog =" true" />
72
68
>
73
69
{{ $gettext('Link kopieren') }}
74
70
</button >
75
- <button v-if = " !downloadInProgress " class = " button " @click = " downloadFile() " >
71
+ <a :href = " downloadUrl " :download = " selectedFileName " class = " button " >
76
72
{{ $gettext('Herunterladen') }}
77
- </button >
78
- <button v-else class =" button" @click =" abortDownload()" >
79
- {{ $gettext('Herunterladen abbrechen') }}
80
- </button >
73
+ </a >
81
74
</template >
82
75
</StudipDialog >
83
76
</div >
@@ -112,26 +105,6 @@ export default {
112
105
},
113
106
114
107
computed: {
115
- tuned_presentations () {
116
- let tuned = this .presentations .map ((media ) => {
117
- media .loading = false ;
118
- media .download_controller = new AbortController ();
119
- media .progress = 0 ;
120
- return media;
121
- });
122
- return tuned;
123
- },
124
-
125
- tuned_presenters () {
126
- let tuned = this .presenters .map ((media ) => {
127
- media .loading = false ;
128
- media .download_controller = new AbortController ();
129
- media .progress = 0 ;
130
- return media;
131
- });
132
- return tuned;
133
- },
134
-
135
108
hasPresenterVideo () {
136
109
return this .presenters .length > 0 ;
137
110
},
@@ -140,90 +113,24 @@ export default {
140
113
return this .presentations .length > 0 ;
141
114
},
142
115
143
- downloadInProgress () {
144
- return this .selectedMedia ? .loading ;
116
+ selectedMediaIndex () {
117
+ return this .selectedMedia ? .size ;
145
118
},
146
- },
147
119
148
- methods: {
149
- abortDownload () {
150
- if (this .downloadInProgress ) {
151
- this .selectedMedia .download_controller .abort ();
152
- this .selectedMedia .progress = 0 ;
153
- this .selectedMedia .loading = false ;
154
- }
155
- },
156
- async downloadFile () {
157
- const index = this .selectedMedia ? .size ;
158
- const type = this .selectedSource ;
159
- if (this .selectedMedia ? .loading === true ) {
160
- return ;
161
- }
162
- this .$store .dispatch (' clearMessages' , true );
163
- let view = this ;
164
-
165
- let url = window .OpencastPlugin .REDIRECT_URL + ' /download/' + this .event .token + ' /' + type + ' /' + index;
166
- this .selectedMedia .loading = true ;
167
- this .selectedMedia .progress = 0 ;
168
-
169
- let dummy_download_link = null ;
170
-
171
- axios
172
- .get (url, {
173
- responseType: ' blob' ,
174
- signal: this .selectedMedia .download_controller .signal ,
175
- onDownloadProgress : (progressEvent ) => {
176
- let percentage = Math .round ((progressEvent .loaded * 100 ) / index);
177
- if (percentage > 100 ) {
178
- percentage = 100 ;
179
- }
180
- this .selectedMedia .progress = percentage;
181
- },
182
- })
183
- .then ((response ) => {
184
- const blob = new Blob ([response .data ]);
185
- dummy_download_link = document .createElement (' a' );
186
- dummy_download_link .href = URL .createObjectURL (blob);
187
- dummy_download_link .download = this .getFileName (this .selectedMedia );
188
- dummy_download_link .click ();
189
- view .$store .dispatch (' addMessage' , {
190
- type: ' success' ,
191
- text: this .$gettext (' Herunterladen des Mediums abgeschlossen.' ),
192
- dialog: true ,
193
- });
194
- })
195
- .catch ((err ) => {
196
- let message = {
197
- type: ' error' ,
198
- text: this .$gettext (' Herunterladen des Mediums fehlgeschlagen!' ),
199
- dialog: true ,
200
- };
201
- if (axios .isCancel (err)) {
202
- message .type = ' warning' ;
203
- message .text = this .$gettext (' Herunterladen des Mediums abgebrochen!' );
204
- }
205
- view .$store .dispatch (' addMessage' , message);
206
- })
207
- .finally (() => {
208
- this .resetMediaDownloadProps ();
209
- if (dummy_download_link) {
210
- URL .revokeObjectURL (dummy_download_link .href );
211
- dummy_download_link .remove ();
212
- dummy_download_link = null ;
213
- }
214
- });
120
+ downloadUrl () {
121
+ return window .OpencastPlugin .REDIRECT_URL + ' /download/' + this .event .token + ' /' + this .selectedSource + ' /' + this .selectedMediaIndex ;
215
122
},
216
123
217
- resetMediaDownloadProps () {
218
- this .selectedMedia .loading = false ;
219
- this .selectedMedia .download_controller = new AbortController ();
220
- this .selectedMedia .progress = 0 ;
221
- },
124
+ selectedFileName () {
125
+ return this .getFileName (this .selectedMedia );
126
+ }
127
+ },
222
128
129
+ methods: {
223
130
getFileName (media ) {
224
- let res = media .info ;
131
+ let res = media? .info || ' ' ;
225
132
res = res .replace (' * ' , ' x ' ).replace (/ \s + / g , ' ' );
226
- let ext = media .url .split (' .' ).pop ();
133
+ let ext = media? .url .split (' .' ).pop () || ' ' ;
227
134
return this .event .title + ' (' + res + ' ).' + ext;
228
135
},
229
136
@@ -285,19 +192,19 @@ export default {
285
192
this .extractDownloads ();
286
193
if (this .hasPresenterVideo ) {
287
194
this .selectedSource = ' presenter' ;
288
- this .selectedMedia = this .tuned_presenters [0 ];
195
+ this .selectedMedia = this .presenters [0 ];
289
196
} else {
290
197
this .selectedSource = ' presentation' ;
291
- this .selectedMedia = this .tuned_presentations [0 ];
198
+ this .selectedMedia = this .presentations [0 ];
292
199
}
293
200
},
294
201
watch: {
295
202
selectedSource (newSource ) {
296
203
if (newSource === ' presenter' ) {
297
- this .selectedMedia = this .tuned_presenters [0 ];
204
+ this .selectedMedia = this .presenters [0 ];
298
205
}
299
206
if (newSource === ' presentation' ) {
300
- this .selectedMedia = this .tuned_presentations [0 ];
207
+ this .selectedMedia = this .presentations [0 ];
301
208
}
302
209
}
303
210
}
0 commit comments