Skip to content

Commit 0e7e012

Browse files
committed
feat: add popup to check gpf services status
1 parent 81ac880 commit 0e7e012

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

src/css/index.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ input[type="submit"].disabled {
152152
font-size: 14px;
153153
}
154154

155+
/* POPUP services GPF */
156+
.gpfServiceName {
157+
font-family: "Open Sans Semibold";
158+
}
159+
160+
.gpfStatusPopup ul,
161+
.gpfStatusPopup p {
162+
margin: 2px 0;
163+
}
164+
165+
.gpfStatusPopup ul {
166+
margin-top: 8px;
167+
padding-left: 15px;
168+
}
169+
155170
.secondary-button {
156171
color: var(--darker-green);
157172
background-color: var(--light-green);

src/css/position.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
color: var(--dark-grey);
251251
border-radius: 15px;
252252
padding: 0;
253+
border: 1px solid #DDE1E6;
253254
}
254255

255256
.maplibregl-popup-content > div > div:nth-child(2).divPopupContent {

src/js/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function app() {
9191
map.once("moveend", () => {
9292
StatusPopups.getNetworkPopup(map);
9393
StatusPopups.getEditoPopup(map);
94+
StatusPopups.getGpfStatusPopup(map);
9495
});
9596
if (urlParams.get("l1") && urlParams.get("l2") && urlParams.get("m") && urlParams.get("title") && urlParams.get("color")) {
9697
const feature = {
@@ -311,6 +312,7 @@ function app() {
311312
map.once("moveend", () => {
312313
StatusPopups.getNetworkPopup(map);
313314
StatusPopups.getEditoPopup(map);
315+
StatusPopups.getGpfStatusPopup(map);
314316
});
315317
}
316318

@@ -352,6 +354,7 @@ function app() {
352354
map.once("moveend", () => {
353355
StatusPopups.getNetworkPopup(map);
354356
StatusPopups.getEditoPopup(map);
357+
StatusPopups.getGpfStatusPopup(map);
355358
});
356359
});
357360
}
@@ -366,6 +369,7 @@ function app() {
366369
if (!Globals.mapLoaded) {
367370
SplashScreen.hide();
368371
StatusPopups.getEditoPopup(map);
372+
StatusPopups.getGpfStatusPopup(map);
369373
}
370374
}, 2000);
371375
}, 4000);

src/js/status-popups.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,61 @@ function getEditoPopup (map) {
7777
});
7878
}
7979

80+
function getGpfStatusPopup (map) {
81+
fetch("https://ignf.github.io/cartes-ign-services-uptime/cartes-ign-status-TEST.json?v=0").then(res => res.json()).then( (res) => {
82+
let msgDiv = null;
83+
let serviceList = null;
84+
for (const [key, value] of Object.entries(res)) {
85+
if (value.up) {
86+
continue;
87+
}
88+
if (!msgDiv) {
89+
msgDiv = document.createElement("div");
90+
const titleDiv = document.createElement("div");
91+
titleDiv.classList.add("divPositionTitle");
92+
titleDiv.innerText = "Fonctionnalités indisponibles";
93+
msgDiv.appendChild(titleDiv);
94+
95+
const contentDiv = document.createElement("div");
96+
contentDiv.classList.add("divPopupContent");
97+
msgDiv.appendChild(contentDiv);
98+
99+
const intro = document.createElement("p");
100+
intro.innerText = "Du fait d'une indisponibilité de la plateforme sur laquelle l'application se base, les fonctionnalités suivantes peuvent rencontrer des problèmes ou être indisponibles :";
101+
contentDiv.appendChild(intro);
102+
103+
serviceList = document.createElement("ul");
104+
contentDiv.appendChild(serviceList);
105+
}
106+
const li = document.createElement("li");
107+
const date = new Date(0);
108+
date.setUTCSeconds(value.since);
109+
let sinceText = "";
110+
if (value.since !== 0) {
111+
sinceText = `(depuis le ${date.toLocaleString("fr-FR", {month: "numeric", day: "numeric", hour: "2-digit", minute:"2-digit"})})`;
112+
}
113+
const element = `
114+
<span class="gpfServiceName">${key}</span> ${sinceText}
115+
`;
116+
li.innerHTML = element;
117+
serviceList.appendChild(li);
118+
}
119+
if (msgDiv) {
120+
PopupUtils.showGpfStatusPopup(`
121+
<div id="editoPopup">
122+
<div class="divPopupClose" onclick="onClosegpfStatusPopup(event)"></div>
123+
<div>${msgDiv.innerHTML}</div>
124+
</div>
125+
`
126+
, map);
127+
}
128+
129+
}).catch((err) => {
130+
console.warn("Could not load gpf status");
131+
console.warn(err);
132+
});
133+
}
134+
80135
function getOnboardingModal() {
81136
if (
82137
localStorage.getItem("lastOnboardId") !== null && localStorage.getItem("lastOnboardId") === `${OnboardingConfig.id}`
@@ -102,4 +157,5 @@ export default {
102157
getNetworkPopup,
103158
getEditoPopup,
104159
getOnboardingModal,
160+
getGpfStatusPopup,
105161
};

src/js/utils/popup-utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ let popup = {
1313
let editoPopup = {
1414
popup: null
1515
};
16+
let gpfStatusPopup = {
17+
popup: null
18+
};
1619

1720
function showPopup(content, map, className, closeMethodName, object) {
1821
// on supprime la popup
@@ -52,13 +55,17 @@ function showOnlinePopup(content, map) {
5255
showPopup(content, map, "onlinePopup", "onCloseonlinePopup", popup);
5356
}
5457

55-
5658
function showEditoPopup(content, map) {
5759
showPopup(content, map, "editoPopup", "onCloseeditoPopup", editoPopup);
5860
}
5961

62+
function showGpfStatusPopup(content, map) {
63+
showPopup(content, map, "gpfStatusPopup", "onClosegpfStatusPopup", gpfStatusPopup);
64+
}
65+
6066
export default {
6167
showOnlinePopup,
6268
showEditoPopup,
6369
showPopup,
70+
showGpfStatusPopup,
6471
};

0 commit comments

Comments
 (0)