From 425cea280158d7bf1a03089980a58cfabd37dfab Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Wed, 19 Jun 2024 15:43:26 +0200 Subject: [PATCH 01/30] feat: enable dashboard plugin entry point --- d2.config.js | 11 +- src/DashboardPlugin.js | 579 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 585 insertions(+), 5 deletions(-) create mode 100644 src/DashboardPlugin.js diff --git a/d2.config.js b/d2.config.js index 721b00c9..b8abd165 100644 --- a/d2.config.js +++ b/d2.config.js @@ -1,9 +1,10 @@ const config = { - type: "app", - title: "Climate Data", - entryPoints: { - app: "./src/App.js", - }, + type: "app", + title: "Climate Data", + entryPoints: { + app: "./src/App.js", + plugin: "./src/DashboardPlugin.js", + }, }; module.exports = config; diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js new file mode 100644 index 00000000..2008d373 --- /dev/null +++ b/src/DashboardPlugin.js @@ -0,0 +1,579 @@ +import { DashboardPluginWrapper } from "@dhis2/analytics"; +import React, { useEffect, useState } from "react"; +import OrgUnit from "./components/explore/OrgUnit.js"; + +const DashboardPlugin = (props) => { + const [propsFromParent, setPropsFromParent] = useState(props); + + useEffect(() => setPropsFromParent(props), [props]); + + const orgUnit = { + type: "Feature", + id: "O6uvpzGd5pu", + geometry: { + type: "Polygon", + coordinates: [ + [ + [-11.5914, 8.4875], + [-11.5906, 8.4769], + [-11.5898, 8.4717], + [-11.5882, 8.466], + [-11.5863, 8.4604], + [-11.5837, 8.4549], + [-11.5804, 8.4505], + [-11.5772, 8.4477], + [-11.5738, 8.4456], + [-11.5622, 8.44], + [-11.558, 8.4365], + [-11.5567, 8.4332], + [-11.5565, 8.4295], + [-11.558, 8.4215], + [-11.5582, 8.4185], + [-11.5569, 8.4121], + [-11.5567, 8.4084], + [-11.5571, 8.4047], + [-11.5589, 8.3968], + [-11.5588, 8.3927], + [-11.5574, 8.3877], + [-11.5549, 8.3835], + [-11.5506, 8.3751], + [-11.5488, 8.3707], + [-11.5438, 8.3562], + [-11.5418, 8.3519], + [-11.5398, 8.3489], + [-11.5361, 8.3451], + [-11.5278, 8.3419], + [-11.516, 8.3381], + [-11.5114, 8.3375], + [-11.4946, 8.3367], + [-11.487, 8.3293], + [-11.4838, 8.3251], + [-11.4817, 8.3208], + [-11.4806, 8.3171], + [-11.4795, 8.3018], + [-11.4781, 8.2958], + [-11.4755, 8.2871], + [-11.4735, 8.2834], + [-11.4655, 8.2739], + [-11.4604, 8.2666], + [-11.4574, 8.2635], + [-11.4541, 8.2608], + [-11.4466, 8.2567], + [-11.4348, 8.251], + [-11.4318, 8.2488], + [-11.4281, 8.2452], + [-11.4258, 8.2422], + [-11.4218, 8.2348], + [-11.4183, 8.2272], + [-11.4141, 8.2153], + [-11.4109, 8.2118], + [-11.4048, 8.2085], + [-11.3982, 8.2063], + [-11.3948, 8.2045], + [-11.3916, 8.202], + [-11.3832, 8.1947], + [-11.376, 8.1901], + [-11.3665, 8.1835], + [-11.3669, 8.1797], + [-11.367, 8.1749], + [-11.3682, 8.1693], + [-11.3705, 8.1626], + [-11.3736, 8.1564], + [-11.3695, 8.1524], + [-11.3657, 8.1475], + [-11.3638, 8.1444], + [-11.3623, 8.1407], + [-11.3589, 8.1286], + [-11.3574, 8.1218], + [-11.3525, 8.1071], + [-11.3509, 8.1012], + [-11.3505, 8.0968], + [-11.3504, 8.091], + [-11.3508, 8.0868], + [-11.3516, 8.0819], + [-11.3498, 8.072], + [-11.347, 8.0602], + [-11.3469, 8.056], + [-11.3474, 8.0496], + [-11.3471, 8.0454], + [-11.3456, 8.0375], + [-11.343, 8.0281], + [-11.3425, 8.0253], + [-11.342, 8.0181], + [-11.3418, 7.9976], + [-11.3421, 7.9905], + [-11.3434, 7.9842], + [-11.3477, 7.9708], + [-11.3517, 7.9604], + [-11.3547, 7.9582], + [-11.3645, 7.9522], + [-11.3689, 7.9486], + [-11.3794, 7.9387], + [-11.3816, 7.9369], + [-11.3879, 7.9327], + [-11.3965, 7.9257], + [-11.4018, 7.9224], + [-11.4076, 7.9182], + [-11.413, 7.915], + [-11.42, 7.9101], + [-11.4389, 7.9003], + [-11.449, 7.8935], + [-11.4518, 7.8911], + [-11.4541, 7.8883], + [-11.4566, 7.8844], + [-11.4608, 7.8783], + [-11.467, 7.8668], + [-11.4727, 7.8591], + [-11.4743, 7.8554], + [-11.4751, 7.8514], + [-11.475, 7.8461], + [-11.4744, 7.842], + [-11.4725, 7.8351], + [-11.4716, 7.8295], + [-11.4714, 7.8227], + [-11.4732, 7.8089], + [-11.4743, 7.8025], + [-11.4592, 7.8053], + [-11.4564, 7.8061], + [-11.4489, 7.8097], + [-11.4419, 7.8143], + [-11.4383, 7.8157], + [-11.4336, 7.816], + [-11.4299, 7.8149], + [-11.4253, 7.8128], + [-11.4243, 7.808], + [-11.4211, 7.8027], + [-11.4171, 7.7954], + [-11.4129, 7.7869], + [-11.4111, 7.7811], + [-11.4106, 7.775], + [-11.4112, 7.7695], + [-11.4134, 7.7623], + [-11.4147, 7.7544], + [-11.4169, 7.745], + [-11.4174, 7.7409], + [-11.4178, 7.7326], + [-11.4185, 7.7286], + [-11.4199, 7.725], + [-11.427, 7.7125], + [-11.4281, 7.7086], + [-11.4285, 7.7042], + [-11.4283, 7.6998], + [-11.4278, 7.6969], + [-11.4256, 7.6927], + [-11.4289, 7.6901], + [-11.4315, 7.6877], + [-11.4344, 7.6866], + [-11.4378, 7.6867], + [-11.4411, 7.6885], + [-11.4477, 7.6971], + [-11.4506, 7.7001], + [-11.4539, 7.7026], + [-11.4578, 7.704], + [-11.4644, 7.7039], + [-11.4691, 7.7021], + [-11.4744, 7.6992], + [-11.4829, 7.6921], + [-11.4902, 7.687], + [-11.4988, 7.6801], + [-11.5114, 7.6728], + [-11.5211, 7.6651], + [-11.5359, 7.6576], + [-11.5412, 7.6564], + [-11.5461, 7.6536], + [-11.5491, 7.6505], + [-11.5507, 7.6473], + [-11.5514, 7.6436], + [-11.5512, 7.6391], + [-11.5483, 7.628], + [-11.5477, 7.6232], + [-11.5472, 7.6166], + [-11.5471, 7.6069], + [-11.5475, 7.6039], + [-11.5485, 7.601], + [-11.551, 7.5982], + [-11.554, 7.5968], + [-11.5589, 7.5963], + [-11.5661, 7.5968], + [-11.5817, 7.591], + [-11.5861, 7.5876], + [-11.5889, 7.5845], + [-11.591, 7.581], + [-11.5947, 7.5687], + [-11.5988, 7.559], + [-11.6011, 7.5552], + [-11.6038, 7.5529], + [-11.6108, 7.5496], + [-11.6144, 7.5465], + [-11.6178, 7.5423], + [-11.6258, 7.5363], + [-11.6295, 7.5341], + [-11.6323, 7.5333], + [-11.6366, 7.5328], + [-11.641, 7.5327], + [-11.6454, 7.5329], + [-11.6497, 7.5337], + [-11.6537, 7.5354], + [-11.6626, 7.5412], + [-11.666, 7.5438], + [-11.6699, 7.5479], + [-11.6807, 7.5643], + [-11.6831, 7.5672], + [-11.686, 7.5695], + [-11.6936, 7.5731], + [-11.6978, 7.5739], + [-11.7021, 7.574], + [-11.705, 7.5737], + [-11.7078, 7.5731], + [-11.7136, 7.5711], + [-11.7212, 7.5697], + [-11.7272, 7.5681], + [-11.731, 7.5715], + [-11.7384, 7.5755], + [-11.7408, 7.5789], + [-11.7414, 7.5809], + [-11.7408, 7.5849], + [-11.7387, 7.5886], + [-11.7358, 7.5918], + [-11.7261, 7.6013], + [-11.7227, 7.6059], + [-11.7206, 7.6116], + [-11.7201, 7.6144], + [-11.7197, 7.6275], + [-11.7193, 7.6317], + [-11.7175, 7.6377], + [-11.7169, 7.641], + [-11.7218, 7.6546], + [-11.7232, 7.6598], + [-11.737, 7.6593], + [-11.7451, 7.6556], + [-11.7485, 7.6536], + [-11.7526, 7.6497], + [-11.7549, 7.6464], + [-11.7568, 7.6393], + [-11.7563, 7.6339], + [-11.7546, 7.6269], + [-11.7551, 7.6228], + [-11.7565, 7.6202], + [-11.7594, 7.6168], + [-11.7627, 7.6138], + [-11.7678, 7.6104], + [-11.7701, 7.6077], + [-11.7718, 7.6027], + [-11.7718, 7.5971], + [-11.7709, 7.593], + [-11.769, 7.5874], + [-11.7692, 7.5829], + [-11.7708, 7.5802], + [-11.7733, 7.5785], + [-11.7777, 7.5777], + [-11.7816, 7.5781], + [-11.7886, 7.5805], + [-11.7926, 7.5812], + [-11.7981, 7.5814], + [-11.8052, 7.5804], + [-11.8119, 7.5776], + [-11.8216, 7.573], + [-11.8275, 7.5696], + [-11.83, 7.567], + [-11.8311, 7.564], + [-11.831, 7.5592], + [-11.8295, 7.5548], + [-11.826, 7.5485], + [-11.8246, 7.5446], + [-11.8229, 7.5348], + [-11.8215, 7.5302], + [-11.8211, 7.5269], + [-11.8221, 7.5226], + [-11.8237, 7.5198], + [-11.8293, 7.5146], + [-11.8378, 7.5032], + [-11.8421, 7.4958], + [-11.8452, 7.4912], + [-11.8479, 7.4891], + [-11.8545, 7.4864], + [-11.8605, 7.4835], + [-11.8632, 7.492], + [-11.8665, 7.4987], + [-11.8675, 7.5014], + [-11.868, 7.5043], + [-11.8689, 7.5132], + [-11.87, 7.5176], + [-11.8714, 7.5202], + [-11.8731, 7.5226], + [-11.8829, 7.534], + [-11.886, 7.536], + [-11.8888, 7.5366], + [-11.8931, 7.5369], + [-11.8974, 7.5366], + [-11.9016, 7.5354], + [-11.9054, 7.5333], + [-11.9127, 7.5306], + [-11.917, 7.5296], + [-11.9246, 7.529], + [-11.9337, 7.5293], + [-11.9367, 7.5298], + [-11.9395, 7.5306], + [-11.9469, 7.5346], + [-11.9496, 7.5356], + [-11.9525, 7.5361], + [-11.9629, 7.5371], + [-11.9658, 7.5379], + [-11.9694, 7.5399], + [-11.9716, 7.5417], + [-11.9752, 7.5459], + [-11.9773, 7.5496], + [-11.9811, 7.5607], + [-11.9846, 7.5742], + [-11.9868, 7.5845], + [-11.9903, 7.5911], + [-11.9945, 7.6004], + [-11.9935, 7.6107], + [-11.9933, 7.6301], + [-11.9992, 7.6298], + [-12.0037, 7.6299], + [-12.008, 7.6308], + [-12.017, 7.635], + [-12.0257, 7.642], + [-12.0327, 7.6469], + [-12.0352, 7.6497], + [-12.0369, 7.6528], + [-12.0381, 7.6561], + [-12.0398, 7.6629], + [-12.0414, 7.6674], + [-12.0459, 7.6759], + [-12.0514, 7.6906], + [-12.0592, 7.6983], + [-12.0646, 7.7027], + [-12.0734, 7.7071], + [-12.0809, 7.7098], + [-12.0925, 7.7081], + [-12.1021, 7.7076], + [-12.1099, 7.7076], + [-12.1128, 7.7078], + [-12.1157, 7.7086], + [-12.1187, 7.7108], + [-12.121, 7.7147], + [-12.1219, 7.7188], + [-12.1222, 7.7234], + [-12.122, 7.7392], + [-12.1228, 7.7453], + [-12.1244, 7.7491], + [-12.1306, 7.7553], + [-12.1326, 7.7585], + [-12.1333, 7.7613], + [-12.1338, 7.7658], + [-12.1338, 7.7717], + [-12.1334, 7.7758], + [-12.1323, 7.7824], + [-12.133, 7.786], + [-12.1352, 7.8036], + [-12.1344, 7.813], + [-12.1348, 7.8184], + [-12.136, 7.8219], + [-12.1396, 7.8266], + [-12.1404, 7.8308], + [-12.1389, 7.8399], + [-12.1383, 7.8457], + [-12.1382, 7.8561], + [-12.1387, 7.8634], + [-12.1398, 7.8675], + [-12.1434, 7.874], + [-12.1472, 7.8812], + [-12.1481, 7.8844], + [-12.1483, 7.8878], + [-12.1474, 7.8921], + [-12.1436, 7.8994], + [-12.1401, 7.9036], + [-12.1331, 7.9105], + [-12.1314, 7.9153], + [-12.1312, 7.9238], + [-12.1315, 7.9267], + [-12.1324, 7.9302], + [-12.1353, 7.9343], + [-12.1386, 7.937], + [-12.143, 7.9388], + [-12.1429, 7.9448], + [-12.1418, 7.9491], + [-12.1397, 7.9521], + [-12.1369, 7.9541], + [-12.1314, 7.9565], + [-12.1166, 7.958], + [-12.1126, 7.9591], + [-12.1016, 7.9637], + [-12.095, 7.9658], + [-12.0839, 7.9699], + [-12.0756, 7.9751], + [-12.0693, 7.9785], + [-12.0606, 7.9824], + [-12.0561, 7.9832], + [-12.0421, 7.9841], + [-12.0391, 7.9847], + [-12.0344, 7.9861], + [-12.03, 7.9868], + [-12.0098, 7.9876], + [-12.0054, 7.9884], + [-12.0007, 7.9898], + [-11.9978, 7.9903], + [-11.9843, 7.9908], + [-11.9799, 7.9912], + [-11.976, 7.9926], + [-11.9726, 7.9957], + [-11.9713, 7.9984], + [-11.9657, 7.9993], + [-11.9597, 8.0011], + [-11.9558, 8.0016], + [-11.9505, 8.0013], + [-11.9433, 7.9997], + [-11.9393, 7.9996], + [-11.9336, 8.0007], + [-11.9304, 8.0006], + [-11.9272, 7.9994], + [-11.9234, 7.9974], + [-11.9176, 7.9925], + [-11.9071, 7.9882], + [-11.9005, 7.9859], + [-11.8904, 7.9809], + [-11.8823, 7.9793], + [-11.8786, 7.9781], + [-11.8736, 7.9744], + [-11.8686, 7.9726], + [-11.8627, 7.9723], + [-11.8582, 7.9727], + [-11.8542, 7.9738], + [-11.8431, 7.9786], + [-11.8361, 7.9797], + [-11.8287, 7.9798], + [-11.8235, 7.9771], + [-11.817, 7.9754], + [-11.8199, 7.9839], + [-11.8213, 7.9873], + [-11.8257, 7.992], + [-11.8278, 7.9951], + [-11.8293, 8.0001], + [-11.8294, 8.0037], + [-11.8418, 8.0148], + [-11.8461, 8.0182], + [-11.8497, 8.0201], + [-11.8561, 8.0223], + [-11.8625, 8.0255], + [-11.8659, 8.0278], + [-11.8735, 8.034], + [-11.8913, 8.0454], + [-11.8966, 8.05], + [-11.9004, 8.0541], + [-11.9024, 8.0575], + [-11.9036, 8.0608], + [-11.9042, 8.0648], + [-11.9039, 8.0689], + [-11.902, 8.0745], + [-11.8987, 8.0811], + [-11.8968, 8.092], + [-11.8957, 8.0959], + [-11.8929, 8.1013], + [-11.889, 8.1098], + [-11.8849, 8.1151], + [-11.877, 8.1229], + [-11.8737, 8.1316], + [-11.8683, 8.1425], + [-11.8652, 8.1467], + [-11.8623, 8.1497], + [-11.8601, 8.1515], + [-11.8577, 8.1531], + [-11.855, 8.1542], + [-11.8522, 8.1547], + [-11.8493, 8.1548], + [-11.8436, 8.1542], + [-11.8376, 8.1524], + [-11.8332, 8.1516], + [-11.8161, 8.151], + [-11.8115, 8.1505], + [-11.8075, 8.1492], + [-11.7998, 8.1452], + [-11.7955, 8.1442], + [-11.7893, 8.1437], + [-11.7894, 8.1511], + [-11.7965, 8.1587], + [-11.8005, 8.1648], + [-11.8057, 8.1719], + [-11.8105, 8.1802], + [-11.812, 8.1854], + [-11.8125, 8.1968], + [-11.812, 8.2053], + [-11.8105, 8.2113], + [-11.8059, 8.226], + [-11.8023, 8.2408], + [-11.8018, 8.2437], + [-11.8015, 8.2497], + [-11.8014, 8.2558], + [-11.8017, 8.2603], + [-11.8025, 8.2647], + [-11.8042, 8.2683], + [-11.8067, 8.2714], + [-11.8118, 8.2766], + [-11.8298, 8.2936], + [-11.8325, 8.2967], + [-11.8339, 8.2996], + [-11.8338, 8.3035], + [-11.8318, 8.3079], + [-11.8268, 8.3126], + [-11.8206, 8.3164], + [-11.8178, 8.3189], + [-11.8159, 8.3219], + [-11.8144, 8.3275], + [-11.8147, 8.3309], + [-11.816, 8.3353], + [-11.8179, 8.3397], + [-11.8204, 8.3437], + [-11.8262, 8.351], + [-11.823, 8.3601], + [-11.8211, 8.3634], + [-11.8166, 8.3686], + [-11.8113, 8.3731], + [-11.8028, 8.3777], + [-11.7952, 8.3811], + [-11.7885, 8.3829], + [-11.7839, 8.3846], + [-11.7749, 8.3864], + [-11.7701, 8.389], + [-11.7671, 8.392], + [-11.7648, 8.3953], + [-11.7625, 8.4008], + [-11.7593, 8.4108], + [-11.7574, 8.4152], + [-11.7544, 8.4194], + [-11.7434, 8.4316], + [-11.7387, 8.44], + [-11.7349, 8.4486], + [-11.7335, 8.4531], + [-11.7321, 8.4599], + [-11.7308, 8.4645], + [-11.7281, 8.4708], + [-11.7259, 8.4736], + [-11.7218, 8.477], + [-11.7175, 8.4819], + [-11.7146, 8.4842], + [-11.7103, 8.487], + [-11.7061, 8.4848], + [-11.6984, 8.4803], + [-11.6889, 8.482], + [-11.6765, 8.4832], + [-11.6674, 8.4855], + [-11.6626, 8.4861], + [-11.6527, 8.4864], + [-11.6095, 8.4863], + [-11.5914, 8.4875], + ], + ], + }, + properties: { name: "Bo" }, + }; + + return ( + + {(props) => } + + ); +}; + +export default DashboardPlugin; From 20a3428742fc3a169ea408f27883fad0d9dd49d6 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Wed, 19 Jun 2024 15:44:56 +0200 Subject: [PATCH 02/30] chore: use latest cli-app-scripts and analytics dev branch --- package.json | 2 +- yarn.lock | 328 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 321 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 475429ab..e732af24 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "@dhis2/cli-app-scripts": "^11.7.0" }, "dependencies": { + "@dhis2/analytics": "git+https://github.com/d2-ci/analytics.git#dca4316cdf2a8fd9482dfe1244575baad7ffe228", "@dhis2/app-runtime": "^3.10.6", - "@dhis2/multi-calendar-dates": "1.0.0-alpha.27", "@turf/area": "^6.5.0", "highcharts": "^10.3.3", "react-router-dom": "^6.26.0" diff --git a/yarn.lock b/yarn.lock index 6e114731..187cec4f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1110,7 +1110,29 @@ resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310" integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== -"@babel/runtime@^7.10.0", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.8", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4": +"@babel/runtime-corejs2@^7.4.2": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.24.7.tgz#28e73d50c44812060a58548c5096be4243ee3ee5" + integrity sha512-+Lf6xofiPZLtFwNkpjGHPgJck4b22Yo8h9+WHf3bEbS4ikOyOMNtJk6HSTolEQ2irH1XSoeguaCkrkcgyThrMA== + dependencies: + core-js "^2.6.12" + regenerator-runtime "^0.14.0" + +"@babel/runtime@^7.1.2", "@babel/runtime@^7.9.2": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12" + integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw== + dependencies: + regenerator-runtime "^0.14.0" + +"@babel/runtime@^7.10.0", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.23.2", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4": + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.7.tgz#dd7c88deeb218a0f8bd34d5db1aa242e0f203193" + integrity sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA== + dependencies: + regenerator-runtime "^0.14.0" + +"@babel/runtime@^7.23.8": version "7.25.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.0.tgz#3af9a91c1b739c569d5d80cc917280919c544ecb" integrity sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw== @@ -1855,6 +1877,26 @@ classnames "^2.3.1" prop-types "^15.7.2" +"@dhis2/analytics@git+https://github.com/d2-ci/analytics.git#dca4316cdf2a8fd9482dfe1244575baad7ffe228": + version "26.7.3" + resolved "git+https://github.com/d2-ci/analytics.git#dca4316cdf2a8fd9482dfe1244575baad7ffe228" + dependencies: + "@dhis2/multi-calendar-dates" "1.0.0" + "@dnd-kit/core" "^6.0.7" + "@dnd-kit/sortable" "^7.0.2" + "@dnd-kit/utilities" "^3.2.1" + "@react-hook/debounce" "^4.0.0" + classnames "^2.3.1" + crypto-js "^4.1.1" + d2-utilizr "^0.2.16" + d3-color "^1.2.3" + highcharts "^10.3.3" + lodash "^4.17.21" + markdown-it "^13.0.1" + mathjs "^9.4.2" + react-beautiful-dnd "^10.1.1" + resize-observer-polyfill "^1.5.1" + "@dhis2/app-adapter@11.7.0": version "11.7.0" resolved "https://registry.yarnpkg.com/@dhis2/app-adapter/-/app-adapter-11.7.0.tgz#5ceb982dc377dd4cdcf70ce1cbc5b0a038780ca6" @@ -1863,7 +1905,18 @@ "@dhis2/pwa" "11.7.0" moment "^2.24.0" -"@dhis2/app-runtime@^3.10.4", "@dhis2/app-runtime@^3.10.6": +"@dhis2/app-runtime@^3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-runtime/-/app-runtime-3.10.4.tgz#6064ac728770cc94c4d1975db32bd38533655cc6" + integrity sha512-W/d0WcYYcKAeE5/xCunZEMYUSD1fxG+JDQdRDEUsH5y5hB8i/4o2QQrZK8xa19Z3xQJhaW5ypWWqIQVjTJT2Ww== + dependencies: + "@dhis2/app-service-alerts" "3.10.4" + "@dhis2/app-service-config" "3.10.4" + "@dhis2/app-service-data" "3.10.4" + "@dhis2/app-service-offline" "3.10.4" + "@dhis2/app-service-plugin" "3.10.4" + +"@dhis2/app-runtime@^3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-runtime/-/app-runtime-3.10.6.tgz#10add0b8a2e1de06777e6e78c681a3a8f15ba058" integrity sha512-WfC+AHkw0V3V3/wyLPHoTyAf8i4btLl/R2nMBVs3NEXLwA9mekG/gXs7AEPnK2/p6FVoqXMDwJHEH2b8Iw4UFw== @@ -2005,7 +2058,7 @@ i18next "^10.3" moment "^2.24.0" -"@dhis2/multi-calendar-dates@1.0.0-alpha.27": +"@dhis2/multi-calendar-dates@1.0.0", "@dhis2/multi-calendar-dates@1.0.0-alpha.27": version "1.0.0-alpha.27" resolved "https://registry.yarnpkg.com/@dhis2/multi-calendar-dates/-/multi-calendar-dates-1.0.0-alpha.27.tgz#01bacfba4fdcfd8125fc3493041352ec136f6233" integrity sha512-gaWQ2BclRL6U36FcmGKfl26qS7B2Q+4EGuz5ckYOHblgbkiyh5rZ3JQ5uOvdKIWoPcsOhBri+ZuGc8T9/MTNeQ== @@ -2125,6 +2178,37 @@ "@dhis2/ui-icons" "9.11.1" prop-types "^15.7.2" +"@dnd-kit/accessibility@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@dnd-kit/accessibility/-/accessibility-3.1.0.tgz#1054e19be276b5f1154ced7947fc0cb5d99192e0" + integrity sha512-ea7IkhKvlJUv9iSHJOnxinBcoOI3ppGnnL+VDJ75O45Nss6HtZd8IdN8touXPDtASfeI2T2LImb8VOZcL47wjQ== + dependencies: + tslib "^2.0.0" + +"@dnd-kit/core@^6.0.7": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@dnd-kit/core/-/core-6.1.0.tgz#e81a3d10d9eca5d3b01cbf054171273a3fe01def" + integrity sha512-J3cQBClB4TVxwGo3KEjssGEXNJqGVWx17aRTZ1ob0FliR5IjYgTxl5YJbKTzA6IzrtelotH19v6y7uoIRUZPSg== + dependencies: + "@dnd-kit/accessibility" "^3.1.0" + "@dnd-kit/utilities" "^3.2.2" + tslib "^2.0.0" + +"@dnd-kit/sortable@^7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@dnd-kit/sortable/-/sortable-7.0.2.tgz#791d550872457f3f3c843e00d159b640f982011c" + integrity sha512-wDkBHHf9iCi1veM834Gbk1429bd4lHX4RpAwT0y2cHLf246GAvU2sVw/oxWNpPKQNQRQaeGXhAVgrOl1IT+iyA== + dependencies: + "@dnd-kit/utilities" "^3.2.0" + tslib "^2.0.0" + +"@dnd-kit/utilities@^3.2.0", "@dnd-kit/utilities@^3.2.1", "@dnd-kit/utilities@^3.2.2": + version "3.2.2" + resolved "https://registry.yarnpkg.com/@dnd-kit/utilities/-/utilities-3.2.2.tgz#5a32b6af356dc5f74d61b37d6f7129a4040ced7b" + integrity sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg== + dependencies: + tslib "^2.0.0" + "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -2523,6 +2607,13 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== +"@react-hook/debounce@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@react-hook/debounce/-/debounce-4.0.0.tgz#5da87e7bfa158cfe2830ffc997dc1b755e261379" + integrity sha512-706Xcg+KKWHk9BuZQUQ0ZQKp9zhv3/MbqFenWVfHcynYpSGRVwQTzJRGvPxvsdtXxJv+HfgKTY/O/hEejakwmA== + dependencies: + "@react-hook/latest" "^1.0.2" + "@react-hook/latest@^1.0.2": version "1.0.3" resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80" @@ -4572,6 +4663,11 @@ commondir@^1.0.1: resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== +complex.js@^2.0.15: + version "2.1.1" + resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.1.1.tgz#0675dac8e464ec431fb2ab7d30f41d889fb25c31" + integrity sha512-8njCHOTtFFLtegk6zQo0kkVX1rngygb/KQI6z1qZxlFI3scluC+LVTCFbrkWjBv4vvLlbQ9t88IPMC6k95VTTg== + compress-commons@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-2.1.1.tgz#9410d9a534cf8435e3fbbb7c6ce48de2dc2f0610" @@ -4690,6 +4786,11 @@ core-js-pure@^3.23.3: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.38.0.tgz#bc802cd152e33d5b0ec733b656c71cb847cac701" integrity sha512-8balb/HAXo06aHP58mZMtXgD8vcnXz9tUDePgqBgJgKdmTlMt+jw3ujqniuBDQXMvTzxnMpxHFeuSM3g1jWQuQ== +core-js@^2.6.12: + version "2.6.12" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" + integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== + core-js@^3.19.2: version "3.38.0" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.38.0.tgz#8acb7c050bf2ccbb35f938c0d040132f6110f636" @@ -4784,6 +4885,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" +crypto-js@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.2.0.tgz#4d931639ecdfd12ff80e8186dba6af2c2e856631" + integrity sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q== + crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" @@ -4801,6 +4907,13 @@ css-blank-pseudo@^3.0.3: dependencies: postcss-selector-parser "^6.0.9" +css-box-model@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/css-box-model/-/css-box-model-1.2.1.tgz#59951d3b81fd6b2074a62d49444415b0d2b4d7c1" + integrity sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw== + dependencies: + tiny-invariant "^1.0.6" + css-declaration-sorter@^6.3.1: version "6.4.1" resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz#28beac7c20bad7f1775be3a7129d7eae409a3a71" @@ -4984,6 +5097,24 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== +d2-utilizr@^0.2.16: + version "0.2.16" + resolved "https://registry.yarnpkg.com/d2-utilizr/-/d2-utilizr-0.2.16.tgz#b71df7ca8c7ab5125ca8bdb4899611bc6782a754" + integrity sha512-8Cqwe/3TIsHeLfRVsWFKYqRrY3ZzuHAJqkEMCPGW9gyNCAAnTPVjROFwBwonv0zodQhVntn1DlJCay/GTBPj1A== + dependencies: + lodash.isboolean "^3.0.3" + lodash.isfunction "^3.0.8" + lodash.ismap "^4.3.0" + lodash.isnumber "^3.0.3" + lodash.isobject "^3.0.2" + lodash.isset "^4.3.0" + lodash.isstring "^4.0.1" + +d3-color@^1.2.3: + version "1.4.1" + resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-1.4.1.tgz#c52002bf8846ada4424d55d97982fef26eb3bc8a" + integrity sha512-p2sTHSLCJI2QKunbGb7ocOh7DgTAn8IrLx21QRc/BSnodXM4sv6aLQlnfpvehFMLZEfBc6g9pH9SWQccFYfJ9Q== + damerau-levenshtein@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" @@ -5058,7 +5189,7 @@ decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== -decimal.js@^10.2.1: +decimal.js@^10.2.1, decimal.js@^10.3.1: version "10.4.3" resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.3.tgz#1044092884d245d1b7f65725fa4ad4c6f781cc23" integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA== @@ -5460,6 +5591,11 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== +entities@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" + integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== + eol@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/eol/-/eol-0.9.1.tgz#f701912f504074be35c6117a5c4ade49cd547acd" @@ -5630,6 +5766,11 @@ escape-html@^1.0.3, escape-html@~1.0.3: resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== +escape-latex@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/escape-latex/-/escape-latex-1.2.0.tgz#07c03818cf7dac250cce517f4fda1b001ef2bca1" + integrity sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw== + escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -6292,7 +6433,7 @@ forwarded@0.2.0: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== -fraction.js@^4.3.7: +fraction.js@^4.1.1, fraction.js@^4.3.7: version "4.3.7" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew== @@ -6759,6 +6900,13 @@ highcharts@^10.3.3: resolved "https://registry.yarnpkg.com/highcharts/-/highcharts-10.3.3.tgz#b8acca24f2d4b1f2f726540734166e59e07b35c4" integrity sha512-r7wgUPQI9tr3jFDn3XT36qsNwEIZYcfgz4mkKEA6E4nn5p86y+u1EZjazIG4TRkl5/gmGRtkBUiZW81g029RIw== +hoist-non-react-statics@^3.3.0: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hoopy@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" @@ -7090,6 +7238,13 @@ internal-slot@^1.0.4, internal-slot@^1.0.7: hasown "^2.0.0" side-channel "^1.0.4" +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" @@ -7552,6 +7707,11 @@ jake@^10.8.5: filelist "^1.0.4" minimatch "^3.1.2" +javascript-natural-sort@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59" + integrity sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw== + jest-changed-files@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-27.5.1.tgz#a348aed00ec9bf671cc58a66fcbe7c3dfd6a68f5" @@ -8325,6 +8485,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +linkify-it@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-4.0.1.tgz#01f1d5e508190d06669982ba31a7d9f56a5751ec" + integrity sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw== + dependencies: + uc.micro "^1.0.1" + loader-runner@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" @@ -8400,11 +8567,46 @@ lodash.get@^4.4.2: resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== +lodash.isboolean@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" + integrity sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg== + +lodash.isfunction@^3.0.8: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" + integrity sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw== + +lodash.ismap@^4.3.0: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.ismap/-/lodash.ismap-4.4.2.tgz#836bf06dee57fd3d2aa357bf6946e61d1e77e279" + integrity sha512-djSMwsQ2aRroLLC+xNzJXIFkEkM28FYzNykbBPZpcgdsNV9vx+BIwuMUoSBSf+1f7wB+pym/nlAWCOeI+L8ysw== + +lodash.isnumber@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" + integrity sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw== + +lodash.isobject@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/lodash.isobject/-/lodash.isobject-3.0.2.tgz#3c8fb8d5b5bf4bf90ae06e14f2a530a4ed935e1d" + integrity sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA== + lodash.isplainobject@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA== +lodash.isset@^4.3.0: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.isset/-/lodash.isset-4.4.2.tgz#d5eecc56b7a97ab588509e4795b3541b1cdb67bb" + integrity sha512-3+m3GgoE5hTnRfbgCvOjGVHp2YAm/+MKpAS2JkaL9b5BISNRT+VkGngS7r3nAAschsx4fdLnWsM4wcDyvu0UCA== + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + integrity sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw== + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" @@ -8519,6 +8721,17 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" +markdown-it@^13.0.1: + version "13.0.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.2.tgz#1bc22e23379a6952e5d56217fbed881e0c94d536" + integrity sha512-FtwnEuuK+2yVU7goGn/MJ0WBZMM9ZPgU9spqlFs7/A/pDIUNSOQZhUgOqYCficIuR2QaFnrt8LHqBWsbTAoI5w== + dependencies: + argparse "^2.0.1" + entities "~3.0.1" + linkify-it "^4.0.1" + mdurl "^1.0.1" + uc.micro "^1.0.5" + match-sorter@^6.0.2: version "6.3.4" resolved "https://registry.yarnpkg.com/match-sorter/-/match-sorter-6.3.4.tgz#afa779d8e922c81971fbcb4781c7003ace781be7" @@ -8527,6 +8740,21 @@ match-sorter@^6.0.2: "@babel/runtime" "^7.23.8" remove-accents "0.5.0" +mathjs@^9.4.2: + version "9.5.2" + resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-9.5.2.tgz#e0f3279320dc6f49e45d99c4fcdd8b52231f0462" + integrity sha512-c0erTq0GP503/Ch2OtDOAn50GIOsuxTMjmE00NI/vKJFSWrDaQHRjx6ai+16xYv70yBSnnpUgHZGNf9FR9IwmA== + dependencies: + "@babel/runtime" "^7.15.4" + complex.js "^2.0.15" + decimal.js "^10.3.1" + escape-latex "^1.2.0" + fraction.js "^4.1.1" + javascript-natural-sort "^0.7.1" + seedrandom "^3.0.5" + tiny-emitter "^2.1.0" + typed-function "^2.0.0" + mdn-data@2.0.14: version "2.0.14" resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" @@ -8537,6 +8765,11 @@ mdn-data@2.0.4: resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b" integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA== +mdurl@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" + integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== + media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -8549,6 +8782,11 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "^1.0.4" +memoize-one@^5.0.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.2.1.tgz#8337aa3c4335581839ec01c3d594090cebe8f00e" + integrity sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q== + merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -9927,7 +10165,7 @@ prompts@^2.0.1, prompts@^2.4.2: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: +prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== @@ -10011,6 +10249,11 @@ queue-microtask@^1.2.2: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +raf-schd@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/raf-schd/-/raf-schd-4.0.3.tgz#5d6c34ef46f8b2a0e880a8fcdb743efc5bfdbc1a" + integrity sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ== + raf@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39" @@ -10062,6 +10305,20 @@ react-app-polyfill@^3.0.0: regenerator-runtime "^0.13.9" whatwg-fetch "^3.6.2" +react-beautiful-dnd@^10.1.1: + version "10.1.1" + resolved "https://registry.yarnpkg.com/react-beautiful-dnd/-/react-beautiful-dnd-10.1.1.tgz#d753088d77d7632e77cf8a8935fafcffa38f574b" + integrity sha512-TdE06Shfp56wm28EzjgC56EEMgGI5PDHejJ2bxuAZvZr8CVsbksklsJC06Hxf0MSL7FHbflL/RpkJck9isuxHg== + dependencies: + "@babel/runtime-corejs2" "^7.4.2" + css-box-model "^1.1.1" + memoize-one "^5.0.1" + prop-types "^15.6.1" + raf-schd "^4.0.0" + react-redux "^5.0.7" + redux "^4.0.1" + tiny-invariant "^1.0.4" + react-dev-utils@^12.0.0, react-dev-utils@^12.0.1: version "12.0.1" resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73" @@ -10119,7 +10376,7 @@ react-final-form@^6.5.3: dependencies: "@babel/runtime" "^7.15.4" -react-is@^16.13.1: +react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -10134,6 +10391,11 @@ react-is@^18.0.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== +react-lifecycles-compat@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" + integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA== + react-popper@^2.2.5: version "2.3.0" resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-2.3.0.tgz#17891c620e1320dce318bad9fede46a5f71c70ba" @@ -10151,6 +10413,19 @@ react-query@^3.13.11: broadcast-channel "^3.4.1" match-sorter "^6.0.2" +react-redux@^5.0.7: + version "5.1.2" + resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.1.2.tgz#b19cf9e21d694422727bf798e934a916c4080f57" + integrity sha512-Ns1G0XXc8hDyH/OcBHOxNgQx9ayH3SPxBnFCOidGKSle8pKihysQw2rG/PmciUQRoclhVBO8HMhiRmGXnDja9Q== + dependencies: + "@babel/runtime" "^7.1.2" + hoist-non-react-statics "^3.3.0" + invariant "^2.2.4" + loose-envify "^1.1.0" + prop-types "^15.6.1" + react-is "^16.6.0" + react-lifecycles-compat "^3.0.0" + react-refresh@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046" @@ -10278,6 +10553,13 @@ recursive-readdir@^2.2.2: dependencies: minimatch "^3.0.5" +redux@^4.0.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.1.tgz#c08f4306826c49b5e9dc901dee0452ea8fce6197" + integrity sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w== + dependencies: + "@babel/runtime" "^7.9.2" + reflect.getprototypeof@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz#3ab04c32a8390b770712b7a8633972702d278859" @@ -10704,6 +10986,11 @@ schema-utils@^4.0.0, schema-utils@^4.2.0: ajv-formats "^2.1.1" ajv-keywords "^5.1.0" +seedrandom@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" + integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== + select-hose@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" @@ -11615,6 +11902,16 @@ thunky@^1.0.2: resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== +tiny-emitter@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" + integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q== + +tiny-invariant@^1.0.4, tiny-invariant@^1.0.6: + version "1.3.3" + resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.3.tgz#46680b7a873a0d5d10005995eb90a70d74d60127" + integrity sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg== + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -11721,11 +12018,16 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.3, tslib@^2.3.1: +tslib@^2.0.0, tslib@^2.3.1: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== +tslib@^2.0.3: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -11836,6 +12138,11 @@ typed-array-length@^1.0.6: is-typed-array "^1.1.13" possible-typed-array-names "^1.0.0" +typed-function@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.1.0.tgz#ded6f8a442ba8749ff3fe75bc41419c8d46ccc3f" + integrity sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ== + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -11858,6 +12165,11 @@ typescript@^3.6.3: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== +uc.micro@^1.0.1, uc.micro@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== + uglify-js@^3.1.4: version "3.19.2" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.19.2.tgz#319ae26a5fbd18d03c7dc02496cfa1d6f1cd4307" From 297f425ba5659725fb6a13d53c451a61d9bffe9a Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Mon, 12 Aug 2024 12:05:32 +0200 Subject: [PATCH 03/30] chore: indicate this is a dashboard plugin in d2.config.js --- d2.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/d2.config.js b/d2.config.js index b8abd165..c1539e57 100644 --- a/d2.config.js +++ b/d2.config.js @@ -1,5 +1,6 @@ const config = { type: "app", + pluginType: "dashboard", title: "Climate Data", entryPoints: { app: "./src/App.js", From 642f6f908d1ae1210afb4a259da246eb68f1ee90 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 16 Aug 2024 09:52:31 +0200 Subject: [PATCH 04/30] chore: use uppercase for pluginType value --- d2.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2.config.js b/d2.config.js index c1539e57..cb2a77de 100644 --- a/d2.config.js +++ b/d2.config.js @@ -1,6 +1,6 @@ const config = { type: "app", - pluginType: "dashboard", + pluginType: "DASHBOARD", title: "Climate Data", entryPoints: { app: "./src/App.js", From fbd92dbed6085e261341c722625189f3f107c17c Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 16 Aug 2024 09:57:56 +0200 Subject: [PATCH 05/30] chore: restore missing dep after rebase --- package.json | 1 + yarn.lock | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/package.json b/package.json index e732af24..136934cd 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "@dhis2/analytics": "git+https://github.com/d2-ci/analytics.git#dca4316cdf2a8fd9482dfe1244575baad7ffe228", "@dhis2/app-runtime": "^3.10.6", + "@dhis2/multi-calendar-dates": "1.0.0-alpha.27", "@turf/area": "^6.5.0", "highcharts": "^10.3.3", "react-router-dom": "^6.26.0" diff --git a/yarn.lock b/yarn.lock index 187cec4f..a1bff611 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1927,16 +1927,33 @@ "@dhis2/app-service-offline" "3.10.6" "@dhis2/app-service-plugin" "3.10.6" +"@dhis2/app-service-alerts@3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-service-alerts/-/app-service-alerts-3.10.4.tgz#a7cce660015d79980679175e677cf6c6c3f4c7eb" + integrity sha512-DmSLx/kHOHpgGiL8zG0oa6D3MeCY3wPMDGqj+Gfegr654Lmyf4d2vLI7HSZUSOCdraP/fSYTypsdZmWYoXoLBQ== + "@dhis2/app-service-alerts@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-alerts/-/app-service-alerts-3.10.6.tgz#47e65d7ed57a4bd801a513b0f71d0ed2839ea363" integrity sha512-2r9IUBp5Z5zuSqjTEWpt+rx7tP5AqrtkPJ8ZVOKW5YBn1DB4bQ5ti9GOevHM4othr7Mrmt22UADPgfEkfc7XzQ== +"@dhis2/app-service-config@3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-service-config/-/app-service-config-3.10.4.tgz#2bede4df9b036350200cbc085a2a68439fa4fa0a" + integrity sha512-SCFdNxJKpiBjYsU9s0R+u9GrXjzmUEpGpudmC5eQqNV6ajLiebe/pS2jcSPFzjUtHVQMADk0X8TkERoOBqWcxA== + "@dhis2/app-service-config@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-config/-/app-service-config-3.10.6.tgz#bf952156329ab48d6da407522c6e06072fdf896a" integrity sha512-Z/rSBjCc8kP78QYhKNyGoCafGfwpqMDg8mV2x/H6CavgEicOa+qHX3bkKV6+fC9Sw2FnsWHRemxYRkgbW/BD3g== +"@dhis2/app-service-data@3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-service-data/-/app-service-data-3.10.4.tgz#dcd993a24d2edd97e7ad8a042a682e60582740ff" + integrity sha512-RaoWniioCe33PcPZoDuO66qOrIt0JeeCN8RzmCDrRVGvGmlDTZ3hNuWm9CnsAvO1U6sYDiulKPqrEQu8YKMG0w== + dependencies: + react-query "^3.13.11" + "@dhis2/app-service-data@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-data/-/app-service-data-3.10.6.tgz#2f3f522b4a5a8c8d531f8901cca502323e566042" @@ -1944,6 +1961,13 @@ dependencies: react-query "^3.13.11" +"@dhis2/app-service-offline@3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-service-offline/-/app-service-offline-3.10.4.tgz#dcdaf3a76c6c7a71f28c89a403ec130bf10fcdf3" + integrity sha512-SUUS+sw3FjR0TMdKSSOVzL8IfPA185gSTHQ1WE4tLc2zE92elvxLL9FuSUuTbu+l1Kr4nRQNLh8muOMWKGnWDg== + dependencies: + lodash "^4.17.21" + "@dhis2/app-service-offline@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-offline/-/app-service-offline-3.10.6.tgz#e1d83520bb292fc51b24eab65d05e1c9fa1e2ad6" @@ -1951,6 +1975,13 @@ dependencies: lodash "^4.17.21" +"@dhis2/app-service-plugin@3.10.4": + version "3.10.4" + resolved "https://registry.yarnpkg.com/@dhis2/app-service-plugin/-/app-service-plugin-3.10.4.tgz#f5412a1320393042012dd75713e3215e51628554" + integrity sha512-GW6xa/5y2yFXvhtLConnaOxKqyu6VPZWRBaQR73/bRRmFcnd7hlMkZ2M0GWSjoW4QHLXlLhXHFsgHPETBftkPg== + dependencies: + post-robot "^10.0.46" + "@dhis2/app-service-plugin@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-plugin/-/app-service-plugin-3.10.6.tgz#1c6792b6d051c4b3301d76d083c3364424140a83" From 9ae7804574f3207e2fbe76f3c37d81995f8faa03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 21 Aug 2024 17:56:03 +0200 Subject: [PATCH 06/30] Minimal dashboard plugin --- d2.config.js | 2 +- src/DashboardPlugin.js | 579 ----------------------- src/components/plugin/DashboardPlugin.js | 18 + src/components/plugin/Plugin.js | 8 + 4 files changed, 27 insertions(+), 580 deletions(-) delete mode 100644 src/DashboardPlugin.js create mode 100644 src/components/plugin/DashboardPlugin.js create mode 100644 src/components/plugin/Plugin.js diff --git a/d2.config.js b/d2.config.js index 255a66b0..2bfe1795 100644 --- a/d2.config.js +++ b/d2.config.js @@ -4,7 +4,7 @@ const config = { title: "Climate app", entryPoints: { app: "./src/App.js", - plugin: "./src/DashboardPlugin.js", + plugin: "./src/plugin/DashboardPlugin.js", }, }; diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js deleted file mode 100644 index 2008d373..00000000 --- a/src/DashboardPlugin.js +++ /dev/null @@ -1,579 +0,0 @@ -import { DashboardPluginWrapper } from "@dhis2/analytics"; -import React, { useEffect, useState } from "react"; -import OrgUnit from "./components/explore/OrgUnit.js"; - -const DashboardPlugin = (props) => { - const [propsFromParent, setPropsFromParent] = useState(props); - - useEffect(() => setPropsFromParent(props), [props]); - - const orgUnit = { - type: "Feature", - id: "O6uvpzGd5pu", - geometry: { - type: "Polygon", - coordinates: [ - [ - [-11.5914, 8.4875], - [-11.5906, 8.4769], - [-11.5898, 8.4717], - [-11.5882, 8.466], - [-11.5863, 8.4604], - [-11.5837, 8.4549], - [-11.5804, 8.4505], - [-11.5772, 8.4477], - [-11.5738, 8.4456], - [-11.5622, 8.44], - [-11.558, 8.4365], - [-11.5567, 8.4332], - [-11.5565, 8.4295], - [-11.558, 8.4215], - [-11.5582, 8.4185], - [-11.5569, 8.4121], - [-11.5567, 8.4084], - [-11.5571, 8.4047], - [-11.5589, 8.3968], - [-11.5588, 8.3927], - [-11.5574, 8.3877], - [-11.5549, 8.3835], - [-11.5506, 8.3751], - [-11.5488, 8.3707], - [-11.5438, 8.3562], - [-11.5418, 8.3519], - [-11.5398, 8.3489], - [-11.5361, 8.3451], - [-11.5278, 8.3419], - [-11.516, 8.3381], - [-11.5114, 8.3375], - [-11.4946, 8.3367], - [-11.487, 8.3293], - [-11.4838, 8.3251], - [-11.4817, 8.3208], - [-11.4806, 8.3171], - [-11.4795, 8.3018], - [-11.4781, 8.2958], - [-11.4755, 8.2871], - [-11.4735, 8.2834], - [-11.4655, 8.2739], - [-11.4604, 8.2666], - [-11.4574, 8.2635], - [-11.4541, 8.2608], - [-11.4466, 8.2567], - [-11.4348, 8.251], - [-11.4318, 8.2488], - [-11.4281, 8.2452], - [-11.4258, 8.2422], - [-11.4218, 8.2348], - [-11.4183, 8.2272], - [-11.4141, 8.2153], - [-11.4109, 8.2118], - [-11.4048, 8.2085], - [-11.3982, 8.2063], - [-11.3948, 8.2045], - [-11.3916, 8.202], - [-11.3832, 8.1947], - [-11.376, 8.1901], - [-11.3665, 8.1835], - [-11.3669, 8.1797], - [-11.367, 8.1749], - [-11.3682, 8.1693], - [-11.3705, 8.1626], - [-11.3736, 8.1564], - [-11.3695, 8.1524], - [-11.3657, 8.1475], - [-11.3638, 8.1444], - [-11.3623, 8.1407], - [-11.3589, 8.1286], - [-11.3574, 8.1218], - [-11.3525, 8.1071], - [-11.3509, 8.1012], - [-11.3505, 8.0968], - [-11.3504, 8.091], - [-11.3508, 8.0868], - [-11.3516, 8.0819], - [-11.3498, 8.072], - [-11.347, 8.0602], - [-11.3469, 8.056], - [-11.3474, 8.0496], - [-11.3471, 8.0454], - [-11.3456, 8.0375], - [-11.343, 8.0281], - [-11.3425, 8.0253], - [-11.342, 8.0181], - [-11.3418, 7.9976], - [-11.3421, 7.9905], - [-11.3434, 7.9842], - [-11.3477, 7.9708], - [-11.3517, 7.9604], - [-11.3547, 7.9582], - [-11.3645, 7.9522], - [-11.3689, 7.9486], - [-11.3794, 7.9387], - [-11.3816, 7.9369], - [-11.3879, 7.9327], - [-11.3965, 7.9257], - [-11.4018, 7.9224], - [-11.4076, 7.9182], - [-11.413, 7.915], - [-11.42, 7.9101], - [-11.4389, 7.9003], - [-11.449, 7.8935], - [-11.4518, 7.8911], - [-11.4541, 7.8883], - [-11.4566, 7.8844], - [-11.4608, 7.8783], - [-11.467, 7.8668], - [-11.4727, 7.8591], - [-11.4743, 7.8554], - [-11.4751, 7.8514], - [-11.475, 7.8461], - [-11.4744, 7.842], - [-11.4725, 7.8351], - [-11.4716, 7.8295], - [-11.4714, 7.8227], - [-11.4732, 7.8089], - [-11.4743, 7.8025], - [-11.4592, 7.8053], - [-11.4564, 7.8061], - [-11.4489, 7.8097], - [-11.4419, 7.8143], - [-11.4383, 7.8157], - [-11.4336, 7.816], - [-11.4299, 7.8149], - [-11.4253, 7.8128], - [-11.4243, 7.808], - [-11.4211, 7.8027], - [-11.4171, 7.7954], - [-11.4129, 7.7869], - [-11.4111, 7.7811], - [-11.4106, 7.775], - [-11.4112, 7.7695], - [-11.4134, 7.7623], - [-11.4147, 7.7544], - [-11.4169, 7.745], - [-11.4174, 7.7409], - [-11.4178, 7.7326], - [-11.4185, 7.7286], - [-11.4199, 7.725], - [-11.427, 7.7125], - [-11.4281, 7.7086], - [-11.4285, 7.7042], - [-11.4283, 7.6998], - [-11.4278, 7.6969], - [-11.4256, 7.6927], - [-11.4289, 7.6901], - [-11.4315, 7.6877], - [-11.4344, 7.6866], - [-11.4378, 7.6867], - [-11.4411, 7.6885], - [-11.4477, 7.6971], - [-11.4506, 7.7001], - [-11.4539, 7.7026], - [-11.4578, 7.704], - [-11.4644, 7.7039], - [-11.4691, 7.7021], - [-11.4744, 7.6992], - [-11.4829, 7.6921], - [-11.4902, 7.687], - [-11.4988, 7.6801], - [-11.5114, 7.6728], - [-11.5211, 7.6651], - [-11.5359, 7.6576], - [-11.5412, 7.6564], - [-11.5461, 7.6536], - [-11.5491, 7.6505], - [-11.5507, 7.6473], - [-11.5514, 7.6436], - [-11.5512, 7.6391], - [-11.5483, 7.628], - [-11.5477, 7.6232], - [-11.5472, 7.6166], - [-11.5471, 7.6069], - [-11.5475, 7.6039], - [-11.5485, 7.601], - [-11.551, 7.5982], - [-11.554, 7.5968], - [-11.5589, 7.5963], - [-11.5661, 7.5968], - [-11.5817, 7.591], - [-11.5861, 7.5876], - [-11.5889, 7.5845], - [-11.591, 7.581], - [-11.5947, 7.5687], - [-11.5988, 7.559], - [-11.6011, 7.5552], - [-11.6038, 7.5529], - [-11.6108, 7.5496], - [-11.6144, 7.5465], - [-11.6178, 7.5423], - [-11.6258, 7.5363], - [-11.6295, 7.5341], - [-11.6323, 7.5333], - [-11.6366, 7.5328], - [-11.641, 7.5327], - [-11.6454, 7.5329], - [-11.6497, 7.5337], - [-11.6537, 7.5354], - [-11.6626, 7.5412], - [-11.666, 7.5438], - [-11.6699, 7.5479], - [-11.6807, 7.5643], - [-11.6831, 7.5672], - [-11.686, 7.5695], - [-11.6936, 7.5731], - [-11.6978, 7.5739], - [-11.7021, 7.574], - [-11.705, 7.5737], - [-11.7078, 7.5731], - [-11.7136, 7.5711], - [-11.7212, 7.5697], - [-11.7272, 7.5681], - [-11.731, 7.5715], - [-11.7384, 7.5755], - [-11.7408, 7.5789], - [-11.7414, 7.5809], - [-11.7408, 7.5849], - [-11.7387, 7.5886], - [-11.7358, 7.5918], - [-11.7261, 7.6013], - [-11.7227, 7.6059], - [-11.7206, 7.6116], - [-11.7201, 7.6144], - [-11.7197, 7.6275], - [-11.7193, 7.6317], - [-11.7175, 7.6377], - [-11.7169, 7.641], - [-11.7218, 7.6546], - [-11.7232, 7.6598], - [-11.737, 7.6593], - [-11.7451, 7.6556], - [-11.7485, 7.6536], - [-11.7526, 7.6497], - [-11.7549, 7.6464], - [-11.7568, 7.6393], - [-11.7563, 7.6339], - [-11.7546, 7.6269], - [-11.7551, 7.6228], - [-11.7565, 7.6202], - [-11.7594, 7.6168], - [-11.7627, 7.6138], - [-11.7678, 7.6104], - [-11.7701, 7.6077], - [-11.7718, 7.6027], - [-11.7718, 7.5971], - [-11.7709, 7.593], - [-11.769, 7.5874], - [-11.7692, 7.5829], - [-11.7708, 7.5802], - [-11.7733, 7.5785], - [-11.7777, 7.5777], - [-11.7816, 7.5781], - [-11.7886, 7.5805], - [-11.7926, 7.5812], - [-11.7981, 7.5814], - [-11.8052, 7.5804], - [-11.8119, 7.5776], - [-11.8216, 7.573], - [-11.8275, 7.5696], - [-11.83, 7.567], - [-11.8311, 7.564], - [-11.831, 7.5592], - [-11.8295, 7.5548], - [-11.826, 7.5485], - [-11.8246, 7.5446], - [-11.8229, 7.5348], - [-11.8215, 7.5302], - [-11.8211, 7.5269], - [-11.8221, 7.5226], - [-11.8237, 7.5198], - [-11.8293, 7.5146], - [-11.8378, 7.5032], - [-11.8421, 7.4958], - [-11.8452, 7.4912], - [-11.8479, 7.4891], - [-11.8545, 7.4864], - [-11.8605, 7.4835], - [-11.8632, 7.492], - [-11.8665, 7.4987], - [-11.8675, 7.5014], - [-11.868, 7.5043], - [-11.8689, 7.5132], - [-11.87, 7.5176], - [-11.8714, 7.5202], - [-11.8731, 7.5226], - [-11.8829, 7.534], - [-11.886, 7.536], - [-11.8888, 7.5366], - [-11.8931, 7.5369], - [-11.8974, 7.5366], - [-11.9016, 7.5354], - [-11.9054, 7.5333], - [-11.9127, 7.5306], - [-11.917, 7.5296], - [-11.9246, 7.529], - [-11.9337, 7.5293], - [-11.9367, 7.5298], - [-11.9395, 7.5306], - [-11.9469, 7.5346], - [-11.9496, 7.5356], - [-11.9525, 7.5361], - [-11.9629, 7.5371], - [-11.9658, 7.5379], - [-11.9694, 7.5399], - [-11.9716, 7.5417], - [-11.9752, 7.5459], - [-11.9773, 7.5496], - [-11.9811, 7.5607], - [-11.9846, 7.5742], - [-11.9868, 7.5845], - [-11.9903, 7.5911], - [-11.9945, 7.6004], - [-11.9935, 7.6107], - [-11.9933, 7.6301], - [-11.9992, 7.6298], - [-12.0037, 7.6299], - [-12.008, 7.6308], - [-12.017, 7.635], - [-12.0257, 7.642], - [-12.0327, 7.6469], - [-12.0352, 7.6497], - [-12.0369, 7.6528], - [-12.0381, 7.6561], - [-12.0398, 7.6629], - [-12.0414, 7.6674], - [-12.0459, 7.6759], - [-12.0514, 7.6906], - [-12.0592, 7.6983], - [-12.0646, 7.7027], - [-12.0734, 7.7071], - [-12.0809, 7.7098], - [-12.0925, 7.7081], - [-12.1021, 7.7076], - [-12.1099, 7.7076], - [-12.1128, 7.7078], - [-12.1157, 7.7086], - [-12.1187, 7.7108], - [-12.121, 7.7147], - [-12.1219, 7.7188], - [-12.1222, 7.7234], - [-12.122, 7.7392], - [-12.1228, 7.7453], - [-12.1244, 7.7491], - [-12.1306, 7.7553], - [-12.1326, 7.7585], - [-12.1333, 7.7613], - [-12.1338, 7.7658], - [-12.1338, 7.7717], - [-12.1334, 7.7758], - [-12.1323, 7.7824], - [-12.133, 7.786], - [-12.1352, 7.8036], - [-12.1344, 7.813], - [-12.1348, 7.8184], - [-12.136, 7.8219], - [-12.1396, 7.8266], - [-12.1404, 7.8308], - [-12.1389, 7.8399], - [-12.1383, 7.8457], - [-12.1382, 7.8561], - [-12.1387, 7.8634], - [-12.1398, 7.8675], - [-12.1434, 7.874], - [-12.1472, 7.8812], - [-12.1481, 7.8844], - [-12.1483, 7.8878], - [-12.1474, 7.8921], - [-12.1436, 7.8994], - [-12.1401, 7.9036], - [-12.1331, 7.9105], - [-12.1314, 7.9153], - [-12.1312, 7.9238], - [-12.1315, 7.9267], - [-12.1324, 7.9302], - [-12.1353, 7.9343], - [-12.1386, 7.937], - [-12.143, 7.9388], - [-12.1429, 7.9448], - [-12.1418, 7.9491], - [-12.1397, 7.9521], - [-12.1369, 7.9541], - [-12.1314, 7.9565], - [-12.1166, 7.958], - [-12.1126, 7.9591], - [-12.1016, 7.9637], - [-12.095, 7.9658], - [-12.0839, 7.9699], - [-12.0756, 7.9751], - [-12.0693, 7.9785], - [-12.0606, 7.9824], - [-12.0561, 7.9832], - [-12.0421, 7.9841], - [-12.0391, 7.9847], - [-12.0344, 7.9861], - [-12.03, 7.9868], - [-12.0098, 7.9876], - [-12.0054, 7.9884], - [-12.0007, 7.9898], - [-11.9978, 7.9903], - [-11.9843, 7.9908], - [-11.9799, 7.9912], - [-11.976, 7.9926], - [-11.9726, 7.9957], - [-11.9713, 7.9984], - [-11.9657, 7.9993], - [-11.9597, 8.0011], - [-11.9558, 8.0016], - [-11.9505, 8.0013], - [-11.9433, 7.9997], - [-11.9393, 7.9996], - [-11.9336, 8.0007], - [-11.9304, 8.0006], - [-11.9272, 7.9994], - [-11.9234, 7.9974], - [-11.9176, 7.9925], - [-11.9071, 7.9882], - [-11.9005, 7.9859], - [-11.8904, 7.9809], - [-11.8823, 7.9793], - [-11.8786, 7.9781], - [-11.8736, 7.9744], - [-11.8686, 7.9726], - [-11.8627, 7.9723], - [-11.8582, 7.9727], - [-11.8542, 7.9738], - [-11.8431, 7.9786], - [-11.8361, 7.9797], - [-11.8287, 7.9798], - [-11.8235, 7.9771], - [-11.817, 7.9754], - [-11.8199, 7.9839], - [-11.8213, 7.9873], - [-11.8257, 7.992], - [-11.8278, 7.9951], - [-11.8293, 8.0001], - [-11.8294, 8.0037], - [-11.8418, 8.0148], - [-11.8461, 8.0182], - [-11.8497, 8.0201], - [-11.8561, 8.0223], - [-11.8625, 8.0255], - [-11.8659, 8.0278], - [-11.8735, 8.034], - [-11.8913, 8.0454], - [-11.8966, 8.05], - [-11.9004, 8.0541], - [-11.9024, 8.0575], - [-11.9036, 8.0608], - [-11.9042, 8.0648], - [-11.9039, 8.0689], - [-11.902, 8.0745], - [-11.8987, 8.0811], - [-11.8968, 8.092], - [-11.8957, 8.0959], - [-11.8929, 8.1013], - [-11.889, 8.1098], - [-11.8849, 8.1151], - [-11.877, 8.1229], - [-11.8737, 8.1316], - [-11.8683, 8.1425], - [-11.8652, 8.1467], - [-11.8623, 8.1497], - [-11.8601, 8.1515], - [-11.8577, 8.1531], - [-11.855, 8.1542], - [-11.8522, 8.1547], - [-11.8493, 8.1548], - [-11.8436, 8.1542], - [-11.8376, 8.1524], - [-11.8332, 8.1516], - [-11.8161, 8.151], - [-11.8115, 8.1505], - [-11.8075, 8.1492], - [-11.7998, 8.1452], - [-11.7955, 8.1442], - [-11.7893, 8.1437], - [-11.7894, 8.1511], - [-11.7965, 8.1587], - [-11.8005, 8.1648], - [-11.8057, 8.1719], - [-11.8105, 8.1802], - [-11.812, 8.1854], - [-11.8125, 8.1968], - [-11.812, 8.2053], - [-11.8105, 8.2113], - [-11.8059, 8.226], - [-11.8023, 8.2408], - [-11.8018, 8.2437], - [-11.8015, 8.2497], - [-11.8014, 8.2558], - [-11.8017, 8.2603], - [-11.8025, 8.2647], - [-11.8042, 8.2683], - [-11.8067, 8.2714], - [-11.8118, 8.2766], - [-11.8298, 8.2936], - [-11.8325, 8.2967], - [-11.8339, 8.2996], - [-11.8338, 8.3035], - [-11.8318, 8.3079], - [-11.8268, 8.3126], - [-11.8206, 8.3164], - [-11.8178, 8.3189], - [-11.8159, 8.3219], - [-11.8144, 8.3275], - [-11.8147, 8.3309], - [-11.816, 8.3353], - [-11.8179, 8.3397], - [-11.8204, 8.3437], - [-11.8262, 8.351], - [-11.823, 8.3601], - [-11.8211, 8.3634], - [-11.8166, 8.3686], - [-11.8113, 8.3731], - [-11.8028, 8.3777], - [-11.7952, 8.3811], - [-11.7885, 8.3829], - [-11.7839, 8.3846], - [-11.7749, 8.3864], - [-11.7701, 8.389], - [-11.7671, 8.392], - [-11.7648, 8.3953], - [-11.7625, 8.4008], - [-11.7593, 8.4108], - [-11.7574, 8.4152], - [-11.7544, 8.4194], - [-11.7434, 8.4316], - [-11.7387, 8.44], - [-11.7349, 8.4486], - [-11.7335, 8.4531], - [-11.7321, 8.4599], - [-11.7308, 8.4645], - [-11.7281, 8.4708], - [-11.7259, 8.4736], - [-11.7218, 8.477], - [-11.7175, 8.4819], - [-11.7146, 8.4842], - [-11.7103, 8.487], - [-11.7061, 8.4848], - [-11.6984, 8.4803], - [-11.6889, 8.482], - [-11.6765, 8.4832], - [-11.6674, 8.4855], - [-11.6626, 8.4861], - [-11.6527, 8.4864], - [-11.6095, 8.4863], - [-11.5914, 8.4875], - ], - ], - }, - properties: { name: "Bo" }, - }; - - return ( - - {(props) => } - - ); -}; - -export default DashboardPlugin; diff --git a/src/components/plugin/DashboardPlugin.js b/src/components/plugin/DashboardPlugin.js new file mode 100644 index 00000000..b9ea1373 --- /dev/null +++ b/src/components/plugin/DashboardPlugin.js @@ -0,0 +1,18 @@ +import { DashboardPluginWrapper } from "@dhis2/analytics"; +import React, { useEffect, useState } from "react"; +import Plugin from "./Plugin.js"; + +const DashboardPlugin = (props) => { + const [propsFromParent, setPropsFromParent] = useState(props); + + // TODO: can props be passed directly to DashboardPluginWrapper? + useEffect(() => setPropsFromParent(props), [props]); + + return ( + + {(props) => } + + ); +}; + +export default DashboardPlugin; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js new file mode 100644 index 00000000..137843f7 --- /dev/null +++ b/src/components/plugin/Plugin.js @@ -0,0 +1,8 @@ +const Plugin = (props) => { + console.log("Plugin props", props); + return ( +
+

Plugin

+
+ ); +}; From b32751682d6e12adb4e032ae4e6a2967a239a84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 10:33:37 +0200 Subject: [PATCH 07/30] console.log for debugging --- src/components/plugin/DashboardPlugin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/plugin/DashboardPlugin.js b/src/components/plugin/DashboardPlugin.js index b9ea1373..1f88ba39 100644 --- a/src/components/plugin/DashboardPlugin.js +++ b/src/components/plugin/DashboardPlugin.js @@ -8,6 +8,8 @@ const DashboardPlugin = (props) => { // TODO: can props be passed directly to DashboardPluginWrapper? useEffect(() => setPropsFromParent(props), [props]); + console.log("propsFromParent", propsFromParent); + return ( {(props) => } From 2d72c3f065589d93c0ba4f4e2dd90b5a3a11ff5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 10:40:43 +0200 Subject: [PATCH 08/30] Code cleaning --- package.json | 2 +- src/components/plugin/DashboardPlugin.js | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0e2ed9b0..70aa99cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "1.3.1", + "version": "999.99.0-dashboard-plugin.0", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/DashboardPlugin.js b/src/components/plugin/DashboardPlugin.js index 1f88ba39..8119fb55 100644 --- a/src/components/plugin/DashboardPlugin.js +++ b/src/components/plugin/DashboardPlugin.js @@ -1,18 +1,13 @@ import { DashboardPluginWrapper } from "@dhis2/analytics"; -import React, { useEffect, useState } from "react"; +import React from "react"; import Plugin from "./Plugin.js"; const DashboardPlugin = (props) => { - const [propsFromParent, setPropsFromParent] = useState(props); - - // TODO: can props be passed directly to DashboardPluginWrapper? - useEffect(() => setPropsFromParent(props), [props]); - - console.log("propsFromParent", propsFromParent); + console.log("DashboardPlugin props", props); return ( - - {(props) => } + + {(propsFromParent) => } ); }; From 16e2781fa1a0a04b78030b790a2e2fb28b2c65b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 10:42:18 +0200 Subject: [PATCH 09/30] yarn deuplicate --- yarn.lock | 67 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 64 deletions(-) diff --git a/yarn.lock b/yarn.lock index 01bb1938..95b688e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1118,21 +1118,7 @@ core-js "^2.6.12" regenerator-runtime "^0.14.0" -"@babel/runtime@^7.1.2", "@babel/runtime@^7.9.2": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12" - integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw== - dependencies: - regenerator-runtime "^0.14.0" - -"@babel/runtime@^7.10.0", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.23.2", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.7.tgz#dd7c88deeb218a0f8bd34d5db1aa242e0f203193" - integrity sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA== - dependencies: - regenerator-runtime "^0.14.0" - -"@babel/runtime@^7.23.8": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.0", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.8", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": version "7.25.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.0.tgz#3af9a91c1b739c569d5d80cc917280919c544ecb" integrity sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw== @@ -1905,18 +1891,7 @@ "@dhis2/pwa" "11.7.0" moment "^2.24.0" -"@dhis2/app-runtime@^3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-runtime/-/app-runtime-3.10.4.tgz#6064ac728770cc94c4d1975db32bd38533655cc6" - integrity sha512-W/d0WcYYcKAeE5/xCunZEMYUSD1fxG+JDQdRDEUsH5y5hB8i/4o2QQrZK8xa19Z3xQJhaW5ypWWqIQVjTJT2Ww== - dependencies: - "@dhis2/app-service-alerts" "3.10.4" - "@dhis2/app-service-config" "3.10.4" - "@dhis2/app-service-data" "3.10.4" - "@dhis2/app-service-offline" "3.10.4" - "@dhis2/app-service-plugin" "3.10.4" - -"@dhis2/app-runtime@^3.10.6": +"@dhis2/app-runtime@^3.10.4", "@dhis2/app-runtime@^3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-runtime/-/app-runtime-3.10.6.tgz#10add0b8a2e1de06777e6e78c681a3a8f15ba058" integrity sha512-WfC+AHkw0V3V3/wyLPHoTyAf8i4btLl/R2nMBVs3NEXLwA9mekG/gXs7AEPnK2/p6FVoqXMDwJHEH2b8Iw4UFw== @@ -1927,33 +1902,16 @@ "@dhis2/app-service-offline" "3.10.6" "@dhis2/app-service-plugin" "3.10.6" -"@dhis2/app-service-alerts@3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-service-alerts/-/app-service-alerts-3.10.4.tgz#a7cce660015d79980679175e677cf6c6c3f4c7eb" - integrity sha512-DmSLx/kHOHpgGiL8zG0oa6D3MeCY3wPMDGqj+Gfegr654Lmyf4d2vLI7HSZUSOCdraP/fSYTypsdZmWYoXoLBQ== - "@dhis2/app-service-alerts@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-alerts/-/app-service-alerts-3.10.6.tgz#47e65d7ed57a4bd801a513b0f71d0ed2839ea363" integrity sha512-2r9IUBp5Z5zuSqjTEWpt+rx7tP5AqrtkPJ8ZVOKW5YBn1DB4bQ5ti9GOevHM4othr7Mrmt22UADPgfEkfc7XzQ== -"@dhis2/app-service-config@3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-service-config/-/app-service-config-3.10.4.tgz#2bede4df9b036350200cbc085a2a68439fa4fa0a" - integrity sha512-SCFdNxJKpiBjYsU9s0R+u9GrXjzmUEpGpudmC5eQqNV6ajLiebe/pS2jcSPFzjUtHVQMADk0X8TkERoOBqWcxA== - "@dhis2/app-service-config@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-config/-/app-service-config-3.10.6.tgz#bf952156329ab48d6da407522c6e06072fdf896a" integrity sha512-Z/rSBjCc8kP78QYhKNyGoCafGfwpqMDg8mV2x/H6CavgEicOa+qHX3bkKV6+fC9Sw2FnsWHRemxYRkgbW/BD3g== -"@dhis2/app-service-data@3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-service-data/-/app-service-data-3.10.4.tgz#dcd993a24d2edd97e7ad8a042a682e60582740ff" - integrity sha512-RaoWniioCe33PcPZoDuO66qOrIt0JeeCN8RzmCDrRVGvGmlDTZ3hNuWm9CnsAvO1U6sYDiulKPqrEQu8YKMG0w== - dependencies: - react-query "^3.13.11" - "@dhis2/app-service-data@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-data/-/app-service-data-3.10.6.tgz#2f3f522b4a5a8c8d531f8901cca502323e566042" @@ -1961,13 +1919,6 @@ dependencies: react-query "^3.13.11" -"@dhis2/app-service-offline@3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-service-offline/-/app-service-offline-3.10.4.tgz#dcdaf3a76c6c7a71f28c89a403ec130bf10fcdf3" - integrity sha512-SUUS+sw3FjR0TMdKSSOVzL8IfPA185gSTHQ1WE4tLc2zE92elvxLL9FuSUuTbu+l1Kr4nRQNLh8muOMWKGnWDg== - dependencies: - lodash "^4.17.21" - "@dhis2/app-service-offline@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-offline/-/app-service-offline-3.10.6.tgz#e1d83520bb292fc51b24eab65d05e1c9fa1e2ad6" @@ -1975,13 +1926,6 @@ dependencies: lodash "^4.17.21" -"@dhis2/app-service-plugin@3.10.4": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@dhis2/app-service-plugin/-/app-service-plugin-3.10.4.tgz#f5412a1320393042012dd75713e3215e51628554" - integrity sha512-GW6xa/5y2yFXvhtLConnaOxKqyu6VPZWRBaQR73/bRRmFcnd7hlMkZ2M0GWSjoW4QHLXlLhXHFsgHPETBftkPg== - dependencies: - post-robot "^10.0.46" - "@dhis2/app-service-plugin@3.10.6": version "3.10.6" resolved "https://registry.yarnpkg.com/@dhis2/app-service-plugin/-/app-service-plugin-3.10.6.tgz#1c6792b6d051c4b3301d76d083c3364424140a83" @@ -12049,16 +11993,11 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.0, tslib@^2.3.1: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.3.1: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== -tslib@^2.0.3: - version "2.6.2" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" - integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== - tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" From 8572f3bd28799fc7895213017a555fc4bf718da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 12:02:12 +0200 Subject: [PATCH 10/30] Plugin setup --- d2.config.js | 2 +- package.json | 2 +- src/App.js | 5 +++ src/DashboardPlugin.js | 11 +++++ .../explore/forecast/DayForecast.js | 4 +- .../explore/forecast/ForecastTab.js | 43 +++++++++++-------- src/components/plugin/DashboardPlugin.js | 15 ------- src/components/plugin/Plugin.js | 27 +++++++++++- src/components/plugin/PluginPage.js | 13 ++++++ .../plugin/styles/Plugin.module.css | 14 ++++++ .../plugin/styles/PluginPage.module.css | 10 +++++ 11 files changed, 106 insertions(+), 40 deletions(-) create mode 100644 src/DashboardPlugin.js delete mode 100644 src/components/plugin/DashboardPlugin.js create mode 100644 src/components/plugin/PluginPage.js create mode 100644 src/components/plugin/styles/Plugin.module.css create mode 100644 src/components/plugin/styles/PluginPage.module.css diff --git a/d2.config.js b/d2.config.js index 2bfe1795..255a66b0 100644 --- a/d2.config.js +++ b/d2.config.js @@ -4,7 +4,7 @@ const config = { title: "Climate app", entryPoints: { app: "./src/App.js", - plugin: "./src/plugin/DashboardPlugin.js", + plugin: "./src/DashboardPlugin.js", }, }; diff --git a/package.json b/package.json index 70aa99cf..c5714db1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.0", + "version": "999.99.0-dashboard-plugin.3", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/App.js b/src/App.js index 65b770e6..e665ecde 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ import SetupPage from "./components/setup/SetupPage"; import SettingsPage from "./components/settings/SettingsPage"; import ErrorPage from "./components/ErrorPage"; import CheckPage from "./components/check/CheckPage"; +import PluginPage from "./components/plugin/PluginPage"; const router = createHashRouter([ { @@ -38,6 +39,10 @@ const router = createHashRouter([ path: "settings", element: , }, + { + path: "plugin", + element: , + }, ], }, ]); diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js new file mode 100644 index 00000000..5a866be0 --- /dev/null +++ b/src/DashboardPlugin.js @@ -0,0 +1,11 @@ +import { DashboardPluginWrapper } from "@dhis2/analytics"; +import React from "react"; +import Plugin from "./components/plugin/Plugin.js"; + +const DashboardPlugin = (props) => ( + + {(parentProps) => } + +); + +export default DashboardPlugin; diff --git a/src/components/explore/forecast/DayForecast.js b/src/components/explore/forecast/DayForecast.js index adcd1bf8..43583e84 100644 --- a/src/components/explore/forecast/DayForecast.js +++ b/src/components/explore/forecast/DayForecast.js @@ -13,7 +13,7 @@ const sixHours = [ { start: "18", end: "24" }, ]; -const DayForecast = ({ date, series }) => { +const DayForecast = ({ date, series, isPlugin }) => { const day = new Date(date).toDateString().slice(0, -5); const temp = series.map((s) => s.data.instant.details.air_temperature); const minTemp = Math.round(Math.min(...temp)); @@ -62,7 +62,7 @@ const DayForecast = ({ date, series }) => { {precip ? i18n.t("{{precip}} mm", { precip }) : null} - {avgHumidity}% + {!isPlugin && {avgHumidity}%} {maxWind} m/s ); diff --git a/src/components/explore/forecast/ForecastTab.js b/src/components/explore/forecast/ForecastTab.js index ae58668f..7f8b00ae 100644 --- a/src/components/explore/forecast/ForecastTab.js +++ b/src/components/explore/forecast/ForecastTab.js @@ -11,7 +11,7 @@ const convertTimezone = (date, timeZone) => const browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; -const ForecastTab = ({ orgUnit }) => { +const ForecastTab = ({ orgUnit, isPlugin }) => { const [data, setData] = useState(); const { settings, loading } = useAppSettings(); @@ -56,7 +56,9 @@ const ForecastTab = ({ orgUnit }) => { {i18n.t("Evening")} {i18n.t("Max/min temp.")} {i18n.t("Precip.")} - {i18n.t("Rel. humidity")} + {!isPlugin && ( + {i18n.t("Rel. humidity")} + )} {i18n.t("Wind")} @@ -66,6 +68,7 @@ const ForecastTab = ({ orgUnit }) => { key={date} date={date} series={timeseries.filter((t) => t.time.startsWith(date))} + isPlugin={isPlugin} /> ))} @@ -84,29 +87,31 @@ const ForecastTab = ({ orgUnit }) => { ECMWF HRES -
- {settings.timeZone - ? i18n.t( - 'The forecast is using the "{{- timeZone}}" time zone. You can change the time zone for your org units under "Settings".', - { timeZone } - ) - : browserTimeZone - ? i18n.t( - 'The forecast is using the time zone of your browser ({{- timeZone}}). You can set the time zone for your org units under "Settings".', - { timeZone } - ) - : i18n.t( - 'The forecast is using the default "{{- timeZone}}" time zone. You can set the time zone for your org units under "Settings".', - { timeZone } - )} -
+ {!isPlugin && ( +
+ {settings.timeZone + ? i18n.t( + 'The forecast is using the "{{- timeZone}}" time zone. You can change the time zone for your org units under "Settings".', + { timeZone } + ) + : browserTimeZone + ? i18n.t( + 'The forecast is using the time zone of your browser ({{- timeZone}}). You can set the time zone for your org units under "Settings".', + { timeZone } + ) + : i18n.t( + 'The forecast is using the default "{{- timeZone}}" time zone. You can set the time zone for your org units under "Settings".', + { timeZone } + )} +
+ )} ); }; ForecastTab.propTypes = { - name: PropTypes.string.isRequired, orgUnit: PropTypes.object.isRequired, + idPlugin: PropTypes.bool, }; export default ForecastTab; diff --git a/src/components/plugin/DashboardPlugin.js b/src/components/plugin/DashboardPlugin.js deleted file mode 100644 index 8119fb55..00000000 --- a/src/components/plugin/DashboardPlugin.js +++ /dev/null @@ -1,15 +0,0 @@ -import { DashboardPluginWrapper } from "@dhis2/analytics"; -import React from "react"; -import Plugin from "./Plugin.js"; - -const DashboardPlugin = (props) => { - console.log("DashboardPlugin props", props); - - return ( - - {(propsFromParent) => } - - ); -}; - -export default DashboardPlugin; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 137843f7..9f1793e5 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -1,8 +1,31 @@ +import ForecastTab from "../explore/forecast/ForecastTab"; +import styles from "./styles/Plugin.module.css"; + +const orgUnit = { + id: "finse", + path: "/world/norway/finse", + displayName: "Finse", + children: [], + geometry: { + type: "Point", + coordinates: [7.502289, 60.602791], + }, + properties: { + name: "Finse", + }, +}; + const Plugin = (props) => { + // const { dashboardItemId } = props; console.log("Plugin props", props); return ( -
-

Plugin

+
+
+ {orgUnit.properties.name}: 10 days weather forecast +
+
); }; + +export default Plugin; diff --git a/src/components/plugin/PluginPage.js b/src/components/plugin/PluginPage.js new file mode 100644 index 00000000..26c92202 --- /dev/null +++ b/src/components/plugin/PluginPage.js @@ -0,0 +1,13 @@ +import Plugin from "./Plugin"; +import styles from "./styles/PluginPage.module.css"; + +const PluginPage = () => ( +
+

Plugin

+
+ +
+
+); + +export default PluginPage; diff --git a/src/components/plugin/styles/Plugin.module.css b/src/components/plugin/styles/Plugin.module.css new file mode 100644 index 00000000..1d1d4093 --- /dev/null +++ b/src/components/plugin/styles/Plugin.module.css @@ -0,0 +1,14 @@ +.plugin { + width: 100%; + height: 100%; + overflow: auto; +} + +.title { + font-size: 14px; + color: var(--colors-grey800); + font-weight: 700; + margin-bottom: 10px; + padding-left: 7px; + padding-top: 5px; +} diff --git a/src/components/plugin/styles/PluginPage.module.css b/src/components/plugin/styles/PluginPage.module.css new file mode 100644 index 00000000..ced387bf --- /dev/null +++ b/src/components/plugin/styles/PluginPage.module.css @@ -0,0 +1,10 @@ +.plugin { + box-shadow: 0 0 3px 0 #999; + border-radius: 3px; + padding: 4px; + background-color: #fff; + box-sizing: content-box; + width: 500px; + height: 500px; + overflow: hidden !important; +} From 6b3ad99956d63ad2e2169b2b12a70350ff0b29b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 12:02:59 +0200 Subject: [PATCH 11/30] Plugin test version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c5714db1..560d83be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.3", + "version": "999.99.0-dashboard-plugin.4", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, From 571deaf9b83c81a76cc39785b95ac2daad8dac6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 17:02:04 +0200 Subject: [PATCH 12/30] Dummy plugin --- package.json | 2 +- src/components/explore/Chart.js | 9 ++- .../explore/temperature/TemperatureDaily.js | 10 ++- .../explore/temperature/TemperatureMonthly.js | 7 +- .../temperature/charts/temperatureDaily.js | 17 +++-- .../temperature/charts/temperatureMonthly.js | 25 +++++-- src/components/plugin/OrgUnitLoader.js | 15 ++++ src/components/plugin/Plugin.js | 73 +++++++++++++------ src/components/plugin/PluginContent.js | 29 ++++++++ src/components/plugin/PluginItems.js | 3 + ...in.module.css => PluginContent.module.css} | 2 +- .../plugin/styles/PluginPage.module.css | 2 +- 12 files changed, 151 insertions(+), 43 deletions(-) create mode 100644 src/components/plugin/OrgUnitLoader.js create mode 100644 src/components/plugin/PluginContent.js create mode 100644 src/components/plugin/PluginItems.js rename src/components/plugin/styles/{Plugin.module.css => PluginContent.module.css} (94%) diff --git a/package.json b/package.json index 560d83be..2e0fd39e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.4", + "version": "999.99.0-dashboard-plugin.6", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/explore/Chart.js b/src/components/explore/Chart.js index f96e1632..a32fee1a 100644 --- a/src/components/explore/Chart.js +++ b/src/components/explore/Chart.js @@ -9,12 +9,17 @@ accessibility(Highcharts); exporting(Highcharts); highchartsMore(Highcharts); -const Chart = ({ config }) => { +const Chart = ({ config, isPlugin }) => { const chartRef = useRef(); useLayoutEffect(() => { + // TODO: Find better way to set chart height to fit plugin container + if (isPlugin) { + config.chart.height = chartRef.current.parentElement.offsetHeight - 32; + } + Highcharts.chart(chartRef.current, config); - }, [config, chartRef]); + }, [config, chartRef, isPlugin]); return
; }; diff --git a/src/components/explore/temperature/TemperatureDaily.js b/src/components/explore/temperature/TemperatureDaily.js index d2dbb12d..6823bae8 100644 --- a/src/components/explore/temperature/TemperatureDaily.js +++ b/src/components/explore/temperature/TemperatureDaily.js @@ -5,19 +5,25 @@ import getDailyConfig from "./charts/temperatureDaily"; import useEarthEngineTimeSeries from "../../../hooks/useEarthEngineTimeSeries"; import { era5Daily } from "../../../data/datasets"; -const TemperatureDaily = ({ orgUnit, period }) => { +const TemperatureDaily = ({ orgUnit, period, isPlugin }) => { const data = useEarthEngineTimeSeries(era5Daily, period, orgUnit); if (!data) { return ; } - return ; + return ( + + ); }; TemperatureDaily.propTypes = { orgUnit: PropTypes.object.isRequired, period: PropTypes.object.isRequired, + isPlugin: PropTypes.bool, }; export default TemperatureDaily; diff --git a/src/components/explore/temperature/TemperatureMonthly.js b/src/components/explore/temperature/TemperatureMonthly.js index 0ef7e1a1..b9d9a572 100644 --- a/src/components/explore/temperature/TemperatureMonthly.js +++ b/src/components/explore/temperature/TemperatureMonthly.js @@ -6,7 +6,7 @@ import useEarthEngineTimeSeries from "../../../hooks/useEarthEngineTimeSeries"; import useEarthEngineClimateNormals from "../../../hooks/useEarthEngineClimateNormals"; import { era5Monthly, era5MonthlyNormals } from "../../../data/datasets"; -const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { +const TemperatureMonthly = ({ orgUnit, period, referencePeriod, isPlugin }) => { const data = useEarthEngineTimeSeries(era5Monthly, period, orgUnit); const normals = useEarthEngineClimateNormals( @@ -25,8 +25,10 @@ const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { orgUnit.properties.name, data, normals, - referencePeriod + referencePeriod, + isPlugin )} + isPlugin={isPlugin} /> ); }; @@ -35,6 +37,7 @@ TemperatureMonthly.propTypes = { orgUnit: PropTypes.object.isRequired, period: PropTypes.object.isRequired, referencePeriod: PropTypes.object.isRequired, + isPlugin: PropTypes.bool, }; export default TemperatureMonthly; diff --git a/src/components/explore/temperature/charts/temperatureDaily.js b/src/components/explore/temperature/charts/temperatureDaily.js index a36d3b20..213cfca9 100644 --- a/src/components/explore/temperature/charts/temperatureDaily.js +++ b/src/components/explore/temperature/charts/temperatureDaily.js @@ -3,7 +3,7 @@ import { colors } from "@dhis2/ui"; import { animation, credits, getDailyPeriod } from "../../../../utils/chart"; import { toCelcius } from "../../../../utils/calc"; -const getChart = (name, data) => { +const getChart = (name, data, isPlugin) => { const series = data.map((d) => ({ x: new Date(d.id).getTime(), y: toCelcius(d["temperature_2m"]), @@ -17,11 +17,13 @@ const getChart = (name, data) => { return { title: { - text: i18n.t("{{name}}: Daily temperatures {{period}}", { - name, - period: getDailyPeriod(data), - nsSeparator: ";", - }), + text: !isPlugin + ? i18n.t("{{name}}: Daily temperatures {{period}}", { + name, + period: getDailyPeriod(data), + nsSeparator: ";", + }) + : "", }, credits, tooltip: { @@ -74,6 +76,9 @@ const getChart = (name, data) => { zIndex: 0, }, ], + exporting: { + enabled: !isPlugin, + }, }; }; diff --git a/src/components/explore/temperature/charts/temperatureMonthly.js b/src/components/explore/temperature/charts/temperatureMonthly.js index 88fba038..3af75b29 100644 --- a/src/components/explore/temperature/charts/temperatureMonthly.js +++ b/src/components/explore/temperature/charts/temperatureMonthly.js @@ -8,7 +8,13 @@ import { } from "../../../../utils/chart"; import { getTimeFromId, toCelcius } from "../../../../utils/calc"; -const getChartConfig = (name, data, normals, referencePeriod) => { +const getChartConfig = ( + name, + data, + normals, + referencePeriod, + isPlugin = false +) => { const series = data.map((d) => ({ x: getTimeFromId(d.id), y: toCelcius(d["temperature_2m"]), @@ -32,17 +38,21 @@ const getChartConfig = (name, data, normals, referencePeriod) => { return { title: { - text: i18n.t("{{name}}: Monthly temperatures {{period}}", { - name, - period: getMonthlyPeriod(data), - nsSeparator: ";", - }), + text: !isPlugin + ? i18n.t("{{name}}: Monthly temperatures {{period}}", { + name, + period: getMonthlyPeriod(data), + nsSeparator: ";", + }) + : "", }, subtitle: { text: i18n.t("Normals from reference period: {{period}}", { period: referencePeriod.id, nsSeparator: ";", }), + floating: false, + verticalAlign: "top", }, credits, tooltip: { @@ -105,6 +115,9 @@ const getChartConfig = (name, data, normals, referencePeriod) => { zIndex: 1, }, ], + exporting: { + enabled: !isPlugin, + }, }; }; diff --git a/src/components/plugin/OrgUnitLoader.js b/src/components/plugin/OrgUnitLoader.js new file mode 100644 index 00000000..c9fd8feb --- /dev/null +++ b/src/components/plugin/OrgUnitLoader.js @@ -0,0 +1,15 @@ +import PluginContent from "./PluginContent"; +import DataLoader from "../shared/DataLoader"; +import useOrgUnit from "../../hooks/useOrgUnit"; + +const OrgUnitLoader = (props) => { + const orgUnit = useOrgUnit(props.orgUnitId); + + return orgUnit ? ( + + ) : ( + + ); +}; + +export default OrgUnitLoader; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 840ff5be..aa74fa0d 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -1,31 +1,60 @@ -import Forecast from "../explore/forecast/Forecast"; -import styles from "./styles/Plugin.module.css"; - -const orgUnit = { - id: "finse", - path: "/world/norway/finse", - displayName: "Finse", - children: [], - geometry: { - type: "Point", - coordinates: [7.502289, 60.602791], +// import PluginItems from "./PluginItems"; +import OrgUnitLoader from "./OrgUnitLoader"; + +// TODO: Keep in data store +const pluginItems = [ + { + id: "DiszpKrYNg8/forecast10days", + url: "#/explore/DiszpKrYNg8/forecast10days", + title: "Ngelehun CHC: Weather forecast", + orgUnitId: "DiszpKrYNg8", + display: "forecast10days", + }, + { + id: "DiszpKrYNg8/temperature/monthly", + url: "#/explore/DiszpKrYNg8/temperature/monthly", + title: "Ngelehun CHC: Monthly temperatures 2023-2024", + orgUnitId: "DiszpKrYNg8", + display: "temperature/monthly", + period: { startTime: "2023-08", endTime: "2024-07" }, + referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, }, - properties: { - name: "Finse", + { + id: "DiszpKrYNg8/temperature/daily", + url: "#/explore/DiszpKrYNg8/temperature/daily", + title: "Ngelehun CHC: Daily Temperatures", + orgUnitId: "DiszpKrYNg8", + display: "temperature/daily", + period: { startTime: "2023-08-01", endTime: "2024-07-12" }, }, +]; + +// TODO: Keep in data store +const dashboardItems = { + tf116s7c3YO: "DiszpKrYNg8/forecast10days", }; const Plugin = (props) => { - // const { dashboardItemId } = props; + /* + const { dashboardItemId } = props; + const pluginItemId = dashboardItems[dashboardItemId]; + + if (!pluginItemId) { + ; + } + + const pluginItem = pluginItems.find((item) => item.id === pluginItemId); + + if (!pluginItem) { + return
Plugin item not found (this should not happen)
; + } + */ + console.log("Plugin props", props); - return ( -
-
- {orgUnit.properties.name}: 10 days weather forecast -
- -
- ); + + const pluginItem = pluginItems[1]; + + return ; }; export default Plugin; diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js new file mode 100644 index 00000000..887214fe --- /dev/null +++ b/src/components/plugin/PluginContent.js @@ -0,0 +1,29 @@ +import Forecast from "../explore/forecast/Forecast"; +import TemperatureMonthly from "../explore/temperature/TemperatureMonthly"; +import TemperatureDaily from "../explore/temperature/TemperatureDaily"; +import styles from "./styles/PluginContent.module.css"; + +const displays = { + forecast10days: Forecast, + "temperature/monthly": TemperatureMonthly, + "temperature/daily": TemperatureDaily, +}; + +const PluginContent = (props) => { + const { display, title } = props; + + const Display = displays[display]; + + if (!Display) { + return
Display not found (this should not happen)
; + } + + return ( +
+
{title}
+ +
+ ); +}; + +export default PluginContent; diff --git a/src/components/plugin/PluginItems.js b/src/components/plugin/PluginItems.js new file mode 100644 index 00000000..2fb79705 --- /dev/null +++ b/src/components/plugin/PluginItems.js @@ -0,0 +1,3 @@ +const PluginItems = ({ items }) =>
Select plugin item
; + +export default PluginItems; diff --git a/src/components/plugin/styles/Plugin.module.css b/src/components/plugin/styles/PluginContent.module.css similarity index 94% rename from src/components/plugin/styles/Plugin.module.css rename to src/components/plugin/styles/PluginContent.module.css index 1d1d4093..aacc1572 100644 --- a/src/components/plugin/styles/Plugin.module.css +++ b/src/components/plugin/styles/PluginContent.module.css @@ -1,4 +1,4 @@ -.plugin { +.content { width: 100%; height: 100%; overflow: auto; diff --git a/src/components/plugin/styles/PluginPage.module.css b/src/components/plugin/styles/PluginPage.module.css index ced387bf..fe874b7d 100644 --- a/src/components/plugin/styles/PluginPage.module.css +++ b/src/components/plugin/styles/PluginPage.module.css @@ -5,6 +5,6 @@ background-color: #fff; box-sizing: content-box; width: 500px; - height: 500px; + height: 400px; overflow: hidden !important; } From d09bac8ccf21c915a122dc19fe8fee8eb9123cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 22 Aug 2024 17:07:49 +0200 Subject: [PATCH 13/30] Dummy plugin --- package.json | 2 +- src/components/plugin/styles/PluginContent.module.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e0fd39e..c59ae06b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.6", + "version": "999.99.0-dashboard-plugin.7", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/styles/PluginContent.module.css b/src/components/plugin/styles/PluginContent.module.css index aacc1572..324983a1 100644 --- a/src/components/plugin/styles/PluginContent.module.css +++ b/src/components/plugin/styles/PluginContent.module.css @@ -1,6 +1,7 @@ .content { width: 100%; height: 100%; + min-height: 400px; /* TODO: remove this */ overflow: auto; } From 18dd4b03c14e568d336c7fc57ea88483d0185773 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 30 Aug 2024 11:58:35 +0200 Subject: [PATCH 14/30] refactor: rewrite resize logic for Highcharts The width worked fine, but the height didn't. Now a container element with the correct size is used as reference to set the chart size every time the container element is resized. --- src/components/explore/Chart.js | 56 ++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/src/components/explore/Chart.js b/src/components/explore/Chart.js index a32fee1a..1e738205 100644 --- a/src/components/explore/Chart.js +++ b/src/components/explore/Chart.js @@ -3,29 +3,63 @@ import Highcharts from "highcharts"; import accessibility from "highcharts/modules/accessibility"; import exporting from "highcharts/highcharts-more"; import highchartsMore from "highcharts/modules/exporting"; -import React, { useRef, useLayoutEffect } from "react"; +import React, { useCallback, useRef, useLayoutEffect, useMemo } from "react"; accessibility(Highcharts); exporting(Highcharts); highchartsMore(Highcharts); const Chart = ({ config, isPlugin }) => { - const chartRef = useRef(); + const containerRef = useRef(null); + const chartRef = useRef(); - useLayoutEffect(() => { - // TODO: Find better way to set chart height to fit plugin container - if (isPlugin) { - config.chart.height = chartRef.current.parentElement.offsetHeight - 32; - } + const titleHeight = 32; - Highcharts.chart(chartRef.current, config); - }, [config, chartRef, isPlugin]); + const onResize = useCallback(() => { + chartRef.current?.setSize( + containerRef.current.offsetWidth, + containerRef.current.offsetHeight, + false + ); + }, []); - return
; + const sizeObserver = useMemo( + () => new window.ResizeObserver(onResize), + [onResize] + ); + + const mountAndObserveContainerRef = useCallback( + (node) => { + if (node === null) { + return; + } + + containerRef.current = node; + sizeObserver.observe(node); + + return sizeObserver.disconnect; + }, + [sizeObserver] + ); + + useLayoutEffect(() => { + chartRef.current = new Highcharts.chart(containerRef.current, config); + }, [config, chartRef]); + + return ( +
+ ); }; Chart.propTypes = { - config: PropTypes.object.isRequired, + config: PropTypes.object.isRequired, + isPlugin: PropTypes.bool, }; export default Chart; From 914336358a230eb1b8625849f2e47c9b0352f3f5 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 6 Sep 2024 16:25:06 +0200 Subject: [PATCH 15/30] feat: call callback for setting custom title/url on dashboard item --- src/components/plugin/Plugin.js | 63 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index aa74fa0d..5b1ceda7 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -3,39 +3,39 @@ import OrgUnitLoader from "./OrgUnitLoader"; // TODO: Keep in data store const pluginItems = [ - { - id: "DiszpKrYNg8/forecast10days", - url: "#/explore/DiszpKrYNg8/forecast10days", - title: "Ngelehun CHC: Weather forecast", - orgUnitId: "DiszpKrYNg8", - display: "forecast10days", - }, - { - id: "DiszpKrYNg8/temperature/monthly", - url: "#/explore/DiszpKrYNg8/temperature/monthly", - title: "Ngelehun CHC: Monthly temperatures 2023-2024", - orgUnitId: "DiszpKrYNg8", - display: "temperature/monthly", - period: { startTime: "2023-08", endTime: "2024-07" }, - referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, - }, - { - id: "DiszpKrYNg8/temperature/daily", - url: "#/explore/DiszpKrYNg8/temperature/daily", - title: "Ngelehun CHC: Daily Temperatures", - orgUnitId: "DiszpKrYNg8", - display: "temperature/daily", - period: { startTime: "2023-08-01", endTime: "2024-07-12" }, - }, + { + id: "DiszpKrYNg8/forecast10days", + url: "#/explore/DiszpKrYNg8/forecast10days", + title: "Ngelehun CHC: Weather forecast", + orgUnitId: "DiszpKrYNg8", + display: "forecast10days", + }, + { + id: "DiszpKrYNg8/temperature/monthly", + url: "#/explore/DiszpKrYNg8/temperature/monthly", + title: "Ngelehun CHC: Monthly temperatures 2023-2024", + orgUnitId: "DiszpKrYNg8", + display: "temperature/monthly", + period: { startTime: "2023-08", endTime: "2024-07" }, + referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, + }, + { + id: "DiszpKrYNg8/temperature/daily", + url: "#/explore/DiszpKrYNg8/temperature/daily", + title: "Ngelehun CHC: Daily Temperatures", + orgUnitId: "DiszpKrYNg8", + display: "temperature/daily", + period: { startTime: "2023-08-01", endTime: "2024-07-12" }, + }, ]; // TODO: Keep in data store const dashboardItems = { - tf116s7c3YO: "DiszpKrYNg8/forecast10days", + tf116s7c3YO: "DiszpKrYNg8/forecast10days", }; const Plugin = (props) => { - /* + /* const { dashboardItemId } = props; const pluginItemId = dashboardItems[dashboardItemId]; @@ -50,11 +50,16 @@ const Plugin = (props) => { } */ - console.log("Plugin props", props); + console.log("Plugin props", props); - const pluginItem = pluginItems[1]; + const pluginItem = pluginItems[1]; - return ; + props.setDashboardItemDetails({ + itemTitle: pluginItem.title, + appUrl: pluginItem.url, + }); + + return ; }; export default Plugin; From e8929137d811361dca3d14f707a2800f5913f023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 10:00:40 +0200 Subject: [PATCH 16/30] Refactor --- .../explore/temperature/TemperatureMonthly.js | 4 ++ .../temperature/plugin/TemperatureMonthly.js | 44 +++++++++++++ src/components/plugin/Plugin.js | 64 ++++++++++--------- src/components/plugin/PluginContent.js | 4 +- 4 files changed, 83 insertions(+), 33 deletions(-) create mode 100644 src/components/explore/temperature/plugin/TemperatureMonthly.js diff --git a/src/components/explore/temperature/TemperatureMonthly.js b/src/components/explore/temperature/TemperatureMonthly.js index bef65232..da3a4b59 100644 --- a/src/components/explore/temperature/TemperatureMonthly.js +++ b/src/components/explore/temperature/TemperatureMonthly.js @@ -47,4 +47,8 @@ const TemperatureMonthly = ({ isPlugin }) => { ); }; +TemperatureMonthly.propTypes = { + isPlugin: PropTypes.bool, +}; + export default TemperatureMonthly; diff --git a/src/components/explore/temperature/plugin/TemperatureMonthly.js b/src/components/explore/temperature/plugin/TemperatureMonthly.js new file mode 100644 index 00000000..a453a1e2 --- /dev/null +++ b/src/components/explore/temperature/plugin/TemperatureMonthly.js @@ -0,0 +1,44 @@ +import PropTypes from "prop-types"; +import Chart from "../../Chart"; +import DataLoader from "../../../shared/DataLoader"; +import getMonthlyConfig from "../charts/temperatureMonthly"; +import useEarthEngineTimeSeries from "../../../../hooks/useEarthEngineTimeSeries"; +import useEarthEngineClimateNormals from "../../../../hooks/useEarthEngineClimateNormals"; +import { era5Monthly, era5MonthlyNormals } from "../../../../data/datasets"; + +const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { + const data = useEarthEngineTimeSeries(era5Monthly, period, orgUnit); + + const normals = useEarthEngineClimateNormals( + era5MonthlyNormals, + referencePeriod, + orgUnit + ); + + const isPlugin = true; + + return ( + <> + {data && normals ? ( + + ) : ( + + )} + + ); +}; + +TemperatureMonthly.propTypes = { + orgUnit: PropTypes.object.isRequired, +}; + +export default TemperatureMonthly; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 5b1ceda7..954e8787 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -3,39 +3,39 @@ import OrgUnitLoader from "./OrgUnitLoader"; // TODO: Keep in data store const pluginItems = [ - { - id: "DiszpKrYNg8/forecast10days", - url: "#/explore/DiszpKrYNg8/forecast10days", - title: "Ngelehun CHC: Weather forecast", - orgUnitId: "DiszpKrYNg8", - display: "forecast10days", - }, - { - id: "DiszpKrYNg8/temperature/monthly", - url: "#/explore/DiszpKrYNg8/temperature/monthly", - title: "Ngelehun CHC: Monthly temperatures 2023-2024", - orgUnitId: "DiszpKrYNg8", - display: "temperature/monthly", - period: { startTime: "2023-08", endTime: "2024-07" }, - referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, - }, - { - id: "DiszpKrYNg8/temperature/daily", - url: "#/explore/DiszpKrYNg8/temperature/daily", - title: "Ngelehun CHC: Daily Temperatures", - orgUnitId: "DiszpKrYNg8", - display: "temperature/daily", - period: { startTime: "2023-08-01", endTime: "2024-07-12" }, - }, + { + id: "DiszpKrYNg8/forecast10days", + url: "#/explore/DiszpKrYNg8/forecast10days", + title: "Ngelehun CHC: Weather forecast", + orgUnitId: "DiszpKrYNg8", + display: "forecast10days", + }, + { + id: "DiszpKrYNg8/temperature/monthly", + url: "#/explore/DiszpKrYNg8/temperature/monthly", + title: "Ngelehun CHC: Monthly temperatures 2023-2024", + orgUnitId: "DiszpKrYNg8", + display: "temperature/monthly", + period: { startTime: "2023-08", endTime: "2024-07" }, + referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, + }, + { + id: "DiszpKrYNg8/temperature/daily", + url: "#/explore/DiszpKrYNg8/temperature/daily", + title: "Ngelehun CHC: Daily Temperatures", + orgUnitId: "DiszpKrYNg8", + display: "temperature/daily", + period: { startTime: "2023-08-01", endTime: "2024-07-12" }, + }, ]; // TODO: Keep in data store const dashboardItems = { - tf116s7c3YO: "DiszpKrYNg8/forecast10days", + tf116s7c3YO: "DiszpKrYNg8/forecast10days", }; const Plugin = (props) => { - /* + /* const { dashboardItemId } = props; const pluginItemId = dashboardItems[dashboardItemId]; @@ -50,16 +50,18 @@ const Plugin = (props) => { } */ - console.log("Plugin props", props); + console.log("Plugin props", props); - const pluginItem = pluginItems[1]; + const pluginItem = pluginItems[1]; + if (props.setDashboardItemDetails) { props.setDashboardItemDetails({ - itemTitle: pluginItem.title, - appUrl: pluginItem.url, + itemTitle: pluginItem.title, + appUrl: pluginItem.url, }); + } - return ; + return ; }; export default Plugin; diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js index 887214fe..495bc192 100644 --- a/src/components/plugin/PluginContent.js +++ b/src/components/plugin/PluginContent.js @@ -1,5 +1,5 @@ import Forecast from "../explore/forecast/Forecast"; -import TemperatureMonthly from "../explore/temperature/TemperatureMonthly"; +import TemperatureMonthly from "../explore/temperature/plugin/TemperatureMonthly"; import TemperatureDaily from "../explore/temperature/TemperatureDaily"; import styles from "./styles/PluginContent.module.css"; @@ -21,7 +21,7 @@ const PluginContent = (props) => { return (
{title}
- +
); }; From 15c25fdc38da0afddbe3ee8dab132d0434313b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 12:45:16 +0200 Subject: [PATCH 17/30] Plugin refactor --- .../temperature/plugin/TemperatureDaily.js | 27 ++++++++++++++++ .../temperature/plugin/TemperatureMonthly.js | 31 +++++++++---------- src/components/plugin/Plugin.js | 10 +++--- src/components/plugin/PluginContent.js | 8 +++-- .../shared/styles/DataLoader.module.css | 4 +-- 5 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 src/components/explore/temperature/plugin/TemperatureDaily.js diff --git a/src/components/explore/temperature/plugin/TemperatureDaily.js b/src/components/explore/temperature/plugin/TemperatureDaily.js new file mode 100644 index 00000000..c196100c --- /dev/null +++ b/src/components/explore/temperature/plugin/TemperatureDaily.js @@ -0,0 +1,27 @@ +import PropTypes from "prop-types"; +import Chart from "../../Chart"; +import DataLoader from "../../../shared/DataLoader"; +import getDailyConfig from "../charts/temperatureDaily"; +import useEarthEngineTimeSeries from "../../../../hooks/useEarthEngineTimeSeries"; +import { era5Daily } from "../../../../data/datasets"; + +const TemperatureDaily = ({ orgUnit, period }) => { + const data = useEarthEngineTimeSeries(era5Daily, period, orgUnit); + const isPlugin = true; + + return data ? ( + + ) : ( + + ); +}; + +TemperatureDaily.propTypes = { + orgUnit: PropTypes.object.isRequired, + period: PropTypes.object.isRequired, +}; + +export default TemperatureDaily; diff --git a/src/components/explore/temperature/plugin/TemperatureMonthly.js b/src/components/explore/temperature/plugin/TemperatureMonthly.js index a453a1e2..deba98bb 100644 --- a/src/components/explore/temperature/plugin/TemperatureMonthly.js +++ b/src/components/explore/temperature/plugin/TemperatureMonthly.js @@ -5,6 +5,7 @@ import getMonthlyConfig from "../charts/temperatureMonthly"; import useEarthEngineTimeSeries from "../../../../hooks/useEarthEngineTimeSeries"; import useEarthEngineClimateNormals from "../../../../hooks/useEarthEngineClimateNormals"; import { era5Monthly, era5MonthlyNormals } from "../../../../data/datasets"; +import { referencePeriods } from "../../ReferencePeriodSelect"; const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { const data = useEarthEngineTimeSeries(era5Monthly, period, orgUnit); @@ -17,28 +18,26 @@ const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { const isPlugin = true; - return ( - <> - {data && normals ? ( - - ) : ( - + return data && normals ? ( + + isPlugin={isPlugin} + /> + ) : ( + ); }; TemperatureMonthly.propTypes = { orgUnit: PropTypes.object.isRequired, + period: PropTypes.object.isRequired, + referencePeriod: PropTypes.oneOf(referencePeriods).isRequired, }; export default TemperatureMonthly; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 954e8787..9b69a0e8 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -12,17 +12,17 @@ const pluginItems = [ }, { id: "DiszpKrYNg8/temperature/monthly", - url: "#/explore/DiszpKrYNg8/temperature/monthly", + url: "#/explore/DiszpKrYNg8/temperature/monthly/2023-09/2024-08/1991-2020", title: "Ngelehun CHC: Monthly temperatures 2023-2024", orgUnitId: "DiszpKrYNg8", display: "temperature/monthly", - period: { startTime: "2023-08", endTime: "2024-07" }, + period: { startTime: "2023-09", endTime: "2024-08" }, referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, }, { id: "DiszpKrYNg8/temperature/daily", - url: "#/explore/DiszpKrYNg8/temperature/daily", - title: "Ngelehun CHC: Daily Temperatures", + url: "#/explore/DiszpKrYNg8/temperature/daily/2023-09-01/2024-08-31", + title: "Ngelehun CHC: Daily Temperatures 2023-2024", orgUnitId: "DiszpKrYNg8", display: "temperature/daily", period: { startTime: "2023-08-01", endTime: "2024-07-12" }, @@ -61,7 +61,7 @@ const Plugin = (props) => { }); } - return ; + return ; }; export default Plugin; diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js index 495bc192..cba27c95 100644 --- a/src/components/plugin/PluginContent.js +++ b/src/components/plugin/PluginContent.js @@ -1,6 +1,6 @@ import Forecast from "../explore/forecast/Forecast"; import TemperatureMonthly from "../explore/temperature/plugin/TemperatureMonthly"; -import TemperatureDaily from "../explore/temperature/TemperatureDaily"; +import TemperatureDaily from "../explore/temperature/plugin/TemperatureDaily"; import styles from "./styles/PluginContent.module.css"; const displays = { @@ -10,7 +10,7 @@ const displays = { }; const PluginContent = (props) => { - const { display, title } = props; + const { display, title, setDashboardItemDetails } = props; const Display = displays[display]; @@ -18,9 +18,11 @@ const PluginContent = (props) => { return
Display not found (this should not happen)
; } + console.log("PluginContent props", props); + return (
-
{title}
+ {setDashboardItemDetails &&
{title}
}
); diff --git a/src/components/shared/styles/DataLoader.module.css b/src/components/shared/styles/DataLoader.module.css index b5685b8f..7f46b4a6 100644 --- a/src/components/shared/styles/DataLoader.module.css +++ b/src/components/shared/styles/DataLoader.module.css @@ -1,9 +1,9 @@ .container { - padding: 20px 0; - line-height: 20px; + line-height: 30px; font-size: 14px; font-style: italic; color: #555; + box-sizing: content-box; } .loader > div:first-child { From ce3b0ebf47f45c3f24118a034320ccfcb2c76bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 13:02:37 +0200 Subject: [PATCH 18/30] Plugin update --- package.json | 2 +- src/components/explore/Chart.js | 3 ++- src/components/plugin/Plugin.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index adb449fc..5121b502 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.7", + "version": "999.99.0-dashboard-plugin.8", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/explore/Chart.js b/src/components/explore/Chart.js index 5174606f..63b5957c 100644 --- a/src/components/explore/Chart.js +++ b/src/components/explore/Chart.js @@ -51,7 +51,8 @@ const Chart = ({ config, isPlugin }) => { return (
{ console.log("Plugin props", props); - const pluginItem = pluginItems[1]; + const pluginItem = pluginItems[2]; if (props.setDashboardItemDetails) { props.setDashboardItemDetails({ From eddd3980f1741497fc4bd277041c94304690f693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 13:12:12 +0200 Subject: [PATCH 19/30] Revert changes --- .../explore/temperature/TemperatureDaily.js | 12 ++---------- .../explore/temperature/TemperatureMonthly.js | 11 ++--------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/components/explore/temperature/TemperatureDaily.js b/src/components/explore/temperature/TemperatureDaily.js index dde8693b..d3b1d3d5 100644 --- a/src/components/explore/temperature/TemperatureDaily.js +++ b/src/components/explore/temperature/TemperatureDaily.js @@ -1,4 +1,3 @@ -import PropTypes from "prop-types"; import { useOutletContext } from "react-router-dom"; import Chart from "../Chart"; import PeriodTypeSelect from "../PeriodTypeSelect"; @@ -9,7 +8,7 @@ import useEarthEngineTimeSeries from "../../../hooks/useEarthEngineTimeSeries"; import exploreStore from "../../../utils/exploreStore"; import { era5Daily } from "../../../data/datasets"; -const TemperatureDaily = ({ isPlugin }) => { +const TemperatureDaily = () => { const orgUnit = useOutletContext(); const period = exploreStore((state) => state.dailyPeriod); @@ -19,10 +18,7 @@ const TemperatureDaily = ({ isPlugin }) => { <> {data ? ( - + ) : ( )} @@ -31,8 +27,4 @@ const TemperatureDaily = ({ isPlugin }) => { ); }; -TemperatureDaily.propTypes = { - isPlugin: PropTypes.bool, -}; - export default TemperatureDaily; diff --git a/src/components/explore/temperature/TemperatureMonthly.js b/src/components/explore/temperature/TemperatureMonthly.js index da3a4b59..a79d4a1e 100644 --- a/src/components/explore/temperature/TemperatureMonthly.js +++ b/src/components/explore/temperature/TemperatureMonthly.js @@ -1,4 +1,3 @@ -import PropTypes from "prop-types"; import { useOutletContext } from "react-router-dom"; import Chart from "../Chart"; import PeriodTypeSelect from "../PeriodTypeSelect"; @@ -11,7 +10,7 @@ import useEarthEngineClimateNormals from "../../../hooks/useEarthEngineClimateNo import exploreStore from "../../../utils/exploreStore"; import { era5Monthly, era5MonthlyNormals } from "../../../data/datasets"; -const TemperatureMonthly = ({ isPlugin }) => { +const TemperatureMonthly = () => { const orgUnit = useOutletContext(); const period = exploreStore((state) => state.monthlyPeriod); const referencePeriod = exploreStore((state) => state.referencePeriod); @@ -33,10 +32,8 @@ const TemperatureMonthly = ({ isPlugin }) => { orgUnit.properties.name, data, normals, - referencePeriod, - isPlugin + referencePeriod )} - isPlugin={isPlugin} /> ) : ( @@ -47,8 +44,4 @@ const TemperatureMonthly = ({ isPlugin }) => { ); }; -TemperatureMonthly.propTypes = { - isPlugin: PropTypes.bool, -}; - export default TemperatureMonthly; From 89acbbe0f0c806e577ec4970974feec39092f231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 13:44:25 +0200 Subject: [PATCH 20/30] Plugin fix --- package.json | 2 +- src/DashboardPlugin.js | 13 ++++++++----- .../temperature/plugin/TemperatureMonthly.js | 3 +-- src/components/plugin/PluginContent.js | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 5121b502..1215fd18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.8", + "version": "999.99.0-dashboard-plugin.10", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js index 5a866be0..f10c9001 100644 --- a/src/DashboardPlugin.js +++ b/src/DashboardPlugin.js @@ -2,10 +2,13 @@ import { DashboardPluginWrapper } from "@dhis2/analytics"; import React from "react"; import Plugin from "./components/plugin/Plugin.js"; -const DashboardPlugin = (props) => ( - - {(parentProps) => } - -); +const DashboardPlugin = (props) => { + console.log("DashboardPlugin props", props); + return ( + + {(parentProps) => } + + ); +}; export default DashboardPlugin; diff --git a/src/components/explore/temperature/plugin/TemperatureMonthly.js b/src/components/explore/temperature/plugin/TemperatureMonthly.js index deba98bb..a44023c3 100644 --- a/src/components/explore/temperature/plugin/TemperatureMonthly.js +++ b/src/components/explore/temperature/plugin/TemperatureMonthly.js @@ -5,7 +5,6 @@ import getMonthlyConfig from "../charts/temperatureMonthly"; import useEarthEngineTimeSeries from "../../../../hooks/useEarthEngineTimeSeries"; import useEarthEngineClimateNormals from "../../../../hooks/useEarthEngineClimateNormals"; import { era5Monthly, era5MonthlyNormals } from "../../../../data/datasets"; -import { referencePeriods } from "../../ReferencePeriodSelect"; const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { const data = useEarthEngineTimeSeries(era5Monthly, period, orgUnit); @@ -37,7 +36,7 @@ const TemperatureMonthly = ({ orgUnit, period, referencePeriod }) => { TemperatureMonthly.propTypes = { orgUnit: PropTypes.object.isRequired, period: PropTypes.object.isRequired, - referencePeriod: PropTypes.oneOf(referencePeriods).isRequired, + referencePeriod: PropTypes.object.isRequired, }; export default TemperatureMonthly; diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js index cba27c95..a30968a4 100644 --- a/src/components/plugin/PluginContent.js +++ b/src/components/plugin/PluginContent.js @@ -22,7 +22,7 @@ const PluginContent = (props) => { return (
- {setDashboardItemDetails &&
{title}
} + {!setDashboardItemDetails &&
{title}
}
); From 30e94abab96bbe680da21f4a988c701e66ad7886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 11 Sep 2024 14:30:39 +0200 Subject: [PATCH 21/30] New plugin version --- package.json | 2 +- src/DashboardPlugin.js | 13 +++++------- .../heat/charts/thermalComfortDaily.js | 21 ++++++++++++------- .../explore/heat/plugin/HeatDaily.js | 21 +++++++++++++++++++ src/components/plugin/Plugin.js | 12 ++++++++--- src/components/plugin/PluginContent.js | 6 ++++-- 6 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 src/components/explore/heat/plugin/HeatDaily.js diff --git a/package.json b/package.json index 1215fd18..02f2882e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.10", + "version": "999.99.0-dashboard-plugin.11", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/DashboardPlugin.js b/src/DashboardPlugin.js index f10c9001..5a866be0 100644 --- a/src/DashboardPlugin.js +++ b/src/DashboardPlugin.js @@ -2,13 +2,10 @@ import { DashboardPluginWrapper } from "@dhis2/analytics"; import React from "react"; import Plugin from "./components/plugin/Plugin.js"; -const DashboardPlugin = (props) => { - console.log("DashboardPlugin props", props); - return ( - - {(parentProps) => } - - ); -}; +const DashboardPlugin = (props) => ( + + {(parentProps) => } + +); export default DashboardPlugin; diff --git a/src/components/explore/heat/charts/thermalComfortDaily.js b/src/components/explore/heat/charts/thermalComfortDaily.js index 3796d01e..1be20c7a 100644 --- a/src/components/explore/heat/charts/thermalComfortDaily.js +++ b/src/components/explore/heat/charts/thermalComfortDaily.js @@ -52,7 +52,7 @@ export const getThickPositons = (plotBands) => [ plotBands[plotBands.length - 1].to, ]; -const getChart = (name, data) => { +const getChart = (name, data, isPlugin) => { const series = data.map((d) => ({ x: new Date(d.id).getTime(), y: toCelcius(d["utci_mean"]), @@ -69,13 +69,15 @@ const getChart = (name, data) => { const tickPositions = getThickPositons(plotBands); return { - title: { - text: i18n.t("{{name}}: Thermal comfort {{period}}", { - name, - period: getDailyPeriod(data), - nsSeparator: ";", - }), - }, + title: !isPlugin + ? { + text: i18n.t("{{name}}: Thermal comfort {{period}}", { + name, + period: getDailyPeriod(data), + nsSeparator: ";", + }), + } + : "", credits: heatCredits, tooltip: { crosshairs: true, @@ -133,6 +135,9 @@ const getChart = (name, data) => { zIndex: 0, }, ], + exporting: { + enabled: !isPlugin, + }, }; }; diff --git a/src/components/explore/heat/plugin/HeatDaily.js b/src/components/explore/heat/plugin/HeatDaily.js new file mode 100644 index 00000000..8e521c9b --- /dev/null +++ b/src/components/explore/heat/plugin/HeatDaily.js @@ -0,0 +1,21 @@ +import Chart from "../../Chart"; +import DataLoader from "../../../shared/DataLoader"; +import getDailyConfig from "../charts/thermalComfortDaily"; +import useEarthEngineTimeSeries from "../../../../hooks/useEarthEngineTimeSeries"; +import { heatDataset } from "../HeatDaily"; + +const HeatDaily = ({ orgUnit, period }) => { + const data = useEarthEngineTimeSeries(heatDataset, period, orgUnit); + const isPlugin = true; + + return data ? ( + + ) : ( + + ); +}; + +export default HeatDaily; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index d8b2d9d1..3d3cd3b6 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -27,6 +27,14 @@ const pluginItems = [ display: "temperature/daily", period: { startTime: "2023-08-01", endTime: "2024-07-12" }, }, + { + id: "DiszpKrYNg8/heat/daily", + url: "#/explore/DiszpKrYNg8/heat/daily/2023-09-01/2024-08-31", + title: "Ngelehun CHC: Daily Temperatures 2023-2024", + orgUnitId: "DiszpKrYNg8", + display: "heat/daily", + period: { startTime: "2023-09-01", endTime: "2024-08-31" }, + }, ]; // TODO: Keep in data store @@ -50,9 +58,7 @@ const Plugin = (props) => { } */ - console.log("Plugin props", props); - - const pluginItem = pluginItems[2]; + const pluginItem = pluginItems[3]; if (props.setDashboardItemDetails) { props.setDashboardItemDetails({ diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js index a30968a4..9f12dd1b 100644 --- a/src/components/plugin/PluginContent.js +++ b/src/components/plugin/PluginContent.js @@ -1,16 +1,18 @@ import Forecast from "../explore/forecast/Forecast"; import TemperatureMonthly from "../explore/temperature/plugin/TemperatureMonthly"; import TemperatureDaily from "../explore/temperature/plugin/TemperatureDaily"; +import HeatDaily from "../explore/heat/plugin/HeatDaily"; import styles from "./styles/PluginContent.module.css"; const displays = { forecast10days: Forecast, "temperature/monthly": TemperatureMonthly, "temperature/daily": TemperatureDaily, + "heat/daily": HeatDaily, }; const PluginContent = (props) => { - const { display, title, setDashboardItemDetails } = props; + const { display } = props; const Display = displays[display]; @@ -20,9 +22,9 @@ const PluginContent = (props) => { console.log("PluginContent props", props); + // {!setDashboardItemDetails &&
{title}
} return (
- {!setDashboardItemDetails &&
{title}
}
); From 7ec4f8e4ec60097d5c13dff914f68f5d7a386a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Mon, 14 Oct 2024 12:59:26 +0200 Subject: [PATCH 22/30] Plugin fix --- package.json | 2 +- src/components/explore/heat/charts/thermalComfortDaily.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 02f2882e..38f47519 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.11", + "version": "999.99.0-dashboard-plugin.13", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/explore/heat/charts/thermalComfortDaily.js b/src/components/explore/heat/charts/thermalComfortDaily.js index 513c4e82..48f63a67 100644 --- a/src/components/explore/heat/charts/thermalComfortDaily.js +++ b/src/components/explore/heat/charts/thermalComfortDaily.js @@ -9,7 +9,7 @@ import { } from "../../../../utils/chart"; import { toCelcius } from "../../../../utils/calc"; -export const getPlotBands = (minMax, settings) => { +export const getPlotBands = (minMax, settings = {}) => { const { heatMin, heatMax } = settings; const minValue = From 99ec215cbcc3c241564f0ce5527ad2461b178909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Sat, 19 Oct 2024 10:47:28 +0200 Subject: [PATCH 23/30] Plugin configuration --- i18n/en.pot | 13 ++++- src/components/import/OrgUnits.js | 3 +- src/components/plugin/Configuration.js | 55 +++++++++++++++++++ src/components/plugin/DataSelect.js | 31 +++++++++++ src/components/plugin/Plugin.js | 4 +- .../plugin/styles/Configuration.module.css | 18 ++++++ .../{import => shared}/OrgUnitTree.js | 27 ++++----- 7 files changed, 132 insertions(+), 19 deletions(-) create mode 100644 src/components/plugin/Configuration.js create mode 100644 src/components/plugin/DataSelect.js create mode 100644 src/components/plugin/styles/Configuration.module.css rename src/components/{import => shared}/OrgUnitTree.js (63%) diff --git a/i18n/en.pot b/i18n/en.pot index 0e9f8589..40e87791 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-09-25T12:23:54.679Z\n" -"PO-Revision-Date: 2024-09-25T12:23:54.679Z\n" +"POT-Creation-Date: 2024-10-17T10:15:42.972Z\n" +"PO-Revision-Date: 2024-10-17T10:15:42.972Z\n" msgid "About this app" msgstr "About this app" @@ -626,6 +626,15 @@ msgstr "Org unit parent needs to be above or equal to the org unit level" msgid "Daily values will be imported between start and end dates" msgstr "Daily values will be imported between start and end dates" +msgid "Configuration" +msgstr "Configuration" + +msgid "Select data" +msgstr "Select data" + +msgid "Organisation unit" +msgstr "Organisation unit" + msgid "" "Set y-axis values for charts in the Explore data section to make it easier " "to compare different org units. Leave blank to calculate based on data " diff --git a/src/components/import/OrgUnits.js b/src/components/import/OrgUnits.js index af566be0..5d180d3f 100644 --- a/src/components/import/OrgUnits.js +++ b/src/components/import/OrgUnits.js @@ -1,6 +1,6 @@ import PropTypes from "prop-types"; import i18n from "@dhis2/d2-i18n"; -import OrgUnitTree from "./OrgUnitTree"; +import OrgUnitTree from "../shared/OrgUnitTree"; import OrgUnitLevel from "./OrgUnitLevel"; import styles from "./styles/OrgUnits.module.css"; @@ -12,6 +12,7 @@ const OrgUnits = ({ selected = {}, onChange }) => { return ( <> +

{i18n.t("Parent organisation unit")}

onChange({ parent, level })} diff --git a/src/components/plugin/Configuration.js b/src/components/plugin/Configuration.js new file mode 100644 index 00000000..d9706ad0 --- /dev/null +++ b/src/components/plugin/Configuration.js @@ -0,0 +1,55 @@ +import { useState } from "react"; +import i18n from "@dhis2/d2-i18n"; +import DataSelect from "./DataSelect"; +import OrgUnitTree from "../shared/OrgUnitTree"; +import useOrgUnit from "../../hooks/useOrgUnit"; +import styles from "./styles/Configuration.module.css"; + +const noGeometryWarning = i18n.t( + "Selected org unit has no geometry, which is required to display data." +); + +const onlyPointWarning = i18n.t( + "Data is only available for facilities (point locations)." +); + +const Configuration = (props) => { + const [dataset, setDataset] = useState(null); + const [orgUnit, setOrgUnit] = useState(null); + const loadedOrgUnit = useOrgUnit(orgUnit?.id); + const isLoaded = !!loadedOrgUnit; + const hasGeometry = loadedOrgUnit?.geometry; + const geometryType = loadedOrgUnit?.geometry?.type; + + // console.log("Configuration", dataset); + + // TODO: Select user org unit + return ( +
+

{i18n.t("Configuration")}

+ + {dataset && ( + <> +

{i18n.t("Organisation unit")}

+
+ +
+ {isLoaded && !hasGeometry && ( +
{noGeometryWarning}
+ )} + {dataset.geometryType && + geometryType && + geometryType !== dataset.geometryType && ( +
{onlyPointWarning}
+ )} + + )} +
+ ); +}; + +export default Configuration; diff --git a/src/components/plugin/DataSelect.js b/src/components/plugin/DataSelect.js new file mode 100644 index 00000000..2b2f606d --- /dev/null +++ b/src/components/plugin/DataSelect.js @@ -0,0 +1,31 @@ +import i18n from "@dhis2/d2-i18n"; +import { SingleSelectField, SingleSelectOption } from "@dhis2/ui"; + +const datasets = [ + { + id: "forecast10days", + name: "10 days forecast", + path: "/forecast10days", + // description: "Only available for facilities (points)", + geometryType: "Point", + }, +]; + +const DataSelect = ({ value, onChange }) => ( +
+ + onChange(datasets.find((d) => d.id === selected)) + } + > + {datasets.map((d, i) => ( + + ))} + + {value &&

{value.description}

} +
+); + +export default DataSelect; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 3d3cd3b6..48b86e7d 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -1,5 +1,6 @@ // import PluginItems from "./PluginItems"; import OrgUnitLoader from "./OrgUnitLoader"; +import Configuration from "./Configuration"; // TODO: Keep in data store const pluginItems = [ @@ -67,7 +68,8 @@ const Plugin = (props) => { }); } - return ; + // return ; + return ; }; export default Plugin; diff --git a/src/components/plugin/styles/Configuration.module.css b/src/components/plugin/styles/Configuration.module.css new file mode 100644 index 00000000..24442810 --- /dev/null +++ b/src/components/plugin/styles/Configuration.module.css @@ -0,0 +1,18 @@ +.content h3 { + font-size: 14px; + font-weight: normal; + margin-bottom: 5px; +} + +.orgUnitTree { + border: 1px solid #e0e0e0; + height: 150px; + overflow-y: auto; +} + +.validation { + color: rgb(187, 70, 13); + margin-top: 6px; + font-size: 13px; + line-height: 14px; +} diff --git a/src/components/import/OrgUnitTree.js b/src/components/shared/OrgUnitTree.js similarity index 63% rename from src/components/import/OrgUnitTree.js rename to src/components/shared/OrgUnitTree.js index 48522a1d..15d056d0 100644 --- a/src/components/import/OrgUnitTree.js +++ b/src/components/shared/OrgUnitTree.js @@ -1,34 +1,30 @@ import PropTypes from "prop-types"; -import i18n from "@dhis2/d2-i18n"; import { useEffect } from "react"; import { OrganisationUnitTree } from "@dhis2/ui"; import useOrgUnitRoots from "../../hooks/useOrgUnitRoots"; -const OrgUnitTree = ({ orgUnit, onChange }) => { +const OrgUnitTree = ({ orgUnit, rootIsDefault = true, onChange }) => { const { roots, error } = useOrgUnitRoots(); // Set for root node as default useEffect(() => { - if (roots && !orgUnit) { + if (rootIsDefault && roots && !orgUnit) { const [root] = roots; onChange({ ...root, selected: [root.path] }); } - }, [roots, orgUnit, onChange]); + }, [rootIsDefault, roots, orgUnit, onChange]); // The warnings "The query should be static, don't create it within the render loop!" // comes from the OrganisationUnitTree component: - // https://dhis2.slack.com/archives/C0BP0RABF/p1641544953003000 + // https://dhis2.slack.com/archives/C0BP0RABF/p1641544953003000x return roots ? ( -
-

{i18n.t("Parent organisation unit")}

- r.id)} - selected={orgUnit?.selected} - onChange={onChange} - singleSelection={true} - initiallyExpanded={roots.map((r) => r.path)} - /> -
+ r.id)} + selected={orgUnit?.selected} + onChange={onChange} + singleSelection={true} + initiallyExpanded={roots.map((r) => r.path)} + /> ) : error ? (
{error.message}
) : null; @@ -36,6 +32,7 @@ const OrgUnitTree = ({ orgUnit, onChange }) => { OrgUnitTree.propTypes = { orgUnit: PropTypes.object, + rootIsDefault: PropTypes.bool, onChange: PropTypes.func.isRequired, }; From cfbd3c3bea171da68a11f01cae8a312aa051ac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Tue, 12 Nov 2024 17:18:04 +0100 Subject: [PATCH 24/30] Plugin configuration --- i18n/en.pot | 22 +++- src/components/plugin/Configuration.js | 53 ++++++-- src/components/plugin/DataSelect.js | 35 +++--- src/components/plugin/OrgUnitLoader.js | 18 ++- src/components/plugin/Plugin.js | 118 +++++++++--------- src/components/plugin/PluginContent.js | 16 +-- src/components/plugin/PluginItems.js | 3 - src/components/plugin/PluginPage.js | 32 +++-- .../plugin/styles/Configuration.module.css | 22 +++- .../plugin/styles/Plugin.module.css | 13 ++ .../plugin/styles/PluginContent.module.css | 15 --- .../plugin/styles/PluginPage.module.css | 36 +++++- src/hooks/usePluginConfig.js | 91 ++++++++++++++ 13 files changed, 328 insertions(+), 146 deletions(-) delete mode 100644 src/components/plugin/PluginItems.js create mode 100644 src/components/plugin/styles/Plugin.module.css delete mode 100644 src/components/plugin/styles/PluginContent.module.css create mode 100644 src/hooks/usePluginConfig.js diff --git a/i18n/en.pot b/i18n/en.pot index 40e87791..0e93cbec 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-10-17T10:15:42.972Z\n" -"PO-Revision-Date: 2024-10-17T10:15:42.972Z\n" +"POT-Creation-Date: 2024-11-12T11:06:57.733Z\n" +"PO-Revision-Date: 2024-11-12T11:06:57.733Z\n" msgid "About this app" msgstr "About this app" @@ -626,15 +626,27 @@ msgstr "Org unit parent needs to be above or equal to the org unit level" msgid "Daily values will be imported between start and end dates" msgstr "Daily values will be imported between start and end dates" +msgid "Selected org unit has no geometry, which is required to display data." +msgstr "Selected org unit has no geometry, which is required to display data." + +msgid "Data is only available for facilities (point locations)." +msgstr "Data is only available for facilities (point locations)." + +msgid "Weather forecast" +msgstr "Weather forecast" + msgid "Configuration" msgstr "Configuration" +msgid "Select organisation unit" +msgstr "Select organisation unit" + +msgid "Done" +msgstr "Done" + msgid "Select data" msgstr "Select data" -msgid "Organisation unit" -msgstr "Organisation unit" - msgid "" "Set y-axis values for charts in the Explore data section to make it easier " "to compare different org units. Leave blank to calculate based on data " diff --git a/src/components/plugin/Configuration.js b/src/components/plugin/Configuration.js index d9706ad0..ccb08aa7 100644 --- a/src/components/plugin/Configuration.js +++ b/src/components/plugin/Configuration.js @@ -1,8 +1,10 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import i18n from "@dhis2/d2-i18n"; +import { Button } from "@dhis2/ui"; import DataSelect from "./DataSelect"; import OrgUnitTree from "../shared/OrgUnitTree"; import useOrgUnit from "../../hooks/useOrgUnit"; +import { datasets } from "./DataSelect"; import styles from "./styles/Configuration.module.css"; const noGeometryWarning = i18n.t( @@ -13,24 +15,54 @@ const onlyPointWarning = i18n.t( "Data is only available for facilities (point locations)." ); -const Configuration = (props) => { - const [dataset, setDataset] = useState(null); +const getPluginConfig = (datasetId, orgUnit) => { + const { id: orgUnitId, displayName } = orgUnit; + + if (datasetId === "forecast10days") { + return { + id: `${orgUnitId}/forecast10days`, + url: `#/explore/${orgUnitId}/forecast10days`, + title: `${displayName}: ${i18n.t("Weather forecast")}`, + display: "forecast10days", + orgUnitId, + }; + } +}; + +const Configuration = ({ config, onDone }) => { + const [datasetId, setDatasetId] = useState(); const [orgUnit, setOrgUnit] = useState(null); const loadedOrgUnit = useOrgUnit(orgUnit?.id); + const dataset = datasets.find((d) => d.id === datasetId); const isLoaded = !!loadedOrgUnit; const hasGeometry = loadedOrgUnit?.geometry; const geometryType = loadedOrgUnit?.geometry?.type; + const isValid = + dataset && + orgUnit && + isLoaded && + hasGeometry && + (dataset.geometryType ? geometryType === dataset.geometryType : true); + + const onDoneClick = () => onDone(getPluginConfig(datasetId, orgUnit)); + + // console.log("Configuration", config, datasetId, orgUnit); - // console.log("Configuration", dataset); + useEffect(() => { + if (config) { + setDatasetId(config.display); + // setOrgUnit({ id: config.orgUnitId }); + } + }, [config]); // TODO: Select user org unit return (

{i18n.t("Configuration")}

- - {dataset && ( + + {datasetId && ( <> -

{i18n.t("Organisation unit")}

+

{i18n.t("Select organisation unit")}

{ )} )} +
); }; diff --git a/src/components/plugin/DataSelect.js b/src/components/plugin/DataSelect.js index 2b2f606d..39b2f15f 100644 --- a/src/components/plugin/DataSelect.js +++ b/src/components/plugin/DataSelect.js @@ -1,7 +1,7 @@ import i18n from "@dhis2/d2-i18n"; import { SingleSelectField, SingleSelectOption } from "@dhis2/ui"; -const datasets = [ +export const datasets = [ { id: "forecast10days", name: "10 days forecast", @@ -11,21 +11,22 @@ const datasets = [ }, ]; -const DataSelect = ({ value, onChange }) => ( -
- - onChange(datasets.find((d) => d.id === selected)) - } - > - {datasets.map((d, i) => ( - - ))} - - {value &&

{value.description}

} -
-); +const DataSelect = ({ value, onChange }) => { + const dataset = datasets.find((d) => d.id === value); + return ( +
+ onChange(selected)} + > + {datasets.map((d, i) => ( + + ))} + + {dataset?.description &&

{dataset.description}

} +
+ ); +}; export default DataSelect; diff --git a/src/components/plugin/OrgUnitLoader.js b/src/components/plugin/OrgUnitLoader.js index c9fd8feb..fbebe865 100644 --- a/src/components/plugin/OrgUnitLoader.js +++ b/src/components/plugin/OrgUnitLoader.js @@ -1,15 +1,21 @@ +import { useEffect } from "react"; import PluginContent from "./PluginContent"; import DataLoader from "../shared/DataLoader"; +import exploreStore from "../../store/exploreStore"; import useOrgUnit from "../../hooks/useOrgUnit"; const OrgUnitLoader = (props) => { - const orgUnit = useOrgUnit(props.orgUnitId); + const loadedOrgUnit = useOrgUnit(props.orgUnitId); + const { orgUnit, setOrgUnit } = exploreStore(); - return orgUnit ? ( - - ) : ( - - ); + useEffect(() => { + setOrgUnit(loadedOrgUnit); + return () => { + setOrgUnit(null); + }; + }, [loadedOrgUnit]); + + return orgUnit ? : ; }; export default OrgUnitLoader; diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 48b86e7d..dddf94b6 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -1,75 +1,69 @@ -// import PluginItems from "./PluginItems"; +import { useState, useEffect } from "react"; +import i18n from "@dhis2/d2-i18n"; +import { Button } from "@dhis2/ui"; import OrgUnitLoader from "./OrgUnitLoader"; import Configuration from "./Configuration"; +import usePluginConfig from "../../hooks/usePluginConfig"; +import styles from "./styles/Plugin.module.css"; -// TODO: Keep in data store -const pluginItems = [ - { - id: "DiszpKrYNg8/forecast10days", - url: "#/explore/DiszpKrYNg8/forecast10days", - title: "Ngelehun CHC: Weather forecast", - orgUnitId: "DiszpKrYNg8", - display: "forecast10days", - }, - { - id: "DiszpKrYNg8/temperature/monthly", - url: "#/explore/DiszpKrYNg8/temperature/monthly/2023-09/2024-08/1991-2020", - title: "Ngelehun CHC: Monthly temperatures 2023-2024", - orgUnitId: "DiszpKrYNg8", - display: "temperature/monthly", - period: { startTime: "2023-09", endTime: "2024-08" }, - referencePeriod: { id: "1991-2020", startTime: 1991, endTime: 2020 }, - }, - { - id: "DiszpKrYNg8/temperature/daily", - url: "#/explore/DiszpKrYNg8/temperature/daily/2023-09-01/2024-08-31", - title: "Ngelehun CHC: Daily Temperatures 2023-2024", - orgUnitId: "DiszpKrYNg8", - display: "temperature/daily", - period: { startTime: "2023-08-01", endTime: "2024-07-12" }, - }, - { - id: "DiszpKrYNg8/heat/daily", - url: "#/explore/DiszpKrYNg8/heat/daily/2023-09-01/2024-08-31", - title: "Ngelehun CHC: Daily Temperatures 2023-2024", - orgUnitId: "DiszpKrYNg8", - display: "heat/daily", - period: { startTime: "2023-09-01", endTime: "2024-08-31" }, - }, -]; +const Plugin = ({ + dashboardItemId, + setDashboardItemDetails, + dashboardMode, +}) => { + const [editMode, setEditMode] = useState(); + const { config, loading, setPluginConfig } = usePluginConfig(dashboardItemId); -// TODO: Keep in data store -const dashboardItems = { - tf116s7c3YO: "DiszpKrYNg8/forecast10days", -}; + useEffect(() => { + if (config && setDashboardItemDetails) { + setDashboardItemDetails({ + itemTitle: config.title, + appUrl: config.url, + }); + } + }, [setDashboardItemDetails, config]); -const Plugin = (props) => { - /* - const { dashboardItemId } = props; - const pluginItemId = dashboardItems[dashboardItemId]; + useEffect(() => { + if ( + dashboardMode === "edit" && + !loading && + !config && + editMode === undefined + ) { + setEditMode(true); + } + }, [editMode, config, loading, dashboardMode]); - if (!pluginItemId) { - ; + if (editMode) { + return ( + { + setPluginConfig(config); + setEditMode(false); + }} + /> + ); } - const pluginItem = pluginItems.find((item) => item.id === pluginItemId); - - if (!pluginItem) { - return
Plugin item not found (this should not happen)
; - } - */ - - const pluginItem = pluginItems[3]; - - if (props.setDashboardItemDetails) { - props.setDashboardItemDetails({ - itemTitle: pluginItem.title, - appUrl: pluginItem.url, - }); + if (loading) { + return
Loading...
; } - // return ; - return ; + return ( +
+ {config ? ( + + ) : ( +
{i18n.t("Not configured")}
+ )} + {dashboardMode === "edit" && ( +
+ +
+ )} +
+ ); }; export default Plugin; diff --git a/src/components/plugin/PluginContent.js b/src/components/plugin/PluginContent.js index 9f12dd1b..79542712 100644 --- a/src/components/plugin/PluginContent.js +++ b/src/components/plugin/PluginContent.js @@ -1,14 +1,7 @@ import Forecast from "../explore/forecast/Forecast"; -import TemperatureMonthly from "../explore/temperature/plugin/TemperatureMonthly"; -import TemperatureDaily from "../explore/temperature/plugin/TemperatureDaily"; -import HeatDaily from "../explore/heat/plugin/HeatDaily"; -import styles from "./styles/PluginContent.module.css"; const displays = { forecast10days: Forecast, - "temperature/monthly": TemperatureMonthly, - "temperature/daily": TemperatureDaily, - "heat/daily": HeatDaily, }; const PluginContent = (props) => { @@ -20,14 +13,7 @@ const PluginContent = (props) => { return
Display not found (this should not happen)
; } - console.log("PluginContent props", props); - - // {!setDashboardItemDetails &&
{title}
} - return ( -
- -
- ); + return ; }; export default PluginContent; diff --git a/src/components/plugin/PluginItems.js b/src/components/plugin/PluginItems.js deleted file mode 100644 index 2fb79705..00000000 --- a/src/components/plugin/PluginItems.js +++ /dev/null @@ -1,3 +0,0 @@ -const PluginItems = ({ items }) =>
Select plugin item
; - -export default PluginItems; diff --git a/src/components/plugin/PluginPage.js b/src/components/plugin/PluginPage.js index 26c92202..1e780f1e 100644 --- a/src/components/plugin/PluginPage.js +++ b/src/components/plugin/PluginPage.js @@ -1,13 +1,31 @@ +import { useState } from "react"; import Plugin from "./Plugin"; import styles from "./styles/PluginPage.module.css"; -const PluginPage = () => ( -
-

Plugin

-
- +const PluginPage = () => { + const [details, setDetails] = useState(null); + + return ( +
+

Plugin

+
+
+
+ {details &&

{details.itemTitle}

} +
+
+
+ +
+
+
+
-
-); + ); +}; export default PluginPage; diff --git a/src/components/plugin/styles/Configuration.module.css b/src/components/plugin/styles/Configuration.module.css index 24442810..bd1f7f8c 100644 --- a/src/components/plugin/styles/Configuration.module.css +++ b/src/components/plugin/styles/Configuration.module.css @@ -1,12 +1,24 @@ +.content { + padding: 10px; +} + +.content h2 { + font-size: 15px; + font-weight: bold; + margin-top: 0; + margin-bottom: 10px; +} + .content h3 { - font-size: 14px; + font-size: 15px; font-weight: normal; - margin-bottom: 5px; + margin-top: 16px; + margin-bottom: 3px; } .orgUnitTree { border: 1px solid #e0e0e0; - height: 150px; + height: 190px; overflow-y: auto; } @@ -16,3 +28,7 @@ font-size: 13px; line-height: 14px; } + +.doneButton { + margin-top: 10px; +} diff --git a/src/components/plugin/styles/Plugin.module.css b/src/components/plugin/styles/Plugin.module.css new file mode 100644 index 00000000..a04896df --- /dev/null +++ b/src/components/plugin/styles/Plugin.module.css @@ -0,0 +1,13 @@ +.container { + width: 100%; + height: 100%; + min-height: 400px; /* TODO: remove this */ + overflow: auto; + position: relative; +} + +.editButton { + position: absolute; + right: 10px; + bottom: 10px; +} diff --git a/src/components/plugin/styles/PluginContent.module.css b/src/components/plugin/styles/PluginContent.module.css deleted file mode 100644 index 324983a1..00000000 --- a/src/components/plugin/styles/PluginContent.module.css +++ /dev/null @@ -1,15 +0,0 @@ -.content { - width: 100%; - height: 100%; - min-height: 400px; /* TODO: remove this */ - overflow: auto; -} - -.title { - font-size: 14px; - color: var(--colors-grey800); - font-weight: 700; - margin-bottom: 10px; - padding-left: 7px; - padding-top: 5px; -} diff --git a/src/components/plugin/styles/PluginPage.module.css b/src/components/plugin/styles/PluginPage.module.css index fe874b7d..6e679490 100644 --- a/src/components/plugin/styles/PluginPage.module.css +++ b/src/components/plugin/styles/PluginPage.module.css @@ -1,10 +1,34 @@ -.plugin { - box-shadow: 0 0 3px 0 #999; - border-radius: 3px; - padding: 4px; +.dashboard { + background-color: #f4f6f8; + padding: 100px; + margin-right: 30px; +} + +.dashboardItem { background-color: #fff; + border-radius: 3px; + box-shadow: 0 0 3px 0 #999; + width: 550px; + height: 564px; + overflow: hidden !important; +} + +.dashboardItemHeader { + margin: 8px; + line-height: 18.4px; +} + +.dashboardItemHeader p { + color: rgb(64, 75, 90); + font-size: 14px; + font-weight: 700; +} + +.dashboardItemContent { + margin: 0 4px 4px 4px; +} + +.plugin { box-sizing: content-box; - width: 500px; - height: 400px; overflow: hidden !important; } diff --git a/src/hooks/usePluginConfig.js b/src/hooks/usePluginConfig.js new file mode 100644 index 00000000..ceb5713e --- /dev/null +++ b/src/hooks/usePluginConfig.js @@ -0,0 +1,91 @@ +import { useState, useCallback, useEffect } from "react"; +import { useDataEngine } from "@dhis2/app-runtime"; + +const APP_NAMESPACE = "CLIMATE_DATA"; +const PLUGINS_KEY = "plugins"; + +const resource = `dataStore/${APP_NAMESPACE}/${PLUGINS_KEY}`; + +// TODO: Only load one plugin config +// TODO: Delete plugin config +const usePluginConfig = (pluginId) => { + const [loading, setLoading] = useState(true); + const [plugins, setPlugins] = useState(); + const [error, setError] = useState(); + const engine = useDataEngine(); + + const config = plugins?.[pluginId]; + + // Fetch plugin configs / create namspace/key if missing + const getPlugins = useCallback(() => { + setLoading(true); + engine + .query({ dataStore: { resource: "dataStore" } }) + .then(({ dataStore }) => { + const createNamespaceKey = () => + engine + .mutate({ + resource, + type: "create", + data: {}, + }) + .then((response) => { + if (response.httpStatusCode === 201) { + setLoading(false); + } else { + setError(response); + } + }) + .catch(setError); + + if (dataStore.includes(APP_NAMESPACE)) { + // Fetch plugin configs if namespace/keys exists in data store + engine + .query({ plugins: { resource } }) + .then(({ plugins }) => { + setPlugins(plugins); + setLoading(false); + }) + .catch((error) => { + if (error.message.includes("(404)")) { + // key not found + createNamespaceKey(); + } + }); + } else { + createNamespaceKey(); + } + }); + }, [engine]); + + const setPluginConfig = useCallback( + (config) => { + engine + .mutate({ + resource, + type: "update", + data: { + ...plugins, + [pluginId]: config, + }, + }) + .then((response) => { + if (response.httpStatusCode === 200) { + getPlugins(); + } else { + setError(response); + } + }) + .catch(setError); + }, + [engine, pluginId, plugins, getPlugins] + ); + + useEffect(() => { + getPlugins(); + }, [engine, getPlugins]); + + return { config, loading: !config && loading, error, setPluginConfig }; +}; + +export default usePluginConfig; From 9cc81201a535afa6afd2eb95346ea6198ff786ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 13 Nov 2024 14:41:47 +0100 Subject: [PATCH 25/30] Plugin configuration --- package.json | 2 +- src/components/plugin/Configuration.js | 9 +++------ src/components/plugin/Plugin.js | 9 ++++----- src/components/shared/OrgUnitTree.js | 14 ++++++++++++-- src/hooks/useOrgUnit.js | 1 + 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 38f47519..271f690f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.13", + "version": "999.99.0-dashboard-plugin.14", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Configuration.js b/src/components/plugin/Configuration.js index ccb08aa7..f163d483 100644 --- a/src/components/plugin/Configuration.js +++ b/src/components/plugin/Configuration.js @@ -32,7 +32,7 @@ const getPluginConfig = (datasetId, orgUnit) => { const Configuration = ({ config, onDone }) => { const [datasetId, setDatasetId] = useState(); const [orgUnit, setOrgUnit] = useState(null); - const loadedOrgUnit = useOrgUnit(orgUnit?.id); + const loadedOrgUnit = useOrgUnit(orgUnit?.id || config?.orgUnitId); const dataset = datasets.find((d) => d.id === datasetId); const isLoaded = !!loadedOrgUnit; const hasGeometry = loadedOrgUnit?.geometry; @@ -46,12 +46,9 @@ const Configuration = ({ config, onDone }) => { const onDoneClick = () => onDone(getPluginConfig(datasetId, orgUnit)); - // console.log("Configuration", config, datasetId, orgUnit); - useEffect(() => { if (config) { setDatasetId(config.display); - // setOrgUnit({ id: config.orgUnitId }); } }, [config]); @@ -60,12 +57,12 @@ const Configuration = ({ config, onDone }) => {

{i18n.t("Configuration")}

- {datasetId && ( + {datasetId && loadedOrgUnit && ( <>

{i18n.t("Select organisation unit")}

diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index dddf94b6..41f962e8 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -6,14 +6,13 @@ import Configuration from "./Configuration"; import usePluginConfig from "../../hooks/usePluginConfig"; import styles from "./styles/Plugin.module.css"; -const Plugin = ({ - dashboardItemId, - setDashboardItemDetails, - dashboardMode, -}) => { +const Plugin = (props) => { + const { dashboardItemId, setDashboardItemDetails, dashboardMode } = props; const [editMode, setEditMode] = useState(); const { config, loading, setPluginConfig } = usePluginConfig(dashboardItemId); + console.log("Climate Plugin props", props); + useEffect(() => { if (config && setDashboardItemDetails) { setDashboardItemDetails({ diff --git a/src/components/shared/OrgUnitTree.js b/src/components/shared/OrgUnitTree.js index 15d056d0..56639d95 100644 --- a/src/components/shared/OrgUnitTree.js +++ b/src/components/shared/OrgUnitTree.js @@ -14,16 +14,26 @@ const OrgUnitTree = ({ orgUnit, rootIsDefault = true, onChange }) => { } }, [rootIsDefault, roots, orgUnit, onChange]); + const path = orgUnit?.properties?.path; + const pathArray = path?.split("/"); + + const initiallyExpanded = + pathArray?.length > 2 + ? [pathArray.slice(0, -1).join("/")] + : roots?.map((r) => r.path); + + console.log("initiallyExpanded", initiallyExpanded); + // The warnings "The query should be static, don't create it within the render loop!" // comes from the OrganisationUnitTree component: // https://dhis2.slack.com/archives/C0BP0RABF/p1641544953003000x return roots ? ( r.id)} - selected={orgUnit?.selected} + selected={orgUnit?.selected || path ? [path] : undefined} onChange={onChange} singleSelection={true} - initiallyExpanded={roots.map((r) => r.path)} + initiallyExpanded={["/ImspTQPwCqd/O6uvpzGd5pu/YuQRtpLP10I"]} /> ) : error ? (
{error.message}
diff --git a/src/hooks/useOrgUnit.js b/src/hooks/useOrgUnit.js index 62d68085..047e9a64 100644 --- a/src/hooks/useOrgUnit.js +++ b/src/hooks/useOrgUnit.js @@ -21,6 +21,7 @@ const useOrgUnit = (id) => { geometry: ou.geometry, properties: { name: ou.displayName, + path: ou.path, }, }), }); From a706a827bbfdc328cbab060909248a3c8ff9ad16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 14 Nov 2024 10:49:36 +0100 Subject: [PATCH 26/30] Bump plugin version --- i18n/en.pot | 10 ++++++++-- package.json | 2 +- src/components/plugin/Configuration.js | 11 ++++++----- src/components/plugin/Plugin.js | 18 ++++++++++-------- src/components/shared/OrgUnitTree.js | 4 +--- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 0e93cbec..776c564c 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-11-12T11:06:57.733Z\n" -"PO-Revision-Date: 2024-11-12T11:06:57.733Z\n" +"POT-Creation-Date: 2024-11-13T13:42:01.843Z\n" +"PO-Revision-Date: 2024-11-13T13:42:01.843Z\n" msgid "About this app" msgstr "About this app" @@ -647,6 +647,12 @@ msgstr "Done" msgid "Select data" msgstr "Select data" +msgid "Not configured" +msgstr "Not configured" + +msgid "Edit" +msgstr "Edit" + msgid "" "Set y-axis values for charts in the Explore data section to make it easier " "to compare different org units. Leave blank to calculate based on data " diff --git a/package.json b/package.json index 271f690f..ef7c3f95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.14", + "version": "999.99.0-dashboard-plugin.15", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Configuration.js b/src/components/plugin/Configuration.js index f163d483..0f3e3cb1 100644 --- a/src/components/plugin/Configuration.js +++ b/src/components/plugin/Configuration.js @@ -16,13 +16,13 @@ const onlyPointWarning = i18n.t( ); const getPluginConfig = (datasetId, orgUnit) => { - const { id: orgUnitId, displayName } = orgUnit; + const { id: orgUnitId, properties } = orgUnit; if (datasetId === "forecast10days") { return { id: `${orgUnitId}/forecast10days`, url: `#/explore/${orgUnitId}/forecast10days`, - title: `${displayName}: ${i18n.t("Weather forecast")}`, + title: `${properties.name}: ${i18n.t("Weather forecast")}`, display: "forecast10days", orgUnitId, }; @@ -32,7 +32,7 @@ const getPluginConfig = (datasetId, orgUnit) => { const Configuration = ({ config, onDone }) => { const [datasetId, setDatasetId] = useState(); const [orgUnit, setOrgUnit] = useState(null); - const loadedOrgUnit = useOrgUnit(orgUnit?.id || config?.orgUnitId); + const loadedOrgUnit = useOrgUnit(orgUnit?.id); const dataset = datasets.find((d) => d.id === datasetId); const isLoaded = !!loadedOrgUnit; const hasGeometry = loadedOrgUnit?.geometry; @@ -44,11 +44,12 @@ const Configuration = ({ config, onDone }) => { hasGeometry && (dataset.geometryType ? geometryType === dataset.geometryType : true); - const onDoneClick = () => onDone(getPluginConfig(datasetId, orgUnit)); + const onDoneClick = () => onDone(getPluginConfig(datasetId, loadedOrgUnit)); useEffect(() => { if (config) { setDatasetId(config.display); + setOrgUnit({ id: config.orgUnitId }); } }, [config]); @@ -57,7 +58,7 @@ const Configuration = ({ config, onDone }) => {

{i18n.t("Configuration")}

- {datasetId && loadedOrgUnit && ( + {datasetId && (!config || loadedOrgUnit) && ( <>

{i18n.t("Select organisation unit")}

diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 41f962e8..a8f8aa53 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -35,18 +35,20 @@ const Plugin = (props) => { if (editMode) { return ( - { - setPluginConfig(config); - setEditMode(false); - }} - /> +
+ { + setPluginConfig(config); + setEditMode(false); + }} + /> +
); } if (loading) { - return
Loading...
; + return
Loading...
; } return ( diff --git a/src/components/shared/OrgUnitTree.js b/src/components/shared/OrgUnitTree.js index 56639d95..f848e577 100644 --- a/src/components/shared/OrgUnitTree.js +++ b/src/components/shared/OrgUnitTree.js @@ -22,8 +22,6 @@ const OrgUnitTree = ({ orgUnit, rootIsDefault = true, onChange }) => { ? [pathArray.slice(0, -1).join("/")] : roots?.map((r) => r.path); - console.log("initiallyExpanded", initiallyExpanded); - // The warnings "The query should be static, don't create it within the render loop!" // comes from the OrganisationUnitTree component: // https://dhis2.slack.com/archives/C0BP0RABF/p1641544953003000x @@ -33,7 +31,7 @@ const OrgUnitTree = ({ orgUnit, rootIsDefault = true, onChange }) => { selected={orgUnit?.selected || path ? [path] : undefined} onChange={onChange} singleSelection={true} - initiallyExpanded={["/ImspTQPwCqd/O6uvpzGd5pu/YuQRtpLP10I"]} + initiallyExpanded={initiallyExpanded} /> ) : error ? (
{error.message}
From c01c5909fba0a32ae6ba75ece2e916f377e7672a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Thu, 14 Nov 2024 16:07:05 +0100 Subject: [PATCH 27/30] onRemove callback --- package.json | 2 +- src/components/plugin/Plugin.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ef7c3f95..431e1c59 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.15", + "version": "999.99.0-dashboard-plugin.16", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index a8f8aa53..352137b5 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -6,18 +6,21 @@ import Configuration from "./Configuration"; import usePluginConfig from "../../hooks/usePluginConfig"; import styles from "./styles/Plugin.module.css"; +function wait(milliseconds) { + return new Promise((resolve) => setTimeout(resolve, milliseconds)); +} + const Plugin = (props) => { const { dashboardItemId, setDashboardItemDetails, dashboardMode } = props; const [editMode, setEditMode] = useState(); const { config, loading, setPluginConfig } = usePluginConfig(dashboardItemId); - console.log("Climate Plugin props", props); - useEffect(() => { if (config && setDashboardItemDetails) { setDashboardItemDetails({ itemTitle: config.title, appUrl: config.url, + onRemove: () => wait(1000), }); } }, [setDashboardItemDetails, config]); From d251e465b3feb21ab2386de4bced8629dd98dcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Mon, 25 Nov 2024 17:04:25 +0100 Subject: [PATCH 28/30] Plugin state handling --- i18n/en.pot | 5 --- package.json | 2 +- src/components/plugin/Plugin.js | 8 ++--- src/hooks/useAppSettings.js | 32 ++++++++--------- src/hooks/usePluginConfig.js | 64 ++++++++++++++++++++++----------- src/utils/dataStore.js | 17 +++++++++ 6 files changed, 80 insertions(+), 48 deletions(-) create mode 100644 src/utils/dataStore.js diff --git a/i18n/en.pot b/i18n/en.pot index 4b2d41ad..2bbaeec7 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,13 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -<<<<<<< HEAD -"POT-Creation-Date: 2024-11-13T13:42:01.843Z\n" -"PO-Revision-Date: 2024-11-13T13:42:01.843Z\n" -======= "POT-Creation-Date: 2024-11-20T14:17:35.520Z\n" "PO-Revision-Date: 2024-11-20T14:17:35.520Z\n" ->>>>>>> main msgid "About this app" msgstr "About this app" diff --git a/package.json b/package.json index 282b4b86..72319599 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.17", + "version": "999.99.0-dashboard-plugin.22", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index c66851e3..7edfeda5 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -13,17 +13,15 @@ function wait(milliseconds) { const Plugin = (props) => { const { dashboardItemId, setDashboardItemDetails, dashboardMode } = props; const [editMode, setEditMode] = useState(); - const { config, loading, setPluginConfig } = usePluginConfig(dashboardItemId); + const { config, loading, setPluginConfig, clearPluginConfig } = + usePluginConfig(dashboardItemId); useEffect(() => { if (config && setDashboardItemDetails) { setDashboardItemDetails({ itemTitle: config.title, appUrl: config.url, - onRemove: () => - wait(1000).then(() => { - console.log("Item will removed"); - }), + onRemove: clearPluginConfig, }); } }, [setDashboardItemDetails, config]); diff --git a/src/hooks/useAppSettings.js b/src/hooks/useAppSettings.js index f06853d7..e22d37ef 100644 --- a/src/hooks/useAppSettings.js +++ b/src/hooks/useAppSettings.js @@ -1,5 +1,6 @@ import { useState, useCallback, useEffect } from "react"; import { useDataEngine } from "@dhis2/app-runtime"; +import { createKeyInNamespace } from "../utils/dataStore"; const APP_NAMESPACE = "CLIMATE_DATA"; const SETTINGS_KEY = "settings"; @@ -20,25 +21,24 @@ const useAppSettings = () => { .then(({ dataStore }) => { if (dataStore.includes(APP_NAMESPACE)) { // Fetch settings if namespace/keys exists in data store - engine.query({ settings: { resource } }).then(({ settings }) => { - setSettings(settings); - setLoading(false); - }); - } else { - // Create namespace/keys if missing in data store engine - .mutate({ - resource, - type: "create", - data: {}, + .query({ settings: { resource } }) + .then(({ settings }) => { + setSettings(settings); + setLoading(false); }) - .then((response) => { - if (response.httpStatusCode === 201) { - setLoading(false); - } else { - setError(response); + .catch((error) => { + if (error.message.includes("(404)")) { + // key not found + createKeyInNamespace(engine, resource) + .then(() => setLoading(false)) + .catch(setError); } - }) + }); + } else { + // Create namespace/keys if missing in data store + createKeyInNamespace(engine, resource) + .then(() => setLoading(false)) .catch(setError); } }); diff --git a/src/hooks/usePluginConfig.js b/src/hooks/usePluginConfig.js index ceb5713e..c41369db 100644 --- a/src/hooks/usePluginConfig.js +++ b/src/hooks/usePluginConfig.js @@ -1,13 +1,13 @@ import { useState, useCallback, useEffect } from "react"; import { useDataEngine } from "@dhis2/app-runtime"; +import { createKeyInNamespace } from "../utils/dataStore"; const APP_NAMESPACE = "CLIMATE_DATA"; const PLUGINS_KEY = "plugins"; const resource = `dataStore/${APP_NAMESPACE}/${PLUGINS_KEY}`; -// TODO: Only load one plugin config -// TODO: Delete plugin config +// TODO: Only load one plugin config at a time const usePluginConfig = (pluginId) => { const [loading, setLoading] = useState(true); const [plugins, setPlugins] = useState(); @@ -22,22 +22,6 @@ const usePluginConfig = (pluginId) => { engine .query({ dataStore: { resource: "dataStore" } }) .then(({ dataStore }) => { - const createNamespaceKey = () => - engine - .mutate({ - resource, - type: "create", - data: {}, - }) - .then((response) => { - if (response.httpStatusCode === 201) { - setLoading(false); - } else { - setError(response); - } - }) - .catch(setError); - if (dataStore.includes(APP_NAMESPACE)) { // Fetch plugin configs if namespace/keys exists in data store engine @@ -49,11 +33,15 @@ const usePluginConfig = (pluginId) => { .catch((error) => { if (error.message.includes("(404)")) { // key not found - createNamespaceKey(); + createKeyInNamespace(engine, resource) + .then(() => setLoading(false)) + .catch(setError); } }); } else { - createNamespaceKey(); + createKeyInNamespace(engine, resource) + .then(() => setLoading(false)) + .catch(setError); } }); }, [engine]); @@ -81,11 +69,45 @@ const usePluginConfig = (pluginId) => { [engine, pluginId, plugins, getPlugins] ); + const clearPluginConfig = useCallback( + () => + new Promise((resolve, reject) => { + const { [pluginId]: removedPlugin, ...remainingPlugins } = plugins; + + engine + .mutate({ + resource, + type: "update", + data: remainingPlugins, + }) + .then((response) => { + if (response.httpStatusCode === 200) { + getPlugins(); + resolve(response); + } else { + setError(response); + reject(response); + } + }) + .catch((error) => { + setError(error); + reject(error); + }); + }), + [engine, pluginId, plugins, getPlugins] + ); + useEffect(() => { getPlugins(); }, [engine, getPlugins]); - return { config, loading: !config && loading, error, setPluginConfig }; + return { + config, + loading: !config && loading, + error, + setPluginConfig, + clearPluginConfig, + }; }; export default usePluginConfig; diff --git a/src/utils/dataStore.js b/src/utils/dataStore.js new file mode 100644 index 00000000..ffaa5000 --- /dev/null +++ b/src/utils/dataStore.js @@ -0,0 +1,17 @@ +export const createKeyInNamespace = (engine, resource) => + new Promise((resolve, reject) => { + engine + .mutate({ + resource, + type: "create", + data: {}, + }) + .then((response) => { + if (response.httpStatusCode === 201) { + resolve(response); + } else { + reject(response); + } + }) + .catch(reject); + }); From acd5dbf1defeb4cd55f35c28f95c06e46393b278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 4 Dec 2024 14:48:04 +0100 Subject: [PATCH 29/30] Finalise plugin support --- i18n/en.pot | 23 ++++++------ package.json | 2 +- src/components/plugin/Configuration.js | 26 +++++++------- src/components/plugin/DataSelect.js | 6 ++-- src/components/plugin/Plugin.js | 28 ++++++++------- src/components/plugin/PluginPage.js | 4 +-- .../plugin/styles/Configuration.module.css | 35 ++++++++++++------- .../plugin/styles/DataSelect.module.css | 3 ++ .../plugin/styles/Plugin.module.css | 11 +++++- .../plugin/styles/PluginPage.module.css | 30 ++++++++++++---- 10 files changed, 105 insertions(+), 63 deletions(-) create mode 100644 src/components/plugin/styles/DataSelect.module.css diff --git a/i18n/en.pot b/i18n/en.pot index 2bbaeec7..fc1188a2 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-11-20T14:17:35.520Z\n" -"PO-Revision-Date: 2024-11-20T14:17:35.520Z\n" +"POT-Creation-Date: 2024-12-04T13:47:27.860Z\n" +"PO-Revision-Date: 2024-12-04T13:47:27.860Z\n" msgid "About this app" msgstr "About this app" @@ -672,23 +672,20 @@ msgstr "Data is only available for facilities (point locations)." msgid "Weather forecast" msgstr "Weather forecast" -msgid "Configuration" -msgstr "Configuration" - -msgid "Select organisation unit" -msgstr "Select organisation unit" +msgid "Choose an organisation unit" +msgstr "Choose an organisation unit" msgid "Done" msgstr "Done" -msgid "Select data" -msgstr "Select data" +msgid "Choose a data source" +msgstr "Choose a data source" -msgid "Not configured" -msgstr "Not configured" +msgid "No data source. Edit this dashboard to configure this item." +msgstr "No data source. Edit this dashboard to configure this item." -msgid "Edit" -msgstr "Edit" +msgid "Configure data source" +msgstr "Configure data source" msgid "" "Set y-axis values for charts in the Explore data section to make it easier " diff --git a/package.json b/package.json index 72319599..c0b46f13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.22", + "version": "999.99.0-dashboard-plugin.24", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Configuration.js b/src/components/plugin/Configuration.js index 0f3e3cb1..8bd28591 100644 --- a/src/components/plugin/Configuration.js +++ b/src/components/plugin/Configuration.js @@ -53,14 +53,12 @@ const Configuration = ({ config, onDone }) => { } }, [config]); - // TODO: Select user org unit return ( -
-

{i18n.t("Configuration")}

+
{datasetId && (!config || loadedOrgUnit) && ( - <> -

{i18n.t("Select organisation unit")}

+
+

{i18n.t("Choose an organisation unit")}

{ geometryType !== dataset.geometryType && (
{onlyPointWarning}
)} - +
)} - +
+ +
); }; diff --git a/src/components/plugin/DataSelect.js b/src/components/plugin/DataSelect.js index 39b2f15f..d49effb2 100644 --- a/src/components/plugin/DataSelect.js +++ b/src/components/plugin/DataSelect.js @@ -1,12 +1,12 @@ import i18n from "@dhis2/d2-i18n"; import { SingleSelectField, SingleSelectOption } from "@dhis2/ui"; +import styles from "./styles/DataSelect.module.css"; export const datasets = [ { id: "forecast10days", name: "10 days forecast", path: "/forecast10days", - // description: "Only available for facilities (points)", geometryType: "Point", }, ]; @@ -14,9 +14,9 @@ export const datasets = [ const DataSelect = ({ value, onChange }) => { const dataset = datasets.find((d) => d.id === value); return ( -
+
onChange(selected)} > diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 7edfeda5..0946678a 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -6,10 +6,6 @@ import Configuration from "./Configuration"; import usePluginConfig from "../../hooks/usePluginConfig"; import styles from "./styles/Plugin.module.css"; -function wait(milliseconds) { - return new Promise((resolve) => setTimeout(resolve, milliseconds)); -} - const Plugin = (props) => { const { dashboardItemId, setDashboardItemDetails, dashboardMode } = props; const [editMode, setEditMode] = useState(); @@ -56,18 +52,26 @@ const Plugin = (props) => { } return ( -
- {config ? ( - - ) : ( -
{i18n.t("Not configured")}
- )} + <> +
+ {config ? ( + + ) : ( +
+ {i18n.t( + "No data source. Edit this dashboard to configure this item." + )} +
+ )} +
{dashboardMode === "edit" && (
- +
)} -
+ ); }; diff --git a/src/components/plugin/PluginPage.js b/src/components/plugin/PluginPage.js index 1e780f1e..2e9f928d 100644 --- a/src/components/plugin/PluginPage.js +++ b/src/components/plugin/PluginPage.js @@ -6,12 +6,12 @@ const PluginPage = () => { const [details, setDetails] = useState(null); return ( -
+

Plugin

- {details &&

{details.itemTitle}

} +

{details ? details.itemTitle : "Climate Data"}

diff --git a/src/components/plugin/styles/Configuration.module.css b/src/components/plugin/styles/Configuration.module.css index bd1f7f8c..11bb4139 100644 --- a/src/components/plugin/styles/Configuration.module.css +++ b/src/components/plugin/styles/Configuration.module.css @@ -1,24 +1,30 @@ -.content { - padding: 10px; +.configuration { + padding: 0 10px 10px 10px; + height: 100%; + display: flex; + flex-direction: column; + /* background-color: lightblue; */ } -.content h2 { - font-size: 15px; - font-weight: bold; - margin-top: 0; - margin-bottom: 10px; -} - -.content h3 { - font-size: 15px; +.configuration h3 { + font-size: 14px; + line-height: 19px; font-weight: normal; + color: rgb(33, 41, 52); margin-top: 16px; margin-bottom: 3px; } +.orgUnitSelect { + flex: 1 1 auto; + /* background-color: antiquewhite; */ + overflow-y: hidden; +} + .orgUnitTree { border: 1px solid #e0e0e0; - height: 190px; + height: calc(100% - 60px); + /* overflow-y: auto; */ overflow-y: auto; } @@ -29,6 +35,11 @@ line-height: 14px; } +.actions { + flex: 0 0 40px; + /* background-color: red; */ +} + .doneButton { margin-top: 10px; } diff --git a/src/components/plugin/styles/DataSelect.module.css b/src/components/plugin/styles/DataSelect.module.css new file mode 100644 index 00000000..8303af51 --- /dev/null +++ b/src/components/plugin/styles/DataSelect.module.css @@ -0,0 +1,3 @@ +.dataSelect { + flex: 0 0 60px; +} diff --git a/src/components/plugin/styles/Plugin.module.css b/src/components/plugin/styles/Plugin.module.css index a04896df..29add5ec 100644 --- a/src/components/plugin/styles/Plugin.module.css +++ b/src/components/plugin/styles/Plugin.module.css @@ -1,11 +1,20 @@ .container { width: 100%; height: 100%; - min-height: 400px; /* TODO: remove this */ overflow: auto; position: relative; } +.notConfigured { + display: flex; + justify-content: center; + align-items: center; + height: 100%; + color: var(--colors-grey800); + font-size: 14px; + font-style: italic; +} + .editButton { position: absolute; right: 10px; diff --git a/src/components/plugin/styles/PluginPage.module.css b/src/components/plugin/styles/PluginPage.module.css index 6e679490..e12a1e8e 100644 --- a/src/components/plugin/styles/PluginPage.module.css +++ b/src/components/plugin/styles/PluginPage.module.css @@ -1,34 +1,52 @@ +.pluginPage { + height: calc(100% - 50px); +} + .dashboard { - background-color: #f4f6f8; - padding: 100px; + padding: 50px; + height: calc(100% - 50px); margin-right: 30px; + background-color: #f4f6f8; } .dashboardItem { + position: absolute; background-color: #fff; border-radius: 3px; box-shadow: 0 0 3px 0 #999; width: 550px; - height: 564px; + height: 500px; + display: flex; + flex-direction: column; overflow: hidden !important; } .dashboardItemHeader { + display: flex; margin: 8px; - line-height: 18.4px; + line-height: 30px; } .dashboardItemHeader p { color: rgb(64, 75, 90); font-size: 14px; font-weight: 700; + margin: 0; + padding: 0; } .dashboardItemContent { - margin: 0 4px 4px 4px; + box-sizing: border-box; + margin-block-end: 4px; + margin-block-start: 0; + margin-inline-end: 4px; + margin-inline-start: 4px; + flex: 1 1; + overflow: hidden; + position: relative; } .plugin { - box-sizing: content-box; overflow: hidden !important; + height: 100%; } From 34bc22567d8a39c18fd05d9079e8ab824d82bb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 4 Dec 2024 14:59:44 +0100 Subject: [PATCH 30/30] Style fix --- i18n/en.pot | 7 +++++-- package.json | 2 +- src/components/plugin/Plugin.js | 8 ++++++-- src/components/plugin/styles/Plugin.module.css | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index fc1188a2..8ccfadec 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-12-04T13:47:27.860Z\n" -"PO-Revision-Date: 2024-12-04T13:47:27.860Z\n" +"POT-Creation-Date: 2024-12-04T13:59:15.469Z\n" +"PO-Revision-Date: 2024-12-04T13:59:15.469Z\n" msgid "About this app" msgstr "About this app" @@ -681,6 +681,9 @@ msgstr "Done" msgid "Choose a data source" msgstr "Choose a data source" +msgid "Loading" +msgstr "Loading" + msgid "No data source. Edit this dashboard to configure this item." msgstr "No data source. Edit this dashboard to configure this item." diff --git a/package.json b/package.json index c0b46f13..13fedc95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-data", - "version": "999.99.0-dashboard-plugin.24", + "version": "999.99.0-dashboard-plugin.25", "description": "Explore and import weather and climate data in DHIS2.", "license": "BSD-3-Clause", "private": true, diff --git a/src/components/plugin/Plugin.js b/src/components/plugin/Plugin.js index 0946678a..a204cbcd 100644 --- a/src/components/plugin/Plugin.js +++ b/src/components/plugin/Plugin.js @@ -48,7 +48,11 @@ const Plugin = (props) => { } if (loading) { - return
Loading...
; + return ( +
+
{i18n.t("Loading")}...
+
+ ); } return ( @@ -57,7 +61,7 @@ const Plugin = (props) => { {config ? ( ) : ( -
+
{i18n.t( "No data source. Edit this dashboard to configure this item." )} diff --git a/src/components/plugin/styles/Plugin.module.css b/src/components/plugin/styles/Plugin.module.css index 29add5ec..18df1eee 100644 --- a/src/components/plugin/styles/Plugin.module.css +++ b/src/components/plugin/styles/Plugin.module.css @@ -5,7 +5,7 @@ position: relative; } -.notConfigured { +.message { display: flex; justify-content: center; align-items: center;