@operato/scene-manufacturing 1.3.17 → 1.3.18
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/CHANGELOG.md +9 -0
- package/cache/translations/system/en.json +1 -0
- package/cache/translations/system/ko.json +1 -0
- package/db.sqlite +0 -0
- package/dist/tact-timer.d.ts +7 -3
- package/dist/tact-timer.js +102 -21
- package/dist/tact-timer.js.map +1 -1
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/tact-timer.d.ts +9 -0
- package/dist/templates/tact-timer.js +10 -1
- package/dist/templates/tact-timer.js.map +1 -1
- package/helps/scene/component/manufacturing/tact-timer.ja.md +50 -16
- package/helps/scene/component/manufacturing/tact-timer.ko.md +61 -24
- package/helps/scene/component/manufacturing/tact-timer.md +52 -15
- package/helps/scene/component/manufacturing/tact-timer.ms.md +49 -12
- package/helps/scene/component/manufacturing/tact-timer.zh.md +50 -13
- package/icons/tact-timer-mask.svg +33 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +23 -3
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +25 -0
- package/logs/application-2024-07-05-08.log +105 -0
- package/logs/application-2024-07-05-12.log +105 -0
- package/logs/application-2024-07-06-01.log +105 -0
- package/logs/application-2024-07-06-03.log +105 -0
- package/logs/{application-2024-06-27-22.log → application-2024-07-06-11.log} +8 -9
- package/logs/connections-2024-07-05-08.log +50 -0
- package/logs/connections-2024-07-05-12.log +50 -0
- package/logs/connections-2024-07-06-01.log +50 -0
- package/logs/connections-2024-07-06-03.log +50 -0
- package/logs/connections-2024-07-06-11.log +47 -0
- package/package.json +2 -2
- package/src/tact-timer.ts +108 -27
- package/src/templates/tact-timer.ts +10 -1
- package/translations/en.json +5 -1
- package/translations/ja.json +6 -2
- package/translations/ko.json +5 -1
- package/translations/ms.json +6 -2
- package/translations/zh.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
package/dist/tact-timer.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
1
|
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
|
5
2
|
import format from './libs/format';
|
|
3
|
+
const mask = new URL('../icons/tact-timer-mask.svg', import.meta.url).href;
|
|
6
4
|
const NATURE = {
|
|
7
5
|
mutable: false,
|
|
8
6
|
resizable: true,
|
|
9
7
|
rotatable: true,
|
|
10
8
|
properties: [
|
|
11
9
|
{
|
|
12
|
-
type: '
|
|
13
|
-
label: '
|
|
14
|
-
name: '
|
|
15
|
-
placeholder: '
|
|
10
|
+
type: 'string',
|
|
11
|
+
label: 'start-time',
|
|
12
|
+
name: 'startTime',
|
|
13
|
+
placeholder: 'YYYYMMDDhhmmss'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'string',
|
|
17
|
+
label: 'end-time',
|
|
18
|
+
name: 'endTime',
|
|
19
|
+
placeholder: 'YYYYMMDDhhmmss'
|
|
16
20
|
},
|
|
17
21
|
{
|
|
18
22
|
type: 'string',
|
|
@@ -68,12 +72,33 @@ const NATURE = {
|
|
|
68
72
|
type: 'boolean',
|
|
69
73
|
label: 'auto-start',
|
|
70
74
|
name: 'autoStart'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
label: 'show-progress',
|
|
79
|
+
name: 'showProgress'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
label: 'show-timer',
|
|
84
|
+
name: 'showTimer'
|
|
71
85
|
}
|
|
72
86
|
],
|
|
73
|
-
'value-property': 'tactTime',
|
|
74
87
|
help: 'scene/component/manufacturing/tact-timer'
|
|
75
88
|
};
|
|
76
89
|
export default class TactTimer extends RectPath(Shape) {
|
|
90
|
+
constructor() {
|
|
91
|
+
super(...arguments);
|
|
92
|
+
this._start = 0;
|
|
93
|
+
this._due = 0;
|
|
94
|
+
}
|
|
95
|
+
static get mask() {
|
|
96
|
+
if (!TactTimer.MASK) {
|
|
97
|
+
TactTimer.MASK = new Image();
|
|
98
|
+
TactTimer.MASK.src = mask;
|
|
99
|
+
}
|
|
100
|
+
return TactTimer.MASK;
|
|
101
|
+
}
|
|
77
102
|
get nature() {
|
|
78
103
|
return NATURE;
|
|
79
104
|
}
|
|
@@ -87,11 +112,17 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
start() {
|
|
90
|
-
|
|
91
|
-
this.
|
|
115
|
+
const { startTime, endTime } = this.state;
|
|
116
|
+
const start = this.parseTime(startTime);
|
|
117
|
+
const end = this.parseTime(endTime);
|
|
118
|
+
if (start && end) {
|
|
119
|
+
this._due = end.getTime();
|
|
120
|
+
this._start = start.getTime();
|
|
121
|
+
this.counting();
|
|
122
|
+
}
|
|
92
123
|
}
|
|
93
124
|
onchange(after) {
|
|
94
|
-
if ('
|
|
125
|
+
if ('startTime' in after || 'endTime' in after) {
|
|
95
126
|
this.start();
|
|
96
127
|
}
|
|
97
128
|
}
|
|
@@ -100,9 +131,15 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
100
131
|
return;
|
|
101
132
|
}
|
|
102
133
|
requestAnimationFrame(() => {
|
|
134
|
+
const { showTimer } = this.state;
|
|
103
135
|
const countdown = this.countdown;
|
|
104
|
-
|
|
105
|
-
|
|
136
|
+
if (showTimer) {
|
|
137
|
+
const text = format(Math.abs(countdown), this.getState('format'));
|
|
138
|
+
this.text = text;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.text = '';
|
|
142
|
+
}
|
|
106
143
|
this.setState('data', this.countdown);
|
|
107
144
|
setTimeout(() => {
|
|
108
145
|
this.counting();
|
|
@@ -110,9 +147,10 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
110
147
|
});
|
|
111
148
|
}
|
|
112
149
|
render(context) {
|
|
113
|
-
var {
|
|
150
|
+
var { top, left, height, width, round = 0, fontColor, increaseFontColor, decreaseFontColor, increaseProgressColor = 'transparent', decreaseProgressColor = 'transparent', underThresholdColor = 'transparent', progressDirection = 'increase', progressThreshold = 0, showProgress, showTimer } = this.state;
|
|
114
151
|
const increase = this.countdown > 0;
|
|
115
|
-
const
|
|
152
|
+
const totalDuration = (this._due - this._start) / 1000;
|
|
153
|
+
const underThreshold = this.countdown / totalDuration < progressThreshold / 100;
|
|
116
154
|
// progress의 색상
|
|
117
155
|
context.beginPath();
|
|
118
156
|
context.roundRect(left, top, width, height, round);
|
|
@@ -120,7 +158,10 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
120
158
|
this.drawFill(context);
|
|
121
159
|
// value의 색상
|
|
122
160
|
context.beginPath();
|
|
123
|
-
|
|
161
|
+
if (!showProgress) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var progress = Math.abs((this.countdown / totalDuration) * 100);
|
|
124
165
|
if (!isNaN(progress)) {
|
|
125
166
|
progress = width - (width * progress) / 100;
|
|
126
167
|
progress = Math.max(Math.min(progress, width), 0);
|
|
@@ -138,6 +179,7 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
138
179
|
context.fill();
|
|
139
180
|
context.beginPath();
|
|
140
181
|
}
|
|
182
|
+
this.drawImage(context, TactTimer.mask, left, top, width, height);
|
|
141
183
|
context.roundRect(left, top, width, height, round);
|
|
142
184
|
this.setState('fontColor', (increase ? increaseFontColor : decreaseFontColor) || fontColor);
|
|
143
185
|
}
|
|
@@ -145,17 +187,56 @@ export default class TactTimer extends RectPath(Shape) {
|
|
|
145
187
|
this.drawStroke(context);
|
|
146
188
|
this.drawText(context);
|
|
147
189
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
parseTime(timeString) {
|
|
191
|
+
if (!timeString || timeString.length !== 14) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const year = parseInt(timeString.slice(0, 4), 10);
|
|
195
|
+
const month = parseInt(timeString.slice(4, 6), 10) - 1;
|
|
196
|
+
const day = parseInt(timeString.slice(6, 8), 10);
|
|
197
|
+
const hour = parseInt(timeString.slice(8, 10), 10);
|
|
198
|
+
const minute = parseInt(timeString.slice(10, 12), 10);
|
|
199
|
+
const second = parseInt(timeString.slice(12, 14), 10);
|
|
200
|
+
return new Date(year, month, day, hour, minute, second);
|
|
153
201
|
}
|
|
154
202
|
get countdown() {
|
|
155
203
|
const due = this._due || 0;
|
|
156
204
|
const now = Date.now();
|
|
157
205
|
return Math.round((due - now) / 1000);
|
|
158
206
|
}
|
|
207
|
+
get value() {
|
|
208
|
+
const { startTime, endTime } = this.state;
|
|
209
|
+
return [startTime, endTime];
|
|
210
|
+
}
|
|
211
|
+
set value(v) {
|
|
212
|
+
if (v instanceof Array) {
|
|
213
|
+
const [startTime, endTime] = v;
|
|
214
|
+
this.setState({
|
|
215
|
+
startTime,
|
|
216
|
+
endTime
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else if (typeof v == 'object') {
|
|
220
|
+
const { startTime, endTime } = v;
|
|
221
|
+
this.setState({
|
|
222
|
+
startTime,
|
|
223
|
+
endTime
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else if (typeof v == 'string') {
|
|
227
|
+
const [startTime, endTime] = v.split(/[-+/%$#_,]+/);
|
|
228
|
+
this.setState({
|
|
229
|
+
startTime,
|
|
230
|
+
endTime
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
this.setState({
|
|
235
|
+
startTime: undefined,
|
|
236
|
+
endTime: undefined
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
159
240
|
}
|
|
160
241
|
Component.register('tact-timer', TactTimer);
|
|
161
242
|
//# sourceMappingURL=tact-timer.js.map
|
package/dist/tact-timer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tact-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;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IACvC,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\nimport format from './libs/format'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'tact-time',\n name: 'tactTime',\n placeholder: 'seconds'\n },\n {\n type: 'string',\n label: 'format',\n name: 'format',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'select',\n label: 'progress-direction',\n name: 'progressDirection',\n property: {\n options: ['', 'increase', 'decrease']\n }\n },\n {\n type: 'color',\n label: 'increase-progress-color',\n name: 'increaseProgressColor'\n },\n {\n type: 'color',\n label: 'decrease-progress-color',\n name: 'decreaseProgressColor'\n },\n {\n type: 'color',\n label: 'increase-font-color',\n name: 'increaseFontColor'\n },\n {\n type: 'color',\n label: 'decrese-font-color',\n name: 'decreaseFontColor'\n },\n {\n type: 'color',\n label: 'under-threshold-color',\n name: 'underThresholdColor'\n },\n {\n type: 'number',\n label: 'progress-threshold',\n name: 'progressThreshold',\n placeholder: '%'\n },\n {\n type: 'number',\n label: 'round',\n name: 'round'\n },\n {\n type: 'boolean',\n label: 'auto-start',\n name: 'autoStart'\n }\n ],\n 'value-property': 'tactTime',\n help: 'scene/component/manufacturing/tact-timer'\n}\n\nexport default class TactTimer extends RectPath(Shape) {\n private _due?: number\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n const { autoStart } = this.state\n\n if (autoStart) {\n this.start()\n }\n }\n\n start() {\n this._due = Date.now() + this.tactTime * 1000\n this.counting()\n }\n\n onchange(after: Properties) {\n if ('tactTime' in after) {\n this.start()\n }\n }\n\n counting() {\n if (this.disposed) {\n return\n }\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n const text = format(Math.abs(countdown), this.getState('format'))\n this.text = text\n\n this.setState('data', this.countdown)\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var {\n tactTime,\n top,\n left,\n height,\n width,\n round = 0,\n fontColor,\n increaseFontColor,\n decreaseFontColor,\n increaseProgressColor = 'transparent',\n decreaseProgressColor = 'transparent',\n underThresholdColor = 'transparent',\n progressDirection = 'increase',\n progressThreshold = 0\n } = this.state\n\n const increase = this.countdown > 0\n const underThreshold = this.countdown / tactTime < progressThreshold / 100\n\n // progress의 색상\n context.beginPath()\n context.roundRect(left, top, width, height, round)\n context.clip()\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = Math.abs((this.countdown / tactTime) * 100)\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n if (progressDirection == 'increase') {\n context.rect(left, top, progress, height)\n } else {\n context.rect(left + progress, top, width - progress, height)\n }\n\n context.fillStyle = increase\n ? underThreshold\n ? underThresholdColor\n : increaseProgressColor\n : decreaseProgressColor\n context.fill()\n\n context.beginPath()\n }\n\n context.roundRect(left, top, width, height, round)\n\n this.setState('fontColor', (increase ? increaseFontColor : decreaseFontColor) || fontColor)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get tactTime() {\n return Number(this.getState('tactTime') || 0)\n }\n\n set tactTime(tactTime) {\n this.setState('tactTime', Number(tactTime) || 0)\n }\n\n get countdown() {\n const due = this._due || 0\n const now = Date.now()\n\n return Math.round((due - now) / 1000)\n }\n}\n\nComponent.register('tact-timer', TactTimer)\n"]}
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O,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,KAAK,CAAC,CAAC;QACT,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;YAC9B,IAAI,CAAC,QAAQ,CAAC;gBACZ,SAAS;gBACT,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;YAChC,IAAI,CAAC,QAAQ,CAAC;gBACZ,SAAS;gBACT,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAI,CAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;YAC/D,IAAI,CAAC,QAAQ,CAAC;gBACZ,SAAS;gBACT,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,CAAC;gBACZ,SAAS,EAAE,SAAS;gBACpB,OAAO,EAAE,SAAS;aACnB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\nimport format from './libs/format'\n\nconst mask = new URL('../icons/tact-timer-mask.svg', import.meta.url).href\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'string',\n label: 'start-time',\n name: 'startTime',\n placeholder: 'YYYYMMDDhhmmss'\n },\n {\n type: 'string',\n label: 'end-time',\n name: 'endTime',\n placeholder: 'YYYYMMDDhhmmss'\n },\n {\n type: 'string',\n label: 'format',\n name: 'format',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'select',\n label: 'progress-direction',\n name: 'progressDirection',\n property: {\n options: ['', 'increase', 'decrease']\n }\n },\n {\n type: 'color',\n label: 'increase-progress-color',\n name: 'increaseProgressColor'\n },\n {\n type: 'color',\n label: 'decrease-progress-color',\n name: 'decreaseProgressColor'\n },\n {\n type: 'color',\n label: 'increase-font-color',\n name: 'increaseFontColor'\n },\n {\n type: 'color',\n label: 'decrese-font-color',\n name: 'decreaseFontColor'\n },\n {\n type: 'color',\n label: 'under-threshold-color',\n name: 'underThresholdColor'\n },\n {\n type: 'number',\n label: 'progress-threshold',\n name: 'progressThreshold',\n placeholder: '%'\n },\n {\n type: 'number',\n label: 'round',\n name: 'round'\n },\n {\n type: 'boolean',\n label: 'auto-start',\n name: 'autoStart'\n },\n {\n type: 'boolean',\n label: 'show-progress',\n name: 'showProgress'\n },\n {\n type: 'boolean',\n label: 'show-timer',\n name: 'showTimer'\n }\n ],\n help: 'scene/component/manufacturing/tact-timer'\n}\n\nexport default class TactTimer extends RectPath(Shape) {\n static MASK: HTMLImageElement\n\n static get mask() {\n if (!TactTimer.MASK) {\n TactTimer.MASK = new Image()\n TactTimer.MASK.src = mask\n }\n\n return TactTimer.MASK\n }\n\n private _start: number = 0\n private _due: number = 0\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n const { autoStart } = this.state\n\n if (autoStart) {\n this.start()\n }\n }\n\n start() {\n const { startTime, endTime } = this.state\n const start = this.parseTime(startTime)\n const end = this.parseTime(endTime)\n\n if (start && end) {\n this._due = end.getTime()\n this._start = start.getTime()\n this.counting()\n }\n }\n\n onchange(after: Properties) {\n if ('startTime' in after || 'endTime' in after) {\n this.start()\n }\n }\n\n counting() {\n if (this.disposed) {\n return\n }\n\n requestAnimationFrame(() => {\n const { showTimer } = this.state\n const countdown = this.countdown\n\n if (showTimer) {\n const text = format(Math.abs(countdown), this.getState('format'))\n this.text = text\n } else {\n this.text = ''\n }\n\n this.setState('data', this.countdown)\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var {\n top,\n left,\n height,\n width,\n round = 0,\n fontColor,\n increaseFontColor,\n decreaseFontColor,\n increaseProgressColor = 'transparent',\n decreaseProgressColor = 'transparent',\n underThresholdColor = 'transparent',\n progressDirection = 'increase',\n progressThreshold = 0,\n showProgress,\n showTimer\n } = this.state\n\n const increase = this.countdown > 0\n const totalDuration = (this._due - this._start) / 1000\n const underThreshold = this.countdown / totalDuration < progressThreshold / 100\n\n // progress의 색상\n context.beginPath()\n context.roundRect(left, top, width, height, round)\n context.clip()\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n if (!showProgress) {\n return\n }\n\n var progress = Math.abs((this.countdown / totalDuration) * 100)\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n if (progressDirection == 'increase') {\n context.rect(left, top, progress, height)\n } else {\n context.rect(left + progress, top, width - progress, height)\n }\n\n context.fillStyle = increase\n ? underThreshold\n ? underThresholdColor\n : increaseProgressColor\n : decreaseProgressColor\n context.fill()\n\n context.beginPath()\n }\n\n this.drawImage(context, TactTimer.mask, left, top, width, height)\n context.roundRect(left, top, width, height, round)\n\n this.setState('fontColor', (increase ? increaseFontColor : decreaseFontColor) || fontColor)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n parseTime(timeString: string): Date | undefined {\n if (!timeString || timeString.length !== 14) {\n return undefined\n }\n const year = parseInt(timeString.slice(0, 4), 10)\n const month = parseInt(timeString.slice(4, 6), 10) - 1\n const day = parseInt(timeString.slice(6, 8), 10)\n const hour = parseInt(timeString.slice(8, 10), 10)\n const minute = parseInt(timeString.slice(10, 12), 10)\n const second = parseInt(timeString.slice(12, 14), 10)\n\n return new Date(year, month, day, hour, minute, second)\n }\n\n get countdown(): number {\n const due = this._due || 0\n const now = Date.now()\n\n return Math.round((due - now) / 1000)\n }\n\n get value() {\n const { startTime, endTime } = this.state\n return [startTime, endTime]\n }\n\n set value(v) {\n if (v instanceof Array) {\n const [startTime, endTime] = v\n this.setState({\n startTime,\n endTime\n })\n } else if (typeof v == 'object') {\n const { startTime, endTime } = v\n this.setState({\n startTime,\n endTime\n })\n } else if (typeof v == 'string') {\n const [startTime, endTime] = (v as string).split(/[-+/%$#_,]+/)\n this.setState({\n startTime,\n endTime\n })\n } else {\n this.setState({\n startTime: undefined,\n endTime: undefined\n })\n }\n }\n}\n\nComponent.register('tact-timer', TactTimer)\n"]}
|
|
@@ -12,6 +12,15 @@ declare const _default: {
|
|
|
12
12
|
fontSize: number;
|
|
13
13
|
lineWidth: number;
|
|
14
14
|
round: number;
|
|
15
|
+
showProgress: boolean;
|
|
16
|
+
showTimer: boolean;
|
|
17
|
+
progressDirection: string;
|
|
18
|
+
increaseProgressColor: string;
|
|
19
|
+
decreaseProgressColor: string;
|
|
20
|
+
increaseFontColor: string;
|
|
21
|
+
decreaseFontColor: string;
|
|
22
|
+
underThresholdColor: string;
|
|
23
|
+
progressThreshold: number;
|
|
15
24
|
};
|
|
16
25
|
}[];
|
|
17
26
|
export default _default;
|
|
@@ -12,6 +12,15 @@ declare const _default: {
|
|
|
12
12
|
fontSize: number;
|
|
13
13
|
lineWidth: number;
|
|
14
14
|
round: number;
|
|
15
|
+
showProgress: boolean;
|
|
16
|
+
showTimer: boolean;
|
|
17
|
+
progressDirection: string;
|
|
18
|
+
increaseProgressColor: string;
|
|
19
|
+
decreaseProgressColor: string;
|
|
20
|
+
increaseFontColor: string;
|
|
21
|
+
decreaseFontColor: string;
|
|
22
|
+
underThresholdColor: string;
|
|
23
|
+
progressThreshold: number;
|
|
15
24
|
};
|
|
16
25
|
};
|
|
17
26
|
export default _default;
|
|
@@ -12,7 +12,16 @@ export default {
|
|
|
12
12
|
height: 40,
|
|
13
13
|
fontSize: 80,
|
|
14
14
|
lineWidth: 1,
|
|
15
|
-
round: 10
|
|
15
|
+
round: 10,
|
|
16
|
+
showProgress: true,
|
|
17
|
+
showTimer: true,
|
|
18
|
+
progressDirection: 'decrease',
|
|
19
|
+
increaseProgressColor: 'green',
|
|
20
|
+
decreaseProgressColor: 'red',
|
|
21
|
+
increaseFontColor: 'navy',
|
|
22
|
+
decreaseFontColor: 'orange',
|
|
23
|
+
underThresholdColor: 'yellow',
|
|
24
|
+
progressThreshold: 30
|
|
16
25
|
}
|
|
17
26
|
};
|
|
18
27
|
//# sourceMappingURL=tact-timer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tact-timer.js","sourceRoot":"","sources":["../../src/templates/tact-timer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAExE,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,KAAK,EAAE,KAAK,CAAC,gGAAgG;IAC7G,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"tact-timer.js","sourceRoot":"","sources":["../../src/templates/tact-timer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAExE,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,KAAK,EAAE,KAAK,CAAC,gGAAgG;IAC7G,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,EAAE;QACT,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,UAAU;QAC7B,qBAAqB,EAAE,OAAO;QAC9B,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,MAAM;QACzB,iBAAiB,EAAE,QAAQ;QAC3B,mBAAmB,EAAE,QAAQ;QAC7B,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/tact-timer.png', import.meta.url).href\n\nexport default {\n type: 'tact timer',\n description: 'tact timer',\n group: 'etc' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,\n icon,\n model: {\n type: 'tact-timer',\n left: 100,\n top: 100,\n width: 200,\n height: 40,\n fontSize: 80,\n lineWidth: 1,\n round: 10,\n showProgress: true,\n showTimer: true,\n progressDirection: 'decrease',\n increaseProgressColor: 'green',\n decreaseProgressColor: 'red',\n increaseFontColor: 'navy',\n decreaseFontColor: 'orange',\n underThresholdColor: 'yellow',\n progressThreshold: 30\n }\n}\n"]}
|
|
@@ -1,40 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
### タクトタイマー(Tact Timer)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
タクトタイマーは生産ラインやプロセスで使用される時間管理ツールで、特定の作業や活動に割り当てられた時間を設定し管理するために使用されます。このツールは開始時間と終了時間に基づいてリアルタイムで経過時間を計算し、実際の経過時間をモニタリングし、プログレスバーとカウントダウンテキストを表示して、使用者に現在の進行状況を視覚的に表現します。これにより、生産プロセスを効率的に管理し、生産量を最適化するのに役立ちます。
|
|
4
4
|
|
|
5
5
|
#### 特性
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- 開始時間(startTime)
|
|
8
|
+
- 作業の開始時間を設定します。
|
|
9
|
+
- フォーマット:'YYYYMMDDhhmmss'
|
|
10
|
+
- 終了時間(endTime)
|
|
11
|
+
- 作業の終了時間を設定します。
|
|
12
|
+
- フォーマット:'YYYYMMDDhhmmss'
|
|
9
13
|
- カウントダウンフォーマット(format)
|
|
10
|
-
- フォーマット:hh:mm:ss
|
|
14
|
+
- フォーマット:'hh:mm:ss'
|
|
11
15
|
- カウントダウン結果の表示形式
|
|
12
16
|
- 進行方向(progressDirection)
|
|
13
17
|
- プログレスバーの進行方向設定
|
|
14
|
-
- increase の場合、increaseProgressColor から始まり、0 を過ぎた後は decreaseProgressColor に変わります
|
|
15
|
-
- decrease の場合、decreaseProgressColor から始まり、0 を過ぎた後は increaseProgressColor
|
|
16
|
-
|
|
17
|
-
変わります
|
|
18
|
-
|
|
18
|
+
- 'increase' の場合、increaseProgressColor から始まり、0 を過ぎた後は decreaseProgressColor に変わります
|
|
19
|
+
- 'decrease' の場合、decreaseProgressColor から始まり、0 を過ぎた後は increaseProgressColor に変わります
|
|
19
20
|
- 増加進行色(increaseProgressColor)
|
|
20
21
|
- 増加時の進行色
|
|
21
|
-
- tackTime 設定から tactTime の 20%のカウントダウンまでの進行色
|
|
22
22
|
- 減少進行色(decreaseProgressColor)
|
|
23
23
|
- 減少時の進行色
|
|
24
|
-
- 増加フォント色(
|
|
24
|
+
- 増加フォント色(increaseFontColor)
|
|
25
25
|
- 増加時のフォント色
|
|
26
|
-
- 減少フォント色(
|
|
26
|
+
- 減少フォント色(decreaseFontColor)
|
|
27
27
|
- 減少時のフォント色
|
|
28
28
|
- 進行閾値(progressThreshold)
|
|
29
|
-
-
|
|
29
|
+
- 警告閾値(%)、進行状況が閾値以下の場合に閾値以下色が使用されます
|
|
30
30
|
- 閾値以下色(underThresholdColor)
|
|
31
31
|
- 閾値以下の進行色
|
|
32
32
|
- 自動開始(autoStart)
|
|
33
33
|
- カウントダウンを自動的に開始します
|
|
34
34
|
- 角を丸くする(round)
|
|
35
35
|
- コンポーネント四角形領域の 4 つの角の丸い形状の半径サイズ
|
|
36
|
+
- 進行色を表示(showProgress)
|
|
37
|
+
- 進行度を背景色で表現する
|
|
38
|
+
- タイマーを表示(showTimer)
|
|
39
|
+
- 残り時間または経過時間をテキストで表示する
|
|
36
40
|
|
|
37
41
|
#### データ
|
|
38
42
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
43
|
+
- 設定された開始時間と終了時間に基づいて、現在の残り時間が毎秒更新されます。
|
|
44
|
+
- タイマーは設定された終了時間を基準に 0 までカウントダウンされます。
|
|
45
|
+
|
|
46
|
+
#### value
|
|
47
|
+
|
|
48
|
+
`value`プロパティは、`startTime`と`endTime`をさまざまな形式で設定するために使用できます。また、さまざまな特殊文字を使用して時間を区切ることができます:
|
|
49
|
+
|
|
50
|
+
- 配列として: `['YYYYMMDDhhmmss', 'YYYYMMDDhhmmss']`
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
component.value = ['20240101000000', '20240101235959']
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- オブジェクトとして:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
component.value = { startTime: '20240101000000', endTime: '20240101235959' }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- 特殊文字を含む文字列として:
|
|
63
|
+
- 使用可能な特殊文字: `-`, `/`, `%`, `$`, `#`, `_`, `,`
|
|
64
|
+
```javascript
|
|
65
|
+
component.value = '20240101000000-20240101235959'
|
|
66
|
+
component.value = '20240101000000/20240101235959'
|
|
67
|
+
component.value = '20240101000000%20240101235959'
|
|
68
|
+
component.value = '20240101000000$20240101235959'
|
|
69
|
+
component.value = '20240101000000#20240101235959'
|
|
70
|
+
component.value = '20240101000000_20240101235959'
|
|
71
|
+
component.value = '20240101000000,20240101235959'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
いずれの場合も、コンポーネントは提供された`startTime`と`endTime`を解析し、それに応じて状態を更新します。
|
|
@@ -1,37 +1,74 @@
|
|
|
1
1
|
# Tact Timer
|
|
2
2
|
|
|
3
|
-
"Tact Timer"는 생산 라인이나 공정에서 사용되는 시간 관리 도구로, 특정 작업이나 활동에 할당된
|
|
3
|
+
"Tact Timer"는 생산 라인이나 공정에서 사용되는 시간 관리 도구로, 특정 작업이나 활동에 할당된 시간을 설정하고 관리하는 데 사용됩니다. 이 도구는 시작 시간과 종료 시간을 기반으로 실시간으로 경과 시간을 계산하고 모니터링하며, 프로그레스 바와 카운트다운 텍스트를 표시하여 사용자에게 현재 진행 상황을 시각적으로 표현합니다. 이를 통해 생산 과정을 효율적으로 관리하고 생산량을 최적화하는 데 도움을 줍니다.
|
|
4
4
|
|
|
5
5
|
## properties
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- 시작 시간(startTime)
|
|
8
|
+
- 작업의 시작 시간을 설정합니다.
|
|
9
|
+
- 형식: 'YYYYMMDDhhmmss'
|
|
10
|
+
- 종료 시간(endTime)
|
|
11
|
+
- 작업의 종료 시간을 설정합니다.
|
|
12
|
+
- 형식: 'YYYYMMDDhhmmss'
|
|
9
13
|
- 카운트다운 포맷(format)
|
|
10
|
-
-
|
|
11
|
-
- 카운트다운 결과
|
|
14
|
+
- 형식: 'hh:mm:ss'
|
|
15
|
+
- 카운트다운 결과 표현 형식
|
|
12
16
|
- 진행 방향(progressDirection)
|
|
13
|
-
-
|
|
14
|
-
- increase
|
|
15
|
-
- decrease
|
|
16
|
-
- 증가
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
- 감소시 폰트 색상
|
|
17
|
+
- 프로그레스 바의 진행 방향을 설정합니다.
|
|
18
|
+
- 'increase': 증가하는 방향으로 진행
|
|
19
|
+
- 'decrease': 감소하는 방향으로 진행
|
|
20
|
+
- 증가 진행 색상(increaseProgressColor)
|
|
21
|
+
- 증가할 때의 진행 색상
|
|
22
|
+
- 감소 진행 색상(decreaseProgressColor)
|
|
23
|
+
- 감소할 때의 진행 색상
|
|
24
|
+
- 증가 폰트 색상(increaseFontColor)
|
|
25
|
+
- 증가할 때의 폰트 색상
|
|
26
|
+
- 감소 폰트 색상(decreaseFontColor)
|
|
27
|
+
- 감소할 때의 폰트 색상
|
|
25
28
|
- 진행 임계값(progressThreshold)
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
+
- 경고 임계값(%). 진행 상황이 임계값 이하인 경우 임계 이하 색상이 사용됨
|
|
30
|
+
- 임계 이하 색상(underThresholdColor)
|
|
31
|
+
- 임계값 이하일 때의 진행 색상
|
|
29
32
|
- 자동 시작(autoStart)
|
|
30
|
-
- 카운트다운을 자동으로
|
|
33
|
+
- 카운트다운을 자동으로 시작합니다.
|
|
31
34
|
- 둥글게(round)
|
|
32
|
-
- 컴포넌트
|
|
35
|
+
- 컴포넌트 사각형 영역의 4꼭지점 부분의 둥근 모양의 반지름 크기
|
|
36
|
+
- 진행 색상 보이기(showProgress)
|
|
37
|
+
- 진행 정도를 배경 색상으로 표현합니다.
|
|
38
|
+
- 타이머 보이기(showTimer)
|
|
39
|
+
- 남은 시간 또는 경과한 시간을 텍스트로 표시합니다.
|
|
33
40
|
|
|
34
41
|
## data
|
|
35
42
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
43
|
+
- 설정된 시작 시간과 종료 시간에 따라 현재 남은 시간이 매초 업데이트됩니다.
|
|
44
|
+
- 타이머는 설정된 종료 시간을 기준으로 0까지 카운트다운됩니다.
|
|
45
|
+
|
|
46
|
+
## value
|
|
47
|
+
|
|
48
|
+
`value` 속성은 `startTime`과 `endTime`을 다양한 형식으로 설정하는 데 사용할 수 있으며, 여러 특수문자를 사용하여 시간을 구분할 수 있습니다:
|
|
49
|
+
|
|
50
|
+
- 배열로 설정: `['YYYYMMDDhhmmss', 'YYYYMMDDhhmmss']`
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
component.value = ['20240101000000', '20240101235959']
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- 객체로 설정:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
component.value = { startTime: '20240101000000', endTime: '20240101235959' }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- 특수문자를 포함한 문자열로 설정:
|
|
63
|
+
- 사용 가능한 특수문자: `-`, `/`, `%`, `$`, `#`, `_`, `,`
|
|
64
|
+
```javascript
|
|
65
|
+
component.value = '20240101000000-20240101235959'
|
|
66
|
+
component.value = '20240101000000/20240101235959'
|
|
67
|
+
component.value = '20240101000000%20240101235959'
|
|
68
|
+
component.value = '20240101000000$20240101235959'
|
|
69
|
+
component.value = '20240101000000#20240101235959'
|
|
70
|
+
component.value = '20240101000000_20240101235959'
|
|
71
|
+
component.value = '20240101000000,20240101235959'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
모든 경우에, 컴포넌트는 제공된 `startTime`과 `endTime`을 파싱하고 이에 따라 상태를 업데이트합니다.
|
|
@@ -1,37 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
### Tact Timer
|
|
2
2
|
|
|
3
|
-
"Tact Timer" is a time management tool used in production lines or processes. It is utilized for setting and managing
|
|
3
|
+
"Tact Timer" is a time management tool used in production lines or processes. It is utilized for setting and managing allocated time for a specific task or activity. This tool calculates elapsed time in real-time, monitors actual elapsed time, and visually represents the current progress to the user by displaying a progress bar and countdown text. It aids in efficiently managing the production process and optimizing output.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
#### properties
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Start Time (startTime)
|
|
8
|
+
- Sets the start time of the task.
|
|
9
|
+
- Format: 'YYYYMMDDhhmmss'
|
|
10
|
+
- End Time (endTime)
|
|
11
|
+
- Sets the end time of the task.
|
|
12
|
+
- Format: 'YYYYMMDDhhmmss'
|
|
9
13
|
- Countdown Format (format)
|
|
10
|
-
-
|
|
14
|
+
- Format: 'hh:mm:ss'
|
|
11
15
|
- Format for displaying the countdown result
|
|
12
16
|
- Progress Direction (progressDirection)
|
|
13
17
|
- Sets the direction of progress for the progress bar
|
|
14
|
-
- In the case of increase, it starts with increaseProgressColor, changing to decreaseProgressColor after passing 0
|
|
15
|
-
- In the case of decrease, it starts with decreaseProgressColor, changing to increaseProgressColor after passing 0
|
|
18
|
+
- In the case of 'increase', it starts with increaseProgressColor, changing to decreaseProgressColor after passing 0
|
|
19
|
+
- In the case of 'decrease', it starts with decreaseProgressColor, changing to increaseProgressColor after passing 0
|
|
16
20
|
- Increase Progress Color (increaseProgressColor)
|
|
17
21
|
- Color for progress during increase
|
|
18
|
-
- Progress color from the setting of tactTime up to 20% level countdown of tactTime
|
|
19
22
|
- Decrease Progress Color (decreaseProgressColor)
|
|
20
23
|
- Color for progress during decrease
|
|
21
|
-
- Increase Font Color (
|
|
24
|
+
- Increase Font Color (increaseFontColor)
|
|
22
25
|
- Font color during increase
|
|
23
|
-
- Decrease Font Color (
|
|
26
|
+
- Decrease Font Color (decreaseFontColor)
|
|
24
27
|
- Font color during decrease
|
|
25
28
|
- Progress Threshold (progressThreshold)
|
|
26
|
-
- Warning threshold (%) of
|
|
29
|
+
- Warning threshold (%) of elapsed time; threshold color is used when progress is below this level
|
|
27
30
|
- Under Threshold Color (underThresholdColor)
|
|
28
31
|
- Color for progress below the threshold
|
|
29
32
|
- Auto Start (autoStart)
|
|
30
33
|
- Automatically starts the countdown
|
|
31
34
|
- Round (round)
|
|
32
35
|
- Radius size of the rounded shape at the four corners of the component's rectangular area
|
|
36
|
+
- Show Progress Color (showProgress)
|
|
37
|
+
- Use background color to represent the degree of progress
|
|
38
|
+
- Show Timer (showTimer)
|
|
39
|
+
- Show remaining time or elapsed time as text
|
|
33
40
|
|
|
34
|
-
|
|
41
|
+
#### data
|
|
35
42
|
|
|
36
|
-
- The current value, counted down from the
|
|
37
|
-
- The
|
|
43
|
+
- The current value, counted down from the start time to the end time, is updated every second (unit: seconds).
|
|
44
|
+
- The timer counts down to 0 based on the set end time.
|
|
45
|
+
|
|
46
|
+
#### value
|
|
47
|
+
|
|
48
|
+
The `value` property can be used to set the `startTime` and `endTime` in different formats and using various special characters to separate the times:
|
|
49
|
+
|
|
50
|
+
- As an array: `['YYYYMMDDhhmmss', 'YYYYMMDDhhmmss']`
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
component.value = ['20240101000000', '20240101235959']
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- As an object:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
component.value = { startTime: '20240101000000', endTime: '20240101235959' }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- As a string with special characters:
|
|
63
|
+
- Allowed special characters: `-`, `/`, `%`, `$`, `#`, `_`, `,`
|
|
64
|
+
```javascript
|
|
65
|
+
component.value = '20240101000000-20240101235959'
|
|
66
|
+
component.value = '20240101000000/20240101235959'
|
|
67
|
+
component.value = '20240101000000%20240101235959'
|
|
68
|
+
component.value = '20240101000000$20240101235959'
|
|
69
|
+
component.value = '20240101000000#20240101235959'
|
|
70
|
+
component.value = '20240101000000_20240101235959'
|
|
71
|
+
component.value = '20240101000000,20240101235959'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
In all cases, the component will parse the provided `startTime` and `endTime` and update its state accordingly.
|