@upsnap/strapi 1.0.4 → 1.0.7

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.
@@ -8288,6 +8288,19 @@ function PageHeader({
8288
8288
  }
8289
8289
  );
8290
8290
  }
8291
+ const LoadingCard = () => /* @__PURE__ */ jsxRuntime.jsxs(
8292
+ designSystem.Flex,
8293
+ {
8294
+ direction: "column",
8295
+ justifyContent: "center",
8296
+ margin: 8,
8297
+ height: { initial: "300px", medium: "400px" },
8298
+ children: [
8299
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}),
8300
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Loading..." })
8301
+ ]
8302
+ }
8303
+ );
8291
8304
  function Dashboard() {
8292
8305
  const [monitorData, setMonitorData] = React.useState(null);
8293
8306
  const [uptimeStats, setUptimeStats] = React.useState(null);
@@ -8313,6 +8326,7 @@ function Dashboard() {
8313
8326
  }
8314
8327
  return "default";
8315
8328
  });
8329
+ const MAX_MONITOR_RETRIES = 3;
8316
8330
  React.useEffect(() => {
8317
8331
  (async () => {
8318
8332
  const fetchedMonitorId = await getPrimaryMonitorId();
@@ -8353,17 +8367,29 @@ function Dashboard() {
8353
8367
  React.useEffect(() => {
8354
8368
  getRegionResponseTimeData();
8355
8369
  }, [responseTimeData, selectedRegion]);
8356
- const handleRefresh = () => {
8370
+ const fetchMonitorDataWithRetry = async (retries = MAX_MONITOR_RETRIES) => {
8371
+ for (let attempt = 0; attempt < retries; attempt++) {
8372
+ try {
8373
+ const res = await request(`/monitor/${monitorId}`, { method: "GET" });
8374
+ if (res?.monitor?.message === "Invalid authentication token") {
8375
+ navigate("/plugins/upsnap/settings");
8376
+ return null;
8377
+ }
8378
+ if (res.monitor?.data) {
8379
+ return res.monitor.data;
8380
+ }
8381
+ } catch (err) {
8382
+ }
8383
+ await new Promise((resolve) => setTimeout(resolve, 500));
8384
+ }
8385
+ return null;
8386
+ };
8387
+ const handleRefresh = async () => {
8357
8388
  const { start, end } = getRangeTimestamps(responseTimeRange || "last_24_hours");
8358
8389
  setIsLoading(true);
8359
- request(`/monitor/${monitorId}`, {
8360
- method: "GET"
8361
- }).then((res) => {
8362
- if (res?.monitor?.message === "Invalid authentication token") {
8363
- navigate("/plugins/upsnap/settings");
8364
- }
8365
- setMonitorData(res.monitor?.data || null);
8366
- });
8390
+ if (!monitorId) return;
8391
+ const monitor = await fetchMonitorDataWithRetry();
8392
+ setMonitorData(monitor);
8367
8393
  request(`/monitor/${monitorId}/uptime-stats?region=${selectedRegion}`, {
8368
8394
  method: "GET"
8369
8395
  }).then((res) => {
@@ -8389,7 +8415,7 @@ function Dashboard() {
8389
8415
  setMonitorIncidents(res.incidentsData?.data || null);
8390
8416
  });
8391
8417
  };
8392
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 1, children: [
8418
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 1, children: !monitorData || isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingCard, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8393
8419
  /* @__PURE__ */ jsxRuntime.jsx(
8394
8420
  PageHeader,
8395
8421
  {
@@ -8415,26 +8441,36 @@ function Dashboard() {
8415
8441
  alignItems: "start",
8416
8442
  style: { alignContent: "space-around", justifyItems: "stretch" },
8417
8443
  children: [
8418
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 4, height: "100%", alignItems: "start", style: { flexWrap: "wrap" }, children: [
8419
- /* @__PURE__ */ jsxRuntime.jsx(
8420
- StatisticsCards,
8421
- {
8422
- monitorData,
8423
- uptimeStats,
8424
- histogramData,
8425
- isLoading
8426
- }
8427
- ),
8428
- /* @__PURE__ */ jsxRuntime.jsx(
8429
- ResponseTimeChart,
8430
- {
8431
- monitor: monitorData?.monitor,
8432
- regionResponseTimeData,
8433
- timeRange: responseTimeRange || "last_24_hours",
8434
- onTimeRangeChange: handleTimeRangeChange
8435
- }
8436
- )
8437
- ] }) }),
8444
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
8445
+ designSystem.Flex,
8446
+ {
8447
+ direction: "column",
8448
+ gap: 4,
8449
+ height: "100%",
8450
+ alignItems: "start",
8451
+ style: { flexWrap: "wrap" },
8452
+ children: [
8453
+ /* @__PURE__ */ jsxRuntime.jsx(
8454
+ StatisticsCards,
8455
+ {
8456
+ monitorData,
8457
+ uptimeStats,
8458
+ histogramData,
8459
+ isLoading
8460
+ }
8461
+ ),
8462
+ /* @__PURE__ */ jsxRuntime.jsx(
8463
+ ResponseTimeChart,
8464
+ {
8465
+ monitor: monitorData?.monitor,
8466
+ regionResponseTimeData,
8467
+ timeRange: responseTimeRange || "last_24_hours",
8468
+ onTimeRangeChange: handleTimeRangeChange
8469
+ }
8470
+ )
8471
+ ]
8472
+ }
8473
+ ) }),
8438
8474
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(HealthCards, { monitorData, isLoading }) })
8439
8475
  ]
8440
8476
  }
@@ -8447,7 +8483,7 @@ function Dashboard() {
8447
8483
  isLoading
8448
8484
  }
8449
8485
  )
