diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-01-26 11:27:51 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-02-02 11:17:54 +0100 |
commit | 8e2b99c3a964d5eef174c068919ce7a941266cf1 (patch) | |
tree | 60e0ee29defb7be74d702138db842de976ea623e /apps/files | |
parent | df75a6e5f37d4dbd1fe6abc0cdfb27037ffd1c99 (diff) | |
download | nextcloud-server-8e2b99c3a964d5eef174c068919ce7a941266cf1.tar.gz nextcloud-server-8e2b99c3a964d5eef174c068919ce7a941266cf1.zip |
fix response for tags and show error message
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/controller/apicontroller.php | 6 | ||||
-rw-r--r-- | apps/files/js/tagsplugin.js | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php index a8bea27e4bb..1bb07010a27 100644 --- a/apps/files/controller/apicontroller.php +++ b/apps/files/controller/apicontroller.php @@ -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; } diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index b00aacfba57..b81f1ec5756 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -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); }); } }; |