feat(fe): enable preferences in fe client and state
This commit is contained in:
parent
1f6fa6d370
commit
5ff6988e0d
8 changed files with 48 additions and 16 deletions
|
@ -14,8 +14,15 @@ export interface Quota {
|
|||
downloadSpeedLimit: number;
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
bgURL: string;
|
||||
export interface BgConfig {
|
||||
url: string;
|
||||
repeat: string;
|
||||
position: string;
|
||||
align: string;
|
||||
}
|
||||
|
||||
export interface Preferences {
|
||||
bg: BgConfig;
|
||||
cssURL: string;
|
||||
lanPackURL: string;
|
||||
}
|
||||
|
@ -26,7 +33,7 @@ export interface User {
|
|||
role: string;
|
||||
quota: Quota;
|
||||
usedSpace: string;
|
||||
settings: Settings;
|
||||
preferences: Preferences | undefined;
|
||||
}
|
||||
|
||||
export interface ListUsersResp {
|
||||
|
@ -74,16 +81,10 @@ export interface ListSharingsResp {
|
|||
export interface ClientConfigMsg {
|
||||
clientCfg: ClientConfig;
|
||||
}
|
||||
|
||||
export interface ClientConfig {
|
||||
siteName: string;
|
||||
siteDesc: string;
|
||||
bg: {
|
||||
url: string;
|
||||
repeat: string;
|
||||
position: string;
|
||||
align: string;
|
||||
};
|
||||
bg: BgConfig;
|
||||
}
|
||||
|
||||
export interface IUsersClient {
|
||||
|
|
|
@ -81,6 +81,16 @@ export const resps = {
|
|||
uploadSpeedLimit: 3,
|
||||
downloadSpeedLimit: 3,
|
||||
},
|
||||
preferences: {
|
||||
bg: {
|
||||
url: "bgUrl",
|
||||
repeat: "bgRepeat",
|
||||
position: "bgPosition",
|
||||
align: "bgAlign",
|
||||
},
|
||||
cssURL: "cssURL",
|
||||
lanPackURL: "lanPackURL",
|
||||
},
|
||||
},
|
||||
},
|
||||
getCaptchaIDMockResp: {
|
||||
|
|
|
@ -6,7 +6,10 @@ import { initUploadMgr } from "../../worker/upload_mgr";
|
|||
import { User, UploadInfo } from "../../client";
|
||||
import { MockFilesClient, resps as filesResps } from "../../client/files_mock";
|
||||
import { MockUsersClient, resps as usersResps } from "../../client/users_mock";
|
||||
import { MockSettingsClient, resps as settingsResps } from "../../client/settings_mock";
|
||||
import {
|
||||
MockSettingsClient,
|
||||
resps as settingsResps,
|
||||
} from "../../client/settings_mock";
|
||||
import { ICoreState, newState } from "../core_state";
|
||||
import { MockWorker, UploadState, UploadEntry } from "../../worker/interface";
|
||||
|
||||
|
@ -115,6 +118,16 @@ describe("State Manager", () => {
|
|||
uploadSpeedLimit: 0,
|
||||
downloadSpeedLimit: 0,
|
||||
},
|
||||
preferences: {
|
||||
bg: {
|
||||
url: "bgUrl",
|
||||
repeat: "bgRepeat",
|
||||
position: "bgPosition",
|
||||
align: "bgAlign",
|
||||
},
|
||||
cssURL: "cssURL",
|
||||
lanPackURL: "lanPackURL",
|
||||
},
|
||||
},
|
||||
};
|
||||
const mockIsAuthedResp = { status: 401, statusText: "", data: {} };
|
||||
|
|
|
@ -24,6 +24,8 @@ export interface UIProps {
|
|||
position: string;
|
||||
align: string;
|
||||
};
|
||||
cssURL: string;
|
||||
lanPackURL: string;
|
||||
}
|
||||
export interface ICoreState {
|
||||
browser: BrowserProps;
|
||||
|
@ -87,6 +89,8 @@ export function initState(): ICoreState {
|
|||
position: "",
|
||||
align: "",
|
||||
},
|
||||
cssURL: "",
|
||||
lanPackURL: "",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -400,6 +400,7 @@ export class AdminPane extends React.Component<Props, State, {}> {
|
|||
role: this.state.newUserRole,
|
||||
quota: undefined,
|
||||
usedSpace: "0",
|
||||
preferences: undefined,
|
||||
})
|
||||
.then((ok: boolean) => {
|
||||
if (!ok) {
|
||||
|
|
|
@ -387,6 +387,9 @@ export class Updater {
|
|||
this.props.login.userRole = resp.data.role;
|
||||
this.props.login.usedSpace = resp.data.usedSpace;
|
||||
this.props.login.quota = resp.data.quota;
|
||||
this.props.ui.bg = resp.data.preferences.bg;
|
||||
this.props.ui.cssURL = resp.data.preferences.cssURL;
|
||||
this.props.ui.lanPackURL = resp.data.preferences.lanPackURL;
|
||||
return true;
|
||||
}
|
||||
this.resetUser();
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ihexxa/quickshare/src/db/sitestore"
|
||||
"github.com/ihexxa/quickshare/src/kvstore"
|
||||
)
|
||||
|
||||
|
@ -44,6 +45,7 @@ type Quota struct {
|
|||
}
|
||||
|
||||
type Preferences struct {
|
||||
Bg *sitestore.BgConfig `json:"bg"`
|
||||
BgURL string `json:"bgURL"`
|
||||
CSSURL string `json:"cssURL"`
|
||||
LanPackURL string `json:"lanPackURL"`
|
||||
|
|
|
@ -698,8 +698,6 @@ func (h *MultiUsersSvc) SetPreferences(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// userstore.setPreferences
|
||||
|
||||
uidStr, ok := claims[q.UserIDParam]
|
||||
if !ok {
|
||||
c.JSON(q.ErrResp(c, 500, errors.New("user id not found")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue