+
+
-
-
- var ctxDailySales = document.getElementById('dailySalesChart').getContext('2d');
- var dailySalesChart = new Chart(ctxDailySales, {
- type: 'line',
- data: {
- labels: dailySalesData.dates,
- datasets: [{
- label: 'Valor em vendas',
- data: dailySalesData.values,
- fill: false,
- borderColor: 'rgba(54, 162, 235, 1)',
- borderWidth: 2,
- tension: 0.5
- }]
- },
- options: {
- scales: {
- y: {
- beginAtZero: true
- }
- }
- }
- });
-
- var ctxDailySalesQuantity = document.getElementById('dailySalesQuantityChart').getContext('2d');
- var dailySalesQuantityChart = new Chart(ctxDailySalesQuantity, {
- type: 'bar',
- data: {
- labels: dailySalesQuantityData.dates,
- datasets: [{
- label: 'Quantidade de Vendas',
- data: dailySalesQuantityData.values,
- backgroundColor: 'rgba(255, 99, 132, 0.6)',
- borderColor: 'rgba(255, 99, 132, 1)',
- borderWidth: 1
- }]
- },
- options: {
- scales: {
- y: {
- beginAtZero: true
- }
- }
- }
- });
-
- var productCountByCategory = JSON.parse('{{ product_count_by_category|safe }}');
- var productCountByBrand = JSON.parse('{{ product_count_by_brand|safe }}');
-
- var ctxCategory = document.getElementById('productByCategoryChart').getContext('2d');
- var productByCategoryChart = new Chart(ctxCategory, {
- type: 'doughnut',
- data: {
- labels: Object.keys(productCountByCategory),
- datasets: [{
- data: Object.values(productCountByCategory),
- borderWidth: 1
- }]
- },
- options: {
- plugins: {
- legend: {
- display: false
- },
- }
- }
- });
-
- var ctxBrand = document.getElementById('productByBrandChart').getContext('2d');
- var productByBrandChart = new Chart(ctxBrand, {
- type: 'doughnut',
- data: {
- labels: Object.keys(productCountByBrand),
- datasets: [{
- data: Object.values(productCountByBrand),
- borderWidth: 1
- }]
- },
- options: {
- plugins: {
- legend: {
- display: false
- },
- }
- }
- });
- });
-
{% endblock %}
diff --git a/static/js/themeMode.js b/static/js/themeMode.js
new file mode 100644
index 0000000..1c993d2
--- /dev/null
+++ b/static/js/themeMode.js
@@ -0,0 +1,30 @@
+document.addEventListener('DOMContentLoaded', function() {
+ const defaultTheme = 'light';
+ const savedTheme = localStorage.getItem('themeMode');
+ const checkDarkMode = document.getElementById('checkDarkMode');
+
+ applyTheme(savedTheme ? savedTheme : defaultTheme);
+
+ if (savedTheme === 'dark' || defaultTheme === 'dark') {
+ checkDarkMode.checked = true;
+ } else {
+ checkDarkMode.checked = false;
+ }
+
+ checkDarkMode.addEventListener('change', function() {
+ const checked = this.checked;
+ const themeMode = checked ? 'dark' : 'light';
+ applyTheme(themeMode);
+ saveThemeMode(checked);
+ });
+});
+
+function applyTheme(themeMode) {
+ const html = document.querySelector('html');
+ html.dataset.bsTheme = themeMode;
+}
+
+function saveThemeMode(checkedTheme) {
+ const themeMode = checkedTheme ? 'dark' : 'light';
+ localStorage.setItem('themeMode', themeMode);
+}
\ No newline at end of file