mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 05:02:14 +01:00
add dashboard frontend
This commit is contained in:
@@ -1,484 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { Head, Link, router, usePage } from '@inertiajs/vue3';
|
||||
import ApplicationMark from '@/Components/ApplicationMark.vue';
|
||||
import { Head } from '@inertiajs/vue3';
|
||||
import Banner from '@/Components/Banner.vue';
|
||||
import Dropdown from '@/Components/Dropdown.vue';
|
||||
import DropdownLink from '@/Components/DropdownLink.vue';
|
||||
import NavLink from '@/Components/NavLink.vue';
|
||||
import ResponsiveNavLink from '@/Components/ResponsiveNavLink.vue';
|
||||
import route from 'ziggy-js';
|
||||
import type { Organization, User } from '@/types/models';
|
||||
import OrganizationSwitcher from '@/Components/OrganizationSwitcher.vue';
|
||||
import CurrentSidebarTimer from '@/Components/CurrentSidebarTimer.vue';
|
||||
import {
|
||||
ChartBarIcon,
|
||||
ClockIcon,
|
||||
FolderIcon,
|
||||
HomeIcon,
|
||||
UserCircleIcon,
|
||||
UserGroupIcon,
|
||||
TagIcon,
|
||||
Cog6ToothIcon,
|
||||
} from '@heroicons/vue/20/solid';
|
||||
import NavigationSidebarItem from '@/Components/NavigationSidebarItem.vue';
|
||||
import UserSettingsIcon from '@/Components/UserSettingsIcon.vue';
|
||||
|
||||
defineProps({
|
||||
title: String,
|
||||
});
|
||||
|
||||
const showingNavigationDropdown = ref(false);
|
||||
|
||||
const page = usePage<{
|
||||
jetstream: {
|
||||
canCreateTeams: boolean;
|
||||
hasTeamFeatures: boolean;
|
||||
managesProfilePhotos: boolean;
|
||||
hasApiFeatures: boolean;
|
||||
};
|
||||
auth: {
|
||||
user: User & { all_teams: Organization[] };
|
||||
};
|
||||
}>();
|
||||
|
||||
const switchToTeam = (team: Organization) => {
|
||||
router.put(
|
||||
route('current-team.update'),
|
||||
{
|
||||
team_id: team.id,
|
||||
},
|
||||
{
|
||||
preserveState: false,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
router.post(route('logout'));
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Head :title="title" />
|
||||
|
||||
<Banner />
|
||||
|
||||
<div class="min-h-screen bg-gray-100 dark:bg-gray-900">
|
||||
<nav
|
||||
class="bg-white dark:bg-gray-800 border-b border-gray-100 dark:border-gray-700">
|
||||
<!-- Primary Navigation Menu -->
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between h-16">
|
||||
<div class="flex">
|
||||
<!-- Logo -->
|
||||
<div class="shrink-0 flex items-center">
|
||||
<Link :href="route('dashboard')">
|
||||
<ApplicationMark class="block h-9 w-auto" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<!-- Navigation Links -->
|
||||
<div
|
||||
class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<NavLink
|
||||
:href="route('dashboard')"
|
||||
:active="route().current('dashboard')">
|
||||
Dashboard
|
||||
</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hidden sm:flex sm:items-center sm:ms-6">
|
||||
<div class="ms-3 relative">
|
||||
<!-- Teams Dropdown -->
|
||||
<Dropdown
|
||||
v-if="page.props.jetstream.hasTeamFeatures"
|
||||
align="right"
|
||||
width="60">
|
||||
<template #trigger>
|
||||
<span class="inline-flex rounded-md">
|
||||
<button
|
||||
type="button"
|
||||
id="currentTeamButton"
|
||||
class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none focus:bg-gray-50 dark:focus:bg-gray-700 active:bg-gray-50 dark:active:bg-gray-700 transition ease-in-out duration-150">
|
||||
{{
|
||||
page.props.auth.user
|
||||
.current_team.name
|
||||
}}
|
||||
|
||||
<svg
|
||||
class="ms-2 -me-0.5 h-4 w-4"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
|
||||
</svg>
|
||||
</button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<div class="w-60">
|
||||
<!-- Organization Management -->
|
||||
<div
|
||||
class="block px-4 py-2 text-xs text-gray-400">
|
||||
Manage Team
|
||||
</div>
|
||||
|
||||
<!-- Organization Settings -->
|
||||
<DropdownLink
|
||||
:href="
|
||||
route(
|
||||
'teams.show',
|
||||
page.props.auth.user
|
||||
.current_team.id
|
||||
)
|
||||
">
|
||||
Team Settings
|
||||
</DropdownLink>
|
||||
|
||||
<DropdownLink
|
||||
v-if="
|
||||
page.props.jetstream
|
||||
.canCreateTeams
|
||||
"
|
||||
:href="route('teams.create')">
|
||||
Create New Team
|
||||
</DropdownLink>
|
||||
|
||||
<!-- Organization Switcher -->
|
||||
<template
|
||||
v-if="
|
||||
page.props.auth.user
|
||||
.all_teams.length > 1
|
||||
">
|
||||
<div
|
||||
class="border-t border-gray-200 dark:border-gray-600" />
|
||||
|
||||
<div
|
||||
class="block px-4 py-2 text-xs text-gray-400">
|
||||
Switch Teams
|
||||
</div>
|
||||
|
||||
<template
|
||||
v-for="team in page.props
|
||||
.auth.user.all_teams"
|
||||
:key="team.id">
|
||||
<form
|
||||
@submit.prevent="
|
||||
switchToTeam(team)
|
||||
">
|
||||
<DropdownLink
|
||||
as="button">
|
||||
<div
|
||||
class="flex items-center">
|
||||
<svg
|
||||
v-if="
|
||||
team.id ==
|
||||
page
|
||||
.props
|
||||
.auth
|
||||
.user
|
||||
.current_team_id
|
||||
"
|
||||
class="me-2 h-5 w-5 text-green-400"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
|
||||
<div>
|
||||
{{
|
||||
team.name
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</DropdownLink>
|
||||
</form>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</div>
|
||||
|
||||
<!-- Settings Dropdown -->
|
||||
<div class="ms-3 relative">
|
||||
<Dropdown align="right" width="48">
|
||||
<template #trigger>
|
||||
<button
|
||||
v-if="
|
||||
page.props.jetstream
|
||||
.managesProfilePhotos
|
||||
"
|
||||
id="currentUserButton"
|
||||
class="flex text-sm border-2 border-transparent rounded-full focus:outline-none focus:border-gray-300 transition">
|
||||
<img
|
||||
class="h-8 w-8 rounded-full object-cover"
|
||||
:src="
|
||||
page.props.auth.user
|
||||
.profile_photo_url
|
||||
"
|
||||
:alt="
|
||||
page.props.auth.user.name
|
||||
" />
|
||||
</button>
|
||||
|
||||
<span
|
||||
v-else
|
||||
class="inline-flex rounded-md">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none focus:bg-gray-50 dark:focus:bg-gray-700 active:bg-gray-50 dark:active:bg-gray-700 transition ease-in-out duration-150">
|
||||
{{ page.props.auth.user.name }}
|
||||
|
||||
<svg
|
||||
class="ms-2 -me-0.5 h-4 w-4"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
||||
</svg>
|
||||
</button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<!-- Account Management -->
|
||||
<div
|
||||
class="block px-4 py-2 text-xs text-gray-400">
|
||||
Manage Account
|
||||
</div>
|
||||
|
||||
<DropdownLink
|
||||
:href="route('profile.show')">
|
||||
Profile
|
||||
</DropdownLink>
|
||||
|
||||
<DropdownLink
|
||||
v-if="
|
||||
page.props.jetstream
|
||||
.hasApiFeatures
|
||||
"
|
||||
:href="route('api-tokens.index')">
|
||||
API Tokens
|
||||
</DropdownLink>
|
||||
|
||||
<div
|
||||
class="border-t border-gray-200 dark:border-gray-600" />
|
||||
|
||||
<!-- Authentication -->
|
||||
<form @submit.prevent="logout">
|
||||
<DropdownLink as="button">
|
||||
Log Out
|
||||
</DropdownLink>
|
||||
</form>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hamburger -->
|
||||
<div class="-me-2 flex items-center sm:hidden">
|
||||
<button
|
||||
class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-900 focus:text-gray-500 dark:focus:text-gray-400 transition duration-150 ease-in-out"
|
||||
@click="
|
||||
showingNavigationDropdown =
|
||||
!showingNavigationDropdown
|
||||
">
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<path
|
||||
:class="{
|
||||
hidden: showingNavigationDropdown,
|
||||
'inline-flex':
|
||||
!showingNavigationDropdown,
|
||||
}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M4 6h16M4 12h16M4 18h16" />
|
||||
<path
|
||||
:class="{
|
||||
hidden: !showingNavigationDropdown,
|
||||
'inline-flex':
|
||||
showingNavigationDropdown,
|
||||
}"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap bg-default-background text-muted">
|
||||
<div
|
||||
class="flex-shrink-0 h-screen fixed w-[250px] px-1.5 py-4 flex flex-col justify-between">
|
||||
<div>
|
||||
<div class="border-b border-default-background-seperator pb-2">
|
||||
<OrganizationSwitcher></OrganizationSwitcher>
|
||||
</div>
|
||||
|
||||
<!-- Responsive Navigation Menu -->
|
||||
<div
|
||||
:class="{
|
||||
block: showingNavigationDropdown,
|
||||
hidden: !showingNavigationDropdown,
|
||||
}"
|
||||
class="sm:hidden">
|
||||
<div class="pt-2 pb-3 space-y-1">
|
||||
<ResponsiveNavLink
|
||||
<div class="border-b border-default-background-seperator">
|
||||
<CurrentSidebarTimer></CurrentSidebarTimer>
|
||||
</div>
|
||||
<nav>
|
||||
<ul class="space-y-1">
|
||||
<NavigationSidebarItem
|
||||
title="Dashboard"
|
||||
:icon="HomeIcon"
|
||||
:href="route('dashboard')"
|
||||
:active="route().current('dashboard')">
|
||||
Dashboard
|
||||
</ResponsiveNavLink>
|
||||
</div>
|
||||
:current="
|
||||
route().current('dashboard')
|
||||
"></NavigationSidebarItem>
|
||||
<NavigationSidebarItem
|
||||
title="Time"
|
||||
:icon="ClockIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
<NavigationSidebarItem
|
||||
title="Reporting"
|
||||
:icon="ChartBarIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- Responsive Settings Options -->
|
||||
<div
|
||||
class="pt-4 pb-1 border-t border-gray-200 dark:border-gray-600">
|
||||
<div class="flex items-center px-4">
|
||||
<div
|
||||
v-if="page.props.jetstream.managesProfilePhotos"
|
||||
class="shrink-0 me-3">
|
||||
<img
|
||||
class="h-10 w-10 rounded-full object-cover"
|
||||
:src="
|
||||
page.props.auth.user.profile_photo_url
|
||||
"
|
||||
:alt="page.props.auth.user.name" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div
|
||||
class="font-medium text-base text-gray-800 dark:text-gray-200">
|
||||
{{ page.props.auth.user.name }}
|
||||
</div>
|
||||
<div class="font-medium text-sm text-gray-500">
|
||||
{{ page.props.auth.user.email }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 space-y-1">
|
||||
<ResponsiveNavLink
|
||||
:href="route('profile.show')"
|
||||
:active="route().current('profile.show')">
|
||||
Profile
|
||||
</ResponsiveNavLink>
|
||||
|
||||
<ResponsiveNavLink
|
||||
v-if="page.props.jetstream.hasApiFeatures"
|
||||
:href="route('api-tokens.index')"
|
||||
:active="route().current('api-tokens.index')">
|
||||
API Tokens
|
||||
</ResponsiveNavLink>
|
||||
|
||||
<!-- Authentication -->
|
||||
<form method="POST" @submit.prevent="logout">
|
||||
<ResponsiveNavLink as="button">
|
||||
Log Out
|
||||
</ResponsiveNavLink>
|
||||
</form>
|
||||
|
||||
<!-- Organization Management -->
|
||||
<template
|
||||
v-if="page.props.jetstream.hasTeamFeatures">
|
||||
<div
|
||||
class="border-t border-gray-200 dark:border-gray-600" />
|
||||
|
||||
<div
|
||||
class="block px-4 py-2 text-xs text-gray-400">
|
||||
Manage Team
|
||||
</div>
|
||||
|
||||
<!-- Organization Settings -->
|
||||
<ResponsiveNavLink
|
||||
:href="
|
||||
route(
|
||||
'teams.show',
|
||||
page.props.auth.user.current_team.id
|
||||
)
|
||||
"
|
||||
:active="route().current('teams.show')">
|
||||
Team Settings
|
||||
</ResponsiveNavLink>
|
||||
|
||||
<ResponsiveNavLink
|
||||
v-if="page.props.jetstream.canCreateTeams"
|
||||
:href="route('teams.create')"
|
||||
:active="route().current('teams.create')">
|
||||
Create New Team
|
||||
</ResponsiveNavLink>
|
||||
|
||||
<!-- Organization Switcher -->
|
||||
<template
|
||||
v-if="
|
||||
page.props.auth.user.all_teams.length >
|
||||
1
|
||||
">
|
||||
<div
|
||||
class="border-t border-gray-200 dark:border-gray-600" />
|
||||
|
||||
<div
|
||||
class="block px-4 py-2 text-xs text-gray-400">
|
||||
Switch Teams
|
||||
</div>
|
||||
|
||||
<template
|
||||
v-for="team in page.props.auth.user
|
||||
.all_teams"
|
||||
:key="team.id">
|
||||
<form
|
||||
@submit.prevent="
|
||||
switchToTeam(team)
|
||||
">
|
||||
<ResponsiveNavLink as="button">
|
||||
<div class="flex items-center">
|
||||
<svg
|
||||
v-if="
|
||||
team.id ==
|
||||
page.props.auth.user
|
||||
.current_team_id
|
||||
"
|
||||
class="me-2 h-5 w-5 text-green-400"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
<div>{{ team.name }}</div>
|
||||
</div>
|
||||
</ResponsiveNavLink>
|
||||
</form>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-muted font-semibold text-sm pt-6 pb-4">
|
||||
Manage
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Page Heading -->
|
||||
<header
|
||||
v-if="$slots.header"
|
||||
class="bg-white dark:bg-gray-800 shadow">
|
||||
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
|
||||
<slot name="header" />
|
||||
</div>
|
||||
</header>
|
||||
<nav>
|
||||
<ul class="space-y-1">
|
||||
<NavigationSidebarItem
|
||||
title="Projects"
|
||||
:icon="FolderIcon"
|
||||
:href="route('dashboard')"
|
||||
:current="
|
||||
route().current('dashboard')
|
||||
"></NavigationSidebarItem>
|
||||
<NavigationSidebarItem
|
||||
title="Clients"
|
||||
:icon="UserCircleIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
<NavigationSidebarItem
|
||||
title="Team"
|
||||
:icon="UserGroupIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
<NavigationSidebarItem
|
||||
title="Tags"
|
||||
:icon="TagIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- Page Content -->
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
<ul
|
||||
class="border-t border-default-background-seperator pt-3 flex justify-between pr-4 items-center">
|
||||
<NavigationSidebarItem
|
||||
class="flex-1"
|
||||
title="Settings"
|
||||
:icon="Cog6ToothIcon"
|
||||
:href="route('dashboard')"></NavigationSidebarItem>
|
||||
|
||||
<UserSettingsIcon></UserSettingsIcon>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="flex-1 ml-[250px]">
|
||||
<Head :title="title" />
|
||||
|
||||
<Banner />
|
||||
|
||||
<div
|
||||
class="min-h-screen bg-default-background border-l border-default-background-seperator">
|
||||
<!-- Page Heading -->
|
||||
<header
|
||||
v-if="$slots.header"
|
||||
class="bg-default-background border-b border-default-background-seperator shadow">
|
||||
<div class="py-6 px-4 sm:px-6 lg:px-8">
|
||||
<slot name="header" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Page Content -->
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user