@difizen/libro-widget 0.1.33 → 0.1.34
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.
- package/es/index.d.ts +3 -4
- package/es/index.d.ts.map +1 -1
- package/es/index.js +3 -4
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +5 -0
- package/es/slider/contribution.d.ts +10 -0
- package/es/slider/contribution.d.ts.map +1 -0
- package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js} +15 -9
- package/es/slider/index.d.ts +3 -0
- package/es/slider/index.d.ts.map +1 -0
- package/es/slider/index.js +2 -0
- package/es/slider/index.less +3 -0
- package/es/slider/view.d.ts +23 -0
- package/es/slider/view.d.ts.map +1 -0
- package/es/{widgets/progress-widget-view.js → slider/view.js} +62 -68
- package/es/text/contribution.d.ts +10 -0
- package/es/text/contribution.d.ts.map +1 -0
- package/es/{widgets/text-widget-view-contribution.js → text/contribution.js} +3 -3
- package/es/text/index.d.ts +3 -0
- package/es/text/index.d.ts.map +1 -0
- package/es/text/index.js +2 -0
- package/es/{widgets/text-widget-view.d.ts → text/view.d.ts} +5 -6
- package/es/text/view.d.ts.map +1 -0
- package/es/{widgets/text-widget-view.js → text/view.js} +11 -12
- package/package.json +6 -5
- package/src/index.spec.ts +2 -3
- package/src/index.ts +3 -4
- package/src/module.ts +15 -0
- package/src/slider/contribution.ts +25 -0
- package/src/slider/index.less +3 -0
- package/src/slider/index.ts +2 -0
- package/src/slider/view.tsx +92 -0
- package/src/{widgets/text-widget-view-contribution.ts → text/contribution.ts} +4 -5
- package/src/text/index.ts +2 -0
- package/src/{widgets/text-widget-view.tsx → text/view.tsx} +7 -10
- package/es/base/comm.d.ts +0 -65
- package/es/base/comm.d.ts.map +0 -1
- package/es/base/comm.js +0 -151
- package/es/base/index.d.ts +0 -7
- package/es/base/index.d.ts.map +0 -1
- package/es/base/index.js +0 -6
- package/es/base/libro-widgets.d.ts +0 -79
- package/es/base/libro-widgets.d.ts.map +0 -1
- package/es/base/libro-widgets.js +0 -286
- package/es/base/protocal.d.ts +0 -171
- package/es/base/protocal.d.ts.map +0 -1
- package/es/base/protocal.js +0 -21
- package/es/base/utils.d.ts +0 -27
- package/es/base/utils.d.ts.map +0 -1
- package/es/base/utils.js +0 -59
- package/es/base/version.d.ts +0 -3
- package/es/base/version.d.ts.map +0 -1
- package/es/base/version.js +0 -2
- package/es/base/widget-manager.d.ts +0 -18
- package/es/base/widget-manager.d.ts.map +0 -1
- package/es/base/widget-manager.js +0 -68
- package/es/base/widget-view-contribution.d.ts +0 -10
- package/es/base/widget-view-contribution.d.ts.map +0 -1
- package/es/base/widget-view-contribution.js +0 -36
- package/es/base/widget-view.d.ts +0 -52
- package/es/base/widget-view.d.ts.map +0 -1
- package/es/base/widget-view.js +0 -137
- package/es/components/index.d.ts +0 -3
- package/es/components/index.d.ts.map +0 -1
- package/es/components/index.js +0 -2
- package/es/components/progressBar.d.ts +0 -15
- package/es/components/progressBar.d.ts.map +0 -1
- package/es/components/progressBar.js +0 -20
- package/es/components/progressCircle.d.ts +0 -11
- package/es/components/progressCircle.d.ts.map +0 -1
- package/es/components/progressCircle.js +0 -16
- package/es/widget-module.d.ts +0 -3
- package/es/widget-module.d.ts.map +0 -1
- package/es/widget-module.js +0 -39
- package/es/widgets/hbox-widget-view-contribution.d.ts +0 -10
- package/es/widgets/hbox-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view-contribution.js +0 -39
- package/es/widgets/hbox-widget-view.d.ts +0 -17
- package/es/widgets/hbox-widget-view.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view.js +0 -69
- package/es/widgets/index.d.ts +0 -9
- package/es/widgets/index.d.ts.map +0 -1
- package/es/widgets/index.js +0 -8
- package/es/widgets/index.less +0 -3
- package/es/widgets/instances-progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.d.ts +0 -31
- package/es/widgets/instances-progress-widget-view.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.js +0 -181
- package/es/widgets/progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/progress-widget-view-contribution.js +0 -39
- package/es/widgets/progress-widget-view.d.ts +0 -25
- package/es/widgets/progress-widget-view.d.ts.map +0 -1
- package/es/widgets/text-widget-view-contribution.d.ts +0 -10
- package/es/widgets/text-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/text-widget-view.d.ts.map +0 -1
- package/src/base/comm.ts +0 -152
- package/src/base/index.ts +0 -6
- package/src/base/libro-widgets.ts +0 -207
- package/src/base/protocal.ts +0 -218
- package/src/base/utils.ts +0 -67
- package/src/base/version.ts +0 -2
- package/src/base/widget-manager.ts +0 -41
- package/src/base/widget-view-contribution.ts +0 -14
- package/src/base/widget-view.tsx +0 -146
- package/src/components/index.ts +0 -3
- package/src/components/progressBar.tsx +0 -29
- package/src/components/progressCircle.tsx +0 -18
- package/src/widget-module.ts +0 -68
- package/src/widgets/hbox-widget-view-contribution.ts +0 -20
- package/src/widgets/hbox-widget-view.tsx +0 -64
- package/src/widgets/index.less +0 -3
- package/src/widgets/index.ts +0 -8
- package/src/widgets/instances-progress-widget-view-contribution.ts +0 -20
- package/src/widgets/instances-progress-widget-view.tsx +0 -160
- package/src/widgets/progress-widget-view-contribution.ts +0 -24
- package/src/widgets/progress-widget-view.tsx +0 -85
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Progress } from 'antd';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Props for the ProgressBar.
|
|
5
|
-
*/
|
|
6
|
-
export interface IProgressBarProps {
|
|
7
|
-
/**
|
|
8
|
-
* The current progress percentage, from 0 to 100
|
|
9
|
-
*/
|
|
10
|
-
percent: number;
|
|
11
|
-
/**
|
|
12
|
-
* Width of progress bar in pixel.
|
|
13
|
-
*/
|
|
14
|
-
width?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function ProgressBar(props: IProgressBarProps) {
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
<Progress
|
|
21
|
-
strokeLinecap="butt"
|
|
22
|
-
percent={props.percent}
|
|
23
|
-
strokeWidth={18}
|
|
24
|
-
showInfo={false}
|
|
25
|
-
style={{ width: '200px' }}
|
|
26
|
-
/>
|
|
27
|
-
</>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Progress } from 'antd';
|
|
2
|
-
/**
|
|
3
|
-
* Props for the ProgressBar.
|
|
4
|
-
*/
|
|
5
|
-
export interface IProgressCircleProps {
|
|
6
|
-
/**
|
|
7
|
-
* The current progress percentage, from 0 to 100
|
|
8
|
-
*/
|
|
9
|
-
percent: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function ProgressCircle(props: IProgressCircleProps) {
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<Progress strokeLinecap="butt" type="circle" percent={props.percent} />;
|
|
16
|
-
</>
|
|
17
|
-
);
|
|
18
|
-
}
|
package/src/widget-module.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { LibroKernelManageModule } from '@difizen/libro-kernel';
|
|
2
|
-
import { ManaModule } from '@difizen/mana-app';
|
|
3
|
-
|
|
4
|
-
import { Comm } from './base/comm.js';
|
|
5
|
-
import {
|
|
6
|
-
WidgetsOption,
|
|
7
|
-
LibroWidgetCommFactory,
|
|
8
|
-
WidgetCommOption,
|
|
9
|
-
LibroWidgets,
|
|
10
|
-
LibroWidgetsFactory,
|
|
11
|
-
WidgetView,
|
|
12
|
-
WidgetViewContribution,
|
|
13
|
-
} from './base/index.js';
|
|
14
|
-
import { LibroWidgetManager } from './base/widget-manager.js';
|
|
15
|
-
import { DefaultWidgetViewContribution } from './base/widget-view-contribution.js';
|
|
16
|
-
import { HBoxModelContribution } from './widgets/hbox-widget-view-contribution.js';
|
|
17
|
-
import { HBoxWidget } from './widgets/hbox-widget-view.js';
|
|
18
|
-
import { ProgressWidget } from './widgets/index.js';
|
|
19
|
-
import { InstancesProgressWidgetViewContribution } from './widgets/instances-progress-widget-view-contribution.js';
|
|
20
|
-
import { InstancesProgressWidget } from './widgets/instances-progress-widget-view.js';
|
|
21
|
-
import { ProgressWidgetViewContribution } from './widgets/progress-widget-view-contribution.js';
|
|
22
|
-
import { TextModelContribution } from './widgets/text-widget-view-contribution.js';
|
|
23
|
-
import { LibroTextWidget } from './widgets/text-widget-view.js';
|
|
24
|
-
|
|
25
|
-
export const WidgetModule = ManaModule.create()
|
|
26
|
-
.contribution(WidgetViewContribution)
|
|
27
|
-
.register(
|
|
28
|
-
Comm,
|
|
29
|
-
{
|
|
30
|
-
token: LibroWidgetCommFactory,
|
|
31
|
-
useFactory: (ctx) => {
|
|
32
|
-
return (options: WidgetCommOption) => {
|
|
33
|
-
const child = ctx.container.createChild();
|
|
34
|
-
child.register({
|
|
35
|
-
token: WidgetCommOption,
|
|
36
|
-
useValue: options,
|
|
37
|
-
});
|
|
38
|
-
return child.get(Comm);
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
LibroWidgets,
|
|
43
|
-
{
|
|
44
|
-
token: LibroWidgetsFactory,
|
|
45
|
-
useFactory: (ctx) => {
|
|
46
|
-
return (options: WidgetsOption) => {
|
|
47
|
-
const child = ctx.container.createChild();
|
|
48
|
-
child.register({
|
|
49
|
-
token: WidgetsOption,
|
|
50
|
-
useValue: options,
|
|
51
|
-
});
|
|
52
|
-
return child.get(LibroWidgets);
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
LibroWidgetManager,
|
|
57
|
-
WidgetView,
|
|
58
|
-
ProgressWidget,
|
|
59
|
-
DefaultWidgetViewContribution,
|
|
60
|
-
ProgressWidgetViewContribution,
|
|
61
|
-
InstancesProgressWidgetViewContribution,
|
|
62
|
-
InstancesProgressWidget,
|
|
63
|
-
HBoxModelContribution,
|
|
64
|
-
HBoxWidget,
|
|
65
|
-
LibroTextWidget,
|
|
66
|
-
TextModelContribution,
|
|
67
|
-
)
|
|
68
|
-
.dependOn(LibroKernelManageModule);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
2
|
-
|
|
3
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
4
|
-
import { WidgetViewContribution } from '../base/protocal.js';
|
|
5
|
-
|
|
6
|
-
import { HBoxWidget } from './hbox-widget-view.js';
|
|
7
|
-
|
|
8
|
-
@singleton({ contrib: WidgetViewContribution })
|
|
9
|
-
export class HBoxModelContribution implements WidgetViewContribution {
|
|
10
|
-
@inject(ViewManager) viewManager: ViewManager;
|
|
11
|
-
canHandle = (attributes: any) => {
|
|
12
|
-
if (attributes._model_name === 'HBoxModel') {
|
|
13
|
-
return 100;
|
|
14
|
-
}
|
|
15
|
-
return 1;
|
|
16
|
-
};
|
|
17
|
-
factory(props: IWidgetViewProps) {
|
|
18
|
-
return this.viewManager.getOrCreateView(HBoxWidget, props);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { LibroContextKey } from '@difizen/libro-core';
|
|
2
|
-
import {
|
|
3
|
-
view,
|
|
4
|
-
ViewOption,
|
|
5
|
-
ViewRender,
|
|
6
|
-
transient,
|
|
7
|
-
useInject,
|
|
8
|
-
ViewInstance,
|
|
9
|
-
inject,
|
|
10
|
-
} from '@difizen/mana-app';
|
|
11
|
-
import { forwardRef } from 'react';
|
|
12
|
-
|
|
13
|
-
import { LibroWidgets } from '../base/libro-widgets.js';
|
|
14
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
15
|
-
import { WidgetView } from '../base/widget-view.js';
|
|
16
|
-
import './index.less';
|
|
17
|
-
|
|
18
|
-
export const HBoxWidgetComponent = forwardRef<HTMLDivElement>(
|
|
19
|
-
function HBoxWidgetComponent() {
|
|
20
|
-
const widgetView = useInject<HBoxWidget>(ViewInstance);
|
|
21
|
-
if (widgetView.isCommClosed) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const hboxChildrenWidget = widgetView.get_child_model();
|
|
25
|
-
return (
|
|
26
|
-
<div className="libro-hbox-widget">
|
|
27
|
-
{hboxChildrenWidget.map((childrenWidgets) => (
|
|
28
|
-
<ViewRender view={childrenWidgets} key={childrenWidgets.id} />
|
|
29
|
-
))}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
},
|
|
33
|
-
);
|
|
34
|
-
@transient()
|
|
35
|
-
@view('libro-hbox-widget-view')
|
|
36
|
-
export class HBoxWidget extends WidgetView {
|
|
37
|
-
override view = HBoxWidgetComponent;
|
|
38
|
-
children: string[];
|
|
39
|
-
layout: string;
|
|
40
|
-
box_style: string;
|
|
41
|
-
override libroWidgets: LibroWidgets;
|
|
42
|
-
constructor(
|
|
43
|
-
@inject(ViewOption) props: IWidgetViewProps,
|
|
44
|
-
@inject(LibroContextKey) libroContextKey: LibroContextKey,
|
|
45
|
-
@inject(LibroWidgets) libroWidgets: LibroWidgets,
|
|
46
|
-
) {
|
|
47
|
-
super(props, libroContextKey);
|
|
48
|
-
this.box_style = props.attributes.bar_style;
|
|
49
|
-
this.layout = props.attributes.layout;
|
|
50
|
-
this.children = props.attributes.children;
|
|
51
|
-
this.libroContextKey = libroContextKey;
|
|
52
|
-
this.libroWidgets = libroWidgets;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get_child_model(): WidgetView[] {
|
|
56
|
-
const childrenWidgets: WidgetView[] = [];
|
|
57
|
-
this.children.forEach((child) => {
|
|
58
|
-
if (this.libroWidgets.hasModel(child.substring(10))) {
|
|
59
|
-
childrenWidgets.push(this.libroWidgets.getModel(child.substring(10)));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return childrenWidgets;
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/widgets/index.less
DELETED
package/src/widgets/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './hbox-widget-view.js';
|
|
2
|
-
export * from './hbox-widget-view-contribution.js';
|
|
3
|
-
export * from './instances-progress-widget-view.js';
|
|
4
|
-
export * from './instances-progress-widget-view-contribution.js';
|
|
5
|
-
export * from './progress-widget-view.js';
|
|
6
|
-
export * from './progress-widget-view-contribution.js';
|
|
7
|
-
export * from './text-widget-view.js';
|
|
8
|
-
export * from './text-widget-view-contribution.js';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
2
|
-
|
|
3
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
4
|
-
import { WidgetViewContribution } from '../base/protocal.js';
|
|
5
|
-
|
|
6
|
-
import { InstancesProgressWidget } from './instances-progress-widget-view.js';
|
|
7
|
-
|
|
8
|
-
@singleton({ contrib: WidgetViewContribution })
|
|
9
|
-
export class InstancesProgressWidgetViewContribution implements WidgetViewContribution {
|
|
10
|
-
@inject(ViewManager) viewManager: ViewManager;
|
|
11
|
-
canHandle = (attributes: any) => {
|
|
12
|
-
if (attributes._model_name === 'InstancesProgressModel') {
|
|
13
|
-
return 100;
|
|
14
|
-
}
|
|
15
|
-
return 1;
|
|
16
|
-
};
|
|
17
|
-
factory(props: IWidgetViewProps) {
|
|
18
|
-
return this.viewManager.getOrCreateView(InstancesProgressWidget, props);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { LibroContextKey } from '@difizen/libro-core';
|
|
2
|
-
import type { KernelMessage } from '@difizen/libro-kernel';
|
|
3
|
-
import {
|
|
4
|
-
useInject,
|
|
5
|
-
view,
|
|
6
|
-
ViewInstance,
|
|
7
|
-
ViewOption,
|
|
8
|
-
transient,
|
|
9
|
-
inject,
|
|
10
|
-
prop,
|
|
11
|
-
} from '@difizen/mana-app';
|
|
12
|
-
import { forwardRef } from 'react';
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
InstanceRecord,
|
|
16
|
-
InstancesRecords,
|
|
17
|
-
ProgressItem,
|
|
18
|
-
} from '../base/protocal.js';
|
|
19
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
20
|
-
import { WidgetView } from '../base/widget-view.js';
|
|
21
|
-
import './index.less';
|
|
22
|
-
|
|
23
|
-
export interface ProgressOverviewProps {
|
|
24
|
-
progressMap: Record<string, ProgressItem>;
|
|
25
|
-
workingProgressKeys: string[];
|
|
26
|
-
prefix: string;
|
|
27
|
-
suffix: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const LibroInstancesProgressWidgetViewComponent = forwardRef<HTMLDivElement>(
|
|
31
|
-
function LibroInstancesProgressWidgetViewComponent(_props, ref) {
|
|
32
|
-
const widgetView = useInject<InstancesProgressWidget>(ViewInstance);
|
|
33
|
-
if (widgetView.isCommClosed) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return (
|
|
37
|
-
<div ref={ref} className="libro-instances-progress-widget">
|
|
38
|
-
<span style={{ paddingRight: 5 }}>{widgetView.prefix}</span>
|
|
39
|
-
<span>
|
|
40
|
-
{widgetView.workingProgressKeys.map((progressKey) => {
|
|
41
|
-
const progressItem = widgetView.progressMap[progressKey];
|
|
42
|
-
return (
|
|
43
|
-
<a
|
|
44
|
-
className="pyodps-progress-launcher"
|
|
45
|
-
style={{ marginRight: 5 }}
|
|
46
|
-
key={progressKey}
|
|
47
|
-
>
|
|
48
|
-
{progressItem && progressItem.name}
|
|
49
|
-
</a>
|
|
50
|
-
);
|
|
51
|
-
})}
|
|
52
|
-
</span>
|
|
53
|
-
<span>{widgetView.suffix}</span>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
@transient()
|
|
59
|
-
@view('libro-widget-instances-progress-view')
|
|
60
|
-
export class InstancesProgressWidget extends WidgetView {
|
|
61
|
-
override view = LibroInstancesProgressWidgetViewComponent;
|
|
62
|
-
@prop()
|
|
63
|
-
prefix: string;
|
|
64
|
-
@prop()
|
|
65
|
-
suffix: string;
|
|
66
|
-
progressMap: Record<string, ProgressItem> = {};
|
|
67
|
-
workingProgressKeys: string[] = []; // Order of groups by time of insertion
|
|
68
|
-
instanceRecords: InstancesRecords = {};
|
|
69
|
-
modalVisible = false;
|
|
70
|
-
modalProgressItemKey = '';
|
|
71
|
-
constructor(
|
|
72
|
-
@inject(ViewOption) props: IWidgetViewProps,
|
|
73
|
-
@inject(LibroContextKey) libroContextKey: LibroContextKey,
|
|
74
|
-
) {
|
|
75
|
-
super(props, libroContextKey);
|
|
76
|
-
this.prefix = props.attributes.prefix;
|
|
77
|
-
this.suffix = props.attributes.suffix;
|
|
78
|
-
}
|
|
79
|
-
updateRecords(progressKey: string) {
|
|
80
|
-
const progressItem = this.progressMap[progressKey];
|
|
81
|
-
if (progressItem) {
|
|
82
|
-
const { instances = [] } = progressItem;
|
|
83
|
-
instances.forEach((instance) => {
|
|
84
|
-
const { id, status } = instance;
|
|
85
|
-
if (!this.instanceRecords[id]) {
|
|
86
|
-
this.instanceRecords[id] = {
|
|
87
|
-
startDate: Date.now(),
|
|
88
|
-
} as InstanceRecord;
|
|
89
|
-
}
|
|
90
|
-
if (status === 'Terminated') {
|
|
91
|
-
if (!this.instanceRecords[id].endDate) {
|
|
92
|
-
this.instanceRecords[id].endDate = Date.now();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Handle incoming comm msg.
|
|
100
|
-
*/
|
|
101
|
-
override handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
|
|
102
|
-
const data = msg.content.data as any;
|
|
103
|
-
const method = data.method;
|
|
104
|
-
switch (method) {
|
|
105
|
-
case 'update':
|
|
106
|
-
if (data.state.prefix) {
|
|
107
|
-
this.prefix = data.state.prefix;
|
|
108
|
-
}
|
|
109
|
-
if (data.state.suffix) {
|
|
110
|
-
this.suffix = data.state.suffix;
|
|
111
|
-
}
|
|
112
|
-
// eslint-disable-next-line no-fallthrough
|
|
113
|
-
case 'custom':
|
|
114
|
-
// eslint-disable-next-line no-case-declarations
|
|
115
|
-
const customMsg = data.content;
|
|
116
|
-
if (customMsg) {
|
|
117
|
-
// message format: '{"action": "action", content: ["content1", "content2"]}'
|
|
118
|
-
const msgObj: { action: 'update' | 'delete' | 'clear'; content: string[] } =
|
|
119
|
-
JSON.parse(customMsg);
|
|
120
|
-
const action: string = msgObj.action;
|
|
121
|
-
const content: string[] = [];
|
|
122
|
-
if (msgObj.content) {
|
|
123
|
-
content.push(...msgObj.content);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
switch (action) {
|
|
127
|
-
case 'update':
|
|
128
|
-
content.forEach((groupJson) => {
|
|
129
|
-
const parsedProgressItem: ProgressItem = JSON.parse(groupJson);
|
|
130
|
-
if (!this.progressMap[parsedProgressItem.key]) {
|
|
131
|
-
this.workingProgressKeys.push(parsedProgressItem.key);
|
|
132
|
-
}
|
|
133
|
-
this.progressMap[parsedProgressItem.key] = parsedProgressItem;
|
|
134
|
-
this.updateRecords(parsedProgressItem.key);
|
|
135
|
-
});
|
|
136
|
-
// ? TODO: 发出一个更新 modal signal 的信号,这里需要取到之前的 key
|
|
137
|
-
break;
|
|
138
|
-
case 'delete':
|
|
139
|
-
content.forEach((groupKey: string) => {
|
|
140
|
-
if (!this.progressMap[groupKey]) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const i = this.workingProgressKeys.indexOf(groupKey);
|
|
144
|
-
if (i >= 0) {
|
|
145
|
-
this.workingProgressKeys.splice(i, 1);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
break;
|
|
149
|
-
case 'clear':
|
|
150
|
-
this.progressMap = {};
|
|
151
|
-
this.workingProgressKeys = [];
|
|
152
|
-
// ? TODO: 发出更新 overview 以及 modal 的 signal
|
|
153
|
-
break;
|
|
154
|
-
default:
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return Promise.resolve();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
2
|
-
|
|
3
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
4
|
-
import { WidgetViewContribution } from '../base/protocal.js';
|
|
5
|
-
|
|
6
|
-
import { ProgressWidget } from './progress-widget-view.js';
|
|
7
|
-
|
|
8
|
-
@singleton({ contrib: WidgetViewContribution })
|
|
9
|
-
export class ProgressWidgetViewContribution implements WidgetViewContribution {
|
|
10
|
-
@inject(ViewManager) viewManager: ViewManager;
|
|
11
|
-
canHandle = (attributes: any) => {
|
|
12
|
-
if (
|
|
13
|
-
attributes._model_name === 'FloatProgressModel' ||
|
|
14
|
-
attributes._model_name === 'IntProgressModel' ||
|
|
15
|
-
attributes._model_name === 'TransientProgressModel'
|
|
16
|
-
) {
|
|
17
|
-
return 100;
|
|
18
|
-
}
|
|
19
|
-
return 1;
|
|
20
|
-
};
|
|
21
|
-
factory(props: IWidgetViewProps) {
|
|
22
|
-
return this.viewManager.getOrCreateView(ProgressWidget, props);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { LibroContextKey } from '@difizen/libro-core';
|
|
2
|
-
import type { KernelMessage } from '@difizen/libro-kernel';
|
|
3
|
-
import {
|
|
4
|
-
view,
|
|
5
|
-
ViewOption,
|
|
6
|
-
transient,
|
|
7
|
-
useInject,
|
|
8
|
-
ViewInstance,
|
|
9
|
-
inject,
|
|
10
|
-
prop,
|
|
11
|
-
} from '@difizen/mana-app';
|
|
12
|
-
import { forwardRef } from 'react';
|
|
13
|
-
|
|
14
|
-
import type { IWidgetViewProps } from '../base/protocal.js';
|
|
15
|
-
import { WidgetView } from '../base/widget-view.js';
|
|
16
|
-
import { ProgressBar } from '../components/index.js';
|
|
17
|
-
import './index.less';
|
|
18
|
-
|
|
19
|
-
export const LibroProgressWidgetComponent = forwardRef<HTMLDivElement>(
|
|
20
|
-
function LibroProgressWidgetComponent() {
|
|
21
|
-
const widgetView = useInject<ProgressWidget>(ViewInstance);
|
|
22
|
-
const percent = widgetView.value / ((widgetView.max - widgetView.min) / 100);
|
|
23
|
-
if (widgetView.isCommClosed) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return (
|
|
27
|
-
<div className="libro-progress-widget">
|
|
28
|
-
<div className="libro-progress-widget-description">
|
|
29
|
-
{widgetView.description}
|
|
30
|
-
</div>
|
|
31
|
-
<ProgressBar percent={percent} />
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
@transient()
|
|
37
|
-
@view('libro-widget-progress-view')
|
|
38
|
-
export class ProgressWidget extends WidgetView {
|
|
39
|
-
override view = LibroProgressWidgetComponent;
|
|
40
|
-
bar_style: string;
|
|
41
|
-
description: string;
|
|
42
|
-
description_tooltip: null;
|
|
43
|
-
layout: string;
|
|
44
|
-
@prop()
|
|
45
|
-
max: number;
|
|
46
|
-
@prop()
|
|
47
|
-
min: number;
|
|
48
|
-
orientation: string;
|
|
49
|
-
style: string;
|
|
50
|
-
@prop()
|
|
51
|
-
value: number;
|
|
52
|
-
constructor(
|
|
53
|
-
@inject(ViewOption) props: IWidgetViewProps,
|
|
54
|
-
@inject(LibroContextKey) libroContextKey: LibroContextKey,
|
|
55
|
-
) {
|
|
56
|
-
super(props, libroContextKey);
|
|
57
|
-
this.bar_style = props.attributes.bar_style;
|
|
58
|
-
this.description = props.attributes.description;
|
|
59
|
-
this.description_tooltip = props.attributes.description_tooltip;
|
|
60
|
-
this.layout = props.attributes.layout;
|
|
61
|
-
this.max = props.attributes.max;
|
|
62
|
-
this.min = props.attributes.min;
|
|
63
|
-
this.orientation = props.attributes.orientation;
|
|
64
|
-
this.style = props.attributes.style;
|
|
65
|
-
this.value = props.attributes.value;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handle incoming comm msg.
|
|
69
|
-
*/
|
|
70
|
-
override handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
|
|
71
|
-
const data = msg.content.data as any;
|
|
72
|
-
const method = data.method;
|
|
73
|
-
switch (method) {
|
|
74
|
-
case 'update':
|
|
75
|
-
case 'echo_update':
|
|
76
|
-
if (data.state.value) {
|
|
77
|
-
this.value = data.state.value;
|
|
78
|
-
}
|
|
79
|
-
if (data.state.description) {
|
|
80
|
-
this.description = data.state.description;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return Promise.resolve();
|
|
84
|
-
}
|
|
85
|
-
}
|