Skip to content

Commit 1f99774

Browse files
authored
Update dashboard.html
Updated
1 parent f3a739a commit 1f99774

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

dashboard.html

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ <h3 id="modal-title"></h3>
180180
</div>
181181

182182
<script>
183+
const AZURE_API_ENDPOINT = "https://EOAgriTool.azurewebsites.net";
184+
183185
document.addEventListener('DOMContentLoaded', () => {
184186
loadDashboardData();
185187
});
@@ -234,9 +236,7 @@ <h3 id="modal-title"></h3>
234236
`;
235237
}
236238

237-
const AZURE_API_ENDPOINT = "https://your-azure-app.azurewebsites.net";
238-
239-
async function loadRecommendations() {
239+
async function fetchRecommendationsData() {
240240
try {
241241
const response = await fetch(`${AZURE_API_ENDPOINT}/recommendations`);
242242
const data = await response.json();
@@ -262,18 +262,19 @@ <h3 id="modal-title"></h3>
262262

263263
async function loadDashboardData() {
264264
try {
265-
const [fields, climate, water, reports] = await Promise.all([
265+
const [fields, climate, water, reports, recommendations] = await Promise.all([
266266
fetchFieldsData(),
267267
fetchClimateData(),
268268
fetchWaterData(),
269269
fetchReportsData(),
270-
loadRecommendations()
270+
fetchRecommendationsData()
271271
]);
272272

273273
document.getElementById('fields-card').innerHTML = `<h3 class="card-title">Field Status</h3>${fields}`;
274274
document.getElementById('climate-card').innerHTML = `<h3 class="card-title">Climate Overview</h3>${climate}`;
275275
document.getElementById('water-card').innerHTML = `<h3 class="card-title">Water Resources</h3>${water}`;
276276
document.getElementById('reports-card').innerHTML = `<h3 class="card-title">Reports</h3>${reports}`;
277+
document.getElementById('recommendations-card').innerHTML = `<h3 class="card-title">🌱 Expert Recommendations</h3>${recommendations}`;
277278
} catch (error) {
278279
console.error('Dashboard error:', error);
279280
document.querySelectorAll('.loading').forEach(el => {
@@ -282,6 +283,31 @@ <h3 id="modal-title"></h3>
282283
}
283284
}
284285

286+
function renderRecommendationCards(recommendations) {
287+
const recommendationsCard = document.getElementById('recommendations-card');
288+
recommendationsCard.innerHTML = `<h3 class="card-title">🌱 Expert Recommendations</h3>`;
289+
recommendations.forEach((rec, index) => {
290+
const recElement = document.createElement('div');
291+
recElement.innerHTML = `
292+
<p><strong>${rec.title}</strong></p>
293+
<p>${rec.summary}</p>
294+
<button onclick="getRecommendationDetails(${index})">View Details</button>
295+
`;
296+
recommendationsCard.appendChild(recElement);
297+
});
298+
}
299+
300+
function displayDetailsModal(details) {
301+
const modal = document.getElementById('detail-modal');
302+
document.getElementById('modal-title').innerText = details.title;
303+
document.getElementById('modal-details').innerText = details.content;
304+
modal.style.display = 'flex';
305+
}
306+
307+
function showError(message) {
308+
console.error(message);
309+
}
310+
285311
function timeSince(dateString) {
286312
const date = new Date(dateString);
287313
const seconds = Math.floor((new Date() - date) / 1000);

0 commit comments

Comments
 (0)