Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file-list: Also display unix mode/permissions #293

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -477,4 +477,4 @@
}
window.customElements.define(FmInnerMapper.is, FmInnerMapper);
</script>
</dom-module>
</dom-module>
19 changes: 17 additions & 2 deletions src/elements/dv-elements/list-view/list-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -103,7 +108,7 @@
flex: 1 1 auto;
max-width: calc(100% - 50px);
}
.ctime, .qos, .size {
.mode, .ctime, .qos, .size {
display: none;
}
}
Expand All @@ -121,6 +126,7 @@
<div id="rename" class="none"></div>
</div>
</div>
<div class="cell mode">[[fileMode]]</div>
<div class="cell ctime">[[creationTime]]</div>
<div class="cell qos">
<iron-icon id="qos-transition-icon" class="none" icon="arrow-forward"></iron-icon>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -279,6 +289,11 @@
`${parentPath}${fileName}`: `${parentPath}/${fileName}`;
}

_computeFileMode(mode, type)
{
return this.convertToUnixPermissions(mode, type);
}

_fileCurrentQOSValue(qos)
{

Expand Down Expand Up @@ -362,4 +377,4 @@
}
window.customElements.define(ListRow.is, ListRow);
</script>
</dom-module>
</dom-module>
10 changes: 8 additions & 2 deletions src/elements/dv-elements/table-header/list-row-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,7 +56,7 @@
flex: 1 1 auto;
max-width: calc(100% - 50px);
}
.ctime, .qos, .size {
.mode, .ctime, .qos, .size {
display: none;
}
}
Expand All @@ -63,6 +68,7 @@
<div class="row cell">
<div class="cell file-icon">Type</div>
<div class="cell name">Name</div>
<div class="cell mode">Mode</div>
<div class="cell ctime">Creation time</div>
<div class="cell qos">File location</div>
<div class="cell size">Size</div>
Expand All @@ -78,4 +84,4 @@
}
window.customElements.define(ListRowHeader.is, ListRowHeader);
</script>
</dom-module>
</dom-module>
16 changes: 15 additions & 1 deletion src/elements/dv-elements/utils/mixins/commons.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down