Browse Source

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

Refs https://github.com/1Panel-dev/1Panel/issues/2066
pull/2196/head
zhengkunwang 1 year ago committed by GitHub
parent
commit
e509fb0571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      backend/utils/files/fileinfo.go
  2. 2
      frontend/src/api/interface/file.ts
  3. 8
      frontend/src/views/host/file-management/index.vue

7
backend/utils/files/fileinfo.go

@ -10,6 +10,7 @@ import (
"os/exec"
"path"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
@ -23,6 +24,8 @@ type FileInfo struct {
Name string `json:"name"`
User string `json:"user"`
Group string `json:"group"`
Uid string `json:"uid"`
Gid string `json:"gid"`
Extension string `json:"extension"`
Content string `json:"content"`
Size int64 `json:"size"`
@ -77,6 +80,8 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
IsHidden: IsHidden(op.Path),
Mode: fmt.Sprintf("%04o", info.Mode().Perm()),
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),
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()),
User: GetUsername(df.Sys().(*syscall.Stat_t).Uid),
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 {

2
frontend/src/api/interface/file.ts

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

8
frontend/src/views/host/file-management/index.vue

@ -128,12 +128,16 @@
</el-table-column>
<el-table-column :label="$t('commons.table.user')" prop="user" show-overflow-tooltip>
<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>
</el-table-column>
<el-table-column :label="$t('file.group')" prop="group">
<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>
</el-table-column>
<el-table-column :label="$t('file.size')" prop="size" max-width="50">

Loading…
Cancel
Save