1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

feat:文件列表增加 uid 和 gid 显示 (#2192)

Refs https://github.com/1Panel-dev/1Panel/issues/2066
This commit is contained in:
zhengkunwang 2023-09-05 18:34:11 +08:00 committed by GitHub
parent e6522ded62
commit e509fb0571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import (
"os/exec" "os/exec"
"path" "path"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"syscall" "syscall"
"time" "time"
@ -23,6 +24,8 @@ type FileInfo struct {
Name string `json:"name"` Name string `json:"name"`
User string `json:"user"` User string `json:"user"`
Group string `json:"group"` Group string `json:"group"`
Uid string `json:"uid"`
Gid string `json:"gid"`
Extension string `json:"extension"` Extension string `json:"extension"`
Content string `json:"content"` Content string `json:"content"`
Size int64 `json:"size"` Size int64 `json:"size"`
@ -77,6 +80,8 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
IsHidden: IsHidden(op.Path), IsHidden: IsHidden(op.Path),
Mode: fmt.Sprintf("%04o", info.Mode().Perm()), Mode: fmt.Sprintf("%04o", info.Mode().Perm()),
User: GetUsername(info.Sys().(*syscall.Stat_t).Uid), User: GetUsername(info.Sys().(*syscall.Stat_t).Uid),
Uid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Uid), 10),
Gid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Gid), 10),
Group: GetGroup(info.Sys().(*syscall.Stat_t).Gid), Group: GetGroup(info.Sys().(*syscall.Stat_t).Gid),
MimeType: GetMimeType(op.Path), MimeType: GetMimeType(op.Path),
} }
@ -208,6 +213,8 @@ func (f *FileInfo) listChildren(dir, showHidden, containSub bool, search string,
Mode: fmt.Sprintf("%04o", df.Mode().Perm()), Mode: fmt.Sprintf("%04o", df.Mode().Perm()),
User: GetUsername(df.Sys().(*syscall.Stat_t).Uid), User: GetUsername(df.Sys().(*syscall.Stat_t).Uid),
Group: GetGroup(df.Sys().(*syscall.Stat_t).Gid), Group: GetGroup(df.Sys().(*syscall.Stat_t).Gid),
Uid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Uid), 10),
Gid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Gid), 10),
} }
if isSymlink { if isSymlink {

View File

@ -5,6 +5,8 @@ export namespace File {
name: string; name: string;
user: string; user: string;
group: string; group: string;
uid: number;
gid: number;
content: string; content: string;
size: number; size: number;
isDir: boolean; isDir: boolean;

View File

@ -128,12 +128,16 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.table.user')" prop="user" show-overflow-tooltip> <el-table-column :label="$t('commons.table.user')" prop="user" show-overflow-tooltip>
<template #default="{ row }"> <template #default="{ row }">
<el-link :underline="false" @click="openChown(row)" type="primary">{{ row.user }}</el-link> <el-link :underline="false" @click="openChown(row)" type="primary">
{{ row.user ? row.user : '-' }} ({{ row.uid }})
</el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('file.group')" prop="group"> <el-table-column :label="$t('file.group')" prop="group">
<template #default="{ row }"> <template #default="{ row }">
<el-link :underline="false" @click="openChown(row)" type="primary">{{ row.group }}</el-link> <el-link :underline="false" @click="openChown(row)" type="primary">
{{ row.group ? row.group : '-' }} ({{ row.gid }})
</el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('file.size')" prop="size" max-width="50"> <el-table-column :label="$t('file.size')" prop="size" max-width="50">