8450
- ] }) });
8486
+ ] }) }) });
8451
8487
  }
8452
8488
  const DetailRow = ({ label, value, isUrl = false, isChip = false }) => {
8453
8489
  const renderValue = () => {
@@ -8536,19 +8572,6 @@ const StatusCard = ({ status, message, error, cardData }) => {
8536
8572
  }
8537
8573
  ) }) }) }) });
8538
8574
  };
8539
- const LoadingCard = () => /* @__PURE__ */ jsxRuntime.jsxs(
8540
- designSystem.Flex,
8541
- {
8542
- direction: "column",
8543
- justifyContent: "center",
8544
- margin: 8,
8545
- height: { initial: "300px", medium: "400px" },
8546
- children: [
8547
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}),
8548
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Loading..." })
8549
- ]
8550
- }
8551
- );
8552
8575
  function RegionWiseCards({
8553
8576
  regions,
8554
8577
  regionNames,
@@ -8281,6 +8281,19 @@ function PageHeader({
8281
8281
  }
8282
8282
  );
8283
8283
  }
8284
+ const LoadingCard = () => /* @__PURE__ */ jsxs(
8285
+ Flex,
8286
+ {
8287
+ direction: "column",
8288
+ justifyContent: "center",
8289
+ margin: 8,
8290
+ height: { initial: "300px", medium: "400px" },
8291
+ children: [
8292
+ /* @__PURE__ */ jsx(Loader, {}),
8293
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Loading..." })
8294
+ ]
8295
+ }
8296
+ );
8284
8297
  function Dashboard() {
8285
8298
  const [monitorData, setMonitorData] = useState(null);
8286
8299
  const [uptimeStats, setUptimeStats] = useState(null);
@@ -8306,6 +8319,7 @@ function Dashboard() {
8306
8319
  }
8307
8320
  return "default";
8308
8321
  });
