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 {
|
try {
|
||||||
$this->tagService->updateFileTags($path, $tags);
|
$this->tagService->updateFileTags($path, $tags);
|
||||||
} catch (\OCP\Files\NotFoundException $e) {
|
} 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) {
|
} 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) {
|
} 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;
|
$result['tags'] = $tags;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,12 +105,12 @@
|
||||||
} else {
|
} else {
|
||||||
tags.push(OC.TAG_FAVORITE);
|
tags.push(OC.TAG_FAVORITE);
|
||||||
}
|
}
|
||||||
|
toggleStar($actionEl, !isFavorite);
|
||||||
|
|
||||||
self.applyFileTags(
|
self.applyFileTags(
|
||||||
dir + '/' + fileName,
|
dir + '/' + fileName,
|
||||||
tags
|
tags
|
||||||
).then(function(result) {
|
).then(function(result) {
|
||||||
toggleStar($actionEl, !isFavorite);
|
|
||||||
// response from server should contain updated tags
|
// response from server should contain updated tags
|
||||||
var newTags = result.tags;
|
var newTags = result.tags;
|
||||||
if (_.isUndefined(newTags)) {
|
if (_.isUndefined(newTags)) {
|
||||||
|
@ -171,8 +171,13 @@
|
||||||
}),
|
}),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
}).fail(function() {
|
}).fail(function(response) {
|
||||||
OC.Notification.showTemporary(t('files', 'An error occurred while trying to update the tags'));
|
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