Compare commits

..

1 Commits

Author SHA1 Message Date
Constantin Graf
32abd2b61f Fixed problem with merge into when project members already exist in destination member 2025-03-10 13:46:57 +01:00
37 changed files with 580 additions and 1661 deletions

View File

@@ -1,172 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\V1;
use App\Enums\Role;
use App\Models\Organization;
use App\Service\DashboardService;
use App\Service\PermissionStore;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\JsonResponse;
class ChartController extends Controller
{
/**
* @throws AuthorizationException
*
* @operationId weeklyProjectOverview
*
* @response array<int, array{value: int, name: string, color: string}>
*/
public function weeklyProjectOverview(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$weeklyProjectOverview = $dashboardService->weeklyProjectOverview($user, $organization);
return response()->json($weeklyProjectOverview);
}
/**
* @throws AuthorizationException
*
* @operationId latestTasks
*
* @response array<int, array{task_id: string, name: string, description: string|null, status: bool, time_entry_id: string|null}>
*/
public function latestTasks(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$latestTasks = $dashboardService->latestTasks($user, $organization);
return response()->json($latestTasks);
}
/**
* @throws AuthorizationException
*
* @operationId lastSevenDays
*
* @response array<int, array{ date: string, duration: int, history: array<int> }>
*/
public function lastSevenDays(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$lastSevenDays = $dashboardService->lastSevenDays($user, $organization);
return response()->json($lastSevenDays);
}
/**
* @throws AuthorizationException
*
* @operationId latestTeamActivity
*
* @response array<int, array{member_id: string, name: string, description: string|null, time_entry_id: string, task_id: string|null, status: bool }>
*/
public function latestTeamActivity(Organization $organization, DashboardService $dashboardService, PermissionStore $permissionStore): JsonResponse
{
$this->checkPermission($organization, 'charts:view:all');
$latestTeamActivity = $dashboardService->latestTeamActivity($organization);
return response()->json($latestTeamActivity);
}
/**
* @throws AuthorizationException
*
* @operationId dailyTrackedHours
*
* @response array<int, array{date: string, duration: int}>
*/
public function dailyTrackedHours(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 60);
return response()->json($dailyTrackedHours);
}
/**
* @throws AuthorizationException
*
* @operationId totalWeeklyTime
*
* @response int
*/
public function totalWeeklyTime(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$totalWeeklyTime = $dashboardService->totalWeeklyTime($user, $organization);
return response()->json($totalWeeklyTime);
}
/**
* @throws AuthorizationException
*
* @operationId totalWeeklyBillableTime
*
* @response int
*/
public function totalWeeklyBillableTime(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$totalWeeklyBillableTime = $dashboardService->totalWeeklyBillableTime($user, $organization);
return response()->json($totalWeeklyBillableTime);
}
/**
* @throws AuthorizationException
*
* @operationId totalWeeklyBillableAmount
*
* @response array{value: int, currency: string}
*/
public function totalWeeklyBillableAmount(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
if (! $showBillableRate) {
throw new AuthorizationException('You do not have permission to view billable rates.');
}
$totalWeeklyBillableAmount = $dashboardService->totalWeeklyBillableAmount($user, $organization);
return response()->json($totalWeeklyBillableAmount);
}
/**
* @throws AuthorizationException
*
* @operationId weeklyHistory
*
* @response array<int, array{date: string, duration: int}>
*/
public function weeklyHistory(Organization $organization, DashboardService $dashboardService): JsonResponse
{
$this->checkPermission($organization, 'charts:view:own');
$user = $this->user();
$weeklyHistory = $dashboardService->getWeeklyHistory($user, $organization);
return response()->json($weeklyHistory);
}
}

View File

@@ -114,8 +114,6 @@ class MemberController extends Controller
* Make a member a placeholder member
*
* @throws AuthorizationException|CanNotRemoveOwnerFromOrganization|ChangingRoleOfPlaceholderIsNotAllowed
*
* @operationId makePlaceholder
*/
public function makePlaceholder(Organization $organization, Member $member, MemberService $memberService): JsonResponse
{

View File

@@ -73,7 +73,6 @@ class ReportController extends Controller
false,
$report->properties->start,
$report->properties->end,
true
);
$historyData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
$timeEntriesQuery->clone(),
@@ -84,7 +83,6 @@ class ReportController extends Controller
true,
$report->properties->start,
$report->properties->end,
true
);
return new DetailedWithDataReportResource($report, $data, $historyData);

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace App\Http\Controllers\Api\V1;
use App\Enums\ExportFormat;
use App\Enums\Role;
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
use App\Exceptions\Api\PdfRendererIsNotConfiguredException;
use App\Exceptions\Api\TimeEntryCanNotBeRestartedApiException;
@@ -181,7 +180,6 @@ class TimeEntryController extends Controller
}
$user = $this->user();
$timezone = $user->timezone;
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
$timeEntriesQuery->with([
@@ -213,8 +211,7 @@ class TimeEntryController extends Controller
$user->week_start,
false,
null,
null,
$showBillableRate
null
);
$html = Blade::render($viewFile, [
'timeEntries' => $timeEntriesQuery->get(),
@@ -288,18 +285,18 @@ class TimeEntryController extends Controller
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* }
* }
*
@@ -315,7 +312,6 @@ class TimeEntryController extends Controller
$this->checkPermission($organization, 'time-entries:view:all');
}
$user = $this->user();
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
$group1Type = $request->getGroup();
$group2Type = $request->getSubGroup();
@@ -329,8 +325,7 @@ class TimeEntryController extends Controller
$user->week_start,
$request->getFillGapsInTimeGroups(),
$request->getStart(),
$request->getEnd(),
$showBillableRate
$request->getEnd()
);
return [
@@ -364,7 +359,6 @@ class TimeEntryController extends Controller
}
$debug = $request->getDebug();
$user = $this->user();
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
$group = $request->getGroup();
$subGroup = $request->getSubGroup();
@@ -378,8 +372,7 @@ class TimeEntryController extends Controller
$user->week_start,
false,
$request->getStart(),
$request->getEnd(),
$showBillableRate
$request->getEnd()
);
$dataHistoryChart = $timeEntryAggregationService->getAggregatedTimeEntries(
$timeEntriesAggregateQuery->clone(),
@@ -389,8 +382,7 @@ class TimeEntryController extends Controller
$user->week_start,
true,
$request->getStart(),
$request->getEnd(),
$showBillableRate
$request->getEnd()
);
$currency = $organization->currency;
$timezone = app(TimezoneService::class)->getTimezoneFromUser($this->user());

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Enums\Role;
use App\Service\DashboardService;
use App\Service\PermissionStore;
use Illuminate\Auth\Access\AuthorizationException;
@@ -20,14 +19,30 @@ class DashboardController extends Controller
{
$user = $this->user();
$organization = $this->currentOrganization();
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 60);
$weeklyHistory = $dashboardService->getWeeklyHistory($user, $organization);
$totalWeeklyTime = $dashboardService->totalWeeklyTime($user, $organization);
$totalWeeklyBillableTime = $dashboardService->totalWeeklyBillableTime($user, $organization);
$totalWeeklyBillableAmount = $dashboardService->totalWeeklyBillableAmount($user, $organization);
$weeklyProjectOverview = $dashboardService->weeklyProjectOverview($user, $organization);
$latestTasks = $dashboardService->latestTasks($user, $organization);
$lastSevenDays = $dashboardService->lastSevenDays($user, $organization);
$latestTeamActivity = null;
if ($permissionStore->has($organization, 'time-entries:view:all')) {
$latestTeamActivity = $dashboardService->latestTeamActivity($organization);
}
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
return Inertia::render('Dashboard');
return Inertia::render('Dashboard', [
'weeklyProjectOverview' => $weeklyProjectOverview,
'latestTasks' => $latestTasks,
'lastSevenDays' => $lastSevenDays,
'latestTeamActivity' => $latestTeamActivity,
'dailyTrackedHours' => $dailyTrackedHours,
'totalWeeklyTime' => $totalWeeklyTime,
'totalWeeklyBillableTime' => $totalWeeklyBillableTime,
'totalWeeklyBillableAmount' => $totalWeeklyBillableAmount,
'weeklyHistory' => $weeklyHistory,
]);
}
}

View File

@@ -18,20 +18,20 @@ use Illuminate\Http\Request;
* description: string|null,
* color: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* description: string|null,
* color: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* }
*/
class DetailedWithDataReportResource extends BaseResource

View File