8322
+ const MAX_MONITOR_RETRIES = 3;
8309
8323
  useEffect(() => {
8310
8324
  (async () => {
8311
8325
  const fetchedMonitorId = await getPrimaryMonitorId();
@@ -8346,17 +8360,29 @@ function Dashboard() {
8346
8360
  useEffect(() => {
8347
8361
  getRegionResponseTimeData();
8348
8362
  }, [responseTimeData, selectedRegion]);
8349
- const handleRefresh = () => {
8363
+ const fetchMonitorDataWithRetry = async (retries = MAX_MONITOR_RETRIES) => {
8364
+ for (let attempt = 0; attempt < retries; attempt++) {
8365
+ try {
8366
+ const res = await request(`/monitor/${monitorId}`, { method: "GET" });
8367
+ if (res?.monitor?.message === "Invalid authentication token") {
8368
+ navigate("/plugins/upsnap/settings");
8369
+ return null;
8370
+ }
8371
+ if (res.monitor?.data) {
8372
+ return res.monitor.data;
8373
+ }
8374
+ } catch (err) {
8375
+ }
8376
+ await new Promise((resolve) => setTimeout(resolve, 500));
8377
+ }
8378
+ return null;
8379
+ };
8380
+ const handleRefresh = async () => {
8350
8381
  const { start, end } = getRangeTimestamps(responseTimeRange || "last_24_hours");
8351
8382
  setIsLoading(true);
8352
- request(`/monitor/${monitorId}`, {
8353
- method: "GET"
8354
- }).then((res) => {
8355
- if (res?.monitor?.message === "Invalid authentication token") {
8356
- navigate("/plugins/upsnap/settings");
8357
- }
8358
- setMonitorData(res.monitor?.data || null);
8359
- });
8383
+ if (!monitorId) return;
8384
+ const monitor = await fetchMonitorDataWithRetry();
8385
+ setMonitorData(monitor);
8360
8386
  request(`/monitor/${monitorId}/uptime-stats?region=${selectedRegion}`, {
8361
8387
  method: "GET"
8362
8388
  }).then((res) => {
@@ -8382,7 +8408,7 @@ function Dashboard() {
8382
8408
  setMonitorIncidents(res.incidentsData?.data || null);
8383
8409
  });
8384
8410
  };
8385
- return /* @__PURE__ */ jsx(Main, { children: /* @__PURE__ */ jsxs(Box, { padding: 1, children: [
8411
+ return /* @__PURE__ */ jsx(Main, { children: /* @__PURE__ */ jsx(Box, { padding: 1, children: !monitorData || isLoading ? /* @__PURE__ */ jsx(LoadingCard, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
8386
8412
  /* @__PURE__ */ jsx(
8387
8413
  PageHeader,
8388
8414
  {
@@ -8408,26 +8434,36 @@ function Dashboard() {
8408
8434
  alignItems: "start",
8409
8435
  style: { alignContent: "space-around", justifyItems: "stretch" },
8410
8436
  children: [
8411
- /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, height: "100%", alignItems: "start", style: { flexWrap: "wrap" }, children: [
8412
- /* @__PURE__ */ jsx(
8413
- StatisticsCards,
8414
- {
8415
- monitorData,
8416
- uptimeStats,
8417
- histogramData,
8418
- isLoading
8419
- }
8420
- ),
8421
- /* @__PURE__ */ jsx(
8422
- ResponseTimeChart,
8423
- {
8424
- monitor: monitorData?.monitor,
8425
- regionResponseTimeData,
8426
- timeRange: responseTimeRange || "last_24_hours",
8427
- onTimeRangeChange: handleTimeRangeChange
8428
- }
8429
- )
8430
- ] }) }),
8437
+ /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(
8438
+ Flex,
8439
+ {
8440
+ direction: "column",
8441
+ gap: 4,
8442
+ height: "100%",
8443
+ alignItems: "start",
8444
+ style: { flexWrap: "wrap" },
8445
+ children: [
8446
+ /* @__PURE__ */ jsx(
8447
+ StatisticsCards,
8448
+ {
8449
+ monitorData,
8450
+ uptimeStats,
8451
+ histogramData,
8452
+ isLoading
8453
+ }
8454
+ ),
8455
+ /* @__PURE__ */ jsx(
8456
+ ResponseTimeChart,
8457
+ {
8458
+ monitor: monitorData?.monitor,
8459
+ regionResponseTimeData,
8460
+ timeRange: responseTimeRange || "last_24_hours",
8461
+ onTimeRangeChange: handleTimeRangeChange
8462
+ }
8463
+ )
8464
+ ]
8465
+ }
8466
+ ) }),
8431
8467
  /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsx(HealthCards, { monitorData, isLoading }) })
8432
8468
  ]
8433
8469
  }
@@ -8440,7 +8476,7 @@ function Dashboard() {
8440
8476
  isLoading
8441
8477
  }
8442
8478
  )
8443
- ] }) });
8479
+ ] }) }) });
8444
8480
  }
8445
8481
  const DetailRow = ({ label, value, isUrl = false, isChip = false }) => {
8446
8482
  const renderValue = () => {
@@ -8529,19 +8565,6 @@ const StatusCard = ({ status, message, error, cardData }) => {
8529
8565
  }
8530
8566
  ) }) }) }) });
8531
8567
  };
8532
- const LoadingCard = () => /* @__PURE__ */ jsxs(
8533
- Flex,
8534
- {
8535
- direction: "column",
8536
- justifyContent: "center",
8537
- margin: 8,
8538
- height: { initial: "300px", medium: "400px" },
8539
- children: [
8540
- /* @__PURE__ */ jsx(Loader, {}),
8541
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Loading..." })
8542
- ]
8543
- }
8544
- );
8545
8568
  function RegionWiseCards({
8546
8569
  regions,
8547
8570
  regionNames,
@@ -38,7 +38,7 @@ const index = {
38
38
  defaultMessage: PLUGIN_ID.slice(0, 1).toUpperCase() + PLUGIN_ID.slice(1)
39
39
  },
40
40
  Component: async () => {
41
- const { App } = await Promise.resolve().then(() => require("./App-wfO4MA3Z.js"));
41
+ const { App } = await Promise.resolve().then(() => require("./App-Bo_F3q6I.js"));
42
42
  return App;
43
43
  }
44
44
  });
@@ -36,7 +36,7 @@ const index = {
36
36
  defaultMessage: PLUGIN_ID.slice(0, 1).toUpperCase() + PLUGIN_ID.slice(1)
37
37
  },
38
38
  Component: async () => {
39
- const { App } = await import("./App-B9MprOch.mjs");
39
+ const { App } = await import("./App-DQN0F1ZK.mjs");
40
40
  return App;
41
41
  }
42
42
  });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.4",
2
+ "version": "1.0.7",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "https://github.com/Appfoster/upsnap-strapi"