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]>
  • Loading branch information
Pytal authored and backportbot[bot] committed Apr 17, 2024
1 parent ef73396 commit a39ec7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
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 @@ -315,6 +315,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 a39ec7b

Please sign in to comment.