From 7ced9e6feb48565e4058283ab4caea4209fef6e7 Mon Sep 17 00:00:00 2001 From: Niklas Edmundsson Date: Thu, 11 May 2023 13:04:19 +0200 Subject: [PATCH] file-list: Also display unix mode/permissions Users sometimes wants to know the mode (permission) flags of objects without having to show the file details of each individual item. This patch adds the familiar unix ls-style representation to the file listing. In order to closer resemble the familiar/expected style, the common function convertToNameValueObject() is also augmented with an optional parameter that allows displaying the file type instead of ? since the mode bits available doesn't include this information. Fixes: https://github.com/dCache/dcache-view/issues/202 Signed-off-by: Niklas Edmundsson --- .../file-metadata-mapper.html | 4 ++-- .../dv-elements/list-view/list-row.html | 19 +++++++++++++++++-- .../table-header/list-row-header.html | 10 ++++++++-- .../dv-elements/utils/mixins/commons.html | 16 +++++++++++++++- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/elements/dv-elements/file-metadata-dashboard/file-metadata-mapper.html b/src/elements/dv-elements/file-metadata-dashboard/file-metadata-mapper.html index 98cd1a4d..d42c5b27 100644 --- a/src/elements/dv-elements/file-metadata-dashboard/file-metadata-mapper.html +++ b/src/elements/dv-elements/file-metadata-dashboard/file-metadata-mapper.html @@ -310,7 +310,7 @@ } if (metadata.mode) { - metadata.mode = this.convertToUnixPermissions(metadata.mode); + metadata.mode = this.convertToUnixPermissions(metadata.mode, metadata.fileType); } for (const objectKey in metadata) { @@ -477,4 +477,4 @@ } window.customElements.define(FmInnerMapper.is, FmInnerMapper); - \ No newline at end of file + diff --git a/src/elements/dv-elements/list-view/list-row.html b/src/elements/dv-elements/list-view/list-row.html index a67a7ac7..e44a1d52 100644 --- a/src/elements/dv-elements/list-view/list-row.html +++ b/src/elements/dv-elements/list-view/list-row.html @@ -82,6 +82,11 @@ flex: 1 1 auto; max-width: calc(100% - 410px); } + .mode { + width: 12ex; + max-width: 12ex; + min-width: 12ex; + } .ctime, .qos { width: 150px; max-width: 150px; @@ -103,7 +108,7 @@ flex: 1 1 auto; max-width: calc(100% - 50px); } - .ctime, .qos, .size { + .mode, .ctime, .qos, .size { display: none; } } @@ -121,6 +126,7 @@
+
[[fileMode]]
[[creationTime]]
@@ -161,6 +167,10 @@ type: String, computed:'_computeFilePath(parentPath, fileMetaData.fileName)' }, + fileMode: { + type: String, + computed:'_computeFileMode(fileMetaData.mode, fileMetaData.fileType)' + }, qosValue: { type: String, notify: true @@ -279,6 +289,11 @@ `${parentPath}${fileName}`: `${parentPath}/${fileName}`; } + _computeFileMode(mode, type) + { + return this.convertToUnixPermissions(mode, type); + } + _fileCurrentQOSValue(qos) { @@ -362,4 +377,4 @@ } window.customElements.define(ListRow.is, ListRow); - \ No newline at end of file + diff --git a/src/elements/dv-elements/table-header/list-row-header.html b/src/elements/dv-elements/table-header/list-row-header.html index abb55ca1..e3d66dd1 100644 --- a/src/elements/dv-elements/table-header/list-row-header.html +++ b/src/elements/dv-elements/table-header/list-row-header.html @@ -33,6 +33,11 @@ flex: 1 1 auto; max-width: calc(100% - 418px); /*This is weird, I don't know where the 8px is coming from*/ } + .mode { + width: 12ex; + max-width: 12ex; + min-width: 12ex; + } .ctime, .qos { width: 150px; max-width: 150px; @@ -51,7 +56,7 @@ flex: 1 1 auto; max-width: calc(100% - 50px); } - .ctime, .qos, .size { + .mode, .ctime, .qos, .size { display: none; } } @@ -63,6 +68,7 @@
Type
Name
+
Mode
Creation time
File location
Size
@@ -78,4 +84,4 @@ } window.customElements.define(ListRowHeader.is, ListRowHeader); - \ No newline at end of file + diff --git a/src/elements/dv-elements/utils/mixins/commons.html b/src/elements/dv-elements/utils/mixins/commons.html index cd9e153f..de443777 100644 --- a/src/elements/dv-elements/utils/mixins/commons.html +++ b/src/elements/dv-elements/utils/mixins/commons.html @@ -21,7 +21,7 @@ } }; } - convertToUnixPermissions(mode) + convertToUnixPermissions(mode, filetype) { const S_IRUSR = 0o0400; // owner has read permission const S_IWUSR = 0o0200; // owner has write permission @@ -43,6 +43,20 @@ const S_IFIFO = 0o010000; // Named pipe const F_TYPE = 0o170000; + /** + * dCache doesn't have the file type in the mode flags, so + * allow this to be injected separately. + */ + if(filetype === "REGULAR") { + mode |= S_IFREG; + } + else if(filetype === "DIR") { + mode |= S_IFDIR; + } + else if(filetype === "LINK") { + mode |= S_IFLNK; + } + const modeChars = ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-',]; const type = mode & F_TYPE;