Display proper file upload errors

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-25 17:54:28 +02:00
parent 63ac985f15
commit b4ead5a2eb
3 changed files with 19 additions and 10 deletions

View File

@@ -911,14 +911,11 @@ input.input-inline {
}
}
#card-attachments {
ul {
margin: 5px;
}
.details {
font-size: 8pt;
padding-left: 15px;
.card-attachments {
.error {
padding-left: 38px;
margin-bottom: 5px;
background-position: 10px;
}
}

View File

@@ -30,13 +30,17 @@ export default class FileService {
this.cardservice = CardService;
this.uploader.onAfterAddingFile = this.onAfterAddingFile.bind(this);
this.uploader.onSuccessItem = this.onSuccessItem.bind(this);
this.uploader.onErrorItem = this.onErrorItem.bind(this);
this.status = null;
}
runUpload (fileItem, attachmentId) {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment');
this.status = null;
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment?type=deck_file');
if (typeof attachmentId !== 'undefined') {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId);
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId + '?type=deck_file');
} else {
fileItem.formData = [
{
@@ -95,6 +99,13 @@ export default class FileService {
this.cardservice.get(item.cardId).attachments.push(response);
}
onErrorItem (item, response) {
this.status = {
error: t('deck', `Failed to upload:`) + ' ' + item.file.name,
message: response.message
};
}
}
app.service('FileService', FileService);

View File

@@ -104,6 +104,7 @@
</div>
</div>
<div class="section-content card-attachments">
<div class="error icon-error" ng-if="fileservice.status"><strong>{{ fileservice.status.error }}</strong><br />{{ fileservice.status.message }}</div>
<attachment-list-component ng-if="params.tab === 1 && cardservice.getCurrent() && isArray(cardservice.getCurrent().attachments)" attachments="cardservice.getCurrent().attachments"></attachment-list-component>
</div>