filemanager: show owner

This commit is contained in:
Johannes Zellner
2023-04-17 17:07:25 +02:00
parent 066dbb79b7
commit a8d2e6634f
2 changed files with 18 additions and 16 deletions

View File

@@ -2,6 +2,8 @@
import superagent from 'superagent';
import { sanitize } from 'pankow/utils';
const BASE_URL = import.meta.env.BASE_URL || '/';
export function createDirectoryModel(origin, accessToken, api) {
return {
@@ -21,12 +23,23 @@ export function createDirectoryModel(origin, accessToken, api) {
// this prepares the entries to be compatible with all components
result.body.entries.forEach(item => {
item.id = item.fileName;
item.name = item.fileName;
item.folderPath = path;
item.modified = new Date(item.mtime);
item.type = item.isDirectory ? 'directory' : 'file',
item.icon = `${BASE_URL}mime-types/${item.mimeType === 'inode/symlink' ? 'none' : item.mimeType.split('/').join('-')}.svg`;
// if we have an image, attach previewUrl
if (item.mimeType.indexOf('image/') === 0) {
item.previewUrl = `${origin}/api/v1/${api}/files/${encodeURIComponent(path + '/' + item.fileName)}?access_token=${accessToken}`;
}
item.folderPath = path;
item.owner = 'unkown';
if (item.uid === 0) item.owner = 'root';
if (item.uid === 33) item.owner = 'www-data';
if (item.uid === 1000) item.owner = 'cloudron';
if (item.uid === 1001) item.owner = 'git';
});
return result.body.entries;