Skip to content

Commit

Permalink
fix: Open Viewer when clicking on photo in folder
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
Signed-off-by: Louis Chemineau <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
Pytal authored and nextcloud-command committed Apr 17, 2024
1 parent edba0d8 commit 746dc6e
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 18 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_AlbumContent_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_AlbumContent_vue.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion lib/Controller/AlbumsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Constants;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
Expand Down Expand Up @@ -109,14 +110,36 @@ private function formatData(iterable $nodes): array {
'mime' => $node->getMimetype(),
'size' => $node->getSize(),
'type' => $node->getType(),
'permissions' => $node->getPermissions(),
'permissions' => $this->formatPermissions($node->getPermissions()),
'hasPreview' => $this->previewManager->isAvailable($node),
];
}

return $result;
}

private function formatPermissions(int $permissions): string {
$strPermissions = '';
if ($permissions) {
if ($permissions & Constants::PERMISSION_CREATE) {
$strPermissions .= 'CK';
}
if ($permissions & Constants::PERMISSION_READ) {
$strPermissions .= 'G';
}
if ($permissions & Constants::PERMISSION_UPDATE) {
$strPermissions .= 'W';
}
if ($permissions & Constants::PERMISSION_DELETE) {
$strPermissions .= 'D';
}
if ($permissions & Constants::PERMISSION_SHARE) {
$strPermissions .= 'R';
}
}
return $strPermissions;
}

private function scanCurrentFolder(Folder $folder, bool $shared): iterable {
$nodes = $folder->getDirectoryListing();

Expand Down
3 changes: 2 additions & 1 deletion src/views/AlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<script>
import { mapActions } from 'vuex'
import { Folder, addNewFileMenuEntry, removeNewFileMenuEntry } from '@nextcloud/files'
import { Folder, addNewFileMenuEntry, removeNewFileMenuEntry, davParsePermissions } from '@nextcloud/files'
import { getCurrentUser } from '@nextcloud/auth'
import { NcActions, NcActionButton, NcButton, NcDialog, NcModal, NcEmptyContent, NcActionSeparator, NcLoadingIcon, isMobile } from '@nextcloud/vue'
import { UploadPicker, getUploader } from '@nextcloud/upload'
Expand Down Expand Up @@ -317,6 +317,7 @@ export default {
...this.album,
owner: getCurrentUser()?.uid ?? '',
source: this.album?.source ?? '',
permissions: davParsePermissions(this.album.permissions),
})
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/views/Folders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<script>
import { mapGetters } from 'vuex'
import { Upload, UploadPicker, getUploader } from '@nextcloud/upload'
import { Folder as NcFolder } from '@nextcloud/files'
import { Folder as NcFolder, davParsePermissions } from '@nextcloud/files'
import { NcEmptyContent } from '@nextcloud/vue'
import VirtualGrid from 'vue-virtual-grid'
Expand Down Expand Up @@ -147,6 +147,7 @@ export default {
return new NcFolder({
...this.folder,
source: decodeURI(this.folder.source),
permissions: davParsePermissions(this.folder.permissions),
})
},
folderContent() {
Expand Down

0 comments on commit 746dc6e

Please sign in to comment.