fix response for tags and show error message
This commit is contained in:
parent
df75a6e5f3
commit
8e2b99c3a9
|
@ -76,11 +76,11 @@ class ApiController extends Controller {
|
|||
try {
|
||||
$this->tagService->updateFileTags($path, $tags);
|
||||
} catch (\OCP\Files\NotFoundException $e) {
|
||||
return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
|
||||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_NOT_FOUND);
|
||||
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
||||
return new DataResponse($e->getMessage(), Http::STATUS_SERVICE_UNAVAILABLE);
|
||||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_SERVICE_UNAVAILABLE);
|
||||
} catch (\Exception $e) {
|
||||
return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
|
||||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
|
|
@ -105,12 +105,12 @@
|
|||
} else {
|
||||
tags.push(OC.TAG_FAVORITE);
|
||||
}
|
||||
toggleStar($actionEl, !isFavorite);
|
||||
|
||||
self.applyFileTags(
|
||||
dir + '/' + fileName,
|
||||
tags
|
||||
).then(function(result) {
|
||||
toggleStar($actionEl, !isFavorite);
|
||||
// response from server should contain updated tags
|
||||
var newTags = result.tags;
|
||||
if (_.isUndefined(newTags)) {
|
||||
|
@ -171,8 +171,13 @@
|
|||
}),
|
||||
dataType: 'json',
|
||||
type: 'POST'
|
||||
}).fail(function() {
|
||||
OC.Notification.showTemporary(t('files', 'An error occurred while trying to update the tags'));
|
||||
}).fail(function(response) {
|
||||
var message = '';
|
||||
// show message if it is available
|
||||
if(response.responseJSON && response.responseJSON.message) {
|
||||
message = ': ' + response.responseJSON.message;
|
||||
}
|
||||
OC.Notification.showTemporary(t('files', 'An error occurred while trying to update the tags') + message);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue