feat(ui/admin): add reindex button

This commit is contained in:
hexxa 2022-08-06 11:00:48 +08:00 committed by Hexxa
parent 48b0ff2df0
commit 349eec92c0
3 changed files with 21 additions and 19 deletions

View file

@ -268,20 +268,6 @@ export class UserForm extends React.Component<
<div className="hr"></div>
<div>
<Flexbox
children={List([
<span>{this.props.msg.pkg.get("action.reindex.desc")}</span>,
<button className="button-default" onClick={resetUsedSpace}>
{this.props.msg.pkg.get("action.reindex")}
</button>,
])}
childrenStyles={List([{}, { justifyContent: "flex-end" }])}
/>
</div>
<div className="hr"></div>
<Flexbox
className="margin-t-m"
children={List([
@ -505,10 +491,6 @@ export class AdminPane extends React.Component<Props, State, {}> {
}
};
reindex = async () => {
return updater().reindex();
}
addUser = async () => {
if (this.state.newUserPwd1 !== this.state.newUserPwd2) {
Env().alertMsg(this.props.msg.pkg.get("settings.pwd.notSame"));
@ -876,6 +858,13 @@ export class SiteCfg extends React.Component<SiteCfgProps, SiteCfgState, {}> {
this.props.update(updater().updateUI);
};
reindex = async () => {
if (!Env().confirmMsg(this.props.msg.pkg.get("action.reindex.confirm"))) {
return;
}
return updater().reindex();
};
render() {
return (
<div>
@ -1050,6 +1039,17 @@ export class SiteCfg extends React.Component<SiteCfgProps, SiteCfgState, {}> {
/>
</div>
</div>
<div className="hr"></div>
<div>
<div className="label">
{this.props.msg.pkg.get("action.reindex.desc")}
</div>
<button className="button-default" onClick={this.reindex}>
{this.props.msg.pkg.get("action.reindex")}
</button>
</div>
</div>
);
}

View file

@ -160,5 +160,6 @@ export const msgs: Map<string, string> = Map({
"action.go": "Go",
"hint.keywords": "Please input keyword(s), separated by spaces",
"action.reindex": "Reindex",
"action.reindex.desc": "Reconstruct the searching index",
"action.reindex.desc": "Reconstruct the search index",
"action.reindex.confirm": "If there are a lot of files and folders, rebuilding index may take some time.",
});

View file

@ -158,4 +158,5 @@ export const msgs: Map<string, string> = Map({
"hint.keywords": "请输入关键字,以空格分隔",
"action.reindex": "重新索引",
"action.reindex.desc": "重新建立搜索索引",
"action.reindex.confirm": "当文件数量较多,重新建立索引将可能花费一些时间",
});