@@ -80,8 +80,6 @@ class JetstreamServiceProvider extends ServiceProvider
Jetstream::defaultApiTokenPermissions([]);
Jetstream::role(Role::Owner->value, 'Owner', [
'charts:view:own',
'charts:view:all',
'projects:view',
'projects:view:all',
'projects:create',
@@ -136,8 +134,6 @@ class JetstreamServiceProvider extends ServiceProvider
])->description('Owner users can perform any action. There is only one owner per organization.');
Jetstream::role(Role::Admin->value, 'Administrator', [
'charts:view:own',
'charts:view:all',
'projects:view',
'projects:view:all',
'projects:create',
@@ -177,10 +173,9 @@ class JetstreamServiceProvider extends ServiceProvider
'invitations:resend',
'invitations:remove',
'members:view',
'members:invite-placeholder',
'members:make-placeholder',
'members:merge-into',
'members:update',
'members:invite-placeholder',
'members:merge-into',
'reports:view',
'reports:create',
'reports:update',
@@ -188,8 +183,6 @@ class JetstreamServiceProvider extends ServiceProvider
])->description('Administrator users can perform any action, except accessing the billing dashboard.');
Jetstream::role(Role::Manager->value, 'Manager', [
'charts:view:own',
'charts:view:all',
'projects:view',
'projects:view:all',
'projects:create',
@@ -230,7 +223,6 @@ class JetstreamServiceProvider extends ServiceProvider
])->description('Managers have full access to all projects, time entries, ect. but cannot manage the organization (add/remove member, edit the organization, ect.).');
Jetstream::role(Role::Employee->value, 'Employee', [
'charts:view:own',
'projects:view',
'tags:view',
'tasks:view',

View File

@@ -10,7 +10,6 @@ use Exception;
use Illuminate\Support\Carbon;
use League\Csv\Exception as CsvException;
use League\Csv\Reader;
use Override;
class GenericProjectsImporter extends DefaultImporter
{
@@ -24,7 +23,7 @@ class GenericProjectsImporter extends DefaultImporter
/**
* @throws ImportException
*/
#[Override]
#[\Override]
public function importData(string $data, string $timezone): void
{
try {
@@ -91,13 +90,13 @@ class GenericProjectsImporter extends DefaultImporter
}
}
#[Override]
#[\Override]
public function getName(): string
{
return __('importer.generic_projects.name');
}
#[Override]
#[\Override]
public function getDescription(): string
{
return __('importer.generic_projects.description');

View File

@@ -22,18 +22,18 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* }
*/
private array $data;
@@ -52,18 +52,18 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* } $data
*/
public function __construct(array $data, ExportFormat $exportFormat, string $currency, TimeEntryAggregationType $group, TimeEntryAggregationType $subGroup)

View File

@@ -27,21 +27,21 @@ class TimeEntryAggregationService
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* }
*/
public function getAggregatedTimeEntries(Builder $timeEntriesQuery, ?TimeEntryAggregationType $group1Type, ?TimeEntryAggregationType $group2Type, string $timezone, Weekday $startOfWeek, bool $fillGapsInTimeGroups, ?Carbon $start, ?Carbon $end, bool $showBillableRate): array
public function getAggregatedTimeEntries(Builder $timeEntriesQuery, ?TimeEntryAggregationType $group1Type, ?TimeEntryAggregationType $group2Type, string $timezone, Weekday $startOfWeek, bool $fillGapsInTimeGroups, ?Carbon $start, ?Carbon $end): array
{
$fillGapsInTimeGroupsIsPossible = $fillGapsInTimeGroups && $start !== null && $end !== null;
$group1Select = null;
@@ -96,7 +96,7 @@ class TimeEntryAggregationService
$group2Response[] = [
'key' => $group2 === '' ? null : (string) $group2,
'seconds' => (int) $aggregate->get(0)->aggregate,
'cost' => $showBillableRate ? (int) $aggregate->get(0)->cost : null,
'cost' => (int) $aggregate->get(0)->cost,
'grouped_type' => null,
'grouped_data' => null,
];
@@ -113,7 +113,7 @@ class TimeEntryAggregationService
$group1Response[] = [
'key' => $group1 === '' ? null : (string) $group1,
'seconds' => $group2ResponseSum,
'cost' => $showBillableRate ? $group2ResponseCost : null,
'cost' => $group2ResponseCost,
'grouped_type' => $group2Type?->value,
'grouped_data' => $group2Response,
];
@@ -133,7 +133,7 @@ class TimeEntryAggregationService
return [
'seconds' => $group1ResponseSum,
'cost' => $showBillableRate ? $group1ResponseCost : null,
'cost' => $group1ResponseCost,
'grouped_type' => $group1Type?->value,
'grouped_data' => $group1Response,
];
@@ -148,25 +148,25 @@ class TimeEntryAggregationService
* description: string|null,
* color: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* description: string|null,
* color: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null,
* grouped_data: null
* }>
* }>,
* seconds: int,
* cost: int|null
* cost: int
* }
*/
public function getAggregatedTimeEntriesWithDescriptions(Builder $timeEntriesQuery, ?TimeEntryAggregationType $group1Type, ?TimeEntryAggregationType $group2Type, string $timezone, Weekday $startOfWeek, bool $fillGapsInTimeGroups, ?Carbon $start, ?Carbon $end, bool $showBillableRate): array
public function getAggregatedTimeEntriesWithDescriptions(Builder $timeEntriesQuery, ?TimeEntryAggregationType $group1Type, ?TimeEntryAggregationType $group2Type, string $timezone, Weekday $startOfWeek, bool $fillGapsInTimeGroups, ?Carbon $start, ?Carbon $end): array
{
$aggregatedTimeEntries = $this->getAggregatedTimeEntries($timeEntriesQuery, $group1Type, $group2Type, $timezone, $startOfWeek, $fillGapsInTimeGroups, $start, $end, $showBillableRate);
$aggregatedTimeEntries = $this->getAggregatedTimeEntries($timeEntriesQuery, $group1Type, $group2Type, $timezone, $startOfWeek, $fillGapsInTimeGroups, $start, $end);
$keysGroup1 = [];
$keysGroup2 = [];
@@ -289,12 +289,12 @@ class TimeEntryAggregationService
* @param array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null|mixed,
* grouped_data: null|mixed
* }>
@@ -302,12 +302,12 @@ class TimeEntryAggregationService
* @return array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: string|null,
* grouped_data: null|array<array{
* key: string|null,
* seconds: int,
* cost: int|null,
* cost: int,
* grouped_type: null|mixed,
* grouped_data: null|mixed
* }>

View File

