amis 1.9.1-beta.0 → 1.9.1-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/RootRenderer.js +10 -2
- package/lib/RootRenderer.js.map +2 -2
- package/lib/Schema.d.ts +3 -2
- package/lib/Schema.js.map +1 -1
- package/lib/SchemaRenderer.js +6 -9
- package/lib/SchemaRenderer.js.map +2 -2
- package/lib/actions/CmptAction.js +4 -4
- package/lib/actions/CmptAction.js.map +2 -2
- package/lib/components/Button.d.ts +11 -10
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +40 -40
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/ContextMenu.d.ts +4 -0
- package/lib/components/ContextMenu.js +23 -7
- package/lib/components/ContextMenu.js.map +2 -2
- package/lib/components/DatePicker.d.ts +40 -40
- package/lib/components/DateRangePicker.d.ts +40 -40
- package/lib/components/Form.d.ts +22 -0
- package/lib/components/Form.js +44 -0
- package/lib/components/Form.js.map +13 -0
- package/lib/components/FormField.d.ts +65 -0
- package/lib/components/FormField.js +48 -0
- package/lib/components/FormField.js.map +13 -0
- package/lib/components/InputBox.d.ts +10 -10
- package/lib/components/InputBox.js +4 -3
- package/lib/components/InputBox.js.map +2 -2
- package/lib/components/InputBoxWithSuggestion.d.ts +280 -0
- package/lib/components/InputBoxWithSuggestion.js +65 -0
- package/lib/components/InputBoxWithSuggestion.js.map +13 -0
- package/lib/components/ListGroup.d.ts +10 -10
- package/lib/components/PickerContainer.d.ts +4 -2
- package/lib/components/PickerContainer.js +28 -5
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/Radios.d.ts +10 -10
- package/lib/components/ResultBox.d.ts +40 -40
- package/lib/components/Select.d.ts +195 -202
- package/lib/components/Select.js +7 -3
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Textarea.d.ts +568 -2
- package/lib/components/Textarea.js +129 -1
- package/lib/components/Textarea.js.map +2 -2
- package/lib/components/Toast.js +11 -9
- package/lib/components/Toast.js.map +2 -2
- package/lib/components/UserSelect.d.ts +500 -0
- package/lib/components/UserSelect.js +559 -0
- package/lib/components/UserSelect.js.map +13 -0
- package/lib/components/UserTabSelect.d.ts +320 -0
- package/lib/components/UserTabSelect.js +163 -0
- package/lib/components/UserTabSelect.js.map +13 -0
- package/lib/components/WithRemoteConfig.d.ts +7 -0
- package/lib/components/WithRemoteConfig.js +22 -13
- package/lib/components/WithRemoteConfig.js.map +2 -2
- package/lib/components/calendar/DaysView.d.ts +26 -1
- package/lib/components/calendar/DaysView.js +60 -19
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/calendar/TimeView.d.ts +1 -1
- package/lib/components/calendar/TimeView.js +10 -3
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/formula/Picker.js +4 -4
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/icons.d.ts +7 -1
- package/lib/components/icons.js +17 -1
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +3 -1
- package/lib/components/index.js.map +2 -2
- package/lib/components/json-schema/Array.d.ts +3 -0
- package/lib/components/json-schema/Array.js +125 -0
- package/lib/components/json-schema/Array.js.map +13 -0
- package/lib/components/json-schema/Item.d.ts +3 -0
- package/lib/components/json-schema/Item.js +34 -0
- package/lib/components/json-schema/Item.js.map +13 -0
- package/lib/components/json-schema/Object.d.ts +3 -0
- package/lib/components/json-schema/Object.js +178 -0
- package/lib/components/json-schema/Object.js.map +13 -0
- package/lib/components/json-schema/index.d.ts +279 -0
- package/lib/components/json-schema/index.js +16 -0
- package/lib/components/json-schema/index.js.map +13 -0
- package/lib/components/schema-editor/Array.js +2 -2
- package/lib/components/schema-editor/Array.js.map +2 -2
- package/lib/components/schema-editor/Common.d.ts +2 -0
- package/lib/components/schema-editor/Common.js +39 -3
- package/lib/components/schema-editor/Common.js.map +2 -2
- package/lib/components/schema-editor/Object.js +2 -2
- package/lib/components/schema-editor/Object.js.map +2 -2
- package/lib/components/schema-editor/index.d.ts +45 -41
- package/lib/components/schema-editor/index.js +5 -5
- package/lib/components/schema-editor/index.js.map +2 -2
- package/lib/components/table/ItemActionsWrapper.d.ts +10 -0
- package/lib/components/table/ItemActionsWrapper.js +25 -0
- package/lib/components/table/ItemActionsWrapper.js.map +13 -0
- package/lib/components/table/index.d.ts +48 -41
- package/lib/components/table/index.js +46 -18
- package/lib/components/table/index.js.map +2 -2
- package/lib/helper.css +125 -124
- package/lib/helper.css.map +1 -1
- package/lib/hooks/use-validation-resolver.d.ts +1 -0
- package/lib/hooks/use-validation-resolver.js +49 -0
- package/lib/hooks/use-validation-resolver.js.map +13 -0
- package/lib/icons/department.js +17 -0
- package/lib/icons/menu.js +9 -0
- package/lib/icons/post.js +15 -0
- package/lib/icons/role.js +14 -0
- package/lib/icons/user-remove.js +12 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/de-DE.js +11 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +12 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +14 -3
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.js +25 -11
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.js +5 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Dialog.js +9 -3
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Drawer.js +5 -1
- package/lib/renderers/Drawer.js.map +2 -2
- package/lib/renderers/Form/InputDate.d.ts +2 -2
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/JSONSchema.d.ts +23 -0
- package/lib/renderers/Form/JSONSchema.js +44 -0
- package/lib/renderers/Form/JSONSchema.js.map +13 -0
- package/lib/renderers/Form/JSONSchemaEditor.d.ts +2 -3
- package/lib/renderers/Form/JSONSchemaEditor.js +9 -24
- package/lib/renderers/Form/JSONSchemaEditor.js.map +2 -2
- package/lib/renderers/Form/Options.js +11 -5
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Textarea.d.ts +1 -8
- package/lib/renderers/Form/Textarea.js +11 -75
- package/lib/renderers/Form/Textarea.js.map +2 -2
- package/lib/renderers/Form/UserSelect.d.ts +54 -0
- package/lib/renderers/Form/UserSelect.js +197 -0
- package/lib/renderers/Form/UserSelect.js.map +13 -0
- package/lib/renderers/Form/index.d.ts +1 -1
- package/lib/renderers/Form/index.js +88 -42
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Log.d.ts +28 -0
- package/lib/renderers/Log.js +110 -20
- package/lib/renderers/Log.js.map +2 -2
- package/lib/renderers/Page.js +5 -1
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.js +5 -1
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Table-v2/index.d.ts +14 -2
- package/lib/renderers/Table-v2/index.js +33 -3
- package/lib/renderers/Table-v2/index.js.map +2 -2
- package/lib/renderers/Wizard.js +37 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/form.js +65 -45
- package/lib/store/form.js.map +2 -2
- package/lib/themes/ang-ie11.css +576 -24
- package/lib/themes/ang.css +553 -12
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +576 -24
- package/lib/themes/antd.css +553 -12
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +576 -24
- package/lib/themes/cxd.css +553 -12
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +576 -24
- package/lib/themes/dark.css +553 -12
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +576 -24
- package/lib/themes/default.css +553 -12
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +1 -1
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/renderer-event.js.map +2 -2
- package/package.json +2 -1
- package/schema.json +552 -5
- package/scss/_properties.scss +20 -8
- package/scss/components/_input-box.scss +22 -1
- package/scss/components/_json-schema.scss +124 -0
- package/scss/components/_log.scss +37 -5
- package/scss/components/form/_date-range.scss +1 -0
- package/scss/components/form/_select.scss +9 -0
- package/scss/components/form/_transfer.scss +19 -3
- package/scss/components/form/_user-select.scss +422 -0
- package/scss/helper/background/_background-color.scss +125 -124
- package/scss/themes/_common.scss +2 -0
- package/sdk/ang-ie11.css +670 -24
- package/sdk/ang.css +647 -12
- package/sdk/antd-ie11.css +670 -24
- package/sdk/antd.css +647 -12
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +670 -24
- package/sdk/cxd.css +647 -12
- package/sdk/dark-ie11.css +670 -24
- package/sdk/dark.css +647 -12
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css +125 -124
- package/sdk/helper.css.map +1 -1
- package/sdk/locale/de-DE.js +11 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +16 -16
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +670 -24
- package/sdk/sdk.css +647 -12
- package/sdk/sdk.js +1653 -1637
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/RootRenderer.tsx +27 -15
- package/src/Schema.ts +5 -1
- package/src/SchemaRenderer.tsx +1 -4
- package/src/actions/CmptAction.ts +4 -4
- package/src/components/Button.tsx +3 -0
- package/src/components/Checkbox.tsx +2 -1
- package/src/components/ContextMenu.tsx +25 -7
- package/src/components/Form.tsx +70 -0
- package/src/components/FormField.tsx +127 -0
- package/src/components/InputBox.tsx +4 -1
- package/src/components/InputBoxWithSuggestion.tsx +113 -0
- package/src/components/PickerContainer.tsx +20 -5
- package/src/components/Select.tsx +18 -10
- package/src/components/Textarea.tsx +234 -2
- package/src/components/Toast.tsx +19 -18
- package/src/components/UserSelect.tsx +850 -0
- package/src/components/UserTabSelect.tsx +261 -0
- package/src/components/WithRemoteConfig.tsx +35 -11
- package/src/components/calendar/DaysView.tsx +117 -49
- package/src/components/calendar/TimeView.tsx +11 -6
- package/src/components/formula/Picker.tsx +2 -1
- package/src/components/icons.tsx +17 -1
- package/src/components/index.tsx +3 -1
- package/src/components/json-schema/Array.tsx +216 -0
- package/src/components/json-schema/Item.tsx +47 -0
- package/src/components/json-schema/Object.tsx +339 -0
- package/src/components/json-schema/index.tsx +44 -0
- package/src/components/schema-editor/Array.tsx +3 -1
- package/src/components/schema-editor/Common.tsx +61 -4
- package/src/components/schema-editor/Object.tsx +3 -1
- package/src/components/schema-editor/index.tsx +12 -5
- package/src/components/table/ItemActionsWrapper.tsx +32 -0
- package/src/components/table/index.tsx +115 -58
- package/src/hooks/use-validation-resolver.ts +45 -0
- package/src/icons/department.svg +17 -0
- package/src/icons/menu.svg +2 -0
- package/src/icons/post.svg +15 -0
- package/src/icons/role.svg +14 -0
- package/src/icons/user-remove.svg +12 -0
- package/src/index.tsx +2 -0
- package/src/locale/de-DE.ts +11 -1
- package/src/locale/en-US.ts +12 -1
- package/src/locale/zh-CN.ts +14 -3
- package/src/renderers/Action.tsx +10 -9
- package/src/renderers/CRUD.tsx +5 -1
- package/src/renderers/Dialog.tsx +9 -3
- package/src/renderers/Drawer.tsx +5 -1
- package/src/renderers/Form/InputDate.tsx +9 -4
- package/src/renderers/Form/JSONSchema.tsx +56 -0
- package/src/renderers/Form/JSONSchemaEditor.tsx +8 -27
- package/src/renderers/Form/Options.tsx +17 -7
- package/src/renderers/Form/Textarea.tsx +7 -117
- package/src/renderers/Form/UserSelect.tsx +263 -0
- package/src/renderers/Form/index.tsx +28 -18
- package/src/renderers/Form/wrapControl.tsx +0 -1
- package/src/renderers/Log.tsx +213 -19
- package/src/renderers/Page.tsx +6 -1
- package/src/renderers/Service.tsx +5 -1
- package/src/renderers/Table-v2/index.tsx +65 -2
- package/src/renderers/Wizard.tsx +24 -10
- package/src/store/form.ts +24 -17
- package/src/utils/api.ts +1 -1
- package/src/utils/renderer-event.ts +0 -2
@@ -663,7 +663,7 @@ export default class Form extends React.Component<FormProps, object> {
|
|
663
663
|
}
|
664
664
|
|
665
665
|
// 派发init事件,参数为初始化数据
|
666
|
-
const dispatcher = dispatchEvent(
|
666
|
+
const dispatcher = await dispatchEvent(
|
667
667
|
'inited',
|
668
668
|
createObject(this.props.data, data)
|
669
669
|
);
|
@@ -767,7 +767,7 @@ export default class Form extends React.Component<FormProps, object> {
|
|
767
767
|
if (result) {
|
768
768
|
dispatchEvent('validateSucc', data);
|
769
769
|
} else {
|
770
|
-
dispatchEvent('
|
770
|
+
dispatchEvent('validateError', data);
|
771
771
|
}
|
772
772
|
return result;
|
773
773
|
});
|
@@ -794,9 +794,7 @@ export default class Form extends React.Component<FormProps, object> {
|
|
794
794
|
submit(fn?: (values: object) => Promise<any>): Promise<any> {
|
795
795
|
const {store, messages, translate: __, dispatchEvent, data} = this.props;
|
796
796
|
this.flush();
|
797
|
-
const validateErrCb = () =>
|
798
|
-
dispatchEvent('validateFail', data);
|
799
|
-
};
|
797
|
+
const validateErrCb = () => dispatchEvent('validateError', data);
|
800
798
|
return store.submit(
|
801
799
|
fn,
|
802
800
|
this.hooks['validate'] || [],
|
@@ -871,13 +869,13 @@ export default class Form extends React.Component<FormProps, object> {
|
|
871
869
|
};
|
872
870
|
}
|
873
871
|
|
874
|
-
emitChange(submit: boolean) {
|
872
|
+
async emitChange(submit: boolean) {
|
875
873
|
const {onChange, store, submitOnChange, dispatchEvent, data} = this.props;
|
876
874
|
|
877
875
|
if (!isAlive(store)) {
|
878
876
|
return;
|
879
877
|
}
|
880
|
-
const dispatcher = dispatchEvent('change', createObject(data, store.data));
|
878
|
+
const dispatcher = await dispatchEvent('change', createObject(data, store.data));
|
881
879
|
if (!dispatcher?.prevented) {
|
882
880
|
onChange &&
|
883
881
|
onChange(
|
@@ -980,10 +978,12 @@ export default class Form extends React.Component<FormProps, object> {
|
|
980
978
|
data = store.data;
|
981
979
|
}
|
982
980
|
if (Array.isArray(action.required) && action.required.length) {
|
983
|
-
return store.validateFields(action.required).then(result => {
|
981
|
+
return store.validateFields(action.required).then(async result => {
|
984
982
|
if (!result) {
|
985
|
-
dispatchEvent('validateError', this.props.data);
|
986
|
-
|
983
|
+
const dispatcher = await dispatchEvent('validateError', this.props.data);
|
984
|
+
if (!dispatcher?.prevented) {
|
985
|
+
env.notify('error', __('Form.validateFailed'));
|
986
|
+
}
|
987
987
|
} else {
|
988
988
|
dispatchEvent('validateSucc', this.props.data);
|
989
989
|
this.handleAction(
|
@@ -1039,9 +1039,9 @@ export default class Form extends React.Component<FormProps, object> {
|
|
1039
1039
|
.saveRemote(action.api || (api as Api), values, {
|
1040
1040
|
successMessage: saveSuccess,
|
1041
1041
|
errorMessage: saveFailed,
|
1042
|
-
onSuccess: (result: Payload) => {
|
1042
|
+
onSuccess: async (result: Payload) => {
|
1043
1043
|
// result为提交接口返回的内容
|
1044
|
-
dispatchEvent(
|
1044
|
+
const dispatcher = await dispatchEvent(
|
1045
1045
|
'submitSucc',
|
1046
1046
|
createObject(this.props.data, {result})
|
1047
1047
|
);
|
@@ -1049,20 +1049,30 @@ export default class Form extends React.Component<FormProps, object> {
|
|
1049
1049
|
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
1050
1050
|
store.data[finishedField || 'finished']
|
1051
1051
|
) {
|
1052
|
-
return
|
1052
|
+
return {
|
1053
|
+
cbResult: null,
|
1054
|
+
dispatcher
|
1055
|
+
};
|
1053
1056
|
}
|
1054
|
-
|
1057
|
+
const cbResult = until(
|
1055
1058
|
() => store.checkRemote(finnalAsyncApi as Api, store.data),
|
1056
1059
|
(ret: any) => ret && ret[finishedField || 'finished'],
|
1057
1060
|
cancel => (this.asyncCancel = cancel),
|
1058
1061
|
checkInterval
|
1059
|
-
)
|
1062
|
+
)
|
1063
|
+
return {
|
1064
|
+
cbResult,
|
1065
|
+
dispatcher
|
1066
|
+
};
|
1060
1067
|
},
|
1061
|
-
onFailed: (result: Payload) => {
|
1062
|
-
dispatchEvent(
|
1068
|
+
onFailed: async (result: Payload) => {
|
1069
|
+
const dispatcher = await dispatchEvent(
|
1063
1070
|
'submitFail',
|
1064
1071
|
createObject(this.props.data, {error: result})
|
1065
1072
|
);
|
1073
|
+
return {
|
1074
|
+
dispatcher
|
1075
|
+
};
|
1066
1076
|
}
|
1067
1077
|
})
|
1068
1078
|
.then(async response => {
|
@@ -1183,7 +1193,7 @@ export default class Form extends React.Component<FormProps, object> {
|
|
1183
1193
|
})
|
1184
1194
|
.catch(e => {
|
1185
1195
|
onFailed && onFailed(e, store.errors);
|
1186
|
-
if (throwErrors) {
|
1196
|
+
if (throwErrors || action.countDown) {
|
1187
1197
|
throw e;
|
1188
1198
|
}
|
1189
1199
|
});
|
package/src/renderers/Log.tsx
CHANGED
@@ -3,10 +3,22 @@
|
|
3
3
|
*/
|
4
4
|
import React from 'react';
|
5
5
|
import {Renderer, RendererProps} from '../factory';
|
6
|
-
import {BaseSchema
|
6
|
+
import {BaseSchema} from '../Schema';
|
7
7
|
import Ansi from 'ansi-to-react';
|
8
|
-
import {filter} from '../utils/tpl';
|
9
8
|
import {buildApi, isApiOutdated} from '../utils/api';
|
9
|
+
import VirtualList from '../components/virtual-list';
|
10
|
+
import Button from '../components/Button';
|
11
|
+
import {
|
12
|
+
InputClearIcon,
|
13
|
+
LeftArrowIcon,
|
14
|
+
MinusIcon,
|
15
|
+
PauseIcon,
|
16
|
+
PlusIcon,
|
17
|
+
ReloadIcon,
|
18
|
+
RightArrowIcon
|
19
|
+
} from '../components/icons';
|
20
|
+
|
21
|
+
export type LogOperation = 'stop' | 'restart' | 'showLineNumber' | 'clear';
|
10
22
|
|
11
23
|
/**
|
12
24
|
* 日志展示组件
|
@@ -42,6 +54,26 @@ export interface LogSchema extends BaseSchema {
|
|
42
54
|
* 返回内容字符编码
|
43
55
|
*/
|
44
56
|
encoding?: string;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* 限制最大日志数量
|
60
|
+
*/
|
61
|
+
maxLength?: number;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* 每行高度
|
65
|
+
*/
|
66
|
+
rowHeight?: number;
|
67
|
+
|
68
|
+
/**
|
69
|
+
* 关闭 ANSI 颜色支持
|
70
|
+
*/
|
71
|
+
disableColor?: boolean;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* 一些可操作选项
|
75
|
+
*/
|
76
|
+
operation?: Array<LogOperation>;
|
45
77
|
}
|
46
78
|
|
47
79
|
export interface LogProps
|
@@ -51,6 +83,9 @@ export interface LogProps
|
|
51
83
|
export interface LogState {
|
52
84
|
lastLine: string;
|
53
85
|
logs: string[];
|
86
|
+
refresh: boolean;
|
87
|
+
showLineNumber: boolean;
|
88
|
+
showOperation: boolean;
|
54
89
|
}
|
55
90
|
|
56
91
|
export class Log extends React.Component<LogProps, LogState> {
|
@@ -69,7 +104,10 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
69
104
|
|
70
105
|
state: LogState = {
|
71
106
|
lastLine: '',
|
72
|
-
logs: []
|
107
|
+
logs: [],
|
108
|
+
refresh: true,
|
109
|
+
showLineNumber: false,
|
110
|
+
showOperation: false
|
73
111
|
};
|
74
112
|
|
75
113
|
constructor(props: LogProps) {
|
@@ -124,8 +162,38 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
124
162
|
}
|
125
163
|
}
|
126
164
|
|
165
|
+
refresh = () => {
|
166
|
+
let origin = this.state.refresh;
|
167
|
+
this.setState({
|
168
|
+
refresh: !origin
|
169
|
+
});
|
170
|
+
if (!origin) {
|
171
|
+
this.clear();
|
172
|
+
this.loadLogs();
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
176
|
+
clear = () => {
|
177
|
+
this.setState({
|
178
|
+
logs: [],
|
179
|
+
lastLine: ''
|
180
|
+
});
|
181
|
+
};
|
182
|
+
|
183
|
+
changeShowLineNumber = () => {
|
184
|
+
this.setState({
|
185
|
+
showLineNumber: !this.state.showLineNumber
|
186
|
+
});
|
187
|
+
};
|
188
|
+
|
189
|
+
changeShowOperation = () => {
|
190
|
+
this.setState({
|
191
|
+
showOperation: !this.state.showOperation
|
192
|
+
});
|
193
|
+
};
|
194
|
+
|
127
195
|
async loadLogs() {
|
128
|
-
const {source, data, env, translate: __, encoding} = this.props;
|
196
|
+
const {source, data, env, translate: __, encoding, maxLength} = this.props;
|
129
197
|
// 因为这里返回结果是流式的,和普通 api 请求不一样,如果直接用 fetcher 经过 responseAdaptor 可能会导致出错,所以就直接 fetch 了
|
130
198
|
const api = buildApi(source, data);
|
131
199
|
if (!api.url) {
|
@@ -146,6 +214,12 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
146
214
|
let lastline = '';
|
147
215
|
let logs: string[] = [];
|
148
216
|
for (;;) {
|
217
|
+
if (!this.state.refresh) {
|
218
|
+
await reader.cancel('click cancel button').then(() => {
|
219
|
+
this.props.env.notify('success', '日志已经停止刷新');
|
220
|
+
return;
|
221
|
+
});
|
222
|
+
}
|
149
223
|
let {done, value} = await reader.read();
|
150
224
|
if (value) {
|
151
225
|
let text = new TextDecoder(encoding).decode(value, {stream: true});
|
@@ -162,6 +236,11 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
162
236
|
lines[0] = lastline + lines[0];
|
163
237
|
// 最后一个要么是空,要么是下一行的数据
|
164
238
|
lastline = lines.pop() || '';
|
239
|
+
if (maxLength) {
|
240
|
+
if (logs.length + lines.length > maxLength) {
|
241
|
+
logs.splice(0, logs.length + lines.length - maxLength);
|
242
|
+
}
|
243
|
+
}
|
165
244
|
logs = logs.concat(lines);
|
166
245
|
this.setState({
|
167
246
|
logs: logs,
|
@@ -180,6 +259,21 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
180
259
|
}
|
181
260
|
}
|
182
261
|
|
262
|
+
/**
|
263
|
+
* 渲染某一行
|
264
|
+
*/
|
265
|
+
renderLine(index: number, line: string, showLineNumber: boolean) {
|
266
|
+
const {classnames: cx, disableColor} = this.props;
|
267
|
+
return (
|
268
|
+
<div className={cx('Log-line')} key={index}>
|
269
|
+
{showLineNumber && (
|
270
|
+
<span className={cx('Log-line-number')}>{index + 1} </span>
|
271
|
+
)}
|
272
|
+
{disableColor ? line : <Ansi useClasses>{line}</Ansi>}
|
273
|
+
</div>
|
274
|
+
);
|
275
|
+
}
|
276
|
+
|
183
277
|
render() {
|
184
278
|
const {
|
185
279
|
source,
|
@@ -187,32 +281,132 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
187
281
|
classnames: cx,
|
188
282
|
placeholder,
|
189
283
|
height,
|
190
|
-
|
284
|
+
rowHeight,
|
285
|
+
disableColor,
|
286
|
+
translate: __,
|
287
|
+
operation,
|
288
|
+
env
|
191
289
|
} = this.props;
|
192
290
|
|
291
|
+
const {refresh, showLineNumber, showOperation} = this.state;
|
292
|
+
|
193
293
|
let loading = __(placeholder);
|
194
294
|
|
195
295
|
if (!source) {
|
196
296
|
loading = __('Log.mustHaveSource');
|
197
297
|
}
|
298
|
+
let lines: any;
|
198
299
|
|
199
|
-
const
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
300
|
+
const logs = this.state.lastLine
|
301
|
+
? this.state.logs.concat([this.state.lastLine])
|
302
|
+
: this.state.logs;
|
303
|
+
|
304
|
+
// 如果设置 rowHeight 就开启延迟渲染
|
305
|
+
const useVirtualRender = rowHeight;
|
306
|
+
|
307
|
+
if (useVirtualRender) {
|
308
|
+
lines = (
|
309
|
+
<VirtualList
|
310
|
+
height={height as number}
|
311
|
+
itemCount={logs.length}
|
312
|
+
itemSize={rowHeight}
|
313
|
+
renderItem={({index, style}) => (
|
314
|
+
<div
|
315
|
+
className={cx('Log-line')}
|
316
|
+
key={index}
|
317
|
+
style={{...style, whiteSpace: 'nowrap'}}
|
318
|
+
>
|
319
|
+
{showLineNumber && (
|
320
|
+
<span className={cx('Log-line-number')}>{index + 1} </span>
|
321
|
+
)}
|
322
|
+
{disableColor ? (
|
323
|
+
logs[index]
|
324
|
+
) : (
|
325
|
+
<Ansi useClasses>{logs[index]}</Ansi>
|
326
|
+
)}
|
327
|
+
</div>
|
328
|
+
)}
|
329
|
+
/>
|
204
330
|
);
|
205
|
-
}
|
331
|
+
} else {
|
332
|
+
lines = logs.map((line, index) => {
|
333
|
+
return this.renderLine(index, line, showLineNumber);
|
334
|
+
});
|
335
|
+
}
|
206
336
|
|
207
337
|
return (
|
208
|
-
<div
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
338
|
+
<div className={cx('Log', className)}>
|
339
|
+
<div
|
340
|
+
ref={this.logRef}
|
341
|
+
className={cx('Log-body')}
|
342
|
+
style={{height: useVirtualRender ? 'auto' : height}}
|
343
|
+
>
|
344
|
+
{useVirtualRender ? lines : lines.length ? lines : loading}
|
345
|
+
</div>
|
346
|
+
<div className={cx('Log-operation')}>
|
347
|
+
{operation &&
|
348
|
+
operation?.length > 0 &&
|
349
|
+
(showOperation ? (
|
350
|
+
<>
|
351
|
+
{operation.includes('stop') && (
|
352
|
+
<Button
|
353
|
+
size="sm"
|
354
|
+
title="__('stop')"
|
355
|
+
disabled={!refresh}
|
356
|
+
onClick={this.refresh}
|
357
|
+
>
|
358
|
+
<PauseIcon />
|
359
|
+
</Button>
|
360
|
+
)}
|
361
|
+
|
362
|
+
{operation.includes('restart') && (
|
363
|
+
<Button
|
364
|
+
size="sm"
|
365
|
+
title={__('reload')}
|
366
|
+
disabled={refresh}
|
367
|
+
onClick={this.refresh}
|
368
|
+
>
|
369
|
+
<ReloadIcon />
|
370
|
+
</Button>
|
371
|
+
)}
|
372
|
+
|
373
|
+
{operation.includes('showLineNumber') && (
|
374
|
+
<Button
|
375
|
+
size="sm"
|
376
|
+
title={
|
377
|
+
showLineNumber
|
378
|
+
? __('Log.notShowLineNumber')
|
379
|
+
: __('Log.showLineNumber')
|
380
|
+
}
|
381
|
+
onClick={this.changeShowLineNumber}
|
382
|
+
>
|
383
|
+
{showLineNumber ? <MinusIcon /> : <PlusIcon />}
|
384
|
+
</Button>
|
385
|
+
)}
|
386
|
+
|
387
|
+
{operation.includes('clear') && (
|
388
|
+
<Button size="sm" title={__('clear')} onClick={this.clear}>
|
389
|
+
<InputClearIcon />
|
390
|
+
</Button>
|
391
|
+
)}
|
392
|
+
|
393
|
+
<Button
|
394
|
+
size="sm"
|
395
|
+
title={__('Log.collapse')}
|
396
|
+
onClick={this.changeShowOperation}
|
397
|
+
>
|
398
|
+
<LeftArrowIcon />
|
399
|
+
</Button>
|
400
|
+
</>
|
401
|
+
) : (
|
402
|
+
<div
|
403
|
+
title={__('Log.expand')}
|
404
|
+
className={cx('Log-operation-hidden')}
|
405
|
+
onClick={this.changeShowOperation}
|
406
|
+
>
|
407
|
+
<RightArrowIcon />
|
408
|
+
</div>
|
409
|
+
))}
|
216
410
|
</div>
|
217
411
|
</div>
|
218
412
|
);
|
package/src/renderers/Page.tsx
CHANGED
@@ -467,6 +467,7 @@ export default class Page extends React.Component<PageProps> {
|
|
467
467
|
store.openDrawer(ctx);
|
468
468
|
} else if (action.actionType === 'ajax') {
|
469
469
|
store.setCurrentAction(action);
|
470
|
+
|
470
471
|
return store
|
471
472
|
.saveRemote(action.api as string, ctx, {
|
472
473
|
successMessage:
|
@@ -486,7 +487,11 @@ export default class Page extends React.Component<PageProps> {
|
|
486
487
|
redirect && env.jumpTo(redirect, action);
|
487
488
|
action.reload && this.reloadTarget(action.reload, store.data);
|
488
489
|
})
|
489
|
-
.catch(() => {
|
490
|
+
.catch((e) => {
|
491
|
+
if (throwErrors || action.countDown) {
|
492
|
+
throw e;
|
493
|
+
}
|
494
|
+
});
|
490
495
|
} else {
|
491
496
|
return onAction(e, action, ctx, throwErrors, delegate || this.context);
|
492
497
|
}
|
@@ -523,7 +523,11 @@ export default class Service extends React.Component<ServiceProps> {
|
|
523
523
|
redirect && env.jumpTo(redirect, action);
|
524
524
|
action.reload && this.reloadTarget(action.reload, store.data);
|
525
525
|
})
|
526
|
-
.catch(() => {
|
526
|
+
.catch((e) => {
|
527
|
+
if (throwErrors || action.countDown) {
|
528
|
+
throw e;
|
529
|
+
}
|
530
|
+
});
|
527
531
|
} else {
|
528
532
|
onAction(e, action, data, throwErrors, delegate || this.context);
|
529
533
|
}
|
@@ -113,6 +113,21 @@ export interface ColumnSchema {
|
|
113
113
|
* 当前列是否展示
|
114
114
|
*/
|
115
115
|
toggled?: boolean;
|
116
|
+
|
117
|
+
/**
|
118
|
+
* 列样式
|
119
|
+
*/
|
120
|
+
className?: string;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* 表头单元格样式
|
124
|
+
*/
|
125
|
+
titleClassName?: string;
|
126
|
+
|
127
|
+
/**
|
128
|
+
* 单元格样式
|
129
|
+
*/
|
130
|
+
classNameExpr?: string;
|
116
131
|
}
|
117
132
|
|
118
133
|
export interface RowSelectionOptionsSchema {
|
@@ -156,7 +171,7 @@ export interface RowSelectionSchema {
|
|
156
171
|
/**
|
157
172
|
* 已选择的key值表达式
|
158
173
|
*/
|
159
|
-
selectedRowKeysExpr
|
174
|
+
selectedRowKeysExpr?: string;
|
160
175
|
|
161
176
|
/**
|
162
177
|
* 已选择的key值表达式
|
@@ -583,7 +598,12 @@ export default class TableRenderer extends React.Component<
|
|
583
598
|
}
|
584
599
|
|
585
600
|
return (
|
586
|
-
<div
|
601
|
+
<div
|
602
|
+
key={col}
|
603
|
+
className={cx('Table-head-cell-wrapper', {
|
604
|
+
[`${column.className}`]: !!column.className,
|
605
|
+
[`${column.titleClassName}`]: !!column.titleClassName
|
606
|
+
})}>
|
587
607
|
{content}
|
588
608
|
{remark}
|
589
609
|
{children}
|
@@ -686,6 +706,14 @@ export default class TableRenderer extends React.Component<
|
|
686
706
|
});
|
687
707
|
}
|
688
708
|
|
709
|
+
// 设置了单元格样式
|
710
|
+
if (column.classNameExpr) {
|
711
|
+
clone.className = (record: any, rowIndex: number) => {
|
712
|
+
const className = filter(column.classNameExpr, {record, rowIndex});
|
713
|
+
return `${className}${column.className ? ` ${column.className}` : ''}`;
|
714
|
+
};
|
715
|
+
}
|
716
|
+
|
689
717
|
// 设置了列搜索
|
690
718
|
if (column.searchable) {
|
691
719
|
clone.filterDropdown = (
|
@@ -1129,6 +1157,7 @@ export default class TableRenderer extends React.Component<
|
|
1129
1157
|
classnames: cx,
|
1130
1158
|
placeholder,
|
1131
1159
|
rowClassNameExpr,
|
1160
|
+
itemActions,
|
1132
1161
|
store,
|
1133
1162
|
...rest
|
1134
1163
|
} = this.props;
|
@@ -1233,6 +1262,39 @@ export default class TableRenderer extends React.Component<
|
|
1233
1262
|
};
|
1234
1263
|
}
|
1235
1264
|
|
1265
|
+
let itemActionsConfig = undefined;
|
1266
|
+
if (itemActions) {
|
1267
|
+
const finalActions = Array.isArray(itemActions)
|
1268
|
+
? itemActions.filter(action => !action.hiddenOnHover)
|
1269
|
+
: [];
|
1270
|
+
|
1271
|
+
if (!finalActions.length) {
|
1272
|
+
return null;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
itemActionsConfig = (record: any, rowIndex: number) => {
|
1276
|
+
return (
|
1277
|
+
<div className={cx('Table-itemActions')}>
|
1278
|
+
{finalActions.map((action, index) =>
|
1279
|
+
render(
|
1280
|
+
`itemAction/${index}`,
|
1281
|
+
{
|
1282
|
+
...(action as any),
|
1283
|
+
isMenuItem: true
|
1284
|
+
},
|
1285
|
+
{
|
1286
|
+
key: index,
|
1287
|
+
item: record,
|
1288
|
+
data: record,
|
1289
|
+
rowIndex
|
1290
|
+
}
|
1291
|
+
)
|
1292
|
+
)}
|
1293
|
+
</div>
|
1294
|
+
);
|
1295
|
+
};
|
1296
|
+
}
|
1297
|
+
|
1236
1298
|
return (
|
1237
1299
|
<Table
|
1238
1300
|
{...rest}
|
@@ -1252,6 +1314,7 @@ export default class TableRenderer extends React.Component<
|
|
1252
1314
|
onSort={this.handleSort}
|
1253
1315
|
onFilter={this.handleFilter}
|
1254
1316
|
onDrag={this.handleDragOver}
|
1317
|
+
itemActions={itemActionsConfig}
|
1255
1318
|
></Table>
|
1256
1319
|
);
|
1257
1320
|
}
|
package/src/renderers/Wizard.tsx
CHANGED
@@ -718,23 +718,41 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
718
718
|
|
719
719
|
formStore
|
720
720
|
.saveRemote(action.api || step.api || api!, store.data, {
|
721
|
-
onSuccess: () => {
|
722
|
-
this.dispatchEvent(
|
721
|
+
onSuccess: async (result: any) => {
|
722
|
+
const dispatcher = await this.dispatchEvent(
|
723
|
+
'submitSucc',
|
724
|
+
createObject(this.props.data, {result})
|
725
|
+
);
|
723
726
|
|
724
727
|
if (
|
725
728
|
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
726
729
|
store.data[finishedField || 'finished']
|
727
730
|
) {
|
728
|
-
return
|
731
|
+
return {
|
732
|
+
cbResult: null,
|
733
|
+
dispatcher
|
734
|
+
};
|
729
735
|
}
|
730
736
|
|
731
|
-
|
737
|
+
const cbResult = until(
|
732
738
|
() => store.checkRemote(finnalAsyncApi as Api, store.data),
|
733
739
|
(ret: any) => ret && ret[finishedField || 'finished'],
|
734
740
|
cancel => (this.asyncCancel = cancel)
|
735
741
|
);
|
742
|
+
return {
|
743
|
+
cbResult,
|
744
|
+
dispatcher
|
745
|
+
};
|
736
746
|
},
|
737
|
-
onFailed: error =>
|
747
|
+
onFailed: async (error: any) => {
|
748
|
+
const dispatcher = await this.dispatchEvent(
|
749
|
+
'submitFail',
|
750
|
+
createObject(this.props.data, {error})
|
751
|
+
);
|
752
|
+
return {
|
753
|
+
dispatcher
|
754
|
+
};
|
755
|
+
}
|
738
756
|
})
|
739
757
|
.then(async value => {
|
740
758
|
const feedback = action.feedback;
|
@@ -778,11 +796,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
778
796
|
|
779
797
|
return value;
|
780
798
|
})
|
781
|
-
.catch(error => {
|
782
|
-
this.dispatchEvent('submitFail', {error});
|
783
|
-
store.markSaving(false);
|
784
|
-
console.error(error);
|
785
|
-
});
|
799
|
+
.catch(error => {});
|
786
800
|
} else {
|
787
801
|
onFinished && onFinished(store.data, action);
|
788
802
|
this.setState({completeStep: steps.length});
|