* fix: created dashboard, widgets and dashboard widget model * fix: new user home dashboard * chore: recent projects list * chore: recent collaborators * chore: priority order change * chore: payload changes * chore: collaborator's active issue count * chore: all dashboard widgets added with services and typs * chore: centered metric for pie chart * chore: widget filters * chore: created issue filter * fix: created and assigned issues payload change * chore: created issue payload change * fix: date filter change * chore: implement filters * fix: added expansion fields * fix: changed issue structure with relation * chore: new issues response * fix: project member fix * chore: updated issue_relation structure * chore: code cleanup * chore: update issues response and added empty states * fix: button text wrap * chore: update empty state messages * fix: filters * chore: update dark mode empty states * build-error: Type check in the issue relation service * fix: issues redirection * fix: project empty state * chore: project member active check * chore: project member check in state and priority * chore: remove console logs and replace harcoded values with constants * fix: code refactoring * fix: key name changed * refactor: mapping through similar components using an array * fix: build errors --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com>
89 lines
2.4 KiB
Python
89 lines
2.4 KiB
Python
import uuid
|
|
|
|
# Django imports
|
|
from django.db import models
|
|
from django.conf import settings
|
|
|
|
# Module imports
|
|
from . import BaseModel
|
|
from ..mixins import TimeAuditModel
|
|
|
|
class Dashboard(BaseModel):
|
|
DASHBOARD_CHOICES = (
|
|
("workspace", "Workspace"),
|
|
("project", "Project"),
|
|
("home", "Home"),
|
|
("team", "Team"),
|
|
("user", "User"),
|
|
)
|
|
name = models.CharField(max_length=255)
|
|
description_html = models.TextField(blank=True, default="<p></p>")
|
|
identifier = models.UUIDField(null=True)
|
|
owned_by = models.ForeignKey(
|
|
"db.User",
|
|
on_delete=models.CASCADE,
|
|
related_name="dashboards",
|
|
)
|
|
is_default = models.BooleanField(default=False)
|
|
type_identifier = models.CharField(
|
|
max_length=30,
|
|
choices=DASHBOARD_CHOICES,
|
|
verbose_name="Dashboard Type",
|
|
default="home",
|
|
)
|
|
|
|
def __str__(self):
|
|
"""Return name of the dashboard"""
|
|
return f"{self.name}"
|
|
|
|
class Meta:
|
|
verbose_name = "Dashboard"
|
|
verbose_name_plural = "Dashboards"
|
|
db_table = "dashboards"
|
|
ordering = ("-created_at",)
|
|
|
|
|
|
class Widget(TimeAuditModel):
|
|
id = models.UUIDField(
|
|
default=uuid.uuid4, unique=True, editable=False, db_index=True, primary_key=True
|
|
)
|
|
key = models.CharField(max_length=255)
|
|
filters = models.JSONField(default=dict)
|
|
|
|
def __str__(self):
|
|
"""Return name of the widget"""
|
|
return f"{self.key}"
|
|
|
|
class Meta:
|
|
verbose_name = "Widget"
|
|
verbose_name_plural = "Widgets"
|
|
db_table = "widgets"
|
|
ordering = ("-created_at",)
|
|
|
|
|
|
class DashboardWidget(BaseModel):
|
|
widget = models.ForeignKey(
|
|
Widget,
|
|
on_delete=models.CASCADE,
|
|
related_name="dashboard_widgets",
|
|
)
|
|
dashboard = models.ForeignKey(
|
|
Dashboard,
|
|
on_delete=models.CASCADE,
|
|
related_name="dashboard_widgets",
|
|
)
|
|
is_visible = models.BooleanField(default=True)
|
|
sort_order = models.FloatField(default=65535)
|
|
filters = models.JSONField(default=dict)
|
|
properties = models.JSONField(default=dict)
|
|
|
|
def __str__(self):
|
|
"""Return name of the dashboard"""
|
|
return f"{self.dashboard.name} {self.widget.key}"
|
|
|
|
class Meta:
|
|
unique_together = ("widget", "dashboard")
|
|
verbose_name = "Dashboard Widget"
|
|
verbose_name_plural = "Dashboard Widgets"
|
|
db_table = "dashboard_widgets"
|
|
ordering = ("-created_at",)
|