mirror of
https://github.com/eyebluecn/tank-front
synced 2024-04-21 12:31:55 +00:00
add default preview engines
This commit is contained in:
@@ -183,6 +183,9 @@ let LangEn = {
|
||||
engineReg: "Engine format",
|
||||
engineSuffix: "Engine suffix",
|
||||
enginePreview: "Engine preview",
|
||||
defaultPreview: "Default preview engine",
|
||||
previewEngine: "Number {} preview engine",
|
||||
defaultPreviewDesc: "Default preview engine, can not be removed",
|
||||
engineRegHelper: "template syntax, {url} represents the file path, the preview will automatically replace with the corresponding file url",
|
||||
engineRegPlaceHolder: "eg:https://xxx.xxx.xxx?url={url}",
|
||||
engineSuffixPlaceHolder: "suffix can not be null, split by comma, look like: doc,ppt,xls",
|
||||
@@ -196,6 +199,11 @@ let LangEn = {
|
||||
cronValidate: "Cron expression can not be null",
|
||||
scanScope: "Scan scope",
|
||||
scanUsers: "Scan users",
|
||||
scanPerTenSeconds: "Scan every ten seconds",
|
||||
scanPerThirtySeconds: "Scan every thirty seconds",
|
||||
scanPerMinute: "Scan every minute",
|
||||
scanPerHour: "Scan every hour",
|
||||
scanCustom: "Scan custom",
|
||||
chooseUsers: "Fuzzy search users",
|
||||
chooseUsersValidate: "choose one more user"
|
||||
},
|
||||
@@ -286,7 +294,8 @@ let LangEn = {
|
||||
editSomebodyPassword: "Edit {}'s Password",
|
||||
transfigurationPromptText: "Transfiguration Prompt",
|
||||
transfigurationPrompt: "You will login as this user.Please visit this link in other browser, if in current browser, you will logout.",
|
||||
|
||||
allUsers: "All users",
|
||||
partialUsers: "Partial users"
|
||||
},
|
||||
model: {
|
||||
usernameRule: "only lowercase letter and number and _ is permitted.",
|
||||
|
||||
@@ -184,6 +184,9 @@ let LangZh = {
|
||||
engineReg: "引擎格式",
|
||||
engineSuffix: "匹配后缀",
|
||||
enginePreview: "预览方式",
|
||||
defaultPreview: "默认引擎",
|
||||
previewEngine: "{}号引擎",
|
||||
defaultPreviewDesc: "默认预览引擎,不可移除",
|
||||
engineRegHelper: "此处填写模板语法,{url}表示文件路径,预览时会自动替换成对应的文件url",
|
||||
engineRegPlaceHolder: "例如:https://xxx.xxx.xxx?url={url}",
|
||||
engineSuffixPlaceHolder: '输入后缀,使用逗号分隔,不用带. 例如:doc,ppt,xls',
|
||||
@@ -197,6 +200,11 @@ let LangZh = {
|
||||
cronValidate: "cron表达式不能为空",
|
||||
scanScope: "扫描范围",
|
||||
scanUsers: "扫描用户",
|
||||
scanPerTenSeconds: "每十秒",
|
||||
scanPerThirtySeconds: "每三十秒",
|
||||
scanPerMinute: "每分钟",
|
||||
scanPerHour: "每小时",
|
||||
scanCustom: "自定义",
|
||||
chooseUsers: "模糊搜索用户",
|
||||
chooseUsersValidate: "请选择至少一个用户"
|
||||
},
|
||||
@@ -287,7 +295,8 @@ let LangZh = {
|
||||
editSomebodyPassword: "修改{}的密码",
|
||||
transfigurationPromptText: "变身提示",
|
||||
transfigurationPrompt: "您将使用该用户的身份登录。请复制以下链接到其他浏览器访问,在当前浏览器访问会导致当前用户登录信息失效。",
|
||||
|
||||
allUsers: "全部用户",
|
||||
partialUsers: "局部用户"
|
||||
},
|
||||
model: {
|
||||
usernameRule: "用户名只能包含字母,数字和\"_\"",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import SelectionOption from "../../base/option/SelectionOption";
|
||||
import Lang from "../../global/Lang";
|
||||
|
||||
enum ScanCronType {
|
||||
TEN_SECONDS = "TEN_SECONDS",
|
||||
@@ -14,23 +15,23 @@ const ScanCronTypes: ScanCronType[] = Object.keys(ScanCronType).map(
|
||||
|
||||
const ScanCronTypeMap: { [key in keyof typeof ScanCronType]: SelectionOption } = {
|
||||
TEN_SECONDS: {
|
||||
name: "每十秒",
|
||||
name: Lang.t("preference.scanPerTenSeconds"),
|
||||
value: "@every 10s",
|
||||
},
|
||||
THIRTY_SECONDS: {
|
||||
name: "每三十秒",
|
||||
name: Lang.t("preference.scanPerThirtySeconds"),
|
||||
value: "@every 30s",
|
||||
},
|
||||
MINUTE: {
|
||||
name: "每分钟",
|
||||
name: Lang.t("preference.scanPerMinute"),
|
||||
value: "@every 1m",
|
||||
},
|
||||
HOUR: {
|
||||
name: "每小时",
|
||||
name: Lang.t("preference.scanPerHour"),
|
||||
value: "0 * * * *",
|
||||
},
|
||||
CUSTOM: {
|
||||
name: "自定义",
|
||||
name: Lang.t("preference.scanCustom"),
|
||||
value: "CUSTOM",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import SelectionOption from "../../base/option/SelectionOption";
|
||||
import Lang from "../../global/Lang";
|
||||
|
||||
enum ScanScopeType {
|
||||
ALL = "ALL",
|
||||
@@ -11,11 +12,11 @@ const ScanScopeTypes: ScanScopeType[] = Object.keys(ScanScopeType).map(
|
||||
|
||||
const ScanScopeTypeMap: { [key in keyof typeof ScanScopeType]: SelectionOption } = {
|
||||
ALL: {
|
||||
name: "全部用户",
|
||||
name: Lang.t("user.allUsers"),
|
||||
value: "ALL",
|
||||
},
|
||||
CUSTOM: {
|
||||
name: "局部用户",
|
||||
name: Lang.t("user.partialUsers"),
|
||||
value: "CUSTOM",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -163,7 +163,6 @@ export default class Edit extends TankComponent<IProps, IState> {
|
||||
<InputNumber min={-1} className="w150" />
|
||||
</Form.Item>
|
||||
<span className="pl10">
|
||||
{" "}
|
||||
{Lang.t("preference.current")}:
|
||||
{this.formRef && this.formRef.current
|
||||
? FileUtil.humanFileSize(
|
||||
|
||||
@@ -17,16 +17,6 @@
|
||||
max-height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.preview-tip {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
.engine-box {
|
||||
border: 1px solid #eee;
|
||||
padding: 20px 10px 5px;
|
||||
}
|
||||
|
||||
.basic-info,
|
||||
.preview-info,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { Children } from "react";
|
||||
import { Link, RouteComponentProps } from "react-router-dom";
|
||||
import "./Index.less";
|
||||
import TankComponent from "../../common/component/TankComponent";
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
ScanScopeType,
|
||||
ScanScopeTypeMap,
|
||||
} from "../../common/model/preference/model/ScanScopeType";
|
||||
import PreviewEngineCell from "./widget/PreviewEngineCell";
|
||||
import PreviewEngine from "../../common/model/preference/model/PreviewEngine";
|
||||
|
||||
interface IProps extends RouteComponentProps {}
|
||||
|
||||
@@ -68,7 +70,8 @@ export default class Index extends TankComponent<IProps, IState> {
|
||||
previewConfig: { previewEngines },
|
||||
scanConfig,
|
||||
} = this.preference;
|
||||
console.log(scanConfig);
|
||||
|
||||
console.log(PreviewEngine.defaultPreviewEngines());
|
||||
|
||||
return (
|
||||
<div className="page-preference-index">
|
||||
@@ -173,30 +176,17 @@ export default class Index extends TankComponent<IProps, IState> {
|
||||
</Link>
|
||||
</header>
|
||||
<div className="content">
|
||||
{previewEngines.length ? (
|
||||
previewEngines.map((engines, index) => (
|
||||
<div key={index} className="relative mb10 engine-box">
|
||||
<Tooltip title={Lang.t("preference.enginePreview")}>
|
||||
{engines.previewInSite ? (
|
||||
<Tag className="preview-tip" color="warning">
|
||||
{Lang.t("preference.previewCurrent")}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag className="preview-tip" color="success">
|
||||
{Lang.t("preference.previewOpen")}
|
||||
</Tag>
|
||||
)}
|
||||
</Tooltip>
|
||||
<InfoCell name={Lang.t("preference.engineReg")}>
|
||||
{engines.url}
|
||||
</InfoCell>
|
||||
<InfoCell name={Lang.t("preference.engineSuffix")}>
|
||||
{engines.extensions}
|
||||
</InfoCell>
|
||||
</div>
|
||||
{previewEngines.map((engine, index) => (
|
||||
<PreviewEngineCell
|
||||
key={index}
|
||||
engine={engine}
|
||||
order={index + 1}
|
||||
/>
|
||||
))}
|
||||
{Children.toArray(
|
||||
PreviewEngine.defaultPreviewEngines().map((engine) => (
|
||||
<PreviewEngineCell engine={engine} />
|
||||
))
|
||||
) : (
|
||||
<Empty description={Lang.t("preference.noEngine")} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import "./PreviewConfigPanel.less";
|
||||
import TankComponent from "../../../common/component/TankComponent";
|
||||
import PreviewConfig from "../../../common/model/preference/model/PreviewConfig";
|
||||
import PreviewEngine from "../../../common/model/preference/model/PreviewEngine";
|
||||
import PreviewEngineCell from "./PreviewEngineCell";
|
||||
import PreviewEngineEditCell from "./PreviewEngineEditCell";
|
||||
import { Button } from "antd";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import Lang from "../../../common/model/global/Lang";
|
||||
@@ -43,7 +43,7 @@ export default class PreviewConfigPanel extends TankComponent<IProps, IState> {
|
||||
{previewConfig.previewEngines.map(
|
||||
(previewEngine: PreviewEngine, index: number) => {
|
||||
return (
|
||||
<PreviewEngineCell
|
||||
<PreviewEngineEditCell
|
||||
key={index}
|
||||
previewEngine={previewEngine}
|
||||
index={index}
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
|
||||
.widget-preview-engine-cell {
|
||||
|
||||
margin-bottom: 15px;
|
||||
.preview-engine-cell {
|
||||
position: relative;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
|
||||
.engine-title {
|
||||
border-bottom: 1px solid #eeeeee;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
|
||||
padding: 10px 10px 0;
|
||||
margin-bottom: 10px;
|
||||
.tip-box {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.engine-content {
|
||||
padding: 10px;
|
||||
|
||||
.castle-widget-info-cell {
|
||||
|
||||
.info-cell-name {
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,115 +1,52 @@
|
||||
import React from "react";
|
||||
import "./PreviewEngineCell.less";
|
||||
import TankComponent from "../../../common/component/TankComponent";
|
||||
import React from "react";
|
||||
import PreviewEngine from "../../../common/model/preference/model/PreviewEngine";
|
||||
import { DeleteOutlined } from "@ant-design/icons";
|
||||
import { Form, Input, Switch, Tooltip } from "antd";
|
||||
import { Tag, Tooltip } from "antd";
|
||||
import Lang from "../../../common/model/global/Lang";
|
||||
import { QuestionCircleOutlined } from "@ant-design/icons";
|
||||
import InfoCell from "../../widget/InfoCell";
|
||||
|
||||
interface IProps {
|
||||
previewEngine: PreviewEngine;
|
||||
index: number;
|
||||
onDelete: () => void;
|
||||
engine: PreviewEngine;
|
||||
order?: number; // 从1开始
|
||||
}
|
||||
|
||||
interface IState {}
|
||||
export default function PreviewEngineCell(props: IProps) {
|
||||
const { engine, order } = props;
|
||||
|
||||
export default class PreviewEngineCell extends TankComponent<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { previewEngine } = this.props;
|
||||
|
||||
return (
|
||||
<div className="widget-preview-engine-cell">
|
||||
<div className="engine-title">
|
||||
<span>{Lang.t("preference.engine", this.props.index + 1)}</span>
|
||||
<span>
|
||||
<DeleteOutlined
|
||||
className="btn-action text-danger"
|
||||
onClick={() => {
|
||||
this.props.onDelete();
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div className="engine-content">
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip title={Lang.t("preference.engineRegHelper")}>
|
||||
<div>
|
||||
{Lang.t("preference.engineReg")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
rules={[
|
||||
{ required: true, message: Lang.t("preference.engineRegHelper") },
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
value={previewEngine.url}
|
||||
placeholder={Lang.t("preference.engineRegPlaceHolder")}
|
||||
onChange={(e) => {
|
||||
previewEngine.url = e.target.value;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip title={Lang.t("preference.engineSuffixPlaceHolder")}>
|
||||
<div>
|
||||
{Lang.t("preference.engineSuffix")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: Lang.t("preference.engineSuffixPlaceHolder"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
value={previewEngine.extensions}
|
||||
placeholder={Lang.t("preference.engineSuffixPlaceHolder")}
|
||||
onChange={(e) => {
|
||||
previewEngine.extensions = e.target.value;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip
|
||||
title={`${Lang.t("preference.previewCurrent")} or ${Lang.t(
|
||||
"preference.previewOpen"
|
||||
)}`}
|
||||
>
|
||||
<div>
|
||||
{Lang.t("preference.previewCurrent")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<Switch
|
||||
checked={previewEngine.previewInSite}
|
||||
onChange={(val) => {
|
||||
previewEngine.previewInSite = val;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
return (
|
||||
<div className="preview-engine-cell">
|
||||
<div className="engine-box">
|
||||
<p className="title">
|
||||
{order ? Lang.t("preference.previewEngine", order) : Lang.t("preference.defaultPreview")}
|
||||
</p>
|
||||
<InfoCell name={Lang.t("preference.engineReg")}>{engine.url}</InfoCell>
|
||||
<InfoCell name={Lang.t("preference.engineSuffix")}>
|
||||
{engine.extensions}
|
||||
</InfoCell>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
<div className="tip-box">
|
||||
{
|
||||
order ? null: (
|
||||
<Tooltip title={Lang.t("preference.defaultPreviewDesc")}>
|
||||
<Tag className="tip mr10" color="success">
|
||||
{Lang.t("preference.defaultPreview")}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
<Tooltip title={Lang.t("preference.enginePreview")}>
|
||||
{engine.previewInSite ? (
|
||||
<Tag className="tip mr0" color="purple">
|
||||
{Lang.t("preference.previewCurrent")}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag className="tip mr0" color="purple">
|
||||
{Lang.t("preference.previewOpen")}
|
||||
</Tag>
|
||||
)}
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
.widget-preview-engine-cell {
|
||||
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
|
||||
.engine-title {
|
||||
border-bottom: 1px solid #eeeeee;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
|
||||
.engine-content {
|
||||
padding: 10px;
|
||||
|
||||
.castle-widget-info-cell {
|
||||
|
||||
.info-cell-name {
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import React from "react";
|
||||
import "./PreviewEngineEditCell.less";
|
||||
import TankComponent from "../../../common/component/TankComponent";
|
||||
import PreviewEngine from "../../../common/model/preference/model/PreviewEngine";
|
||||
import { DeleteOutlined } from "@ant-design/icons";
|
||||
import { Form, Input, Switch, Tooltip } from "antd";
|
||||
import Lang from "../../../common/model/global/Lang";
|
||||
import { QuestionCircleOutlined } from "@ant-design/icons";
|
||||
|
||||
interface IProps {
|
||||
previewEngine: PreviewEngine;
|
||||
index: number;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
interface IState {}
|
||||
|
||||
export default class PreviewEngineEditCell extends TankComponent<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { previewEngine } = this.props;
|
||||
|
||||
return (
|
||||
<div className="widget-preview-engine-cell">
|
||||
<div className="engine-title">
|
||||
<span>{Lang.t("preference.engine", this.props.index + 1)}</span>
|
||||
<span>
|
||||
<DeleteOutlined
|
||||
className="btn-action text-danger"
|
||||
onClick={() => {
|
||||
this.props.onDelete();
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div className="engine-content">
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip title={Lang.t("preference.engineRegHelper")}>
|
||||
<div>
|
||||
{Lang.t("preference.engineReg")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
rules={[
|
||||
{ required: true, message: Lang.t("preference.engineRegHelper") },
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
value={previewEngine.url}
|
||||
placeholder={Lang.t("preference.engineRegPlaceHolder")}
|
||||
onChange={(e) => {
|
||||
previewEngine.url = e.target.value;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip title={Lang.t("preference.engineSuffixPlaceHolder")}>
|
||||
<div>
|
||||
{Lang.t("preference.engineSuffix")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: Lang.t("preference.engineSuffixPlaceHolder"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
value={previewEngine.extensions}
|
||||
placeholder={Lang.t("preference.engineSuffixPlaceHolder")}
|
||||
onChange={(e) => {
|
||||
previewEngine.extensions = e.target.value;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<Tooltip
|
||||
title={`${Lang.t("preference.previewCurrent")} or ${Lang.t(
|
||||
"preference.previewOpen"
|
||||
)}`}
|
||||
>
|
||||
<div>
|
||||
{Lang.t("preference.previewCurrent")}
|
||||
<QuestionCircleOutlined className="btn-action text-warning" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<Switch
|
||||
checked={previewEngine.previewInSite}
|
||||
onChange={(val) => {
|
||||
previewEngine.previewInSite = val;
|
||||
this.updateUI();
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user