@vixoniccom/kpi-chart 0.0.1-dev.4 → 0.0.1-dev.5
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 +7 -0
- package/build/main.js +97 -7
- package/build.zip +0 -0
- package/package.json +3 -2
- package/src/components/App.tsx +12 -3
- package/src/components/utils.ts +1 -1
- package/src/style.css +9 -0
package/build.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Lorenzo Alfaro Bravo"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.0.1-dev.
|
|
11
|
+
"version": "0.0.1-dev.5",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"prepublishOnly": "vixonic-module-packager --mode=build",
|
|
14
14
|
"watch": "vixonic-module-packager --mode=watch",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"localforage": "^1.10.0",
|
|
25
25
|
"react": "^17.0.2",
|
|
26
26
|
"react-charts": "^3.0.0-beta.57",
|
|
27
|
-
"react-dom": "^17.0.2"
|
|
27
|
+
"react-dom": "^17.0.2",
|
|
28
|
+
"react-loader-spinner": "^6.1.6"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/react": "^18.3.12",
|
package/src/components/App.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
1
2
|
import axios from "axios";
|
|
2
3
|
import localforage from "localforage";
|
|
3
|
-
import
|
|
4
|
+
import { Circles } from "react-loader-spinner";
|
|
4
5
|
import { FontLoader } from "./FontLoader";
|
|
5
6
|
import { ChartContainer } from "./ChartContainer";
|
|
6
7
|
import { FormattedText } from "./FormattedText";
|
|
@@ -39,6 +40,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
39
40
|
const backgroundImageState = params?.backgroundImage
|
|
40
41
|
? `url("${data.downloadsPath}/${params?.backgroundImage.filename}")`
|
|
41
42
|
: "";
|
|
43
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
42
44
|
// Definición de variable que contiene los datos procesados provenientes de la URL
|
|
43
45
|
const [sheetData, setSheetData] = useState<Series[]>([]);
|
|
44
46
|
// Definición de mensaje del sistema
|
|
@@ -46,7 +48,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
46
48
|
"Sin datos disponibles"
|
|
47
49
|
);
|
|
48
50
|
// Definición de nombre fijo de columna de categoría
|
|
49
|
-
const categoryColumnName = "
|
|
51
|
+
const categoryColumnName = "category";
|
|
50
52
|
// Definición de cantidad máxima de columnas y filas para procesar desde Google
|
|
51
53
|
const fixedMaxRows = 100;
|
|
52
54
|
const fixedMaxColumns = 10; // 10 máx, no usar más, a menos que sea agreguen más colores en ChartContainer
|
|
@@ -56,8 +58,10 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
56
58
|
|
|
57
59
|
// Función para hacer request de Google y almacenar los datos procesados en localforage
|
|
58
60
|
const getData = async () => {
|
|
61
|
+
setLoading(true);
|
|
59
62
|
const googleID = params?.url?.split("/")[5];
|
|
60
63
|
const key = getStorageKey(googleID);
|
|
64
|
+
localforage.clear();
|
|
61
65
|
const storedData: any = await localforage.getItem(key);
|
|
62
66
|
if (!storedData?.items || storedData?.items?.length === 0) {
|
|
63
67
|
const data = await requestData(googleID);
|
|
@@ -74,6 +78,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
74
78
|
setDataAndTime(storedData.items, targetDate - now);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
81
|
+
setLoading(false);
|
|
77
82
|
};
|
|
78
83
|
|
|
79
84
|
// Función para actualizar el estado de los datos y el tiempo de actualización
|
|
@@ -169,7 +174,11 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
169
174
|
downloadsPath={data.downloadsPath}
|
|
170
175
|
/>
|
|
171
176
|
{/* Render de chart o mensaje del sistema/personalizado */}
|
|
172
|
-
{
|
|
177
|
+
{loading ? (
|
|
178
|
+
<div className="loading-container">
|
|
179
|
+
<Circles ariaLabel="loading-indicator" color="gray" />
|
|
180
|
+
</div>
|
|
181
|
+
) : sheetData.length > 0 ? (
|
|
173
182
|
<ChartContainer data={sheetData} parameters={params} />
|
|
174
183
|
) : (
|
|
175
184
|
<FormattedText
|
package/src/components/utils.ts
CHANGED
|
@@ -158,7 +158,7 @@ export const getCleanData = (
|
|
|
158
158
|
if (h === "" || h === undefined) {
|
|
159
159
|
return `nn-feature-${index}`;
|
|
160
160
|
}
|
|
161
|
-
return h.trim().toLocaleLowerCase()
|
|
161
|
+
return h.trim().toLocaleLowerCase();
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
// Eliminación de duplicados (columnas y registros)
|
package/src/style.css
CHANGED