aldehyde 0.2.194 → 0.2.195

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,248 +1,256 @@
1
- import React, { CSSProperties } from "react";
1
+ import React, {CSSProperties} from "react";
2
2
  import "./index.css";
3
- import { Button, Col, Form, Input, Row, FormInstance } from "antd";
3
+ import {Button, Col, Form, Input, Row, FormInstance} from "antd";
4
4
  import {
5
- LockOutlined,
6
- SafetyCertificateOutlined,
7
- UserOutlined,
5
+ LockOutlined,
6
+ SafetyCertificateOutlined,
7
+ UserOutlined,
8
8
  } from "@ant-design/icons";
9
9
  import HCserviceV3 from "../tmpl/hcservice-v3";
10
- import { LocaleContext } from "../locale/LocaleProvider";
10
+ import {LocaleContext} from "../locale/LocaleProvider";
11
11
  import Vertify from "./vertify/index";
12
12
  import Units from "../units";
13
+ import ResetPassword from "../layout/menu/reset-password";
13
14
 
14
15
  interface LoginProps {
15
- onFinish: (token: string) => void;
16
- title?: any;
17
- programCode?: string;
18
- autoSaveUser?: boolean;
16
+ onFinish: (token: string) => void;
17
+ title?: any;
18
+ programCode?: string;
19
+ autoSaveUser?: boolean;
19
20
  }
20
21
 
21
22
  interface LoginState {
22
- username?: string;
23
- password?: string;
24
- loading?: boolean;
25
- needKaptcha?: boolean;
26
- kaptchaImg?: string;
27
- kaptchaToken?: string;
28
- pubkey?: string;
29
- vertify: boolean;
30
- showSlideVertify: boolean;
23
+ username?: string;
24
+ password?: string;
25
+ loading?: boolean;
26
+ needKaptcha?: boolean;
27
+ kaptchaImg?: string;
28
+ kaptchaToken?: string;
29
+ pubkey?: string;
30
+ vertify: boolean;
31
+ showSlideVertify: boolean;
31
32
  }
32
33
 
