-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '65182-add-widgets' into 'master'
65182 add widgets See merge request chameleon-system-oss/chameleon-shop!61
- Loading branch information
Showing
7 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Attach event listener to the button | ||
const button = document.querySelector("#lastOrdersDashboardWidgetReload"); | ||
|
||
if (button) { | ||
button.addEventListener("click", function (event) { | ||
event.preventDefault(); | ||
|
||
// URL and target information | ||
const serviceAlias = this.getAttribute("data-service-alias"); | ||
const reloadUrl = `/cms/api/dashboard/widget/${serviceAlias}/getWidgetHtmlAsJson`; | ||
|
||
// Fetch data | ||
fetch(reloadUrl, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json" | ||
} | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error(`HTTP-Error! Status: ${response.status}`); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
// Parse the JSON string if needed | ||
const parsedData = typeof data === "string" ? JSON.parse(data) : data; | ||
const { htmlTable, dateTime } = parsedData; | ||
|
||
console.log(dateTime); // Verify the content | ||
|
||
// Update the target container | ||
const targetDiv = document.querySelector("#widget-last-orders .card-body"); | ||
if (targetDiv) { | ||
// Animation: hide old HTML | ||
targetDiv.style.opacity = 0; | ||
|
||
setTimeout(() => { | ||
// Insert new HTML | ||
targetDiv.innerHTML = htmlTable; | ||
|
||
// Animation: fade in new HTML | ||
targetDiv.style.transition = "opacity 0.5s"; | ||
targetDiv.style.opacity = 1; | ||
}, 300); | ||
} | ||
|
||
// Optionally update timestamp | ||
const footerElement = document.querySelector(`#widget-last-orders .card-footer .widget-timestamp`); | ||
if (footerElement) { | ||
footerElement.textContent = dateTime; | ||
} | ||
}) | ||
.catch(error => { | ||
console.error("Error loading the widget data:", error); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters