Skip to content

Commit

Permalink
Merge pull request #38 from SmartReports/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
PaulMagos authored Nov 24, 2023
2 parents 5d481d8 + 5c1875c commit aadea89
Show file tree
Hide file tree
Showing 20 changed files with 606 additions and 58 deletions.
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"cSpell.words": [
"smartreport"
]
"kpis",
"smartreport",
"uids"
],
"editor.inlineSuggest.showToolbar": "always"
}
71 changes: 71 additions & 0 deletions smartreport/smartreport_app/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from django.contrib import admin
from .models import (
Kpi,
ReportTemplate,
ReportTemplatePage,
ReportTemplateImage,
KpiReportElement,
Alarm,
DashboardLayout
)


class KpiReportElementInline(admin.TabularInline):
model = KpiReportElement
extra = 1


class ReportTemplatePageInline(admin.TabularInline):
model = ReportTemplatePage
extra = 1
show_change_link = True
inlines = [KpiReportElementInline]

@admin.register(Kpi)
class KpiAdmin(admin.ModelAdmin):
list_display = ("kb_name",)
search_fields = ("kb_name",)


@admin.register(ReportTemplate)
class ReportTemplateAdmin(admin.ModelAdmin):
list_display = ("id", "name", "frequency")
list_filter = ("frequency",)
inlines = [ReportTemplatePageInline]


@admin.register(ReportTemplatePage)
class ReportTemplatePageAdmin(admin.ModelAdmin):
list_display = ("report_template", "layout")
list_filter = ("layout",)
inlines = [KpiReportElementInline]


@admin.register(KpiReportElement)
class KpiReportElementAdmin(admin.ModelAdmin):
list_display = ("report_page", "kpis", "chart_type")
list_filter = ("chart_type",)


@admin.register(Alarm)
class AlarmAdmin(admin.ModelAdmin):
list_display = ("id", "user_type", "kpi", "min_value", "max_value")
list_filter = ("user_type", "kpi")
search_fields = ("user_type", "kpi__name")

def get_kpi_name(self, obj):
return obj.kpi.name

get_kpi_name.short_description = "KPI Name"

@admin.register(DashboardLayout)
class DashboardLayoutAdmin(admin.ModelAdmin):
list_display = ('id', 'user_type', 'layout') # Fields to display in the list view
list_filter = ("user_type", )
search_fields = ('user_type',) # Fields to enable searching in the admin interface

@admin.register(ReportTemplateImage)
class ReportTemplateImageAdmin(admin.ModelAdmin):
list_display = ('id', 'user_type', 'report_id', 'img')
list_filter = ('report_id', 'user_type')
search_fields = ('report_id', 'user_type')
13 changes: 10 additions & 3 deletions smartreport_app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Kpi,
ReportTemplate,
ReportTemplatePage,
ReportTemplateImage,
KpiReportElement,
Alarm,
DashboardLayout
Expand All @@ -23,8 +24,8 @@ class ReportTemplatePageInline(admin.TabularInline):

@admin.register(Kpi)
class KpiAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)
list_display = ("kb_name",)
search_fields = ("kb_name",)


@admin.register(ReportTemplate)
Expand All @@ -43,7 +44,7 @@ class ReportTemplatePageAdmin(admin.ModelAdmin):

@admin.register(KpiReportElement)
class KpiReportElementAdmin(admin.ModelAdmin):
list_display = ("report_page", "kpi", "chart_type")
list_display = ("report_page", "chart_type")
list_filter = ("chart_type",)


Expand All @@ -63,3 +64,9 @@ class DashboardLayoutAdmin(admin.ModelAdmin):
list_display = ('id', 'user_type', 'layout') # Fields to display in the list view
list_filter = ("user_type", )
search_fields = ('user_type',) # Fields to enable searching in the admin interface

@admin.register(ReportTemplateImage)
class ReportTemplateImageAdmin(admin.ModelAdmin):
list_display = ('id', 'user_type', 'report_id', 'img')
list_filter = ('report_id', 'user_type')
search_fields = ('report_id', 'user_type')
8 changes: 6 additions & 2 deletions smartreport_app/kb_interface.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

def kb_interface(kpi_name, params):
def kb_interface(params):
# kpi_list = params['kpi_list'] # id of the kpi in the kb
plot_type = params['chart_type']
# start_time = params['start_time']
# end_time = params['end_time']
# frequency = params['frequency']

# other parameters like the time period
kpi_name = "pippo"

