|
1 | 1 | <html>
|
2 | 2 | <head>
|
3 | 3 | <meta charset="utf-8" />
|
| 4 | + <link rel="icon" href="data:;base64,iVBORw0KGgo=" /> |
4 | 5 | <title>$PAGE_TITLE</title>
|
5 | 6 | <script src="https://cdn.plot.ly/plotly-3.0.1.min.js" charset="utf-8"></script>
|
6 | 7 | </head>
|
|
59 | 60 | const fileInfo = []; // To track which variable each promise belongs to
|
60 | 61 |
|
61 | 62 | // Collect all groups and prepare file loading
|
62 |
| - Object.keys(dict_var_info).forEach((v) => { |
63 |
| - dict_var_info[v].forEach((el) => { |
64 |
| - avail_groups.push(el["group"]); |
65 |
| - }); |
66 |
| - |
67 |
| - // Prepare file loading for each variable |
68 |
| - const fileTypes = ["reference.csv", "test.csv", "errors.csv"]; |
69 |
| - fileTypes.forEach((f) => { |
70 |
| - const file = [srv_url, dict_var_info[v][0]["dir"], f].join("/"); |
71 |
| - filePromises.push(loadCSV(file)); |
72 |
| - fileInfo.push({ variable: v, type: f }); |
| 63 | + // Check if server is accessible first |
| 64 | + fetch(srv_url) |
| 65 | + .then(response => { |
| 66 | + if (!response.ok) { |
| 67 | + throw new Error(`Server not accessible (status: ${response.status})`); |
| 68 | + } |
| 69 | + Object.keys(dict_var_info).forEach((v) => { |
| 70 | + dict_var_info[v].forEach((el) => { |
| 71 | + avail_groups.push(el["group"]); |
| 72 | + }); |
| 73 | + // Prepare file loading for each variable |
| 74 | + const fileTypes = ["reference.csv", "test.csv", "errors.csv"]; |
| 75 | + fileTypes.forEach((f) => { |
| 76 | + const file = [srv_url, dict_var_info[v][0]["dir"], f].join("/"); |
| 77 | + filePromises.push(loadCSV(file)); |
| 78 | + fileInfo.push({ variable: v, type: f }); |
| 79 | + }); |
| 80 | + }); |
73 | 81 | });
|
74 |
| - }); |
75 | 82 |
|
76 | 83 | // Wait for all files to load
|
77 | 84 | const csvDataSets = await Promise.all(filePromises);
|
|
116 | 123 | console.error("Error loading or processing data:", error);
|
117 | 124 | document.getElementById("myDiv").innerHTML = `<div style="text-align:center;padding:20px;color:red;">
|
118 | 125 | Error loading data: ${error.message}<br>
|
119 |
| - <button onclick="make_plot()">Retry</button> |
| 126 | + <button onclick="makePlot()">Retry</button> |
120 | 127 | </div>`;
|
121 | 128 | }
|
122 | 129 | }
|
|
0 commit comments