From: Dan Brown Date: Sat, 19 May 2018 17:44:40 +0000 (+0100) Subject: Started work on revisions in image manager X-Git-Tag: v0.22.0~1^2~5^2~6 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/refs/pull/837/head?ds=inline Started work on revisions in image manager --- diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index b156a8425..bf7f3bb82 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -257,6 +257,18 @@ class ImageController extends Controller return response()->json($pageSearch); } + /** + * Get the revisions for an image. + * @param $id + * @return \Illuminate\Http\JsonResponse + */ + public function getRevisions($id) + { + $image = $this->imageRepo->getById($id); + $revisions = $image->revisions()->orderBy('id', 'desc')->get(); + return response()->json($revisions); + } + /** * Deletes an image and all thumbnail/image files * @param int $id diff --git a/app/Repos/ImageRepo.php b/app/Repos/ImageRepo.php index eff856872..384ea5454 100644 --- a/app/Repos/ImageRepo.php +++ b/app/Repos/ImageRepo.php @@ -201,7 +201,7 @@ class ImageRepo * @throws \BookStack\Exceptions\ImageUploadException * @throws \Exception */ - private function loadThumbs(Image $image) + protected function loadThumbs(Image $image) { $image->thumbs = [ 'gallery' => $this->getThumbnail($image, 150, 150), diff --git a/resources/assets/js/vues/image-manager.js b/resources/assets/js/vues/image-manager.js index bef666192..2a11a6ff2 100644 --- a/resources/assets/js/vues/image-manager.js +++ b/resources/assets/js/vues/image-manager.js @@ -24,6 +24,9 @@ const data = { searching: false, searchTerm: '', + revisions: [], + selectedRevision: null, + imageUpdateSuccess: false, imageDeleteSuccess: false, deleteConfirm: false, @@ -110,6 +113,8 @@ const methods = { let currentTime = Date.now(); let timeDiff = currentTime - previousClickTime; let isDblClick = timeDiff < dblClickTime && image.id === previousClickImage; + this.revisions = []; + this.selectedRevision = null if (isDblClick) { this.callbackAndHide(image); @@ -117,6 +122,11 @@ const methods = { this.selectedImage = image; this.deleteConfirm = false; this.dependantPages = false; + if (this.imageType === 'drawio') { + this.$http.get(window.baseUrl(`/images/revisions/${image.id}`)).then(resp => { + this.revisions = resp.data; + }) + } } previousClickTime = currentTime; @@ -172,6 +182,11 @@ const methods = { this.images.unshift(event.data); this.$events.emit('success', trans('components.image_upload_success')); }, + + selectRevision(revision) { + let rev = (this.selectedRevision === revision) ? null : revision; + this.selectedRevision = rev; + } }; const computed = { diff --git a/resources/assets/sass/_components.scss b/resources/assets/sass/_components.scss index 27dcfda64..76150fe44 100644 --- a/resources/assets/sass/_components.scss +++ b/resources/assets/sass/_components.scss @@ -221,10 +221,19 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { } img { max-width: 100%; - max-height: 200px; + max-height: 180px; display: block; margin: 0 auto $-m auto; - box-shadow: $bs-light; + box-shadow: 0 1px 21px 1px rgba(76, 76, 76, 0.3); + } + .image-manager-viewer { + height: 196px; + display: flex; + align-items: center; + justify-content: center; + a { + display: inline-block; + } } .dropzone-container { border-bottom: 1px solid #DDD; diff --git a/resources/views/components/image-manager.blade.php b/resources/views/components/image-manager.blade.php index 45b30697b..92a69c05d 100644 --- a/resources/views/components/image-manager.blade.php +++ b/resources/views/components/image-manager.blade.php @@ -47,10 +47,17 @@
-
-
+
+ + + +
+ + + @@ -60,7 +67,7 @@
-
+
@@ -84,6 +91,28 @@
+ {{--Revisions View--}} +
+
+
Revisions
+ + + + + +
+ + (Current) + + +
+ +
+

+ No revisions found +

+
+
diff --git a/routes/web.php b/routes/web.php index 40b00c75d..254da9cd4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -98,6 +98,7 @@ Route::group(['middleware' => 'auth'], function () { Route::post('/drawing/upload', 'ImageController@uploadDrawing'); Route::put('/drawing/upload/{id}', 'ImageController@updateDrawing'); Route::get('/usage/{id}', 'ImageController@usage'); + Route::get('/revisions/{id}', 'ImageController@getRevisions'); Route::post('/{type}/upload', 'ImageController@uploadByType'); Route::get('/{type}/all', 'ImageController@getAllByType'); Route::get('/{type}/all/{page}', 'ImageController@getAllByType');