@@ -136,7 +136,6 @@ test('test that starting and updating the time while running works', async ({
await Promise.all([
page.waitForResponse(async (response) => {
return (
response.url().includes('/time-entries') &&
response.status() === 200 &&
(await response.headerValue('Content-Type')) ===
'application/json' &&

View File

@@ -18,7 +18,6 @@ export function newTimeEntryResponse(
) {
return page.waitForResponse(async (response) => {
return (
response.url().includes('/time-entries') &&
response.status() === status &&
(await response.headerValue('Content-Type')) ===
'application/json' &&

View File

@@ -1,80 +0,0 @@
<script setup lang="ts">
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import DialogModal from '@/packages/ui/src/DialogModal.vue';
import {ref} from 'vue';
import {api, type Member} from '@/packages/api/src';
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
import {useMutation} from '@tanstack/vue-query';
import {getCurrentOrganizationId} from "@/utils/useUser";
import {useNotificationsStore} from "@/utils/notification";
import {useMembersStore} from "@/utils/useMembers";
const {handleApiRequestNotifications} = useNotificationsStore();
const show = defineModel('show', {default: false});
const saving = ref(false);
const props = defineProps<{
member: Member;
}>();
const turnToPlaceholderMutation = useMutation({
mutationFn: async () => {
const organizationId = getCurrentOrganizationId();
if (organizationId === null) {
throw new Error('No current organization id - create report');
}
return await api.makePlaceholder(undefined, {
params: {
organization: organizationId,
member: props.member.id
},
});
},
});
async function submit() {
saving.value = true;
await handleApiRequestNotifications(
() =>
turnToPlaceholderMutation.mutateAsync(),
'Deactivating the member was successful!',
'There was an error deactivating the user.',
() => {
show.value = false;
useMembersStore().fetchMembers()
}
);
}
</script>
<template>
<DialogModal closeable :show="show" @close="show = false">
<template #title>
<div class="flex space-x-2">
<span> Deactivate User </span>
</div>
</template>
<template #content>
<p>
Deactivating the user <strong>{{ member.name }} </strong> will remove the user's access to
the organization. You will not be billed for inactive users and all time entries will be preserved.
</p>
</template>
<template #footer>
<SecondaryButton @click="show = false"> Cancel</SecondaryButton>
<PrimaryButton
class="ms-3"
:class="{ 'opacity-25': saving }"
:disabled="saving"
@click="submit()">
Deactivate
</PrimaryButton>
</template>
</DialogModal>
</template>
<style scoped></style>

View File

@@ -1,14 +1,13 @@
<script setup lang="ts">
import { TrashIcon, UserCircleIcon, PencilSquareIcon, ArrowDownOnSquareStackIcon } from '@heroicons/vue/20/solid';
import { TrashIcon, PencilSquareIcon, ArrowDownOnSquareStackIcon } from '@heroicons/vue/20/solid';
import type { Member } from '@/packages/api/src';
import {canDeleteMembers, canMakeMembersPlaceholders, canMergeMembers, canUpdateMembers} from '@/utils/permissions';
import {canDeleteMembers, canMergeMembers, canUpdateMembers} from '@/utils/permissions';
import MoreOptionsDropdown from '@/packages/ui/src/MoreOptionsDropdown.vue';
const emit = defineEmits<{
delete: [];
edit: [];
merge: [];
makePlaceholder: [];
}>();
const props = defineProps<{
member: Member;
@@ -48,14 +47,6 @@ const props = defineProps<{
<ArrowDownOnSquareStackIcon class="w-5 text-icon-active"></ArrowDownOnSquareStackIcon>
<span>Merge</span>
</button>
<button
v-if="props.member.role !== 'placeholder' && canMakeMembersPlaceholders()"
:aria-label="'Make Member ' + props.member.name + ' a placeholder'"
class="flex items-center space-x-3 w-full px-3 py-2.5 text-start text-sm font-medium leading-5 text-white hover:bg-card-background-active focus:outline-none focus:bg-card-background-active transition duration-150 ease-in-out"
@click="emit('makePlaceholder')">
<UserCircleIcon class="w-5 text-icon-active"></UserCircleIcon>
<span>Deactivate</span>
</button>
</div>
</MoreOptionsDropdown>
</template>

View File

@@ -15,7 +15,6 @@ import MemberEditModal from '@/Components/Common/Member/MemberEditModal.vue';
import { getOrganizationCurrencyString } from '@/utils/money';
import { formatCents } from '@/packages/ui/src/utils/money';
import MemberMergeModal from "@/Components/Common/Member/MemberMergeModal.vue";
import MemberMakePlaceholderModal from "@/Components/Common/Member/MemberMakePlaceholderModal.vue";
const props = defineProps<{
member: Member;
@@ -23,7 +22,6 @@ const props = defineProps<{
const showEditMemberModal = ref(false);
const showMergeMemberModal = ref(false);
const showMakeMemberPlaceholderModal = ref(false);
function removeMember() {
useMembersStore().removeMember(props.member.id);
@@ -108,14 +106,12 @@ const userHasValidMailAddress = computed(() => {
@edit="showEditMemberModal = true"
@delete="removeMember"
@merge="showMergeMemberModal = true"
@make-placeholder="showMakeMemberPlaceholderModal = true"
></MemberMoreOptionsDropdown>
</div>
<MemberEditModal
v-model:show="showEditMemberModal"
:member="member"></MemberEditModal>
<MemberMergeModal v-model:show="showMergeMemberModal" :member="member"></MemberMergeModal>
<MemberMakePlaceholderModal v-model:show="showMakeMemberPlaceholderModal" :member="member"></MemberMakePlaceholderModal>
</TableRow>
</template>

View File

@@ -12,7 +12,7 @@ type AggregatedGroupedData = GroupedData & {
type GroupedData = {
seconds: number;
cost: number | null;
cost: number;
description: string | null | undefined;
};
@@ -48,7 +48,7 @@ const expanded = ref(false);
{{ formatHumanReadableDuration(entry.seconds) }}
</div>
<div class="justify-end pr-6 flex items-center">
{{entry.cost ? formatCents(entry.cost, getOrganizationCurrencyString()) : '--' }}
{{ formatCents(entry.cost, getOrganizationCurrencyString()) }}
</div>
</div>
<div

View File

@@ -2,13 +2,9 @@
import { router } from '@inertiajs/vue3';
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
import {canViewReport} from "@/utils/permissions";
import {computed} from "vue";
defineProps<{
active: 'reporting' | 'detailed' | 'shared';
}>();
const showSharedReports = computed(() => canViewReport());
</script>
<template>
@@ -24,7 +20,6 @@ const showSharedReports = computed(() => canViewReport());
>Detailed</TabBarItem
>
<TabBarItem
v-if="showSharedReports"
:active="active === 'shared'"
@click="router.visit(route('reporting.shared'))"
>Shared</TabBarItem

View File

@@ -1,45 +1,29 @@
<script lang="ts" setup>
import VChart, { THEME_KEY } from "vue-echarts";
import { provide, computed } from "vue";
import { use } from "echarts/core";
import DashboardCard from "@/Components/Dashboard/DashboardCard.vue";
import { BoltIcon } from "@heroicons/vue/20/solid";
import { HeatmapChart } from "echarts/charts";
import VChart, { THEME_KEY } from 'vue-echarts';
import { provide, ref } from 'vue';
import { use } from 'echarts/core';
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
import { BoltIcon } from '@heroicons/vue/20/solid';
import { HeatmapChart } from 'echarts/charts';
import {
CalendarComponent,
TitleComponent,
TooltipComponent,
VisualMapComponent
} from "echarts/components";
import { CanvasRenderer } from "echarts/renderers";
import dayjs from "dayjs";
VisualMapComponent,
} from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
import dayjs from 'dayjs';
import {
firstDayIndex,
formatDate,
formatHumanReadableDuration,
getDayJsInstance
} from "@/packages/ui/src/utils/time";
import { useCssVar } from "@vueuse/core";
import { useQuery } from "@tanstack/vue-query";
import { getCurrentOrganizationId } from "@/utils/useUser";
import { api } from "@/packages/api/src";
import { LoadingSpinner } from "@/packages/ui/src";
getDayJsInstance,
} from '@/packages/ui/src/utils/time';
import { useCssVar } from '@vueuse/core';
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
const { data: dailyHoursTracked, isLoading } = useQuery({
queryKey: ["dailyTrackedHours", organizationId],
queryFn: () => {
return api.dailyTrackedHours({
params: {
organization: organizationId.value!
}
});
},
enabled: computed(() => !!organizationId.value)
});
const props = defineProps<{
dailyHoursTracked: { duration: number; date: string }[];
}>();
use([
TitleComponent,
@@ -47,113 +31,89 @@ use([
VisualMapComponent,
CalendarComponent,
HeatmapChart,
CanvasRenderer
CanvasRenderer,
]);
provide(THEME_KEY, "dark");
provide(THEME_KEY, 'dark');
const max = computed(() => {
if (!isLoading.value && dailyHoursTracked.value) {
return Math.max(
Math.max(...dailyHoursTracked.value.map((el) => el.duration)),
1
);
} else {
return 1;
}
}
const max = Math.max(
Math.max(...props.dailyHoursTracked.map((el) => el.duration)),
1
);
const backgroundColor = useCssVar("--color-bg-secondary");
const itemBackgroundColor = useCssVar("--color-bg-tertiary");
const option = computed(() => {
return {
tooltip: {},
visualMap: {
min: 0,
max: max.value,
type: "piecewise",
orient: "horizontal",
left: "center",
top: "center",
inRange: {
color: [itemBackgroundColor.value, "#2DBE45"]
},
show: false
const backgroundColor = useCssVar('--color-bg-secondary');
const itemBackgroundColor = useCssVar('--color-bg-tertiary');
const option = ref({
tooltip: {},
visualMap: {
min: 0,
max: max,
type: 'piecewise',
orient: 'horizontal',
left: 'center',
top: 'center',
inRange: {
color: [itemBackgroundColor.value, '#2DBE45'],
},
show: false,
},
calendar: {
top: 40,
bottom: 20,
left: 40,
right: 10,
cellSize: [40, 40],
dayLabel: {
firstDay: firstDayIndex.value,
},
splitLine: {
show: false,
},
range: [
dayjs().format('YYYY-MM-DD'),
getDayJsInstance()()
.subtract(50, 'day')
.startOf('week')
.format('YYYY-MM-DD'),
],
itemStyle: {
color: 'transparent',
borderWidth: 8,
borderColor: backgroundColor.value,
},
yearLabel: { show: false },
},
series: {
type: 'heatmap',
coordinateSystem: 'calendar',
data: props.dailyHoursTracked.map((el) => [el.date, el.duration]),
itemStyle: {
borderRadius: 5,
borderColor: 'rgba(255,255,255,0.05)',
borderWidth: 1,
},
tooltip: {
valueFormatter: (value: number, dataIndex: number) => {
return (
formatDate(props.dailyHoursTracked[dataIndex].date) +
': ' +
formatHumanReadableDuration(value)
);
},
calendar: {
top: 40,
bottom: 20,
left: 40,
right: 10,
cellSize: [40, 40],
dayLabel: {
firstDay: firstDayIndex.value
},
splitLine: {
show: false
},
range: [
dayjs().format("YYYY-MM-DD"),
getDayJsInstance()()
.subtract(50, "day")
.startOf("week")
.format("YYYY-MM-DD")
],
itemStyle: {
color: "transparent",
borderWidth: 8,
borderColor: backgroundColor.value
},
yearLabel: { show: false }
},
series: {
type: "heatmap",
coordinateSystem: "calendar",
data: dailyHoursTracked?.value?.map((el) => [el.date, el.duration]) ?? [],
itemStyle: {
borderRadius: 5,
borderColor: "rgba(255,255,255,0.05)",
borderWidth: 1
},
tooltip: {
valueFormatter: (value: number, dataIndex: number) => {
if(dailyHoursTracked?.value){
return (
formatDate(dailyHoursTracked?.value[dataIndex].date) +
": " +
formatHumanReadableDuration(value)
);
}
else {
return "";
}
}
}
},
backgroundColor: "transparent"
};
});
},
},
backgroundColor: 'transparent',
});
</script>
<template>
<DashboardCard title="Activity Graph" :icon="BoltIcon">
<div class="px-2">
<div v-if="isLoading" class="flex justify-center items-center h-40">
<LoadingSpinner />
</div>
<div v-else-if="dailyHoursTracked">
<v-chart
class="chart"
:autoresize="true"
:option="option"
style="height: 260px; background-color: transparent" />
</div>
<div v-else class="text-center text-gray-500 py-8">
No activity data available
</div>
<v-chart
class="chart"
:autoresize="true"
:option="option"
style="height: 260px; background-color: transparent" />
</div>
</DashboardCard>
</template>

View File

@@ -1,53 +1,24 @@
<script setup lang="ts">
import { useQuery } from "@tanstack/vue-query";
import { computed } from "vue";
import DashboardCard from "@/Components/Dashboard/DashboardCard.vue";
import DayOverviewCardEntry from "@/Components/Dashboard/DayOverviewCardEntry.vue";
import { CalendarIcon } from "@heroicons/vue/20/solid";
import { getCurrentOrganizationId } from "@/utils/useUser";
import { api } from "@/packages/api/src";
import { LoadingSpinner } from "@/packages/ui/src";
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
// Set up the query
const { data: last7Days, isLoading } = useQuery({
queryKey: ["lastSevenDays", organizationId],
queryFn: () => {
return api.lastSevenDays({
params: {
organization: organizationId.value!
}
});
},
enabled: computed(() => !!organizationId.value),
placeholderData: Array.from({ length: 7 }, (_, i) => ({
date: new Date(Date.now() - i * 24 * 60 * 60 * 1000).toISOString().split("T")[0],
duration: 0,
history: Array(8).fill(0)
}))
});
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
import DayOverviewCardEntry from '@/Components/Dashboard/DayOverviewCardEntry.vue';
import { CalendarIcon } from '@heroicons/vue/20/solid';
defineProps<{
last7Days: {
date: string;
duration: number; // Total duration in seconds
history: number[]; // Array representing the duration in seconds of the 3h windows for the day
}[];
}>();
</script>
<template>
<DashboardCard title="Last 7 Days" :icon="CalendarIcon">
<div v-if="isLoading" class="flex justify-center items-center h-40">
<LoadingSpinner />
</div>
<div v-else-if="last7Days">
<DayOverviewCardEntry
v-for="day in last7Days"
:key="day.date"
:class="last7Days.length === 7 ? 'last:border-0 first:pt-3' : ''"
:date="day.date"
:history="day.history"
:duration="day.duration"></DayOverviewCardEntry>
</div>
<div v-else class="text-center text-gray-500 py-8">
No data available
</div>
<DayOverviewCardEntry
v-for="day in last7Days"
:key="day.date"
:class="last7Days.length === 7 ? 'last:border-0 first:pt-3' : ''"
:date="day.date"
:history="day.history"
:duration="day.duration"></DayOverviewCardEntry>
</DashboardCard>
</template>

View File

@@ -1,83 +1,32 @@
<script setup lang="ts">
import { useQuery } from "@tanstack/vue-query";
import { computed } from "vue";
import RecentlyTrackedTasksCardEntry from "@/Components/Dashboard/RecentlyTrackedTasksCardEntry.vue";
import DashboardCard from "@/Components/Dashboard/DashboardCard.vue";
import { CheckCircleIcon } from "@heroicons/vue/20/solid";
import SecondaryButton from "@/packages/ui/src/Buttons/SecondaryButton.vue";
import { PlusCircleIcon } from "@heroicons/vue/24/solid";
import { router } from "@inertiajs/vue3";
import { getCurrentMembershipId, getCurrentOrganizationId } from "@/utils/useUser";
import { api } from "@/packages/api/src";
import { LoadingSpinner } from "@/packages/ui/src";
import RecentlyTrackedTasksCardEntry from '@/Components/Dashboard/RecentlyTrackedTasksCardEntry.vue';
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
import { CheckCircleIcon } from '@heroicons/vue/20/solid';
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import { PlusCircleIcon } from '@heroicons/vue/24/solid';
import { router } from '@inertiajs/vue3';
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
// Function to fetch latest tasks using the API client
// Set up the query
const { data: timeEntriesResponse, isLoading, refetch } = useQuery({
queryKey: ["timeEntries", organizationId],
queryFn: () => {
return api.getTimeEntries({
params: {
organization: organizationId.value!
},
queries: {
member_id: getCurrentMembershipId()
}
});
},
enabled: computed(() => !!organizationId.value)
});
const latestTasks = computed(() => {
if (!timeEntriesResponse.value) {
return [];
}
return timeEntriesResponse.value.data;
});
const filteredLatestTasks = computed(() => {
// do not include running time entries
const finishedTimeEntries = latestTasks.value.filter((item) => item.end !== null);
// filter out duplicates based on description, task, project, tags and billable
return finishedTimeEntries.filter((item, index, self) => {
return index === self.findIndex((t) => (
t.description === item.description &&
t.task_id === item.task_id &&
t.project_id === item.project_id &&
t.tags.length === item.tags.length &&
t.tags.every((tag) => item.tags.includes(tag)) &&
t.billable === item.billable
));
}).slice(0, 4);
});
// Listen for dashboard refresh events
window.addEventListener("dashboard:refresh", () => {
refetch();
});
const props = defineProps<{
latestTasks: {
id: string;
name: string;
project_name: string;
project_id: string;
}[];
}>();
</script>
<template>
<DashboardCard title="Recent Time Entries" :icon="CheckCircleIcon">
<div v-if="isLoading" class="flex justify-center items-center h-40">
<LoadingSpinner />
</div>
<div v-else-if="filteredLatestTasks && filteredLatestTasks.length > 0">
<RecentlyTrackedTasksCardEntry
v-for="lastTask in filteredLatestTasks"
:key="lastTask.id"
:time-entry="lastTask"
:class="filteredLatestTasks.length === 4 ? 'last:border-0' : ''"></RecentlyTrackedTasksCardEntry>
</div>
<DashboardCard title="Recently Tracked Tasks" :icon="CheckCircleIcon">
<RecentlyTrackedTasksCardEntry
v-for="lastTask in props.latestTasks"
:key="lastTask.id"
:class="props.latestTasks.length === 4 ? 'last:border-0' : ''"
:project_id="lastTask.project_id"
:task_id="lastTask.id"
:title="lastTask.name"></RecentlyTrackedTasksCardEntry>
<div
v-else
v-if="props.latestTasks.length === 0"
class="text-center flex flex-1 justify-center items-center">
<div>
<PlusCircleIcon
@@ -87,12 +36,12 @@ window.addEventListener("dashboard:refresh", () => {
</h3>
<p class="pb-5 text-sm">Create tasks inside of a project!</p>
<SecondaryButton @click="router.visit(route('projects'))"
>Go to Projects
>Go to Projects
</SecondaryButton>
</div>
</div>
<div
v-if="latestTasks && latestTasks.length === 1"
v-if="props.latestTasks.length === 1"
class="text-center flex flex-1 justify-center items-center text-sm">
<div>
<PlusCircleIcon
@@ -100,7 +49,7 @@ window.addEventListener("dashboard:refresh", () => {
<h3 class="text-white font-semibold">Add more tasks</h3>
<p class="pb-5">Create tasks inside of a project!</p>
<SecondaryButton @click="router.visit(route('projects'))"
>Go to Projects
>Go to Projects
</SecondaryButton>
</div>
</div>

View File

@@ -6,16 +6,17 @@ import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
import { getDayJsInstance } from '@/packages/ui/src/utils/time';
import type { TimeEntry } from "@/packages/api/src";
const props = defineProps<{
timeEntry: TimeEntry
title: string;
project_id: string;
task_id: string;
}>();
const { projects } = storeToRefs(useProjectsStore());
const project = computed(() => {
return projects.value.find((project) => project.id === props.timeEntry.project_id);
return projects.value.find((project) => project.id === props.project_id);
});
const { currentTimeEntry } = storeToRefs(useCurrentTimeEntryStore());
@@ -25,28 +26,23 @@ async function startTaskTimer() {
if (currentTimeEntry.value.id) {
await setActiveState(false);
}
currentTimeEntry.value.description = props.timeEntry.description;
currentTimeEntry.value.project_id = props.timeEntry.project_id;
currentTimeEntry.value.task_id = props.timeEntry.task_id;
currentTimeEntry.value.tags = props.timeEntry.tags;
currentTimeEntry.value.billable = props.timeEntry.billable;
currentTimeEntry.value.project_id = props.project_id;
currentTimeEntry.value.task_id = props.task_id;
currentTimeEntry.value.start = getDayJsInstance().utc().format();
await setActiveState(true);
useCurrentTimeEntryStore().fetchCurrentTimeEntry();
}
</script>
<template>
<div
class="px-3.5 py-2 grid grid-cols-5 border-b border-b-card-background-separator">
<div class="col-span-4">
<p class="font-medium text-white text-sm pb-1 truncate">
<span v-if="timeEntry.description"> {{ timeEntry.description }}</span>
<span v-else class="text-text-tertiary">No description</span>
<p class="font-semibold text-white text-sm pb-1 overflow-ellipsis">
{{ title }}
</p>
<ProjectBadge
:name="project?.name ?? 'No Project'"
:name="project?.name"
:color="project?.color"></ProjectBadge>
</div>
<div class="flex items-center justify-center">

View File

@@ -1,52 +1,33 @@
<script lang="ts" setup>
import { useQuery } from '@tanstack/vue-query';
import { computed } from 'vue';
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
import TeamActivityCardEntry from '@/Components/Dashboard/TeamActivityCardEntry.vue';
import { UserGroupIcon } from '@heroicons/vue/20/solid';
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import { getCurrentOrganizationId } from '@/utils/useUser';
import { api } from '@/packages/api/src';
import { LoadingSpinner } from "@/packages/ui/src";
import { router } from '@inertiajs/vue3';
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
// Set up the query
const { data: latestTeamActivity, isLoading } = useQuery({
queryKey: ['latestTeamActivity', organizationId],
queryFn: () => {
return api.latestTeamActivity({
params: {
organization: organizationId.value!
}
})
},
enabled: computed(() => !!organizationId.value),
});
defineProps<{
latestTeamActivity: {
user_id: string;
name: string;
description: string;
time_entry_id: string;
task_id: string;
status: boolean;
}[];
}>();
</script>
<template>
<DashboardCard title="Team Activity" :icon="UserGroupIcon">
<div v-if="isLoading" class="flex justify-center items-center h-40">
<LoadingSpinner />
</div>
<div v-else-if="latestTeamActivity">
<TeamActivityCardEntry
v-for="activity in latestTeamActivity"
:key="activity.time_entry_id"
:class="latestTeamActivity.length === 4 ? 'last:border-0' : ''"
:name="activity.name"
:description="activity.description"
:working="activity.status"></TeamActivityCardEntry>
</div>
<div v-else class="text-center text-gray-500 py-8">
No team activity found
</div>
<TeamActivityCardEntry
v-for="activity in latestTeamActivity"
:key="activity.user_id"
:class="latestTeamActivity.length === 4 ? 'last:border-0' : ''"
:name="activity.name"
:description="activity.description"
:working="activity.status"></TeamActivityCardEntry>
<div
v-if="latestTeamActivity && latestTeamActivity.length <= 1"
v-if="latestTeamActivity.length <= 1"
class="text-center flex flex-1 justify-center items-center">
<div>
<UserGroupIcon

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
defineProps<{
name: string;
description: string | null;
description: string;
working?: boolean;
}>();
</script>

View File

@@ -1,28 +1,25 @@
<script setup lang="ts">
import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { BarChart } from "echarts/charts";
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
import { BarChart } from 'echarts/charts';
import {
GridComponent,
LegendComponent,
TitleComponent,
TooltipComponent
} from "echarts/components";
import VChart, { THEME_KEY } from "vue-echarts";
import { computed, provide } from "vue";
import StatCard from "@/Components/Common/StatCard.vue";
import { ClockIcon } from "@heroicons/vue/20/solid";
import CardTitle from "@/packages/ui/src/CardTitle.vue";
import LinearGradient from "zrender/lib/graphic/LinearGradient";
import ProjectsChartCard from "@/Components/Dashboard/ProjectsChartCard.vue";
import { formatHumanReadableDuration } from "@/packages/ui/src/utils/time";
import { formatCents } from "@/packages/ui/src/utils/money";
import { getWeekStart } from "@/packages/ui/src/utils/settings";
import { useCssVar } from "@vueuse/core";
import { getOrganizationCurrencyString } from "@/utils/money";
import { useQuery } from "@tanstack/vue-query";
import { getCurrentOrganizationId } from "@/utils/useUser";
import { api } from "@/packages/api/src";
TooltipComponent,
} from 'echarts/components';
import VChart, { THEME_KEY } from 'vue-echarts';
import { computed, provide, ref } from 'vue';
import StatCard from '@/Components/Common/StatCard.vue';
import { ClockIcon } from '@heroicons/vue/20/solid';
import CardTitle from '@/packages/ui/src/CardTitle.vue';
import LinearGradient from 'zrender/lib/graphic/LinearGradient';
import ProjectsChartCard from '@/Components/Dashboard/ProjectsChartCard.vue';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { formatCents } from '@/packages/ui/src/utils/money';
import { getWeekStart } from '@/packages/ui/src/utils/settings';
import { useCssVar } from '@vueuse/core';
import { getOrganizationCurrencyString } from '@/utils/money';
use([
CanvasRenderer,
@@ -30,22 +27,85 @@ use([
TitleComponent,
GridComponent,
TooltipComponent,
LegendComponent
LegendComponent,
]);
provide(THEME_KEY, "dark");
const accentColor = useCssVar("--color-accent-quaternary");
provide(THEME_KEY, 'dark');
const props = defineProps<{
weeklyProjectOverview: {
value: number;
name: string;
color: string;
}[];
totalWeeklyTime: number;
totalWeeklyBillableTime: number;
totalWeeklyBillableAmount: {
value: number;
currency: string;
};
weeklyHistory: {
date: string;
duration: number;
}[];
}>();
const accentColor = useCssVar('--color-accent-quaternary');
const seriesData = computed(() => {
return props.weeklyHistory.map((el) => {
return {
value: el.duration,
...{
itemStyle: {
borderColor: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(' + accentColor.value + ',0.7)',
},
{
offset: 1,
color: 'rgba(' + accentColor.value + ',0.5)',
},
]),
emphasis: {
color: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(' + accentColor.value + ',0.9)',
},
{
offset: 1,
color: 'rgba(' + accentColor.value + ',0.7)',
},
]),
},
borderRadius: [12, 12, 0, 0],
color: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(' + accentColor.value + ',0.7)',
},
{
offset: 1,
color: 'rgba(' + accentColor.value + ',0.5)',
},
]),
},
},
};
});
});
const weekdays = computed(() => {
const daysOrder = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const daysOrder = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const dayMapping: Record<string, string> = {
monday: "Mon",
tuesday: "Tue",
wednesday: "Wed",
thursday: "Thu",
friday: "Fri",
saturday: "Sat",
sunday: "Sun"
monday: 'Mon',
tuesday: 'Tue',
wednesday: 'Wed',
thursday: 'Thu',
friday: 'Fri',
saturday: 'Sat',
sunday: 'Sun',
};
if (dayMapping[getWeekStart()]) {
@@ -62,179 +122,59 @@ const weekdays = computed(() => {
}
});
const markLineColor = useCssVar("--color-border-secondary");
const markLineColor = useCssVar('--color-border-secondary');
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
// Set up the queries
const { data: weeklyProjectOverview } = useQuery({
queryKey: ["weeklyProjectOverview", organizationId],
queryFn: () => {
return api.weeklyProjectOverview({
params: {
organization: organizationId.value!
}
});
const option = ref({
tooltip: {
trigger: 'item',
},
enabled: computed(() => !!organizationId.value)
});
const { data: totalWeeklyTime } = useQuery({
queryKey: ["totalWeeklyTime", organizationId],
queryFn: () => {
return api.totalWeeklyTime({
params: {
organization: organizationId.value!
}
});
grid: {
top: 0,
right: 0,
bottom: 50,
left: 0,
},
enabled: computed(() => !!organizationId.value)
});
const { data: totalWeeklyBillableTime } = useQuery({
queryKey: ["totalWeeklyBillableTime", organizationId],
queryFn: () => {
return api.totalWeeklyBillableTime({
params: {
organization: organizationId.value!
}
});
},
enabled: computed(() => !!organizationId.value)
});
const { data: totalWeeklyBillableAmount } = useQuery({
queryKey: ["totalWeeklyBillableAmount", organizationId],
queryFn: () => {
return api.totalWeeklyBillableAmount({
params: {
organization: organizationId.value!
}
});
},
enabled: computed(() => !!organizationId.value)
});
const { data: weeklyHistory } = useQuery({
queryKey: ["weeklyHistory", organizationId],
queryFn: () => {
return api.weeklyHistory({
params: {
organization: organizationId.value!
}
});
},
enabled: computed(() => !!organizationId.value)
});
const seriesData = computed(() => {
if (!weeklyHistory.value) {
return [];
}
return weeklyHistory.value?.map((el) => {
return {
value: el.duration,
...{
itemStyle: {
borderColor: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(" + accentColor.value + ",0.7)"
},
{
offset: 1,
color: "rgba(" + accentColor.value + ",0.5)"
}
]),
emphasis: {
color: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(" + accentColor.value + ",0.9)"
},
{
offset: 1,
color: "rgba(" + accentColor.value + ",0.7)"
}
])
},
borderRadius: [12, 12, 0, 0],
color: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(" + accentColor.value + ",0.7)"
},
{
offset: 1,
color: "rgba(" + accentColor.value + ",0.5)"
}
])
}
}
};
});
});
const option = computed(() => {
return {
tooltip: {
trigger: "item"
},
grid: {
top: 0,
right: 0,
bottom: 50,
left: 0
},
backgroundColor: "transparent",
xAxis: {
type: "category",
data: weekdays.value,
axisLine: {
backgroundColor: 'transparent',
xAxis: {
type: 'category',
data: weekdays.value,
axisLine: {
lineStyle: {
color: "transparent" // Set desired color here
}
color: 'transparent', // Set desired color here
},
},
axisLabel: {
fontSize: 16,
fontWeight: 600,
margin: 24,
fontFamily: "Outfit, sans-serif"
fontWeight: 600,
margin: 24,
fontFamily: 'Outfit, sans-serif',
},
axisTick: {
lineStyle: {
color: "transparent" // Set desired color here
}
}
},
yAxis: {
type: "value",
splitLine: {
lineStyle: {
color: markLineColor.value
}
}
color: 'transparent', // Set desired color here
},
},
series: [
{
data: seriesData.value,
type: "bar",
tooltip: {
valueFormatter: (value: number) => {
return formatHumanReadableDuration(value);
}
}
}
]
}
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
color: markLineColor.value,
},
},
},
series: [
{
data: seriesData,
type: 'bar',
tooltip: {
valueFormatter: (value: number) => {
return formatHumanReadableDuration(value);
},
},
},
],
});
</script>
<template>
@@ -245,35 +185,28 @@ const option = computed(() => {
title="This Week"
class="pb-8"
:icon="ClockIcon"></CardTitle>
<v-chart
v-if="weeklyHistory"
:autoresize="true" class="chart" :option="option" />
<v-chart :autoresize="true" class="chart" :option="option" />
</div>
<div class="space-y-6">
<StatCard
title="Spent Time"
:value="
totalWeeklyTime ?
formatHumanReadableDuration(totalWeeklyTime) : '--'" />
:value="formatHumanReadableDuration(props.totalWeeklyTime)" />
<StatCard
title="Billable Time"
:value="
totalWeeklyBillableTime ?
formatHumanReadableDuration(totalWeeklyBillableTime) : '--'
formatHumanReadableDuration(props.totalWeeklyBillableTime)
" />
<StatCard
title="Billable Amount"
:value="
totalWeeklyBillableAmount ?
formatCents(
totalWeeklyBillableAmount.value,
props.totalWeeklyBillableAmount.value,
getOrganizationCurrencyString()
) : '--'
)
" />
<ProjectsChartCard
v-if="weeklyProjectOverview"
:weekly-project-overview="
weeklyProjectOverview
props.weeklyProjectOverview
"></ProjectsChartCard>
</div>
</div>

View File

@@ -14,7 +14,7 @@ const props = defineProps<{
icon?: Component;
current?: boolean;
href: string;
subItems?: { title: string; route: string, show: boolean }[];
subItems?: { title: string; route: string }[];
}>();
const open = useSessionStorage('nav-collapse-state-' + props.title, true);
@@ -66,7 +66,6 @@ const open = useSessionStorage('nav-collapse-state-' + props.title, true);
:key="subItem.title"
class="w-full relative">
<NavigationSidebarLink
v-if="subItem.show"
:title="subItem.title"
:current="route().current(subItem.route)"
:href="

View File

@@ -27,7 +27,7 @@ import {
canUpdateOrganization,
canViewClients,
canViewMembers,
canViewProjects, canViewReport,
canViewProjects,
canViewTags,
} from '@/utils/permissions';
import { isBillingActivated } from '@/utils/billing';
@@ -118,17 +118,14 @@ const page = usePage<{
{
title: 'Overview',
route: 'reporting',
show: true
},
{
title: 'Detailed',
route: 'reporting.detailed',
show: true
},
{
title: 'Shared',
route: 'reporting.shared',
show: canViewReport()
},
]"
:current="

View File

@@ -1,51 +1,100 @@
<script setup lang="ts">
import AppLayout from "@/Layouts/AppLayout.vue";
import TimeTracker from "@/Components/TimeTracker.vue";
import RecentlyTrackedTasksCard from "@/Components/Dashboard/RecentlyTrackedTasksCard.vue";
import LastSevenDaysCard from "@/Components/Dashboard/LastSevenDaysCard.vue";
import TeamActivityCard from "@/Components/Dashboard/TeamActivityCard.vue";
import ThisWeekOverview from "@/Components/Dashboard/ThisWeekOverview.vue";
import ActivityGraphCard from "@/Components/Dashboard/ActivityGraphCard.vue";
import MainContainer from "@/packages/ui/src/MainContainer.vue";
import { canViewMembers } from "@/utils/permissions";
import { useQueryClient } from "@tanstack/vue-query";
import AppLayout from '@/Layouts/AppLayout.vue';
import TimeTracker from '@/Components/TimeTracker.vue';
import RecentlyTrackedTasksCard from '@/Components/Dashboard/RecentlyTrackedTasksCard.vue';
import LastSevenDaysCard from '@/Components/Dashboard/LastSevenDaysCard.vue';
import TeamActivityCard from '@/Components/Dashboard/TeamActivityCard.vue';
import ThisWeekOverview from '@/Components/Dashboard/ThisWeekOverview.vue';
import ActivityGraphCard from '@/Components/Dashboard/ActivityGraphCard.vue';
import MainContainer from '@/packages/ui/src/MainContainer.vue';
import { canViewMembers } from '@/utils/permissions';
import { router } from '@inertiajs/vue3';
const queryClient = useQueryClient();
const refreshDashboardData = () => {
// Invalidate all dashboard queries to trigger refetching
queryClient.invalidateQueries({ queryKey: ["latestTasks"] });
queryClient.invalidateQueries({ queryKey: ["lastSevenDays"] });
queryClient.invalidateQueries({ queryKey: ["dailyTrackedHours"] });
queryClient.invalidateQueries({ queryKey: ["latestTeamActivity"] });
queryClient.invalidateQueries({ queryKey: ["weeklyProjectOverview"] });
queryClient.invalidateQueries({ queryKey: ["totalWeeklyTime"] });
queryClient.invalidateQueries({ queryKey: ["totalWeeklyBillableTime"] });
queryClient.invalidateQueries({ queryKey: ["totalWeeklyBillableAmount"] });
queryClient.invalidateQueries({ queryKey: ["weeklyHistory"] });
};
const props = defineProps<{
latestTasks: {
id: string;
name: string;
project_name: string;
project_id: string;
}[];
latestTeamActivity: {
user_id: string;
name: string;
description: string;
time_entry_id: string;
task_id: string;
status: boolean;
}[];
lastSevenDays: {
date: string;
duration: number; // Total duration in seconds
history: number[]; // Array representing the duration in seconds of the 3h windows for the day
}[];
dailyTrackedHours: { duration: number; date: string }[];
weeklyProjectOverview: {
value: number;
name: string;
color: string;
}[];
totalWeeklyTime: number;
totalWeeklyBillableTime: number;
totalWeeklyBillableAmount: {
value: number;
currency: string;
};
weeklyHistory: {
date: string;
duration: number;
}[];
}>();
function refreshDashboardData() {
router.reload({
only: [
'latestTasks',
'latestTeamActivity',
'lastSevenDays',
'dailyTrackedHours',
'weeklyProjectOverview',
'totalWeeklyTime',
'totalWeeklyBillableTime',
'totalWeeklyBillableAmount',
'weeklyHistory',
],
});
}
</script>
<template>
<AppLayout title="Dashboard" data-testid="dashboard_view">
<MainContainer
class="pt-5 sm:pt-8 pb-4 sm:pb-6 border-b border-default-background-separator">
<TimeTracker @change="refreshDashboardData"></TimeTracker>
</MainContainer>
<MainContainer
class="grid gap-5 sm:gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 pt-3 sm:pt-5 pb-4 sm:pb-6 border-b border-default-background-separator items-stretch">
<RecentlyTrackedTasksCard></RecentlyTrackedTasksCard>
<LastSevenDaysCard></LastSevenDaysCard>
<ActivityGraphCard></ActivityGraphCard>
<TeamActivityCard
v-if="canViewMembers()"
class="flex lg:hidden xl:flex">
</TeamActivityCard>
</MainContainer>
<MainContainer class="py-5">
<ThisWeekOverview></ThisWeekOverview>
</MainContainer>
<MainContainer
class="pt-5 sm:pt-8 pb-4 sm:pb-6 border-b border-default-background-separator">
<TimeTracker @change="refreshDashboardData"></TimeTracker>
</MainContainer>
<MainContainer
class="grid gap-5 sm:gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 pt-3 sm:pt-5 pb-4 sm:pb-6 border-b border-default-background-separator items-stretch">
<RecentlyTrackedTasksCard
:latest-tasks="props.latestTasks"></RecentlyTrackedTasksCard>
<LastSevenDaysCard
:last7-days="props.lastSevenDays"></LastSevenDaysCard>
<ActivityGraphCard
:daily-hours-tracked="
props.dailyTrackedHours
"></ActivityGraphCard>
<TeamActivityCard
v-if="canViewMembers()"
class="flex lg:hidden xl:flex"
:latest-team-activity="
props.latestTeamActivity
"></TeamActivityCard>
</MainContainer>
<MainContainer class="py-5">
<ThisWeekOverview
:weekly-project-overview="props.weeklyProjectOverview"
:total-weekly-billable-amount="props.totalWeeklyBillableAmount"
:total-weekly-billable-time="props.totalWeeklyBillableTime"
:total-weekly-time="props.totalWeeklyTime"
:weekly-history="props.weeklyHistory"></ThisWeekOverview>
</MainContainer>
</AppLayout>
</template>

View File

@@ -53,7 +53,6 @@ onMounted(() => {
if (canViewProjectMembers()) {
useProjectMembersStore().fetchProjectMembers(projectId);
}
useTasksStore().fetchTasks();
});
const showEditProjectModal = ref(false);

View File

@@ -464,11 +464,10 @@ const tableData = computed(() => {
<div
class="justify-end pr-6 flex items-center font-medium">
{{
aggregatedTableTimeEntries.cost ?
formatCents(
aggregatedTableTimeEntries.cost,
getOrganizationCurrencyString()
) : '--'
)
}}
</div>
</div>

View File

@@ -58,7 +58,7 @@ import {
PaginationRoot,
} from 'radix-vue';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { getCurrentOrganizationId, getCurrentMembershipId } from '@/utils/useUser';
import { getCurrentOrganizationId } from '@/utils/useUser';
import { useTimeEntriesStore } from '@/utils/useTimeEntries';
import ReportingTabNavbar from '@/Components/Common/Reporting/ReportingTabNavbar.vue';
import ReportingExportButton from '@/Components/Common/Reporting/ReportingExportButton.vue';
@@ -66,7 +66,7 @@ import type { ExportFormat } from '@/types/reporting';
import { useNotificationsStore } from '@/utils/notification';
import TimeEntryMassActionRow from '@/packages/ui/src/TimeEntry/TimeEntryMassActionRow.vue';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import {canCreateProjects, canViewAllTimeEntries} from '@/utils/permissions';
import { canCreateProjects } from '@/utils/permissions';
import ReportingExportModal from '@/Components/Common/Reporting/ReportingExportModal.vue';
const startDate = useSessionStorage<string>(
@@ -98,7 +98,6 @@ function getFilterAttributes() {
};
const params = {
...defaultParams,
member_id: !canViewAllTimeEntries() ? getCurrentMembershipId() : undefined,
member_ids:
selectedMembers.value.length > 0
? selectedMembers.value

View File

@@ -94,6 +94,28 @@ const OrganizationUpdateRequest = z
employees_can_see_billable_rates: z.boolean().optional(),
})
.passthrough();
const VersionRequest = z
.object({
version: z.string().max(255),
build: z.string().max(255),
url: z.string().max(255),
})
.passthrough();
const TelemetryRequest = z
.object({
version: z.string().max(255),
build: z.string().max(255),
url: z.string().max(255).url(),
user_count: z.number().int(),
organization_count: z.number().int(),
audit_count: z.number().int(),
project_count: z.number().int(),
project_member_count: z.number().int(),
client_count: z.number().int(),
task_count: z.number().int(),
time_entry_count: z.number().int(),
})
.passthrough();
const ProjectResource = z
.object({
id: z.string(),
@@ -503,6 +525,8 @@ export const schemas = {
MemberMergeIntoRequest,
OrganizationResource,
OrganizationUpdateRequest,
VersionRequest,
TelemetryRequest,
ProjectResource,
ProjectStoreRequest,
ProjectUpdateRequest,
@@ -611,332 +635,6 @@ const endpoints = makeApi([
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/daily-tracked-hours',
alias: 'dailyTrackedHours',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({ date: z.string(), duration: z.number().int() })
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/last-seven-days',
alias: 'lastSevenDays',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({
date: z.string(),
duration: z.number().int(),
history: z.array(z.number().int()),
})
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/latest-tasks',
alias: 'latestTasks',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({
task_id: z.string(),
name: z.string(),
description: z.union([z.string(), z.null()]),
status: z.boolean(),
time_entry_id: z.union([z.string(), z.null()]),
})
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/latest-team-activity',
alias: 'latestTeamActivity',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({
member_id: z.string(),
name: z.string(),
description: z.union([z.string(), z.null()]),
time_entry_id: z.string(),
task_id: z.union([z.string(), z.null()]),
status: z.boolean(),
})
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/total-weekly-billable-amount',
alias: 'totalWeeklyBillableAmount',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z
.object({ value: z.number().int(), currency: z.string() })
.passthrough(),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/total-weekly-billable-time',
alias: 'totalWeeklyBillableTime',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.number().int(),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/total-weekly-time',
alias: 'totalWeeklyTime',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.number().int(),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/weekly-history',
alias: 'weeklyHistory',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({ date: z.string(), duration: z.number().int() })
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/charts/weekly-project-overview',
alias: 'weeklyProjectOverview',
requestFormat: 'json',
parameters: [
{
name: 'organization',
type: 'Path',
schema: z.string(),
},
],
response: z.array(
z
.object({
value: z.number().int(),
name: z.string(),
color: z.string(),
})
.passthrough()
),
errors: [
{
status: 401,
description: `Unauthenticated`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 403,
description: `Authorization error`,
schema: z.object({ message: z.string() }).passthrough(),
},
{
status: 404,
description: `Not found`,
schema: z.object({ message: z.string() }).passthrough(),
},
],
},
{
method: 'get',
path: '/v1/organizations/:organization/clients',
@@ -1798,7 +1496,7 @@ const endpoints = makeApi([
{
method: 'post',
path: '/v1/organizations/:organization/members/:member/make-placeholder',
alias: 'makePlaceholder',
alias: 'v1.members.make-placeholder',
requestFormat: 'json',
parameters: [
{
@@ -3451,7 +3149,7 @@ If the group parameters are all set to &#x60;null&#x60; or are all missing, the
.object({
key: z.union([z.string(), z.null()]),
seconds: z.number().int(),
cost: z.union([z.number(), z.null()]),
cost: z.number().int(),
grouped_type: z.union([
z.string(),
z.null(),
@@ -3467,10 +3165,7 @@ If the group parameters are all set to &#x60;null&#x60; or are all missing, the
seconds: z
.number()
.int(),
cost: z.union([
z.number(),
z.null(),
]),
cost: z.number().int(),
grouped_type: z.null(),
grouped_data: z.null(),
})
@@ -3484,7 +3179,7 @@ If the group parameters are all set to &#x60;null&#x60; or are all missing, the
z.null(),
]),
seconds: z.number().int(),
cost: z.union([z.number(), z.null()]),
cost: z.number().int(),
})
.passthrough(),
})
@@ -3803,6 +3498,58 @@ If the group parameters are all set to &#x60;null&#x60; or are all missing, the
},
],
},
{
method: 'post',
path: '/v1/ping/telemetry',
alias: 'v1.ping.telemetry',
requestFormat: 'json',
parameters: [
{
name: 'body',
type: 'Body',
schema: TelemetryRequest,
},
],
response: z.object({ success: z.boolean() }).passthrough(),
errors: [
{
status: 422,
description: `Validation error`,
schema: z
.object({
message: z.string(),
errors: z.record(z.array(z.string())),
})
.passthrough(),
},
],
},
{
method: 'post',
path: '/v1/ping/version',
alias: 'v1.ping.version',
requestFormat: 'json',
parameters: [
{
name: 'body',
type: 'Body',
schema: VersionRequest,
},
],
response: z.object({ version: z.string() }).passthrough(),
errors: [
{
status: 422,
description: `Validation error`,
schema: z
.object({
message: z.string(),
errors: z.record(z.array(z.string())),
})
.passthrough(),
},
],
},
{
method: 'get',
path: '/v1/public/reports',

View File

@@ -81,10 +81,6 @@ export function canMergeMembers() {
return currentUserHasPermission('members:merge-into');
}
export function canMakeMembersPlaceholders() {
return currentUserHasPermission('members:make-placeholder');
}
export function canInvitePlaceholderMembers() {
return currentUserHasPermission('members:invite-placeholder');
}
@@ -109,16 +105,9 @@ export function canManageBilling() {
return currentUserHasPermission('billing');
}
export function canViewReport() {
return currentUserHasPermission('reports:view');
}
export function canUpdateReport() {
return currentUserHasPermission('reports:update');
}
export function canDeleteReport() {
return currentUserHasPermission('reports:delete');
}
export function canViewAllTimeEntries() {
return currentUserHasPermission('time-entries:view:all');
}

View File

@@ -3,7 +3,6 @@
declare(strict_types=1);
use App\Http\Controllers\Api\V1\ApiTokenController;
use App\Http\Controllers\Api\V1\ChartController;
use App\Http\Controllers\Api\V1\ClientController;
use App\Http\Controllers\Api\V1\ExportController;
use App\Http\Controllers\Api\V1\ImportController;
@@ -124,19 +123,6 @@ Route::prefix('v1')->name('v1.')->group(static function (): void {
Route::delete('/reports/{report}', [ReportController::class, 'destroy'])->name('destroy');
});
// Chart routes
Route::name('charts.')->prefix('/organizations/{organization}/charts')->group(static function (): void {
Route::get('/weekly-project-overview', [ChartController::class, 'weeklyProjectOverview'])->name('weekly-project-overview');
Route::get('/latest-tasks', [ChartController::class, 'latestTasks'])->name('latest-tasks');
Route::get('/last-seven-days', [ChartController::class, 'lastSevenDays'])->name('last-seven-days');
Route::get('/latest-team-activity', [ChartController::class, 'latestTeamActivity'])->name('latest-team-activity');
Route::get('/daily-tracked-hours', [ChartController::class, 'dailyTrackedHours'])->name('daily-tracked-hours');
Route::get('/total-weekly-time', [ChartController::class, 'totalWeeklyTime'])->name('total-weekly-time');
Route::get('/total-weekly-billable-time', [ChartController::class, 'totalWeeklyBillableTime'])->name('total-weekly-billable-time');
Route::get('/total-weekly-billable-amount', [ChartController::class, 'totalWeeklyBillableAmount'])->name('total-weekly-billable-amount');
Route::get('/weekly-history', [ChartController::class, 'weeklyHistory'])->name('weekly-history');
});
// Tag routes
Route::name('tags.')->prefix('/organizations/{organization}')->group(static function (): void {
Route::get('/tags', [TagController::class, 'index'])->name('index');

View File

@@ -53,9 +53,6 @@ abstract class TestCaseWithDatabase extends TestCase
];
}
/**
* @return object{user: User, organization: Organization, member: Member, owner: User, ownerMember: Member}
*/
public function createUserWithRole(Role $role): object
{
$owner = User::factory()->create();

View File

@@ -1,303 +0,0 @@
<?php
declare(strict_types=1);
namespace Tests\Unit\Endpoint\Api\V1;
use App\Enums\Role;
use Laravel\Passport\Passport;
use Tests\Unit\Endpoint\Web\EndpointTestAbstract;
class ChartEndpointTest extends EndpointTestAbstract
{
public function test_weekly_project_overview_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.weekly-project-overview', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_weekly_project_overview_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.weekly-project-overview', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_latest_tasks_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.latest-tasks', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_latest_tasks_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.latest-tasks', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_last_seven_days_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.last-seven-days', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_last_seven_days_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.last-seven-days', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_latest_team_activity_endpoint_fails_if_user_has_no_permission_to_view_chart_for_the_whole_orgnaization(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.latest-team-activity', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_latest_team_activity_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:all']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.latest-team-activity', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_daily_tracked_hours_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.daily-tracked-hours', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_daily_tracked_hours_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.daily-tracked-hours', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_total_weekly_time_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-time', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_total_weekly_time_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-time', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_total_weekly_billable_time_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-billable-time', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_total_weekly_billable_time_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-billable-time', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_total_weekly_billable_amount_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-billable-amount', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_total_weekly_billable_amount_endpoint_fails_if_the_user_is_an_employee_but_the_organization_does_not_allow_employees_to_view_billable_rates(): void
{
// Arrange
$user = $this->createUserWithRole(Role::Employee);
$organization = $user->organization;
$organization->employees_can_see_billable_rates = false;
$organization->save();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-billable-amount', [
'organization' => $organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_total_weekly_billable_amount_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithRole(Role::Employee);
$organization = $user->organization;
$organization->employees_can_see_billable_rates = true;
$organization->save();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.total-weekly-billable-amount', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
public function test_weekly_history_endpoint_fails_if_user_has_no_permission_to_view_chart(): void
{
// Arrange
$user = $this->createUserWithPermission();
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.weekly-history', [
'organization' => $user->organization,
]));
// Assert
$response->assertStatus(403);
}
public function test_weekly_history_endpoint_returns_chart_data(): void
{
// Arrange
$user = $this->createUserWithPermission(['charts:view:own']);
Passport::actingAs($user->user);
// Act
$response = $this->getJson(route('api.v1.charts.weekly-history', [
'organization' => $user->organization,
]));
// Assert
$response->assertOk();
}
}

View File

@@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
#[UsesClass(DashboardController::class)]
class DashboardEndpointTest extends EndpointTestAbstract
{
public function test_showing_dashboard_succeeds_for_empty_user(): void
public function test_showing_dashboard_succeeds_for_empty_user_with_no_data_entries(): void
{
// Arrange
$user = User::factory()->withPersonalOrganization()->create();
@@ -27,9 +27,30 @@ class DashboardEndpointTest extends EndpointTestAbstract
// Assert
$response->assertSuccessful();
$response->assertInertia(fn (Assert $page) => $page
->has('weeklyProjectOverview')
->has('latestTasks')
->has('lastSevenDays')
->has('latestTeamActivity')
->has('dailyTrackedHours')
->has('totalWeeklyTime')
->has('totalWeeklyBillableTime')
->has('totalWeeklyBillableAmount')
->has('weeklyHistory')
->whereNot('weeklyProjectOverview', null)
->whereNot('latestTasks', null)
->whereNot('lastSevenDays', null)
->whereNot('latestTeamActivity', null)
->whereNot('dailyTrackedHours', null)
->whereNot('totalWeeklyTime', null)
->whereNot('totalWeeklyBillableTime', null)
->whereNot('totalWeeklyBillableAmount', null)
->whereNot('weeklyHistory', null)
->whereNot('latestTeamActivity', null)
);
}
public function test_showing_dashboard_succeeds_for_user_with_employee_role(): void
public function test_showing_dashboard_succeeds_with_less_data_for_user_with_employee_role(): void
{
// Arrange
$organization = Organization::factory()->create();
@@ -42,5 +63,25 @@ class DashboardEndpointTest extends EndpointTestAbstract
// Assert
$response->assertSuccessful();
$response->assertInertia(fn (Assert $page) => $page
->has('weeklyProjectOverview')
->has('latestTasks')
->has('lastSevenDays')
->has('latestTeamActivity')
->has('dailyTrackedHours')
->has('totalWeeklyTime')
->has('totalWeeklyBillableTime')
->has('totalWeeklyBillableAmount')
->has('weeklyHistory')
->whereNot('weeklyProjectOverview', null)
->whereNot('latestTasks', null)
->whereNot('lastSevenDays', null)
->where('latestTeamActivity', null)
->whereNot('dailyTrackedHours', null)
->whereNot('totalWeeklyTime', null)
->whereNot('totalWeeklyBillableTime', null)
->whereNot('totalWeeklyBillableAmount', null)
->whereNot('weeklyHistory', null)
);
}
}

View File

@@ -41,8 +41,7 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
Weekday::Monday,
false,
null,
null,
true
null
);
// Assert
@@ -89,7 +88,6 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
false,
Carbon::now()->subDays(2)->utc(),
Carbon::now()->subDay()->utc(),
true
);
// Assert
@@ -139,91 +137,6 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
], $result);
}
public function test_aggregate_time_entries_without_billable_amounts(): void
{
// Arrange
$project1 = Project::factory()->create([
// Note: To ensure deterministic order
'id' => '5de4e6df-9560-4675-95be-18d42c441bfc',
]);
$project2 = Project::factory()->create([
// Note: To ensure deterministic order
'id' => '130bdf66-d370-4564-aec7-7171e9b415f7',
]);
TimeEntry::factory()->startWithDuration(now(), 10)->forProject($project1)->create([
'description' => 'Test',
]);
TimeEntry::factory()->startWithDuration(now(), 10)->forProject($project2)->create([
'description' => '',
]);
TimeEntry::factory()->startWithDuration(now(), 10)->forProject($project1)->create([
'description' => 'Test',
]);
TimeEntry::factory()->startWithDuration(now(), 10)->forProject($project2)->create([
'description' => 'Test',
]);
$query = TimeEntry::query();
// Act
$result = $this->service->getAggregatedTimeEntries(
$query,
TimeEntryAggregationType::Project,
TimeEntryAggregationType::Description,
'Europe/Vienna',
Weekday::Monday,
false,
Carbon::now()->subDays(2)->utc(),
Carbon::now()->subDay()->utc(),
false
);
// Assert
$this->assertSame([
'seconds' => 40,
'cost' => null,
'grouped_type' => 'project',
'grouped_data' => [
[
'key' => $project2->getKey(),
'seconds' => 20,
'cost' => null,
'grouped_type' => 'description',
'grouped_data' => [
[
'key' => null,
'seconds' => 10,
'cost' => null,
'grouped_type' => null,
'grouped_data' => null,
],
[
'key' => 'Test',
'seconds' => 10,
'cost' => null,
'grouped_type' => null,
'grouped_data' => null,
],
],
],
[
'key' => $project1->getKey(),
'seconds' => 20,
'cost' => null,
'grouped_type' => 'description',
'grouped_data' => [
[
'key' => 'Test',
'seconds' => 20,
'cost' => null,
'grouped_type' => null,
'grouped_data' => null,
],
],
],
],
], $result);
}
public function test_aggregate_time_entries_empty_state_by_day_and_project_with_filled_gaps(): void
{
// Arrange
@@ -240,7 +153,6 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
true,
Carbon::now()->subDays(2)->utc(),
Carbon::now()->subDay()->utc(),
true
);
// Assert
@@ -282,7 +194,6 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
true,
Carbon::now()->subDays(2),
Carbon::now()->subDay(),
true
);
// Assert
@@ -309,7 +220,6 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
true,
Carbon::now()->subDays(2),
Carbon::now()->subDay(),
true
);
// Assert
@@ -344,8 +254,7 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
Weekday::Monday,
false,
null,
null,
true
null
);
// Assert
@@ -433,8 +342,7 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
Weekday::Monday,
true,
null,
null,
true
null
);
// Assert