feat(explorer): save user's view setting to server / optionally share view setting via share link (#2232)

This commit is contained in:
Aaron Liu
2025-06-05 10:00:37 +08:00
parent c13b7365b0
commit 522fcca6af
31 changed files with 704 additions and 158 deletions

View File

@@ -209,6 +209,8 @@ type FileClient interface {
Update(ctx context.Context, file *ent.File) (*ent.File, error)
// ListEntities lists entities
ListEntities(ctx context.Context, args *ListEntityParameters) (*ListEntityResult, error)
// UpdateProps updates props of a file
UpdateProps(ctx context.Context, file *ent.File, props *types.FileProps) (*ent.File, error)
}
func NewFileClient(client *ent.Client, dbType conf.DBType, hasher hashid.Encoder) FileClient {
@@ -275,6 +277,17 @@ func (f *fileClient) Update(ctx context.Context, file *ent.File) (*ent.File, err
return q.Save(ctx)
}
func (f *fileClient) UpdateProps(ctx context.Context, file *ent.File, props *types.FileProps) (*ent.File, error) {
file, err := f.client.File.UpdateOne(file).
SetProps(props).
Save(ctx)
if err != nil {
return nil, err
}
return file, nil
}
func (f *fileClient) CountByTimeRange(ctx context.Context, start, end *time.Time) (int, error) {
if start == nil || end == nil {
return f.client.File.Query().Count(ctx)
@@ -554,6 +567,10 @@ func (f *fileClient) Copy(ctx context.Context, files []*ent.File, dstMap map[int
stm.SetPrimaryEntity(file.PrimaryEntity)
}
if file.Props != nil && dstMap[file.FileChildren][0].OwnerID == file.OwnerID {
stm.SetProps(file.Props)
}
return stm
})