From 32676305780eff568094791adaeecd2c2a01fad9 Mon Sep 17 00:00:00 2001 From: Marwan Alwali Date: Sat, 3 May 2025 15:51:01 +0300 Subject: [PATCH] update --- inventory/views.py | 4 +- static/css/custom.css | 24 +++++++- static/js/crm-dashboard.js | 79 ------------------------ templates/base.html | 1 + templates/dashboards/manager.html | 1 - templates/dashboards/sales.html | 1 - templates/header.html | 51 +--------------- templates/index.html | 19 ++++-- templates/inventory/car_detail.html | 83 +++++++++++++++++--------- templates/inventory/car_list_view.html | 18 +++--- 10 files changed, 107 insertions(+), 174 deletions(-) diff --git a/inventory/views.py b/inventory/views.py index 173c6b00..2012916b 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -22,7 +22,7 @@ from django.conf import settings from django.db import transaction from django.db.models import Func from django.contrib import messages -from django.http import JsonResponse +from django.http import JsonResponse, HttpResponseForbidden from django.forms import HiddenInput, ValidationError from django.shortcuts import HttpResponse from django.db.models import Sum, F, Count @@ -362,6 +362,8 @@ class ManagerDashboard(LoginRequiredMixin, TemplateView): def dispatch(self, request, *args, **kwargs): if not request.user.is_authenticated: return redirect("welcome") + if not getattr(request.user, 'dealer', False): + return HttpResponseForbidden("You are not authorized to view this dashboard.") return super().dispatch(request, *args, **kwargs) def get_context_data(self, **kwargs): diff --git a/static/css/custom.css b/static/css/custom.css index 5b485e9f..7a939487 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -27,4 +27,26 @@ .rtl .fa-chevron-right { transform: scaleX(-1); -} \ No newline at end of file +} + +.spinner-container { + display: flex; + align-items: center; + gap: 10px; + padding: 10px; + color: #555; + font-size: 14px; +} + +.spinner { + width: 18px; + height: 18px; + border: 3px solid #ccc; + border-top-color: #333; + border-radius: 50%; + animation: spin 0.6s linear infinite; +} + +@keyframes spin { + to { transform: rotate(360deg); } +} diff --git a/static/js/crm-dashboard.js b/static/js/crm-dashboard.js index 5f7eceb5..58d4b86d 100644 --- a/static/js/crm-dashboard.js +++ b/static/js/crm-dashboard.js @@ -120,85 +120,7 @@ /* Echarts Total Sales */ /* -------------------------------------------------------------------------- */ - const contactsBySourceChartInit = () => { - const { getColor, getData, toggleColor } = window.phoenix.utils; - const chartElContainer = document.querySelector( - '.echart-contact-by-source-container' - ); - const chartEl = chartElContainer.querySelector('.echart-contact-by-source'); - const chartLabel = chartElContainer.querySelector('[data-label]'); - if (chartEl) { - const userOptions = getData(chartEl, 'echarts'); - const chart = window.echarts.init(chartEl); - const data = [ - { value: 80, name: 'Organic Search' }, - { value: 65, name: 'Paid Search' }, - { value: 40, name: 'Direct Traffic' }, - { value: 220, name: 'Social Media' }, - { value: 120, name: 'Referrals' }, - { value: 35, name: 'Others Campaigns' } - ]; - const totalSource = data.reduce((acc, val) => val.value + acc, 0); - if (chartLabel) { - chartLabel.innerHTML = totalSource; - } - const getDefaultOptions = () => ({ - color: [ - getColor('primary'), - getColor('success'), - getColor('info'), - getColor('info-light'), - toggleColor(getColor('danger-lighter'), getColor('danger-darker')), - toggleColor(getColor('warning-light'), getColor('warning-dark')) - ], - tooltip: { - trigger: 'item', - borderWidth: 0, - position: (...params) => handleTooltipPosition(params), - extraCssText: 'z-index: 1000' - }, - responsive: true, - maintainAspectRatio: false, - - series: [ - { - name: 'Contacts by Source', - type: 'pie', - radius: ['55%', '90%'], - startAngle: 90, - avoidLabelOverlap: false, - itemStyle: { - borderColor: getColor('body-bg'), - borderWidth: 3 - }, - - label: { - show: false - }, - emphasis: { - label: { - show: false - } - }, - labelLine: { - show: false - }, - data - } - ], - grid: { - bottom: 0, - top: 0, - left: 0, - right: 0, - containLabel: false - } - }); - - echartSetOption(chart, userOptions, getDefaultOptions); - } - }; // dayjs.extend(advancedFormat); @@ -1338,7 +1260,6 @@ const { docReady } = window.phoenix.utils; - docReady(contactsBySourceChartInit); docReady(contactsCreatedChartInit); docReady(newUsersChartsInit); docReady(newLeadsChartsInit); diff --git a/templates/base.html b/templates/base.html index 9fb869bf..21f7ebb4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -60,6 +60,7 @@ } --> {% block customCSS %} + {% endblock %} diff --git a/templates/dashboards/manager.html b/templates/dashboards/manager.html index 9f20bc6a..51f9651d 100644 --- a/templates/dashboards/manager.html +++ b/templates/dashboards/manager.html @@ -1,4 +1,3 @@ -{% extends 'base.html' %} {% load i18n static custom_filters django_ledger%} {% block content %} diff --git a/templates/dashboards/sales.html b/templates/dashboards/sales.html index e0c26d51..cf776614 100644 --- a/templates/dashboards/sales.html +++ b/templates/dashboards/sales.html @@ -1,4 +1,3 @@ -{% extends 'base.html' %} {% load i18n static custom_filters django_ledger%} {% block content %} diff --git a/templates/header.html b/templates/header.html index 4dfe8614..e17519ee 100644 --- a/templates/header.html +++ b/templates/header.html @@ -5,55 +5,8 @@