33
34
  class Login extends React.PureComponent<LoginProps, LoginState> {
34
- state = {
35
- username: "",
36
- password: "",
37
- loading: true,
38
- needKaptcha: false,
39
- kaptchaImg: null,
40
- kaptchaToken: null,
41
- pubkey: undefined,
42
- vertify: false,
43
- showSlideVertify: false,
44
- };
45
- formRef = React.createRef<FormInstance>();
46
- static contextType = LocaleContext;
47
- context: React.ContextType<typeof LocaleContext>;
48
-
49
- componentDidMount = async () => {
50
- const { programCode } = this.props;
51
- localStorage.setItem("version", "v1");
52
-
53
- if (programCode) Units.setProgramCode(programCode);
54
- window.removeEventListener("keydown", this.handleKeyDown);
55
- let pubkey = await HCserviceV3.getRasPubkey(null, programCode);
56
- this.setState({
57
- pubkey,
58
- loading: false,
59
- });
60
- };
61
-
62
- getKaptchaToken = async () => {
63
- const { programCode } = this.props;
64
- let res = await HCserviceV3.getKaptchaToken(programCode);
65
- if (res) {
66
- let kaptchaImg;
67
- if (res.img && res.img.indexOf("data:") == 0) {
68
- kaptchaImg = res.img;
69
- } else {
70
- kaptchaImg = `data:image/png;base64,${res.img}`;
71
- }
72
- this.setState({
73
- kaptchaImg,
74
- kaptchaToken: res.kaptchaToken,
75
- needKaptcha: true,
76
- });
77
- }
78
- };
79
-
80
- handleSubmit = async () => {
81
- this.setState({
82
- loading: true,
83
- });
84
- let { kaptchaToken, pubkey, needKaptcha, vertify } = this.state;
85
-
86
- await this.formRef.current
87
- .validateFields()
88
- .then(async (values) => {
89
- // if (needKaptcha && !vertify)
90
- // return this.setState({ showSlideVertify: false });
91
-
92
- const { programCode } = this.props;
93
- let json = { username: values.username, password: values.password };
94
- let res = await HCserviceV3.login(
95
- json,
96
- kaptchaToken,
97
- values.kaptchaText,
98
- pubkey,
99
- programCode
100
- );
101
- if (res.status === "success") {
102
- this.props.onFinish(res.token);
103
- } else if (res.status === "error") {
104
- this.setState({ needKaptcha: true, vertify: false });
105
- await this.getKaptchaToken();
35
+ state = {
36
+ username: "",
37
+ password: "",
38
+ loading: true,
39
+ needKaptcha: false,
40
+ kaptchaImg: null,
41
+ kaptchaToken: null,
42
+ pubkey: undefined,
43
+ vertify: false,
44
+ showSlideVertify: false,
45
+ };
46
+ formRef = React.createRef<FormInstance>();
47
+ static contextType = LocaleContext;
48
+ context: React.ContextType<typeof LocaleContext>;
49
+
50
+ componentDidMount = async () => {
51
+ const {programCode} = this.props;
52
+ localStorage.setItem("version", "v1");
53
+
54
+ if (programCode) Units.setProgramCode(programCode);
55
+ window.removeEventListener("keydown", this.handleKeyDown);
56
+ let pubkey = await HCserviceV3.getRasPubkey(null, programCode);
57
+ this.setState({
58
+ pubkey,
59
+ loading: false,
60
+ });
61
+ };
62
+
63
+ getKaptchaToken = async () => {
64
+ const {programCode} = this.props;
65
+ let res = await HCserviceV3.getKaptchaToken(programCode);
66
+ if (res) {
67
+ let kaptchaImg;
68
+ if (res.img && res.img.indexOf("data:") == 0) {
69
+ kaptchaImg = res.img;
70
+ } else {
71
+ kaptchaImg = `data:image/png;base64,${res.img}`;
72
+ }
73
+ this.setState({
74
+ kaptchaImg,
75
+ kaptchaToken: res.kaptchaToken,
76
+ needKaptcha: true,
77
+ });
78
+ }
79
+ };
80
+
81
+ handleSubmit = async () => {
82
+ this.setState({
83
+ loading: true,
84
+ });
85
+ let {kaptchaToken, pubkey, needKaptcha, vertify} = this.state;
86
+
87
+ await this.formRef.current
88
+ .validateFields()
89
+ .then(async (values) => {
90
+ // if (needKaptcha && !vertify)
91
+ // return this.setState({ showSlideVertify: false });
92
+
93
+ const {programCode} = this.props;
94
+ let json = {username: values.username, password: values.password};
95
+ let res = await HCserviceV3.login(
96
+ json,
97
+ kaptchaToken,
98
+ values.kaptchaText,
99
+ pubkey,
100
+ programCode
101
+ );
102
+ if (res.status === "success") {
103
+ this.props.onFinish(res.token);
104
+ } else if (res.status === "error") {
105
+ this.setState({needKaptcha: true, vertify: false});
106
+ await this.getKaptchaToken();
107
+ }
108
+ })
109
+ .catch((errorInfo) => {
110
+ });
111
+ this.setState({
112
+ loading: false,
113
+ });
114
+ };
115
+
116
+ handleKeyDown = (event) => {
117
+ //按下enter键,触发login事件
118
+ switch (event.keyCode) {
119
+ case 13:
120
+ this.handleSubmit();
121
+ break;
122
+ default:
123
+ break;
106
124
  }
107
- })
108
- .catch((errorInfo) => {});
109
- this.setState({
110
- loading: false,
111
- });
112
- };
113
-
114
- handleKeyDown = (event) => {
115
- //按下enter键,触发login事件
116
- switch (event.keyCode) {
117
- case 13:
118
- this.handleSubmit();
119
- break;
120
- default:
121
- break;
125
+ };
126
+
127
+ changeKaptcha = async (event) => {
128
+ //切换验证码
129
+ await this.getKaptchaToken();
130
+ };
131
+
132
+ render() {
133
+ const {loading, needKaptcha, kaptchaImg, showSlideVertify} = this.state;
134
+
135
+ const {autoSaveUser = true} = this.props;
136
+
137
+ const {translate} = this.context;
138
+ return (
139
+ <>
140
+ <Form
141
+ style={{width: 350}}
142
+ ref={this.formRef}
143
+ name="normal_login"
144
+ initialValues={{remember: true}}
145
+ >
146
+ {this.props.title}
147
+ <Form.Item
148
+ name="username"
149
+ rules={[
150
+ {required: true, message: translate("${请输入}${用户名}!")},
151
+ {
152
+ max: 30,
153
+ min: 0,
154
+ message: translate("${请输入}${0-30个字符}!"),
155
+ },
156
+ ]}
157
+ >
158
+ <Input
159
+ prefix={<UserOutlined className="site-form-item-icon"/>}
160
+ placeholder={translate("${用户名}")}
161
+ autoComplete={autoSaveUser ? "on" : "off"}
162
+ />
163
+ </Form.Item>
164
+ <Form.Item
165
+ name="password"
166
+ rules={[
167
+ {required: true, message: translate("${请输入}${密码}!")},
168
+ ]}
169
+ >
170
+ <Input
171
+ style={
172
+ autoSaveUser
173
+ ? {}
174
+ : ({"-webkit-text-security": "disc"} as CSSProperties)
175
+ }
176
+ type={autoSaveUser ? "password" : "text"}
177
+ placeholder={translate("${密码}")}
178
+ onKeyDown={this.handleKeyDown}
179
+ autoComplete={autoSaveUser ? "on" : "off"}
180
+ prefix={<LockOutlined className="site-form-item-icon"/>}
181
+ />
182
+ </Form.Item>
183
+ {needKaptcha ? (
184
+ <Row gutter={8}>
185
+ <Col span={12}>
186
+ <Form.Item
187
+ name="kaptchaText"
188
+ rules={[
189
+ {
190
+ required: true,
191
+ message: translate("${请输入}${验证码}!"),
192
+ },
193
+ ]}
194
+ >
195
+ <Input
196
+ prefix={
197
+ <SafetyCertificateOutlined className="site-form-item-icon"/>
198
+ }
199
+ placeholder={translate("${验证码}")}
200
+ onKeyDown={this.handleKeyDown}
201
+ />
202
+ </Form.Item>
203
+ </Col>
204
+ <Col span={12}>
205
+ <img
206
+ style={{cursor: "pointer"}}
207
+ height={30}
208
+ width={90}
209
+ title={translate("${点击刷新}")}
210
+ onClick={this.changeKaptcha}
211
+ src={kaptchaImg}
212
+ ></img>
213
+ </Col>
214
+ </Row>
215
+ ) : (
216
+ ""
217
+ )}
218
+ <Form.Item>
219
+ <Button
220
+ type="primary"
221
+ style={{width: "100%"}}
222
+ loading={loading}
223
+ onClick={this.handleSubmit}
224
+ >
225
+ {translate("${登录}")}
226
+ </Button>
227
+ </Form.Item>
228
+ <Form.Item style={{marginBottom:0}}>
229
+ <Row gutter={8}>
230
+ <Col span={6} offset={18}><ResetPassword></ResetPassword></Col>
231
+ </Row>
232
+ </Form.Item>
233
+ </Form>
234
+
235
+ {showSlideVertify ? (
236
+ <div style={{width: "100%", height: "100%", background: "white"}}>
237
+ <Vertify
238
+ onSuccess={() =>
239
+ this.setState({vertify: true, showSlideVertify: false}, () =>
240
+ this.handleSubmit()
241
+ )
242
+ }
243
+ onFail={() =>
244
+ this.setState({vertify: false, showSlideVertify: true})
245
+ }
246
+ ></Vertify>
247
+ </div>
248
+ ) : (
249
+ <></>
250
+ )}
251
+ </>
252
+ );
122
253
  }
123
- };
124
-
125
- changeKaptcha = async (event) => {
126
- //切换验证码
127
- await this.getKaptchaToken();
128
- };
129
-
130
- render() {
131
- const { loading, needKaptcha, kaptchaImg, showSlideVertify } = this.state;
132
-
133
- const { autoSaveUser = true } = this.props;
134
-
135
- const { translate } = this.context;
136
- return (
137
- <>
138
- <Form
139
- style={{ width: 350 }}
140
- ref={this.formRef}
141
- name="normal_login"
142
- initialValues={{ remember: true }}
143
- >
144
- {this.props.title}
145
- <Form.Item
146
- name="username"
147
- rules={[
148
- { required: true, message: translate("${请输入}${用户名}!") },
149
- {
150
- max: 30,
151
- min: 0,
152
- message: translate("${请输入}${0-30个字符}!"),
153
- },
154
- ]}
155
- >
156
- <Input
157
- prefix={<UserOutlined className="site-form-item-icon" />}
158
- placeholder={translate("${用户名}")}
159
- autoComplete={autoSaveUser ? "on" : "off"}
160
- />
161
- </Form.Item>
162
- <Form.Item
163
- name="password"
164
- rules={[
165
- { required: true, message: translate("${请输入}${密码}!") },
166
- ]}
167
- >
168
- <Input
169
- style={
170
- autoSaveUser
171
- ? {}
172
- : ({ "-webkit-text-security": "disc" } as CSSProperties)
173
- }
174
- type={autoSaveUser ? "password" : "text"}
175
- placeholder={translate("${密码}")}
176
- onKeyDown={this.handleKeyDown}
177
- autoComplete={autoSaveUser ? "on" : "off"}
178
- prefix={<LockOutlined className="site-form-item-icon" />}
179
- />
180
- </Form.Item>
181
- {needKaptcha ? (
182
- <Row gutter={8}>
183
- <Col span={12}>
184
- <Form.Item
185
- name="kaptchaText"
186
- rules={[
187
- {
188
- required: true,
189
- message: translate("${请输入}${验证码}!"),
190
- },
191
- ]}
192
- >
193
- <Input
194
- prefix={
195
- <SafetyCertificateOutlined className="site-form-item-icon" />
196
- }
197
- placeholder={translate("${验证码}")}
198
- onKeyDown={this.handleKeyDown}
199
- />
200
- </Form.Item>
201
- </Col>
202
- <Col span={12}>
203
- <img
204
- style={{ cursor: "pointer" }}
205
- height={30}
206
- width={90}
207
- title={translate("${点击刷新}")}
208
- onClick={this.changeKaptcha}
209
- src={kaptchaImg}
210
- ></img>
211
- </Col>
212
- </Row>
213
- ) : (
214
- ""
215
- )}
216
- <Form.Item>
217
- <Button
218
- type="primary"
219
- style={{ width: "100%" }}
220
- loading={loading}
221
- onClick={this.handleSubmit}
222
- >
223
- {translate("${登录}")}
224
- </Button>
225
- </Form.Item>
226
- </Form>
227
- {showSlideVertify ? (
228
- <div style={{ width: "100%", height: "100%", background: "white" }}>
229
- <Vertify
230
- onSuccess={() =>
231
- this.setState({ vertify: true, showSlideVertify: false }, () =>
232
- this.handleSubmit()
233
- )
234
- }
235
- onFail={() =>
236
- this.setState({ vertify: false, showSlideVertify: true })
237
- }
238
- ></Vertify>
239
- </div>
240
- ) : (
241
- <></>
242
- )}
243
- </>
244
- );
245
- }
246
254
  }
247
255
 
248
256
  export default Login;
@@ -4,6 +4,8 @@ import LoginBgPng from "./img/login-bg.png";
4
4
  import { useLocale } from "../locale/useLocale";
5
5
  import HCDataSource from "../tmpl/hc-data-source";
6
6
  import Units from "../units";
7
+ import {Button, Col, Row} from "antd";
8
+ import ResetPassword from "../layout/menu/reset-password";
7
9
 
8
10
  const LoginPage = () => {
9
11
  const { translate } = useLocale();
@@ -51,6 +53,9 @@ const LoginPage = () => {
51
53
  Units.setHydrocarbonToken(token);
52
54
  }}
53
55
  ></Login>
56
+ <Row>
57
+ <Col span={6} offset={18}><ResetPassword></ResetPassword></Col>
58
+ </Row>
54
59
  </div>
55
60
  </div>
56
61
  );
@@ -699,15 +699,26 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
699
699
  {ltmplConfig.rowFileButtons &&
700
700
  ltmplConfig.rowFileButtons.length > 0
701
701
  ? ltmplConfig.rowFileButtons.map((openFileButton) => {
702
- return (
703
- <NewinFileView
704
- title={openFileButton.title}
705
- filePath={HCService.toFilePath(record[openFileButton.fieldId], serverKey)}
706
- serverKey={serverKey}
707
- key={openFileButton.id}
708
- //size={"small"}
709
- />
710
- );
702
+ let v= record[openFileButton.fieldId];
703
+ if(v){
704
+ if(v instanceof Array){
705
+ v=v[0];
706
+ }
707
+ if(v.includes("@R@")>0){
708
+ v=v.split("@R@")[1];
709
+ }
710
+ return (
711
+ <NewinFileView
712
+ title={openFileButton.title}
713
+ filePath={HCService.toFilePath(v, serverKey)}
714
+ serverKey={serverKey}
715
+ key={openFileButton.id}
716
+ //size={"small"}
717
+ />
718
+ );
719
+ }else{
720
+ return "";
721
+ }
711
722
  })
712
723
  : ""}
713
724
  {buttons.includes("singleDelete") &&
@@ -42,7 +42,6 @@ export default class HcserviceV3 {
42
42
  }
43
43
 
44
44
  static toFilePath(value,serverKey) {
45
- debugger
46
45
  if (!value) {
47
46
  return null;
48
47
  }
@@ -1034,10 +1033,16 @@ export default class HcserviceV3 {
1034
1033
  },
1035
1034
  method: "GET",
1036
1035
  });
1037
- // if (res.status === 'success') {
1038
- // successHandle(res.token);
1039
- // }
1040
- return res;
1036
+ if(res.passwordState){
1037
+ if(res.passwordState=="expiry"){
1038
+ message.warning(translate("${"+res.message+"}"), 10);
1039
+ }else if(res.passwordState=="expiried"){
1040
+ message.error(translate("${"+res.message+"}"), 10)
1041
+ }else if(res.passwordState=="restricted"){
1042
+ message.error(translate("${"+res.message+"}"), 15)
1043
+ }
1044
+ }
1045
+ return {status:res.status,token:res.token};
1041
1046
  }
1042
1047
 
1043
1048
  static async setContext(json) {
@@ -130,7 +130,6 @@ TmplConfigAnalysis.currentL1 = function(config: string, format: string) {
130
130
  date = date.startOf("second");
131
131
  return date.format("YYYY-MM-DD HH:mm:ss");
132
132
  }
133
- debugger
134
133
  return date.format(format);
135
134
  } else {
136
135
  return null;