fix(ui/admin): fix SetUser related issues
This commit is contained in:
parent
d3bac9a47d
commit
cff7ce6af4
5 changed files with 22 additions and 16 deletions
|
@ -4,7 +4,7 @@ export const defaultTimeout = 10000;
|
||||||
export const userIDParam = "uid";
|
export const userIDParam = "uid";
|
||||||
|
|
||||||
export interface Quota {
|
export interface Quota {
|
||||||
spaceLimit: number;
|
spaceLimit: string;
|
||||||
uploadSpeedLimit: number;
|
uploadSpeedLimit: number;
|
||||||
downloadSpeedLimit: number;
|
downloadSpeedLimit: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ export class UserForm extends React.Component<
|
||||||
changeSpaceLimit = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
changeSpaceLimit = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
quota: {
|
quota: {
|
||||||
spaceLimit: parseInt(ev.target.value, 10),
|
spaceLimit: ev.target.value,
|
||||||
uploadSpeedLimit: this.state.quota.uploadSpeedLimit,
|
uploadSpeedLimit: this.state.quota.uploadSpeedLimit,
|
||||||
downloadSpeedLimit: this.state.quota.downloadSpeedLimit,
|
downloadSpeedLimit: this.state.quota.downloadSpeedLimit,
|
||||||
},
|
},
|
||||||
|
@ -111,10 +111,12 @@ export class UserForm extends React.Component<
|
||||||
|
|
||||||
setUser = async () => {
|
setUser = async () => {
|
||||||
return updater()
|
return updater()
|
||||||
.setUser(this.props.id, this.props.role, this.props.quota)
|
.setUser(this.props.id, this.state.role, this.state.quota)
|
||||||
.then((ok: boolean) => {
|
.then((ok: boolean) => {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
alert("failed to set user");
|
alert("failed to set user");
|
||||||
|
} else {
|
||||||
|
alert("user is updated");
|
||||||
}
|
}
|
||||||
return updater().listUsers();
|
return updater().listUsers();
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,8 +26,6 @@ export class AuthPane extends React.Component<Props, State, {}> {
|
||||||
pwd: "",
|
pwd: "",
|
||||||
captchaInput: "",
|
captchaInput: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initIsAuthed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changeUser = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
changeUser = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
@ -42,14 +40,6 @@ export class AuthPane extends React.Component<Props, State, {}> {
|
||||||
this.setState({ captchaInput: ev.target.value });
|
this.setState({ captchaInput: ev.target.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
initIsAuthed = () => {
|
|
||||||
updater()
|
|
||||||
.initIsAuthed()
|
|
||||||
.then(() => {
|
|
||||||
this.update(updater().updateLogin);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
login = async () => {
|
login = async () => {
|
||||||
return updater()
|
return updater()
|
||||||
.login(
|
.login(
|
||||||
|
|
|
@ -18,6 +18,7 @@ export class StateMgr extends React.Component<Props, State, {}> {
|
||||||
constructor(p: Props) {
|
constructor(p: Props) {
|
||||||
super(p);
|
super(p);
|
||||||
this.state = newState();
|
this.state = newState();
|
||||||
|
this.initUpdater(this.state); // don't await
|
||||||
}
|
}
|
||||||
|
|
||||||
setUsersClient = (client: IUsersClient) => {
|
setUsersClient = (client: IUsersClient) => {
|
||||||
|
@ -28,7 +29,7 @@ export class StateMgr extends React.Component<Props, State, {}> {
|
||||||
this.filesClient = client;
|
this.filesClient = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
initUpdater = (state: ICoreState): Promise<void> => {
|
initUpdater = async (state: ICoreState): Promise<void> => {
|
||||||
updater().init(state);
|
updater().init(state);
|
||||||
if (this.usersClient == null || this.filesClient == null) {
|
if (this.usersClient == null || this.filesClient == null) {
|
||||||
console.error("updater's clients are not inited");
|
console.error("updater's clients are not inited");
|
||||||
|
@ -38,7 +39,20 @@ export class StateMgr extends React.Component<Props, State, {}> {
|
||||||
|
|
||||||
const params = new URLSearchParams(document.location.search.substring(1));
|
const params = new URLSearchParams(document.location.search.substring(1));
|
||||||
return updater()
|
return updater()
|
||||||
.getCaptchaID()
|
.initIsAuthed()
|
||||||
|
.then(() => {
|
||||||
|
this.update(updater().updateLogin);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (updater().props.login.authed) {
|
||||||
|
updater().displayPane("");
|
||||||
|
} else {
|
||||||
|
updater().displayPane("login");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return updater().getCaptchaID();
|
||||||
|
})
|
||||||
.then((ok: boolean) => {
|
.then((ok: boolean) => {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
alert("failed to get captcha id");
|
alert("failed to get captcha id");
|
||||||
|
|
|
@ -305,7 +305,7 @@ export class Updater {
|
||||||
};
|
};
|
||||||
|
|
||||||
initIsAuthed = async (): Promise<void> => {
|
initIsAuthed = async (): Promise<void> => {
|
||||||
return updater()
|
return this
|
||||||
.isAuthed()
|
.isAuthed()
|
||||||
.then((isAuthed) => {
|
.then((isAuthed) => {
|
||||||
updater().setAuthed(isAuthed);
|
updater().setAuthed(isAuthed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue