Skip to content

Commit

Permalink
#1283 aiku analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
inikoo committed Jan 5, 2025
1 parent daa46c9 commit 6524417
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getBreadcrumbs($suffix = null): array
'type' => 'simple',
'simple' => [
'route' => [
'name' => 'grp.sysadmin.users.request.index',
'name' => 'grp.sysadmin.analytics.request.index',
],
'label' => __('User Requests'),
'icon' => 'fal fa-bars',
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/SysAdmin/Group/GetOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getSection(Group $group): array
[
'name' => __('User Requests'),
'icon' => 'fal fa-road',
'route' => route('grp.sysadmin.users.request.index'),
'route' => route('grp.sysadmin.analytics.request.index'),
'count' => $group->sysadminStats->number_user_requests ?? 0
],
],
Expand Down
81 changes: 81 additions & 0 deletions app/Actions/SysAdmin/UI/ShowSysAdminAnalyticsDashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* Author: Raul Perusquia <raul@inikoo.com>
* Created: Sun, 05 Jan 2025 14:59:28 Malaysia Time, Kuala Lumpur, Malaysia
* Copyright (c) 2025, Raul A Perusquia Flores
*/

namespace App\Actions\SysAdmin\UI;

use App\Actions\OrgAction;
use App\Actions\UI\Dashboards\ShowGroupDashboard;
use App\Enums\UI\SysAdmin\SysAdminAnalyticsDashboardTabsEnum;
use App\Models\SysAdmin\Group;
use Inertia\Inertia;
use Inertia\Response;
use Lorisleiva\Actions\ActionRequest;

class ShowSysAdminAnalyticsDashboard extends OrgAction
{
public function authorize(ActionRequest $request): bool
{
return $request->user()->hasPermissionTo("sysadmin.view");
}


public function handle(Group $group): Group
{
return $group;
}

public function asController(ActionRequest $request): Group
{
$group = group();
$this->initialisationFromGroup($group, $request)->withTab(SysAdminAnalyticsDashboardTabsEnum::values());

return $this->handle($group);
}


public function htmlResponse(Group $group): Response
{
return Inertia::render(
'SysAdmin/SysAdminAnalyticsDashboard',
[
'breadcrumbs' => $this->getBreadcrumbs(),
'title' => __('System analytics'),
'pageHead' => [
'icon' => [
'icon' => ['fal', 'fa-analytics'],
'title' => __('System analytics')
],
'title' => __('System analytics'),
],
'tabs' => [
'current' => $this->tab,
'navigation' => SysAdminAnalyticsDashboardTabsEnum::navigation()
],
]
);
}

public function getBreadcrumbs(): array
{
return
array_merge(
ShowGroupDashboard::make()->getBreadcrumbs(),
[
[
'type' => 'simple',
'simple' => [
'route' => [
'name' => 'grp.sysadmin.analytics.dashboard'
],
'label' => __('analytics'),
]
]
]
);
}
}
2 changes: 1 addition & 1 deletion app/Actions/SysAdmin/User/WithUserSubNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getUserNavigation(User $user, ActionRequest $request): array
[
"label" => __("Visit Logs"),
"route" => [
// "name" => "grp.sysadmin.users.request.index",
// "name" => "grp.sysadmin.analytics.request.index",
// "parameters" => [
// 'user' => $user->username
// ],
Expand Down
11 changes: 10 additions & 1 deletion app/Actions/UI/Grp/Layout/GetGroupNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function handle(User $user): array
'subSections' => [
[
'label' => __('users'),
'icon' => ['fal', 'fa-terminal'],
'icon' => ['fal', 'fa-user-circle'],
'root' => 'grp.sysadmin.users.',
'route' => [
'name' => 'grp.sysadmin.users.index',
Expand All @@ -191,6 +191,15 @@ public function handle(User $user): array

]
],
[
'label' => __('analytics'),
'icon' => ['fal', 'fa-analytics'],
'root' => 'grp.sysadmin.analytics.',
'route' => [
'name' => 'grp.sysadmin.analytics.dashboard',

]
],
[
'label' => __('system settings'),
'icon' => ['fal', 'fa-cog'],
Expand Down
56 changes: 56 additions & 0 deletions resources/js/Pages/Grp/SysAdmin/SysAdminAnalyticsDashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
- Author: Raul Perusquia <raul@inikoo.com>
- Created: Sun, 05 Jan 2025 14:59:28 Malaysia Time, Kuala Lumpur, Malaysia
- Copyright (c) 2025, Raul A Perusquia Flores
-->

<script setup lang="ts">
import { Head } from '@inertiajs/vue3'
import PageHeading from '@/Components/Headings/PageHeading.vue'
import Tabs from "@/Components/Navigation/Tabs.vue"

import { useTabChange } from "@/Composables/tab-change"
import { capitalize } from "@/Composables/capitalize"
import { computed, defineAsyncComponent, ref } from 'vue'
import type { Component } from 'vue'

import { PageHeading as TSPageHeading } from '@/types/PageHeading'
import { Tabs as TSTabs } from '@/types/Tabs'

const props = defineProps<{
title: string,
pageHead: TSPageHeading
tabs: TSTabs
dashboard_stats: {
label: string
count: number
icon: string
}[]


}>()
const currentTab = ref(props.tabs.current)
const handleTabUpdate = (tabSlug: string) => useTabChange(tabSlug, currentTab)

const component = computed(() => {

const components: Component = {
dashboard: {}
}

return components[currentTab.value]

})


</script>

<template>
<Head :title="capitalize(title)" />
<PageHeading :data="pageHead"></PageHeading>
<Tabs :current="currentTab" :navigation="tabs.navigation" @update:tab="handleTabUpdate" />
<component :is="component" :data="props[currentTab as keyof typeof props]" :tab="currentTab" />


</template>

0 comments on commit 6524417

Please sign in to comment.