if plot_type == 'line':
response = {
Expand Down
19 changes: 19 additions & 0 deletions smartreport_app/migrations/0004_archivedreport_user_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.7 on 2023-11-23 14:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0003_dashboardlayout_display'),
]

operations = [
migrations.AddField(
model_name='archivedreport',
name='user_type',
field=models.CharField(choices=[('doctor', 'Doctor'), ('parent', 'Parent'), ('project_manager', 'Project Manager'), ('machine_maintainer', 'Machine Maintainer')], default='doctor', max_length=128),
preserve_default=False,
),
]
23 changes: 23 additions & 0 deletions smartreport_app/migrations/0004_reporttemplateimage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2023-11-23 15:51

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0003_dashboardlayout_display'),
]

operations = [
migrations.CreateModel(
name='ReportTemplateImage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_type', models.CharField(choices=[('doctor', 'Doctor'), ('parent', 'Parent'), ('project_manager', 'Project Manager'), ('machine_maintainer', 'Machine Maintainer')], max_length=128)),
('img', models.TextField(null=True)),
('report_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='smartreport_app.reporttemplate')),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.2.7 on 2023-11-23 15:31

from django.db import migrations, models
import django.db.models.deletion
import smartreport_app.models


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0004_archivedreport_user_type'),
]

operations = [
migrations.RenameField(
model_name='kpi',
old_name='name',
new_name='kb_id',
),
migrations.RemoveField(
model_name='kpireportelement',
name='kpi',
),
migrations.AddField(
model_name='kpi',
name='kb_counter',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='kpi',
name='kb_description',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='kpi',
name='kb_formula',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='kpi',
name='kb_name',
field=models.CharField(default='default_value', max_length=255),
preserve_default=False,
),
migrations.AddField(
model_name='kpi',
name='kb_source',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='kpi',
name='kb_unit',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='kpi',
name='user_type',
field=models.JSONField(default=smartreport_app.models.DEFAULT_USER_CHOICES),
),
migrations.CreateModel(
name='KpiReportElementKpi',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('kpi', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='appears_in', to='smartreport_app.kpi')),
('kpiReportElement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='kpis', to='smartreport_app.kpireportelement')),
],
),
]
26 changes: 26 additions & 0 deletions smartreport_app/migrations/0006_email_archivedreport_sent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.7 on 2023-11-23 16:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0005_rename_name_kpi_kb_id_remove_kpireportelement_kpi_and_more'),
]

operations = [
migrations.CreateModel(
name='Email',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_type', models.CharField(choices=[('doctor', 'Doctor'), ('parent', 'Parent'), ('project_manager', 'Project Manager'), ('machine_maintainer', 'Machine Maintainer')], max_length=128)),
('emails', models.JSONField()),
],
),
migrations.AddField(
model_name='archivedreport',
name='sent',
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.7 on 2023-11-24 09:12

from django.db import migrations, models
import smartreport_app.models


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0006_email_archivedreport_sent'),
]

operations = [
migrations.AlterField(
model_name='kpi',
name='allowed_charts',
field=models.JSONField(blank=True, default=smartreport_app.models.DEFAULT_CHART_CHOICES, null=True),
),
migrations.AlterField(
model_name='kpi',
name='user_type',
field=models.JSONField(blank=True, default=smartreport_app.models.DEFAULT_USER_CHOICES, null=True),
),
]
14 changes: 14 additions & 0 deletions smartreport_app/migrations/0008_merge_20231124_1255.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.7 on 2023-11-24 12:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0004_reporttemplateimage'),
('smartreport_app', '0007_alter_kpi_allowed_charts_alter_kpi_user_type'),
]

operations = [
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Generated by Django 4.2.7 on 2023-11-24 15:44

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0008_merge_20231124_1255'),
]

operations = [
migrations.RenameField(
model_name='kpi',
old_name='kb_id',
new_name='kb_uid',
),
migrations.RemoveField(
model_name='kpi',
name='kb_source',
),
migrations.AddField(
model_name='kpi',
name='created',
field=models.DateTimeField(blank=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='kpi',
name='kb_frequency',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='kpi',
name='kb_range',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='kpi',
name='kb_taxonomy',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='reporttemplate',
name='created',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions smartreport_app/migrations/0010_remove_kpi_isnew.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2023-11-24 16:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('smartreport_app', '0009_rename_kb_id_kpi_kb_uid_remove_kpi_kb_source_and_more'),
]

operations = [
migrations.RemoveField(
model_name='kpi',
name='isNew',
),
]
Loading

0 comments on commit aadea89

Please sign in to comment.