diff --git a/migrations/8_dashboardview.go b/migrations/8_dashboardview.go new file mode 100644 index 0000000..b2fdb47 --- /dev/null +++ b/migrations/8_dashboardview.go @@ -0,0 +1,43 @@ +package migrations + +import ( + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/daos" + "github.com/pocketbase/pocketbase/tools/types" +) + +const dashboardCountsViewUpdateQuery = `SELECT id, count FROM ( + SELECT 'users' as id, COUNT(users.id) as count FROM users + UNION + SELECT 'tickets' as id, COUNT(tickets.id) as count FROM tickets + UNION + SELECT 'tasks' as id, COUNT(tasks.id) as count FROM tasks + UNION + SELECT 'reactions' as id, COUNT(reactions.id) as count FROM reactions +) as counts;` + +func dashboardCountsViewUpdateUp(db dbx.Builder) error { + dao := daos.New(db) + + collection, err := dao.FindCollectionByNameOrId(dashboardCountsViewName) + if err != nil { + return err + } + + collection.Options = types.JsonMap{"query": dashboardCountsViewUpdateQuery} + + return dao.SaveCollection(collection) +} + +func dashboardCountsViewUpdateDown(db dbx.Builder) error { + dao := daos.New(db) + + collection, err := dao.FindCollectionByNameOrId(dashboardCountsViewName) + if err != nil { + return err + } + + collection.Options = types.JsonMap{"query": dashboardCountsViewQuery} + + return dao.SaveCollection(collection) +} diff --git a/migrations/migrations.go b/migrations/migrations.go index 7fbedc1..f541468 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -12,4 +12,5 @@ func Register() { migrations.Register(reactionsUp, reactionsDown, "1700000005_reactions.go") migrations.Register(systemuserUp, systemuserDown, "1700000006_systemuser.go") migrations.Register(searchViewUp, searchViewDown, "1700000007_search_view.go") + migrations.Register(dashboardCountsViewUpdateUp, dashboardCountsViewUpdateDown, "1700000008_dashboardview.go") } diff --git a/ui/index.html b/ui/index.html index eb40416..de3d68a 100644 --- a/ui/index.html +++ b/ui/index.html @@ -7,7 +7,7 @@ Catalyst -
+
diff --git a/ui/src/components/TanView.vue b/ui/src/components/TanView.vue index 7dca086..335048e 100644 --- a/ui/src/components/TanView.vue +++ b/ui/src/components/TanView.vue @@ -7,17 +7,16 @@ defineProps<{ isPending: boolean isError: boolean error: Error | null - value: any }>() diff --git a/ui/src/components/dashboard/OpenTasks.vue b/ui/src/components/dashboard/OpenTasks.vue index 8f49e3e..da7ae83 100644 --- a/ui/src/components/dashboard/OpenTasks.vue +++ b/ui/src/components/dashboard/OpenTasks.vue @@ -1,5 +1,6 @@ diff --git a/ui/src/components/dashboard/TicketTypes.vue b/ui/src/components/dashboard/TicketTypes.vue index c97aa07..a9c2bae 100644 --- a/ui/src/components/dashboard/TicketTypes.vue +++ b/ui/src/components/dashboard/TicketTypes.vue @@ -30,7 +30,7 @@ const namedTypes = computed(() => {