@gisce/ooui 0.3.5 → 0.4.2
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/Graph/GraphAxis.d.ts +4 -1
- package/dist/Graph/GraphAxis.js +9 -1
- package/dist/Graph/GraphAxis.js.map +1 -1
- package/dist/Graph/GraphChart.d.ts +2 -2
- package/dist/Graph/graphHelper.d.ts +2 -2
- package/dist/Graph/graphHelper.js +4 -2
- package/dist/Graph/graphHelper.js.map +1 -1
- package/dist/helpers/contextParser.js +2 -1
- package/dist/helpers/contextParser.js.map +1 -1
- package/package.json +1 -1
- package/src/Graph/GraphAxis.ts +8 -0
- package/src/Graph/GraphChart.ts +2 -2
- package/src/Graph/graphHelper.ts +6 -4
- package/src/helpers/contextParser.ts +2 -1
- package/src/spec/Graph.spec.ts +6 -4
- package/src/spec/contextParser.spec.ts +9 -0
|
@@ -7,9 +7,12 @@ export declare class GraphAxis {
|
|
|
7
7
|
get axis(): Axis | undefined;
|
|
8
8
|
_operator: Operator | undefined;
|
|
9
9
|
get operator(): Operator | undefined;
|
|
10
|
-
|
|
10
|
+
_label: string | undefined;
|
|
11
|
+
get label(): string | undefined;
|
|
12
|
+
constructor({ name, axis, operator, label, }: {
|
|
11
13
|
name: string;
|
|
12
14
|
axis: Axis;
|
|
13
15
|
operator?: Operator;
|
|
16
|
+
label: string | undefined;
|
|
14
17
|
});
|
|
15
18
|
}
|
package/dist/Graph/GraphAxis.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var GraphAxis = /** @class */ (function () {
|
|
2
2
|
function GraphAxis(_a) {
|
|
3
|
-
var name = _a.name, axis = _a.axis, operator = _a.operator;
|
|
3
|
+
var name = _a.name, axis = _a.axis, operator = _a.operator, label = _a.label;
|
|
4
4
|
this._name = name;
|
|
5
5
|
this._axis = axis;
|
|
6
6
|
this._operator = operator;
|
|
7
|
+
this._label = label;
|
|
7
8
|
}
|
|
8
9
|
Object.defineProperty(GraphAxis.prototype, "name", {
|
|
9
10
|
get: function () {
|
|
@@ -26,6 +27,13 @@ var GraphAxis = /** @class */ (function () {
|
|
|
26
27
|
enumerable: false,
|
|
27
28
|
configurable: true
|
|
28
29
|
});
|
|
30
|
+
Object.defineProperty(GraphAxis.prototype, "label", {
|
|
31
|
+
get: function () {
|
|
32
|
+
return this._label;
|
|
33
|
+
},
|
|
34
|
+
enumerable: false,
|
|
35
|
+
configurable: true
|
|
36
|
+
});
|
|
29
37
|
return GraphAxis;
|
|
30
38
|
}());
|
|
31
39
|
export { GraphAxis };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphAxis.js","sourceRoot":"","sources":["../../src/Graph/GraphAxis.ts"],"names":[],"mappings":"AAGA;
|
|
1
|
+
{"version":3,"file":"GraphAxis.js","sourceRoot":"","sources":["../../src/Graph/GraphAxis.ts"],"names":[],"mappings":"AAGA;IAqBE,mBAAY,EAUX;YATC,IAAI,UAAA,EACJ,IAAI,UAAA,EACJ,QAAQ,cAAA,EACR,KAAK,WAAA;QAOL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAlCD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,+BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAGD,sBAAI,4BAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAkBH,gBAAC;AAAD,CAAC,AArCD,IAqCC"}
|
|
@@ -3,7 +3,7 @@ import { Graph, GraphType } from "./Graph";
|
|
|
3
3
|
export declare class GraphChart extends Graph {
|
|
4
4
|
_x: GraphAxis | undefined;
|
|
5
5
|
get x(): GraphAxis | undefined;
|
|
6
|
-
_y: GraphAxis | undefined;
|
|
7
|
-
get y(): GraphAxis | undefined;
|
|
6
|
+
_y: GraphAxis[] | undefined;
|
|
7
|
+
get y(): GraphAxis[] | undefined;
|
|
8
8
|
constructor(type: GraphType, element: HTMLElement);
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphAxis } from ".";
|
|
2
2
|
export var parseXYAxis = function (nodes) {
|
|
3
|
-
var xyAxis = {};
|
|
3
|
+
var xyAxis = { x: undefined, y: [] };
|
|
4
4
|
Array.prototype.forEach.call(nodes, function (child) {
|
|
5
5
|
if (child.nodeType === child.ELEMENT_NODE) {
|
|
6
6
|
if (child.nodeName === "field") {
|
|
@@ -8,6 +8,7 @@ export var parseXYAxis = function (nodes) {
|
|
|
8
8
|
var axis = child.getAttribute("axis");
|
|
9
9
|
var operator = child.getAttribute("operator");
|
|
10
10
|
var name_1 = child.getAttribute("name");
|
|
11
|
+
var label = child.getAttribute("label");
|
|
11
12
|
if (!axis) {
|
|
12
13
|
throw new Error("Field " + name_1 + " doesn't have an axis");
|
|
13
14
|
}
|
|
@@ -18,12 +19,13 @@ export var parseXYAxis = function (nodes) {
|
|
|
18
19
|
axis: axis,
|
|
19
20
|
name: name_1,
|
|
20
21
|
operator: operator,
|
|
22
|
+
label: label || undefined,
|
|
21
23
|
});
|
|
22
24
|
if (axis === "x") {
|
|
23
25
|
xyAxis.x = graphAxis;
|
|
24
26
|
}
|
|
25
27
|
else if (axis === "y") {
|
|
26
|
-
xyAxis.y
|
|
28
|
+
xyAxis.y.push(graphAxis);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphHelper.js","sourceRoot":"","sources":["../../src/Graph/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YAEH,IAAI,IAAI,KAAK,GAAG,EAAE;gBAChB,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;aACtB;iBAAM,IAAI,IAAI,KAAK,GAAG,EAAE;gBACvB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC1B;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAgB,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -9,7 +9,8 @@ export var parseContext = function (_a) {
|
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
11
|
// TODO: maybe this can be accomplished more performant and elegant with regex
|
|
12
|
-
var
|
|
12
|
+
var singleQuotesReplace = context.replace(/\"/g, "'");
|
|
13
|
+
var strNoWhitespaces = singleQuotesReplace.replace(/\s/g, "");
|
|
13
14
|
var replaceTrue = strNoWhitespaces.replace(/True/g, "true");
|
|
14
15
|
var replaceFalse = replaceTrue.replace(/False/g, "false");
|
|
15
16
|
var strNoClauLeft = replaceFalse.replace(/\{/g, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextParser.js","sourceRoot":"","sources":["../../src/helpers/contextParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,EAQ5B;QAPC,OAAO,aAAA,EACP,MAAM,YAAA,EACN,MAAM,YAAA;IAMN,mGAAmG;IACnG,IAAI;QACF,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAE/B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO,SAAS,CAAC;SAClB;QAED,8EAA8E;QAC9E,IAAM,
|
|
1
|
+
{"version":3,"file":"contextParser.js","sourceRoot":"","sources":["../../src/helpers/contextParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,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MAAM;gBACnB,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EACpB;gBACA,IAAM,aAAa,GAAG,gBAAgB,CAAC;oBACrC,MAAM,QAAA;oBACN,MAAM,QAAA;oBACN,SAAS,EAAE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;iBACxD,CAAC,CAAC;gBACH,eAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,aAAa,IAAI,SAAS,CAAC;aACxE;iBAAM;gBACL,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;oBACvB,eAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;iBAClD;qBAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;oBAC/B,eAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;iBACnD;qBAAM;oBACL,eAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAC1D,IAAI,EACJ,EAAE,CACH,CAAC;iBACH;aACF;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,eAAa,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/Graph/GraphAxis.ts
CHANGED
|
@@ -17,17 +17,25 @@ export class GraphAxis {
|
|
|
17
17
|
return this._operator;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
_label: string | undefined;
|
|
21
|
+
get label(): string | undefined {
|
|
22
|
+
return this._label;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
constructor({
|
|
21
26
|
name,
|
|
22
27
|
axis,
|
|
23
28
|
operator,
|
|
29
|
+
label,
|
|
24
30
|
}: {
|
|
25
31
|
name: string;
|
|
26
32
|
axis: Axis;
|
|
27
33
|
operator?: Operator;
|
|
34
|
+
label: string | undefined;
|
|
28
35
|
}) {
|
|
29
36
|
this._name = name;
|
|
30
37
|
this._axis = axis;
|
|
31
38
|
this._operator = operator;
|
|
39
|
+
this._label = label;
|
|
32
40
|
}
|
|
33
41
|
}
|
package/src/Graph/GraphChart.ts
CHANGED
|
@@ -8,8 +8,8 @@ export class GraphChart extends Graph {
|
|
|
8
8
|
return this._x;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
_y: GraphAxis | undefined;
|
|
12
|
-
get y(): GraphAxis | undefined {
|
|
11
|
+
_y: GraphAxis[] | undefined;
|
|
12
|
+
get y(): GraphAxis[] | undefined {
|
|
13
13
|
return this._y;
|
|
14
14
|
}
|
|
15
15
|
constructor(type: GraphType, element: HTMLElement) {
|
package/src/Graph/graphHelper.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Axis, GraphAxis, Operator } from ".";
|
|
2
2
|
|
|
3
3
|
export type XYAxis = {
|
|
4
|
-
x: GraphAxis;
|
|
5
|
-
y: GraphAxis;
|
|
4
|
+
x: GraphAxis | undefined;
|
|
5
|
+
y: GraphAxis[];
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const parseXYAxis = (nodes: NodeListOf<ChildNode>): XYAxis => {
|
|
9
|
-
const xyAxis:
|
|
9
|
+
const xyAxis: XYAxis = { x: undefined, y: [] };
|
|
10
10
|
|
|
11
11
|
Array.prototype.forEach.call(nodes, (child: Element) => {
|
|
12
12
|
if (child.nodeType === child.ELEMENT_NODE) {
|
|
@@ -15,6 +15,7 @@ export const parseXYAxis = (nodes: NodeListOf<ChildNode>): XYAxis => {
|
|
|
15
15
|
const axis = child.getAttribute("axis");
|
|
16
16
|
const operator = child.getAttribute("operator");
|
|
17
17
|
const name = child.getAttribute("name");
|
|
18
|
+
const label = child.getAttribute("label");
|
|
18
19
|
|
|
19
20
|
if (!axis) {
|
|
20
21
|
throw new Error(`Field ${name} doesn't have an axis`);
|
|
@@ -28,12 +29,13 @@ export const parseXYAxis = (nodes: NodeListOf<ChildNode>): XYAxis => {
|
|
|
28
29
|
axis: axis as Axis,
|
|
29
30
|
name,
|
|
30
31
|
operator: operator as Operator,
|
|
32
|
+
label: label || undefined,
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
if (axis === "x") {
|
|
34
36
|
xyAxis.x = graphAxis;
|
|
35
37
|
} else if (axis === "y") {
|
|
36
|
-
xyAxis.y
|
|
38
|
+
xyAxis.y.push(graphAxis);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
});
|
|
@@ -18,7 +18,8 @@ export const parseContext = ({
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// TODO: maybe this can be accomplished more performant and elegant with regex
|
|
21
|
-
const
|
|
21
|
+
const singleQuotesReplace = context.replace(/\"/g, "'");
|
|
22
|
+
const strNoWhitespaces = singleQuotesReplace.replace(/\s/g, "");
|
|
22
23
|
var replaceTrue = strNoWhitespaces.replace(/True/g, "true");
|
|
23
24
|
var replaceFalse = replaceTrue.replace(/False/g, "false");
|
|
24
25
|
const strNoClauLeft = replaceFalse.replace(/\{/g, "");
|
package/src/spec/Graph.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphIndicator, GraphChart, parseGraph } from "..";
|
|
1
|
+
import { GraphIndicator, GraphChart, parseGraph, GraphAxis } from "..";
|
|
2
2
|
|
|
3
3
|
describe("A Graph", () => {
|
|
4
4
|
it("should parse a basic XML title and type indicator", () => {
|
|
@@ -22,14 +22,16 @@ describe("A Graph", () => {
|
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
const graph = parseGraph(xml) as GraphChart;
|
|
25
|
+
const y: GraphAxis = graph.y![0];
|
|
26
|
+
|
|
25
27
|
expect(graph.type).toBe("line");
|
|
26
28
|
expect(graph.x).toBeDefined();
|
|
27
29
|
expect(graph.y).toBeDefined();
|
|
28
30
|
expect(graph.x?.name).toBe("data_alta");
|
|
29
|
-
expect(
|
|
31
|
+
expect(y.name).toBe("data_alta");
|
|
30
32
|
expect(graph.x?.axis).toBe("x");
|
|
31
|
-
expect(
|
|
33
|
+
expect(y.axis).toBe("y");
|
|
32
34
|
expect(graph.x?.operator).toBeNull();
|
|
33
|
-
expect(
|
|
35
|
+
expect(y.operator).toBe("+");
|
|
34
36
|
});
|
|
35
37
|
});
|
|
@@ -71,5 +71,14 @@ describe("A Context Parser", () => {
|
|
|
71
71
|
expect(parsedContext!["active_id"]).toBeDefined();
|
|
72
72
|
expect(parsedContext!["active_id"]).toBe(3);
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
it("should properly parse with double quotes", () => {
|
|
76
|
+
const str = "{\"active_id\": 3}";
|
|
77
|
+
|
|
78
|
+
const parsedContext = parseContext({ context: str });
|
|
79
|
+
|
|
80
|
+
expect(parsedContext!["active_id"]).toBeDefined();
|
|
81
|
+
expect(parsedContext!["active_id"]).toBe(3);
|
|
82
|
+
});
|
|
74
83
|
});
|
|
75
84
|
});
|