@fmsim/machine 0.0.53 → 0.0.55
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/dist/features/client-api.js +1 -1
- package/dist/features/client-api.js.map +1 -1
- package/dist/features/mcs-status-default.js +1 -1
- package/dist/features/mcs-status-default.js.map +1 -1
- package/dist/stocker-capacity-bar.js +73 -10
- package/dist/stocker-capacity-bar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/zone-capacity-bar.js +73 -9
- package/dist/zone-capacity-bar.js.map +1 -1
- package/package.json +2 -2
- package/src/features/client-api.ts +1 -1
- package/src/features/mcs-status-default.ts +1 -1
- package/src/stocker-capacity-bar.ts +97 -12
- package/src/zone-capacity-bar.ts +97 -11
- package/translations/en.json +1 -0
- package/translations/ja.json +2 -0
- package/translations/ko.json +2 -0
- package/translations/ms.json +2 -0
- package/translations/zh.json +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zone-capacity-bar.js","sourceRoot":"","sources":["../src/zone-capacity-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyC,MAAM,wBAAwB,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV,GAAG,sBAAsB;QACzB;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,eAAe;SACvB;QACD;YACE,IAAI,EA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AAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,kCAAkC;IACpC,CAAC;IAED,YAAY,CAAC,KAAiB,EAAE,MAAkB;QAChD,MAAM,EACJ,eAAe,GAAG,CAAC,EACnB,WAAW,GAAG,GAAG,EACjB,aAAa,GAAG,GAAG,EACpB,GAAG,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QAEjD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACjD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,CAAA;QAC9C,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,GAAG,CAAA;QAElD,IAAI,CAAC,QAAQ,CAAC;YACZ,YAAY;YACZ,WAAW;YACX,aAAa;YACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC;SACtD,CAAC,CAAA;IACJ,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, POSITION, Properties } from '@hatiolab/things-scene'\nimport { LEGEND_CAPACITY } from './features/mcs-status-default'\nimport { safeRound } from './utils/safe-round'\nimport { getVaueOnRanges } from './utils/get-value-on-ranges'\nimport { MCSZoneMixin, MCSZoneMixinProperties } from './features/mcs-zone-mixin'\nimport MCSUnit from './mcs-unit'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n ...MCSZoneMixinProperties,\n {\n type: 'number',\n name: 'currentUsage',\n label: 'current-usage'\n },\n {\n type: 'number',\n name: 'highWatermark',\n label: 'high-watermark'\n },\n {\n type: 'number',\n name: 'lowWatermark',\n label: 'low-watermark'\n },\n {\n type: 'number',\n name: 'maxCapacity',\n label: 'max-capacity'\n },\n {\n type: 'number',\n label: 'round',\n name: 'round',\n property: {\n min: 0\n }\n },\n {\n type: 'hidden',\n name: 'usage',\n label: 'usage'\n }\n ],\n 'value-property': 'usage'\n}\n\nvar controlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { left, top, width, height } = component.model\n\n var transcoorded = component.transcoordP2S(point.x, point.y)\n var round = ((transcoorded.x - left) / (width / 2)) * 100\n\n round = safeRound(round, width, height)\n\n component.set({\n round\n })\n }\n}\n\nexport default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {\n static get nature() {\n return NATURE\n }\n\n get controls() {\n var { left, top, width, round, height } = this.state\n round = round == undefined ? 0 : safeRound(round, width, height)\n\n return [\n {\n x: left + (width / 2) * (round / 100),\n y: top,\n handler: controlHandler\n }\n ]\n }\n\n getLegendFallback() {\n return LEGEND_CAPACITY\n }\n\n get statusColor() {\n return getVaueOnRanges(this.usage, this.legend)\n }\n\n get text() {\n return this.usage + '%'\n }\n\n render(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n\n if (width >= height) {\n this.renderLandscape(context)\n } else {\n this.renderPortrait(context)\n }\n }\n\n renderLandscape(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n const { lineWidth, strokeStyle, round, fillStyle = '#aaa' } = this.state\n\n context.strokeStyle = strokeStyle\n context.lineWidth = lineWidth\n\n context.save()\n context.translate(left, top)\n\n // gauge background\n context.beginPath()\n\n context.fillStyle = fillStyle\n context.roundRect(0, 0, width, height, round)\n\n context.fill()\n context.stroke()\n\n context.clip()\n\n // gauge foreground\n context.beginPath()\n\n context.fillStyle = this.statusColor!\n\n context.rect(0, 0, (width / 100) * this.usage, height)\n context.fill()\n\n context.beginPath()\n context.strokeStyle = strokeStyle\n context.roundRect(0, 0, width, height, round)\n context.stroke()\n\n context.beginPath()\n\n context.translate(-left, -top)\n context.restore()\n }\n\n renderPortrait(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n const { lineWidth, strokeStyle, round, fillStyle } = this.state\n\n context.strokeStyle = strokeStyle\n context.lineWidth = lineWidth\n\n context.save()\n context.translate(left, top)\n\n // gauge background\n context.beginPath()\n\n context.fillStyle = fillStyle\n context.roundRect(0, 0, width, height, round)\n\n context.fill()\n context.stroke()\n\n context.clip()\n\n // gauge foreground\n context.beginPath()\n\n context.fillStyle = this.statusColor!\n\n context.rect(0, height - (height / 100) * this.usage, width, (height / 100) * this.usage)\n context.fill()\n\n context.beginPath()\n context.roundRect(0, 0, width, height, round)\n context.stroke()\n\n context.beginPath()\n\n context.translate(-left, -top)\n context.restore()\n }\n\n get usage() {\n const { currentUsage = 0, maxCapacity = 100 } = this.state\n return Math.round((currentUsage / maxCapacity) * 100)\n }\n\n set usage(usage: number) {\n // intentionally have done nothing\n }\n\n onchangeData(after: Properties, before: Properties): void {\n const {\n CURRENTCAPACITY = 0,\n MAXCAPACITY = 100,\n HIGHWATERMARK = 100\n } = typeof this.data == 'object' ? this.data : {}\n\n const currentUsage = Number(CURRENTCAPACITY) || 0\n const maxCapacity = Number(MAXCAPACITY) || 100\n const highWatermark = Number(HIGHWATERMARK) || 100\n\n this.setState({\n currentUsage,\n maxCapacity,\n highWatermark,\n usage: Math.round((currentUsage / maxCapacity) * 100)\n })\n }\n}\n\nComponent.register('ZoneCapacityBar', ZoneCapacityBar)\n"]}
|
|
1
|
+
{"version":3,"file":"zone-capacity-bar.js","sourceRoot":"","sources":["../src/zone-capacity-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyC,MAAM,wBAAwB,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,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AC;YACZ,YAAY;YACZ,WAAW;YACX,aAAa;YACb,YAAY;YACZ,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC;SACtD,CAAC,CAAA;IACJ,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, POSITION, Properties } from '@hatiolab/things-scene'\nimport { LEGEND_CAPACITY } from './features/mcs-status-default'\nimport { safeRound } from './utils/safe-round'\nimport { getVaueOnRanges } from './utils/get-value-on-ranges'\nimport { MCSZoneMixin, MCSZoneMixinProperties } from './features/mcs-zone-mixin'\nimport MCSUnit from './mcs-unit'\nimport { themesColorRange } from './features/client-api'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n ...MCSZoneMixinProperties,\n {\n type: 'select',\n label: 'legend-name',\n name: 'legendName',\n property: {\n options: themesColorRange\n }\n },\n {\n type: 'number',\n name: 'currentUsage',\n label: 'current-usage'\n },\n {\n type: 'number',\n name: 'highWatermark',\n label: 'high-watermark'\n },\n {\n type: 'number',\n name: 'lowWatermark',\n label: 'low-watermark'\n },\n {\n type: 'number',\n name: 'maxCapacity',\n label: 'max-capacity'\n },\n {\n type: 'boolean',\n name: 'fullup',\n label: 'fullup'\n },\n {\n type: 'number',\n label: 'round',\n name: 'round',\n property: {\n min: 0\n }\n },\n {\n type: 'hidden',\n name: 'usage',\n label: 'usage'\n }\n ],\n 'value-property': 'usage'\n}\n\nvar controlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { left, top, width, height } = component.model\n\n var transcoorded = component.transcoordP2S(point.x, point.y)\n var round = ((transcoorded.x - left) / (width / 2)) * 100\n\n round = safeRound(round, width, height)\n\n component.set({\n round\n })\n }\n}\n\nexport default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {\n static get nature() {\n return NATURE\n }\n\n get controls() {\n var { left, top, width, round, height } = this.state\n round = round == undefined ? 0 : safeRound(round, width, height)\n\n return [\n {\n x: left + (width / 2) * (round / 100),\n y: top,\n handler: controlHandler\n }\n ]\n }\n\n getLegendFallback() {\n return LEGEND_CAPACITY\n }\n\n get statusColor() {\n const { fullup } = this.state\n return fullup ? 'red' : getVaueOnRanges(this.usage, this.legend)\n }\n\n get text() {\n return this.usage + '%'\n }\n\n render(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n\n if (width >= height) {\n this.renderLandscape(context)\n } else {\n this.renderPortrait(context)\n }\n }\n\n renderLandscape(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state\n\n context.save()\n context.translate(left, top)\n\n // gauge background\n context.beginPath()\n\n context.fillStyle = fillStyle\n context.roundRect(0, 0, width, height, round)\n\n context.fill()\n context.stroke()\n\n context.clip()\n\n // gauge foreground\n context.beginPath()\n\n context.fillStyle = this.statusColor!\n\n context.rect(0, 0, (width / 100) * this.usage, height)\n context.fill()\n\n // high-watermark level\n\n if (highWatermark && highWatermark > 0 && highWatermark < 100) {\n context.beginPath()\n\n context.strokeStyle = 'black'\n context.lineWidth = 1\n context.setLineDash([3])\n\n const x = (width / 100) * highWatermark\n context.moveTo(x, 0)\n context.lineTo(x, height)\n\n context.stroke()\n }\n\n // low-watermark level\n\n if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {\n context.beginPath()\n\n context.strokeStyle = 'black'\n context.lineWidth = 1\n context.setLineDash([3])\n\n const x = (width / 100) * lowWatermark\n context.moveTo(x, 0)\n context.lineTo(x, height)\n\n context.stroke()\n }\n\n // gauge outline\n context.beginPath()\n\n context.setLineDash([])\n context.strokeStyle = strokeStyle\n context.lineWidth = lineWidth\n context.roundRect(0, 0, width, height, round)\n context.stroke()\n\n context.beginPath()\n\n context.translate(-left, -top)\n context.restore()\n }\n\n renderPortrait(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state\n\n context.save()\n context.translate(left, top)\n\n // gauge background\n context.beginPath()\n\n context.fillStyle = fillStyle\n context.roundRect(0, 0, width, height, round)\n\n context.fill()\n\n context.clip()\n\n // gauge foreground\n context.beginPath()\n\n context.fillStyle = this.statusColor!\n\n context.rect(0, height - (height / 100) * this.usage, width, (height / 100) * this.usage)\n context.fill()\n\n // high-watermark level\n\n if (highWatermark && highWatermark > 0 && highWatermark < 100) {\n context.beginPath()\n\n context.strokeStyle = 'black'\n context.lineWidth = 1\n context.setLineDash([3])\n\n const y = height - (height / 100) * highWatermark\n context.moveTo(0, y)\n context.lineTo(width, y)\n\n context.stroke()\n }\n\n // low-watermark level\n\n if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {\n context.beginPath()\n\n context.strokeStyle = 'black'\n context.lineWidth = 1\n context.setLineDash([3])\n\n const y = height - (height / 100) * lowWatermark\n context.moveTo(0, y)\n context.lineTo(width, y)\n\n context.stroke()\n }\n\n // gauge outline\n context.beginPath()\n\n context.setLineDash([])\n context.strokeStyle = strokeStyle\n context.lineWidth = lineWidth\n context.roundRect(0, 0, width, height, round)\n context.stroke()\n\n context.beginPath()\n\n context.translate(-left, -top)\n context.restore()\n }\n\n get usage() {\n const { currentUsage = 0, maxCapacity = 100 } = this.state\n return Math.round((currentUsage / maxCapacity) * 100)\n }\n\n set usage(usage: number) {\n // intentionally have done nothing\n }\n\n onchangeData(after: Properties, before: Properties): void {\n const {\n CURRENTCAPACITY = 0,\n MAXCAPACITY = 100,\n HIGHWATERMARK = 100,\n LOWWATERMARK = 0,\n FULLUP = false\n } = typeof this.data == 'object' ? this.data : {}\n\n const currentUsage = Number(CURRENTCAPACITY) || 0\n const maxCapacity = Number(MAXCAPACITY) || 100\n const highWatermark = Number(HIGHWATERMARK) || 100\n const lowWatermark = Number(LOWWATERMARK) || 0\n\n this.setState({\n currentUsage,\n maxCapacity,\n highWatermark,\n lowWatermark,\n fullup: FULLUP,\n usage: Math.round((currentUsage / maxCapacity) * 100)\n })\n }\n}\n\nComponent.register('ZoneCapacityBar', ZoneCapacityBar)\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fmsim/machine",
|
|
3
3
|
"description": "Layout View를 구성하는 설비(machine)들과 유닛을 구현한 모듈입니다.",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.55",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"things-scene": true,
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"prettier --write"
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "d8d2fb75fd603b6ea89479bc1726d7a805ffe96e"
|
|
59
59
|
}
|
|
@@ -44,7 +44,7 @@ export const themesColorRange = async () => {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const items = response.data.themes.items
|
|
47
|
-
.filter((item: any) => item.type == 'color-
|
|
47
|
+
.filter((item: any) => item.type == 'color-ranges')
|
|
48
48
|
.map((item: any) => item.name)
|
|
49
49
|
const sorted = items.sort()
|
|
50
50
|
|
|
@@ -3,12 +3,21 @@ import { MCSStatusMixin } from './features/mcs-status-mixin'
|
|
|
3
3
|
import { LEGEND_CAPACITY, Legend } from './features/mcs-status-default'
|
|
4
4
|
import { safeRound } from './utils/safe-round'
|
|
5
5
|
import { getVaueOnRanges } from './utils/get-value-on-ranges'
|
|
6
|
+
import { themesColorRange } from './features/client-api'
|
|
6
7
|
|
|
7
8
|
const NATURE: ComponentNature = {
|
|
8
9
|
mutable: false,
|
|
9
10
|
resizable: true,
|
|
10
11
|
rotatable: true,
|
|
11
12
|
properties: [
|
|
13
|
+
{
|
|
14
|
+
type: 'select',
|
|
15
|
+
label: 'legend-name',
|
|
16
|
+
name: 'legendName',
|
|
17
|
+
property: {
|
|
18
|
+
options: themesColorRange
|
|
19
|
+
}
|
|
20
|
+
},
|
|
12
21
|
{
|
|
13
22
|
type: 'number',
|
|
14
23
|
name: 'currentUsage',
|
|
@@ -29,6 +38,11 @@ const NATURE: ComponentNature = {
|
|
|
29
38
|
name: 'maxCapacity',
|
|
30
39
|
label: 'max-capacity'
|
|
31
40
|
},
|
|
41
|
+
{
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
name: 'fullup',
|
|
44
|
+
label: 'fullup'
|
|
45
|
+
},
|
|
32
46
|
{
|
|
33
47
|
type: 'number',
|
|
34
48
|
label: 'round',
|
|
@@ -96,7 +110,8 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
get statusColor() {
|
|
99
|
-
|
|
113
|
+
const { fullup } = this.state
|
|
114
|
+
return fullup ? 'red' : getVaueOnRanges(this.usage, this.legend)
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
get text() {
|
|
@@ -115,10 +130,7 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
115
130
|
|
|
116
131
|
renderLandscape(context: CanvasRenderingContext2D) {
|
|
117
132
|
const { left, top, width, height } = this.bounds
|
|
118
|
-
const { lineWidth, strokeStyle, round, fillStyle = '
|
|
119
|
-
|
|
120
|
-
context.strokeStyle = strokeStyle
|
|
121
|
-
context.lineWidth = lineWidth
|
|
133
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state
|
|
122
134
|
|
|
123
135
|
context.save()
|
|
124
136
|
context.translate(left, top)
|
|
@@ -130,7 +142,6 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
130
142
|
context.roundRect(0, 0, width, height, round)
|
|
131
143
|
|
|
132
144
|
context.fill()
|
|
133
|
-
context.stroke()
|
|
134
145
|
|
|
135
146
|
context.clip()
|
|
136
147
|
|
|
@@ -142,8 +153,44 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
142
153
|
context.rect(0, 0, (width / 100) * this.usage, height)
|
|
143
154
|
context.fill()
|
|
144
155
|
|
|
156
|
+
// high-watermark level
|
|
157
|
+
|
|
158
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
159
|
+
context.beginPath()
|
|
160
|
+
|
|
161
|
+
context.strokeStyle = 'black'
|
|
162
|
+
context.lineWidth = 1
|
|
163
|
+
context.setLineDash([3])
|
|
164
|
+
|
|
165
|
+
const x = (width / 100) * highWatermark
|
|
166
|
+
context.moveTo(x, 0)
|
|
167
|
+
context.lineTo(x, height)
|
|
168
|
+
|
|
169
|
+
context.stroke()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// low-watermark level
|
|
173
|
+
|
|
174
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
175
|
+
context.beginPath()
|
|
176
|
+
|
|
177
|
+
context.strokeStyle = 'black'
|
|
178
|
+
context.lineWidth = 1
|
|
179
|
+
context.setLineDash([3])
|
|
180
|
+
|
|
181
|
+
const x = (width / 100) * lowWatermark
|
|
182
|
+
context.moveTo(x, 0)
|
|
183
|
+
context.lineTo(x, height)
|
|
184
|
+
|
|
185
|
+
context.stroke()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// gauge outline
|
|
145
189
|
context.beginPath()
|
|
190
|
+
|
|
191
|
+
context.setLineDash([])
|
|
146
192
|
context.strokeStyle = strokeStyle
|
|
193
|
+
context.lineWidth = lineWidth
|
|
147
194
|
context.roundRect(0, 0, width, height, round)
|
|
148
195
|
context.stroke()
|
|
149
196
|
|
|
@@ -155,10 +202,7 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
155
202
|
|
|
156
203
|
renderPortrait(context: CanvasRenderingContext2D) {
|
|
157
204
|
const { left, top, width, height } = this.bounds
|
|
158
|
-
const { lineWidth, strokeStyle, round, fillStyle } = this.state
|
|
159
|
-
|
|
160
|
-
context.strokeStyle = strokeStyle
|
|
161
|
-
context.lineWidth = lineWidth
|
|
205
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state
|
|
162
206
|
|
|
163
207
|
context.save()
|
|
164
208
|
context.translate(left, top)
|
|
@@ -170,7 +214,6 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
170
214
|
context.roundRect(0, 0, width, height, round)
|
|
171
215
|
|
|
172
216
|
context.fill()
|
|
173
|
-
context.stroke()
|
|
174
217
|
|
|
175
218
|
context.clip()
|
|
176
219
|
|
|
@@ -182,7 +225,44 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
182
225
|
context.rect(0, height - (height / 100) * this.usage, width, (height / 100) * this.usage)
|
|
183
226
|
context.fill()
|
|
184
227
|
|
|
228
|
+
// high-watermark level
|
|
229
|
+
|
|
230
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
231
|
+
context.beginPath()
|
|
232
|
+
|
|
233
|
+
context.strokeStyle = 'black'
|
|
234
|
+
context.lineWidth = 1
|
|
235
|
+
context.setLineDash([3])
|
|
236
|
+
|
|
237
|
+
const y = height - (height / 100) * highWatermark
|
|
238
|
+
context.moveTo(0, y)
|
|
239
|
+
context.lineTo(width, y)
|
|
240
|
+
|
|
241
|
+
context.stroke()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// low-watermark level
|
|
245
|
+
|
|
246
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
247
|
+
context.beginPath()
|
|
248
|
+
|
|
249
|
+
context.strokeStyle = 'black'
|
|
250
|
+
context.lineWidth = 1
|
|
251
|
+
context.setLineDash([3])
|
|
252
|
+
|
|
253
|
+
const y = height - (height / 100) * lowWatermark
|
|
254
|
+
context.moveTo(0, y)
|
|
255
|
+
context.lineTo(width, y)
|
|
256
|
+
|
|
257
|
+
context.stroke()
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// gauge outline
|
|
185
261
|
context.beginPath()
|
|
262
|
+
|
|
263
|
+
context.setLineDash([])
|
|
264
|
+
context.strokeStyle = strokeStyle
|
|
265
|
+
context.lineWidth = lineWidth
|
|
186
266
|
context.roundRect(0, 0, width, height, round)
|
|
187
267
|
context.stroke()
|
|
188
268
|
|
|
@@ -205,17 +285,22 @@ export default class StockerCapacityBar extends MCSStatusMixin(RectPath(Shape))
|
|
|
205
285
|
const {
|
|
206
286
|
CURRENTCAPACITY = 0,
|
|
207
287
|
MAXCAPACITY = 100,
|
|
208
|
-
HIGHWATERMARK = 100
|
|
288
|
+
HIGHWATERMARK = 100,
|
|
289
|
+
LOWWATERMARK = 0,
|
|
290
|
+
FULLUP = false
|
|
209
291
|
} = typeof this.data == 'object' ? this.data : {}
|
|
210
292
|
|
|
211
293
|
const currentUsage = Number(CURRENTCAPACITY) || 0
|
|
212
294
|
const maxCapacity = Number(MAXCAPACITY) || 100
|
|
213
295
|
const highWatermark = Number(HIGHWATERMARK) || 100
|
|
296
|
+
const lowWatermark = Number(LOWWATERMARK) || 0
|
|
214
297
|
|
|
215
298
|
this.setState({
|
|
216
299
|
currentUsage,
|
|
217
300
|
maxCapacity,
|
|
218
301
|
highWatermark,
|
|
302
|
+
lowWatermark,
|
|
303
|
+
fullup: FULLUP,
|
|
219
304
|
usage: Math.round((currentUsage / maxCapacity) * 100)
|
|
220
305
|
})
|
|
221
306
|
}
|
package/src/zone-capacity-bar.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { safeRound } from './utils/safe-round'
|
|
|
4
4
|
import { getVaueOnRanges } from './utils/get-value-on-ranges'
|
|
5
5
|
import { MCSZoneMixin, MCSZoneMixinProperties } from './features/mcs-zone-mixin'
|
|
6
6
|
import MCSUnit from './mcs-unit'
|
|
7
|
+
import { themesColorRange } from './features/client-api'
|
|
7
8
|
|
|
8
9
|
const NATURE: ComponentNature = {
|
|
9
10
|
mutable: false,
|
|
@@ -11,6 +12,14 @@ const NATURE: ComponentNature = {
|
|
|
11
12
|
rotatable: true,
|
|
12
13
|
properties: [
|
|
13
14
|
...MCSZoneMixinProperties,
|
|
15
|
+
{
|
|
16
|
+
type: 'select',
|
|
17
|
+
label: 'legend-name',
|
|
18
|
+
name: 'legendName',
|
|
19
|
+
property: {
|
|
20
|
+
options: themesColorRange
|
|
21
|
+
}
|
|
22
|
+
},
|
|
14
23
|
{
|
|
15
24
|
type: 'number',
|
|
16
25
|
name: 'currentUsage',
|
|
@@ -31,6 +40,11 @@ const NATURE: ComponentNature = {
|
|
|
31
40
|
name: 'maxCapacity',
|
|
32
41
|
label: 'max-capacity'
|
|
33
42
|
},
|
|
43
|
+
{
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
name: 'fullup',
|
|
46
|
+
label: 'fullup'
|
|
47
|
+
},
|
|
34
48
|
{
|
|
35
49
|
type: 'number',
|
|
36
50
|
label: 'round',
|
|
@@ -86,7 +100,8 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
86
100
|
}
|
|
87
101
|
|
|
88
102
|
get statusColor() {
|
|
89
|
-
|
|
103
|
+
const { fullup } = this.state
|
|
104
|
+
return fullup ? 'red' : getVaueOnRanges(this.usage, this.legend)
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
get text() {
|
|
@@ -105,10 +120,7 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
105
120
|
|
|
106
121
|
renderLandscape(context: CanvasRenderingContext2D) {
|
|
107
122
|
const { left, top, width, height } = this.bounds
|
|
108
|
-
const { lineWidth, strokeStyle, round, fillStyle = '
|
|
109
|
-
|
|
110
|
-
context.strokeStyle = strokeStyle
|
|
111
|
-
context.lineWidth = lineWidth
|
|
123
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state
|
|
112
124
|
|
|
113
125
|
context.save()
|
|
114
126
|
context.translate(left, top)
|
|
@@ -132,8 +144,44 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
132
144
|
context.rect(0, 0, (width / 100) * this.usage, height)
|
|
133
145
|
context.fill()
|
|
134
146
|
|
|
147
|
+
// high-watermark level
|
|
148
|
+
|
|
149
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
150
|
+
context.beginPath()
|
|
151
|
+
|
|
152
|
+
context.strokeStyle = 'black'
|
|
153
|
+
context.lineWidth = 1
|
|
154
|
+
context.setLineDash([3])
|
|
155
|
+
|
|
156
|
+
const x = (width / 100) * highWatermark
|
|
157
|
+
context.moveTo(x, 0)
|
|
158
|
+
context.lineTo(x, height)
|
|
159
|
+
|
|
160
|
+
context.stroke()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// low-watermark level
|
|
164
|
+
|
|
165
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
166
|
+
context.beginPath()
|
|
167
|
+
|
|
168
|
+
context.strokeStyle = 'black'
|
|
169
|
+
context.lineWidth = 1
|
|
170
|
+
context.setLineDash([3])
|
|
171
|
+
|
|
172
|
+
const x = (width / 100) * lowWatermark
|
|
173
|
+
context.moveTo(x, 0)
|
|
174
|
+
context.lineTo(x, height)
|
|
175
|
+
|
|
176
|
+
context.stroke()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// gauge outline
|
|
135
180
|
context.beginPath()
|
|
181
|
+
|
|
182
|
+
context.setLineDash([])
|
|
136
183
|
context.strokeStyle = strokeStyle
|
|
184
|
+
context.lineWidth = lineWidth
|
|
137
185
|
context.roundRect(0, 0, width, height, round)
|
|
138
186
|
context.stroke()
|
|
139
187
|
|
|
@@ -145,10 +193,7 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
145
193
|
|
|
146
194
|
renderPortrait(context: CanvasRenderingContext2D) {
|
|
147
195
|
const { left, top, width, height } = this.bounds
|
|
148
|
-
const { lineWidth, strokeStyle, round, fillStyle } = this.state
|
|
149
|
-
|
|
150
|
-
context.strokeStyle = strokeStyle
|
|
151
|
-
context.lineWidth = lineWidth
|
|
196
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = this.state
|
|
152
197
|
|
|
153
198
|
context.save()
|
|
154
199
|
context.translate(left, top)
|
|
@@ -160,7 +205,6 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
160
205
|
context.roundRect(0, 0, width, height, round)
|
|
161
206
|
|
|
162
207
|
context.fill()
|
|
163
|
-
context.stroke()
|
|
164
208
|
|
|
165
209
|
context.clip()
|
|
166
210
|
|
|
@@ -172,7 +216,44 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
172
216
|
context.rect(0, height - (height / 100) * this.usage, width, (height / 100) * this.usage)
|
|
173
217
|
context.fill()
|
|
174
218
|
|
|
219
|
+
// high-watermark level
|
|
220
|
+
|
|
221
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
222
|
+
context.beginPath()
|
|
223
|
+
|
|
224
|
+
context.strokeStyle = 'black'
|
|
225
|
+
context.lineWidth = 1
|
|
226
|
+
context.setLineDash([3])
|
|
227
|
+
|
|
228
|
+
const y = height - (height / 100) * highWatermark
|
|
229
|
+
context.moveTo(0, y)
|
|
230
|
+
context.lineTo(width, y)
|
|
231
|
+
|
|
232
|
+
context.stroke()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// low-watermark level
|
|
236
|
+
|
|
237
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
238
|
+
context.beginPath()
|
|
239
|
+
|
|
240
|
+
context.strokeStyle = 'black'
|
|
241
|
+
context.lineWidth = 1
|
|
242
|
+
context.setLineDash([3])
|
|
243
|
+
|
|
244
|
+
const y = height - (height / 100) * lowWatermark
|
|
245
|
+
context.moveTo(0, y)
|
|
246
|
+
context.lineTo(width, y)
|
|
247
|
+
|
|
248
|
+
context.stroke()
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// gauge outline
|
|
175
252
|
context.beginPath()
|
|
253
|
+
|
|
254
|
+
context.setLineDash([])
|
|
255
|
+
context.strokeStyle = strokeStyle
|
|
256
|
+
context.lineWidth = lineWidth
|
|
176
257
|
context.roundRect(0, 0, width, height, round)
|
|
177
258
|
context.stroke()
|
|
178
259
|
|
|
@@ -195,17 +276,22 @@ export default class ZoneCapacityBar extends MCSZoneMixin(MCSUnit) {
|
|
|
195
276
|
const {
|
|
196
277
|
CURRENTCAPACITY = 0,
|
|
197
278
|
MAXCAPACITY = 100,
|
|
198
|
-
HIGHWATERMARK = 100
|
|
279
|
+
HIGHWATERMARK = 100,
|
|
280
|
+
LOWWATERMARK = 0,
|
|
281
|
+
FULLUP = false
|
|
199
282
|
} = typeof this.data == 'object' ? this.data : {}
|
|
200
283
|
|
|
201
284
|
const currentUsage = Number(CURRENTCAPACITY) || 0
|
|
202
285
|
const maxCapacity = Number(MAXCAPACITY) || 100
|
|
203
286
|
const highWatermark = Number(HIGHWATERMARK) || 100
|
|
287
|
+
const lowWatermark = Number(LOWWATERMARK) || 0
|
|
204
288
|
|
|
205
289
|
this.setState({
|
|
206
290
|
currentUsage,
|
|
207
291
|
maxCapacity,
|
|
208
292
|
highWatermark,
|
|
293
|
+
lowWatermark,
|
|
294
|
+
fullup: FULLUP,
|
|
209
295
|
usage: Math.round((currentUsage / maxCapacity) * 100)
|
|
210
296
|
})
|
|
211
297
|
}
|
package/translations/en.json
CHANGED
package/translations/ja.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label.current-usage": "current usage",
|
|
3
|
+
"label.fullup": "fullup",
|
|
3
4
|
"label.high-watermark": "high watermark",
|
|
5
|
+
"label.low-watermark": "low watermark",
|
|
4
6
|
"label.legend-name": "legend",
|
|
5
7
|
"label.max-capacity": "max capacity",
|
|
6
8
|
"label.carrier-legend-name": "carrier legend"
|
package/translations/ko.json
CHANGED
package/translations/ms.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label.current-usage": "current usage",
|
|
3
|
+
"label.fullup": "fullup",
|
|
3
4
|
"label.high-watermark": "high watermark",
|
|
5
|
+
"label.low-watermark": "low watermark",
|
|
4
6
|
"label.legend-name": "legend",
|
|
5
7
|
"label.max-capacity": "max capacity",
|
|
6
8
|
"label.carrier-legend-name": "carrier legend"
|
package/translations/zh.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label.current-usage": "current usage",
|
|
3
|
+
"label.fullup": "fullup",
|
|
3
4
|
"label.high-watermark": "high watermark",
|
|
5
|
+
"label.low-watermark": "low watermark",
|
|
4
6
|
"label.legend-name": "legend",
|
|
5
7
|
"label.max-capacity": "max capacity",
|
|
6
8
|
"label.carrier-legend-name": "carrier legend"
|