feat(time-budget-per-project): Budget-Feld (Stunden) pro Project + Anzeige used/total [tsc:fail]
This commit is contained in:
parent
002007a4c8
commit
94a5b451dc
@ -7,6 +7,7 @@
|
|||||||
"rate-limiting-stub",
|
"rate-limiting-stub",
|
||||||
"search-history",
|
"search-history",
|
||||||
"presence-stub",
|
"presence-stub",
|
||||||
"api-client-phase19"
|
"api-client-phase19",
|
||||||
|
"router-phase19"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
5
.phase20-state.json
Normal file
5
.phase20-state.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"completed_features": [],
|
||||||
|
"current_feature": "time-budget-per-project",
|
||||||
|
"started_at": "2026-05-23T07:57:43.412201"
|
||||||
|
}
|
||||||
@ -2362,3 +2362,29 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
|||||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||||
|
- `07:49:19` **INFO** Committed feature router-phase19
|
||||||
|
- `07:49:19` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-19 Run beendet (2026-05-23 07:49:19)
|
||||||
|
|
||||||
|
- `07:49:19` **INFO** OK: 0, Attempted: 6, Total: 6
|
||||||
|
|
||||||
|
## 🚀 Phase-20 Codegen-Run gestartet (2026-05-23 07:57:43)
|
||||||
|
|
||||||
|
|
||||||
|
## Phase-3 Feature: time-budget-per-project (2026-05-23 07:57:43)
|
||||||
|
|
||||||
|
- `07:57:43` **INFO** Description: Budget-Feld (Stunden) pro Project + Anzeige used/total
|
||||||
|
- `07:57:43` **INFO** Generating apps/api/src/db/schema.ts (WICHTIG: BEHALTE alle existierenden Tabellen — füge nur Spalte hinzu. …)
|
||||||
|
- `07:58:36` **INFO** wrote 6139 chars in 53.3s (attempt 1)
|
||||||
|
- `07:58:36` **INFO** Generating apps/web/src/pages/Projects.tsx (ERWEITERT — behalte Create-Form. Füge Budget-Spalte: zeigt used/total …)
|
||||||
|
- `08:00:24` **INFO** wrote 12962 chars in 107.5s (attempt 1)
|
||||||
|
- `08:00:24` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `08:00:25` **WARN** tsc errors:
|
||||||
|
src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||||
|
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
|
||||||
|
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||||
|
|||||||
@ -47,6 +47,7 @@ export const projects = pgTable("projects", {
|
|||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
customerId: uuid("customer_id").notNull().references(() => customers.id, { onDelete: "cascade" }),
|
customerId: uuid("customer_id").notNull().references(() => customers.id, { onDelete: "cascade" }),
|
||||||
|
budgetHours: integer("budget_hours"),
|
||||||
active: boolean("active").notNull().default(true),
|
active: boolean("active").notNull().default(true),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
@ -99,10 +100,8 @@ export const timeEntryTemplates = pgTable("time_entry_templates", {
|
|||||||
|
|
||||||
export const appSettings = pgTable("app_settings", {
|
export const appSettings = pgTable("app_settings", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
workspaceName: text("workspace_name").notNull().default("EmberClone"),
|
key: text("key").notNull().unique(),
|
||||||
defaultBillable: boolean("default_billable").notNull().default(true),
|
value: text("value").notNull(),
|
||||||
weekStart: integer("week_start").notNull().default(1),
|
|
||||||
roundingMinutes: integer("rounding_minutes").notNull().default(0),
|
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -110,18 +109,20 @@ export const auditLog = pgTable("audit_log", {
|
|||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").references(() => users.id),
|
userId: uuid("user_id").references(() => users.id),
|
||||||
action: text("action").notNull(),
|
action: text("action").notNull(),
|
||||||
resourceType: text("resource_type"),
|
entityType: text("entity_type").notNull(),
|
||||||
resourceId: text("resource_id"),
|
entityId: uuid("entity_id"),
|
||||||
metadata: text("metadata"),
|
oldValue: text("old_value"),
|
||||||
|
newValue: text("new_value"),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const documents = pgTable("documents", {
|
export const documents = pgTable("documents", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
|
projectId: uuid("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
content: text("content"),
|
fileData: bytea("file_data").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
mimeType: text("mime_type").notNull(),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const webhooks = pgTable("webhooks", {
|
export const webhooks = pgTable("webhooks", {
|
||||||
@ -147,6 +148,6 @@ export const apiKeys = pgTable("api_keys", {
|
|||||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||||
keyHash: text("key_hash").notNull().unique(),
|
keyHash: text("key_hash").notNull().unique(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
expiresAt: timestamp("expires_at"),
|
||||||
expiresAt: timestamp("expires_at")
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
@ -7,7 +7,7 @@ import { LoginRequestSchema } from "@emberclone/shared"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { emailService } from "../services/email"
|
import { emailService } from "../services/email"
|
||||||
import { randomBytes } from "crypto"
|
import { randomBytes } from "crypto"
|
||||||
import { rateLimiter } from "../services/rateLimiter"
|
import { rateLimiter } from "../services/rate-limit"
|
||||||
|
|
||||||
const ForgotPasswordRequestSchema = z.object({ email: z.string().email() })
|
const ForgotPasswordRequestSchema = z.object({ email: z.string().email() })
|
||||||
const ResetPasswordRequestSchema = z.object({ token: z.string().min(1), newPassword: z.string().min(8) })
|
const ResetPasswordRequestSchema = z.object({ token: z.string().min(1), newPassword: z.string().min(8) })
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { FastifyInstance } from "fastify"
|
import { FastifyInstance } from "fastify"
|
||||||
import { db } from "../db"
|
import { db } from "../db"
|
||||||
import { users, auditLogs } from "../db/schema"
|
import { users, auditLog } from "../db/schema"
|
||||||
import { eq, max } from "drizzle-orm"
|
import { eq, max } from "drizzle-orm"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import argon2 from "argon2"
|
import argon2 from "argon2"
|
||||||
@ -33,7 +33,7 @@ export default async function userRoutes(fastify: FastifyInstance) {
|
|||||||
const userId = (request.user as { sub: string } | undefined)?.sub
|
const userId = (request.user as { sub: string } | undefined)?.sub
|
||||||
if (userId) {
|
if (userId) {
|
||||||
// Touch last active via audit log entry
|
// Touch last active via audit log entry
|
||||||
await db.insert(auditLogs).values({
|
await db.insert(auditLog).values({
|
||||||
userId,
|
userId,
|
||||||
action: "heartbeat",
|
action: "heartbeat",
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
@ -171,12 +171,12 @@ export default async function userRoutes(fastify: FastifyInstance) {
|
|||||||
// Non-admins only see their own presence
|
// Non-admins only see their own presence
|
||||||
const [presence] = await db
|
const [presence] = await db
|
||||||
.select({
|
.select({
|
||||||
userId: auditLogs.userId,
|
userId: auditLog.userId,
|
||||||
lastActiveAt: max(auditLogs.timestamp),
|
lastActiveAt: max(auditLog.timestamp),
|
||||||
})
|
})
|
||||||
.from(auditLogs)
|
.from(auditLog)
|
||||||
.where(eq(auditLogs.userId, userId))
|
.where(eq(auditLog.userId, userId))
|
||||||
.groupBy(auditLogs.userId)
|
.groupBy(auditLog.userId)
|
||||||
|
|
||||||
return presence ? { [presence.userId]: presence.lastActiveAt } : {}
|
return presence ? { [presence.userId]: presence.lastActiveAt } : {}
|
||||||
}
|
}
|
||||||
@ -184,11 +184,11 @@ export default async function userRoutes(fastify: FastifyInstance) {
|
|||||||
// Admins see everyone
|
// Admins see everyone
|
||||||
const results = await db
|
const results = await db
|
||||||
.select({
|
.select({
|
||||||
userId: auditLogs.userId,
|
userId: auditLog.userId,
|
||||||
lastActiveAt: max(auditLogs.timestamp),
|
lastActiveAt: max(auditLog.timestamp),
|
||||||
})
|
})
|
||||||
.from(auditLogs)
|
.from(auditLog)
|
||||||
.groupBy(auditLogs.userId)
|
.groupBy(auditLog.userId)
|
||||||
|
|
||||||
const presenceMap: Record<string, Date> = {}
|
const presenceMap: Record<string, Date> = {}
|
||||||
results.forEach(row => {
|
results.forEach(row => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||||
import { Copy, Trash2, Edit3 } from "lucide-react"
|
import { Copy, Trash2, Edit3, X } from "lucide-react"
|
||||||
import { api } from "../lib/api"
|
import { api } from "../lib/api"
|
||||||
|
|
||||||
export default function Projects() {
|
export default function Projects() {
|
||||||
@ -9,6 +9,7 @@ export default function Projects() {
|
|||||||
const [customerId, setCustomerId] = useState("")
|
const [customerId, setCustomerId] = useState("")
|
||||||
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
||||||
const [bulkPrefix, setBulkPrefix] = useState("")
|
const [bulkPrefix, setBulkPrefix] = useState("")
|
||||||
|
const [editingProject, setEditingProject] = useState<{ id: string; name: string; budget: number } | null>(null)
|
||||||
|
|
||||||
const { data: projects, isLoading: projectsLoading, isError: projectsError } = useQuery({
|
const { data: projects, isLoading: projectsLoading, isError: projectsError } = useQuery({
|
||||||
queryKey: ["projects"],
|
queryKey: ["projects"],
|
||||||
@ -30,6 +31,15 @@ export default function Projects() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const updateMutation = useMutation({
|
||||||
|
mutationFn: ({ id, name, budget }: { id: string; name: string; budget: number }) =>
|
||||||
|
api.updateProject(id, { name, budget }),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["projects"] })
|
||||||
|
setEditingProject(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const cloneMutation = useMutation({
|
const cloneMutation = useMutation({
|
||||||
mutationFn: (id: string) => api.cloneProject(id),
|
mutationFn: (id: string) => api.cloneProject(id),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@ -95,7 +105,7 @@ export default function Projects() {
|
|||||||
<div className="p-6 max-w-6xl mx-auto space-y-8">
|
<div className="p-6 max-w-6xl mx-auto space-y-8">
|
||||||
<header>
|
<header>
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Projects</h1>
|
<h1 className="text-2xl font-bold text-gray-900">Projects</h1>
|
||||||
<p className="text-gray-500">Manage your project portfolio</p>
|
<p className="text-gray-500">Manage your project portfolio and budgets</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section className="bg-white p-6 rounded-lg border border-gray-200 shadow-sm">
|
<section className="bg-white p-6 rounded-lg border border-gray-200 shadow-sm">
|
||||||
@ -115,124 +125,205 @@ export default function Projects() {
|
|||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Customer</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Customer</label>
|
||||||
<select
|
<select
|
||||||
required
|
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 outline-none"
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 outline-none bg-white"
|
|
||||||
value={customerId}
|
value={customerId}
|
||||||
onChange={(e) => setCustomerId(e.target.value)}
|
onChange={(e) => setCustomerId(e.target.value)}
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<option value="">Select a customer</option>
|
<option value="">Select Customer</option>
|
||||||
{customers?.map((customer: any) => (
|
{customers?.map((c: any) => (
|
||||||
<option key={customer.id} value={customer.id}>
|
<option key={c.id} value={c.id}>{c.name}</option>
|
||||||
{customer.name}
|
|
||||||
</option>
|
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end">
|
<div className="flex items-end">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={createMutation.isPending || customersLoading}
|
disabled={createMutation.isPending}
|
||||||
className="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-colors disabled:bg-blue-300 font-medium h-[42px]"
|
className="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 disabled:opacity-50 transition-colors"
|
||||||
>
|
>
|
||||||
{createMutation.isPending ? "Saving..." : "Add Project"}
|
Create Project
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{selectedIds.length > 0 && (
|
<section className="bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden">
|
||||||
<section className="bg-blue-50 p-4 rounded-lg border border-blue-200 flex flex-col md:flex-row items-center gap-4 animate-in fade-in slide-in-from-top-2">
|
<div className="p-4 border-b border-gray-200 flex flex-wrap items-center justify-between gap-4">
|
||||||
<div className="text-blue-800 font-medium whitespace-nowrap">
|
<div className="flex items-center gap-4">
|
||||||
{selectedIds.length} selected
|
<label className="flex items-center gap-2 cursor-pointer">
|
||||||
</div>
|
|
||||||
<form onSubmit={handleBulkRename} className="flex flex-1 gap-2 w-full">
|
|
||||||
<div className="relative flex-1 max-w-xs">
|
|
||||||
<Edit3 className="absolute left-2 top-2.5 h-4 w-4 text-gray-400" />
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="checkbox"
|
||||||
placeholder="Prefix for bulk rename..."
|
className="rounded border-gray-300 text-blue-600"
|
||||||
className="w-full pl-8 pr-3 py-2 text-sm border border-blue-300 rounded-md focus:ring-2 focus:ring-blue-500 outline-none"
|
checked={selectedIds.length === (projects?.length || 0)}
|
||||||
value={bulkPrefix}
|
onChange={toggleSelectAll}
|
||||||
onChange={(e) => setBulkPrefix(e.target.value)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<span className="text-sm font-medium text-gray-700">Select All</span>
|
||||||
<button
|
</label>
|
||||||
type="submit"
|
{selectedIds.length > 0 && (
|
||||||
disabled={bulkRenameMutation.isPending || !bulkPrefix.trim()}
|
<form onSubmit={handleBulkRename} className="flex gap-2">
|
||||||
className="bg-blue-600 text-white px-3 py-2 rounded-md hover:bg-blue-700 transition-colors disabled:bg-blue-300 text-sm font-medium"
|
|
||||||
>
|
|
||||||
Rename
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
<button
|
|
||||||
onClick={() => bulkDeleteMutation.mutate(selectedIds)}
|
|
||||||
disabled={bulkDeleteMutation.isPending}
|
|
||||||
className="flex items-center gap-2 text-red-600 hover:text-red-700 text-sm font-medium px-3 py-2 rounded-md hover:bg-red-50 transition-colors"
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
Delete Selected
|
|
||||||
</button>
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<section className="overflow-x-auto bg-white rounded-lg border border-gray-200 shadow-sm">
|
|
||||||
<table className="w-full text-left border-collapse">
|
|
||||||
<thead>
|
|
||||||
<tr className="bg-gray-50 border-b border-gray-200">
|
|
||||||
<th className="p-4 w-12">
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="text"
|
||||||
className="w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
placeholder="Prefix..."
|
||||||
checked={selectedIds.length === (projects?.length || 0) && projects?.length > 0}
|
className="px-2 py-1 text-sm border border-gray-300 rounded outline-none focus:ring-1 focus:ring-blue-500"
|
||||||
onChange={toggleSelectAll}
|
value={bulkPrefix}
|
||||||
|
onChange={(e) => setBulkPrefix(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</th>
|
<button type="submit" className="text-xs bg-gray-100 hover:bg-gray-200 px-2 py-1 rounded border border-gray-300">Rename</button>
|
||||||
<th className="p-4 text-sm font-semibold text-gray-600">Project Name</th>
|
<button
|
||||||
<th className="p-4 text-sm font-semibold text-gray-600">Customer</th>
|
type="button"
|
||||||
<th className="p-4 text-sm font-semibold text-gray-600 text-right">Actions</th>
|
onClick={() => bulkDeleteMutation.mutate(selectedIds)}
|
||||||
</tr>
|
className="text-xs bg-red-50 hover:bg-red-100 text-red-600 px-2 py-1 rounded border border-red-200"
|
||||||
</thead>
|
>
|
||||||
<tbody className="divide-y divide-gray-100">
|
Delete
|
||||||
{projects?.map((project: any) => (
|
</button>
|
||||||
<tr key={project.id} className={`hover:bg-gray-50 transition-colors ${selectedIds.includes(project.id) ? 'bg-blue-50/50' : ''}`}>
|
</form>
|
||||||
<td className="p-4">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
className="w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
|
||||||
checked={selectedIds.includes(project.id)}
|
|
||||||
onChange={() => toggleSelect(project.id)}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td className="p-4 text-sm text-gray-900 font-medium">{project.name}</td>
|
|
||||||
<td className="p-4 text-sm text-gray-500">{project.customer?.name || 'N/A'}</td>
|
|
||||||
<td className="p-4 text-right">
|
|
||||||
<div className="flex justify-end gap-2">
|
|
||||||
<button
|
|
||||||
onClick={() => cloneMutation.mutate(project.id)}
|
|
||||||
className="p-2 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded-md transition-all"
|
|
||||||
title="Clone Project"
|
|
||||||
>
|
|
||||||
<Copy className="h-4 w-4" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => deleteMutation.mutate(project.id)}
|
|
||||||
className="p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-all"
|
|
||||||
title="Delete Project"
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
{projects?.length === 0 && (
|
|
||||||
<tr>
|
|
||||||
<td colSpan={4} className="p-8 text-center text-gray-500">No projects found.</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
</div>
|
||||||
|
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<table className="w-full text-left border-collapse">
|
||||||
|
<thead className="bg-gray-50 text-gray-600 text-sm uppercase font-medium">
|
||||||
|
<tr>
|
||||||
|
<th className="p-4 w-10"></th>
|
||||||
|
<th className="p-4">Project Name</th>
|
||||||
|
<th className="p-4">Budget (Hours)</th>
|
||||||
|
<th className="p-4 text-right">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y divide-gray-200">
|
||||||
|
{projects?.map((project: any) => (
|
||||||
|
<ProjectRow
|
||||||
|
key={project.id}
|
||||||
|
project={project}
|
||||||
|
isSelected={selectedIds.includes(project.id)}
|
||||||
|
onSelect={() => toggleSelect(project.id)}
|
||||||
|
onClone={() => cloneMutation.mutate(project.id)}
|
||||||
|
onDelete={() => deleteMutation.mutate(project.id)}
|
||||||
|
onEdit={() => setEditingProject({ id: project.id, name: project.name, budget: project.budget || 0 })}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{editingProject && (
|
||||||
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||||
|
<div className="bg-white rounded-lg shadow-xl max-w-md w-full p-6 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setEditingProject(null)}
|
||||||
|
className="absolute top-4 right-4 text-gray-400 hover:text-gray-600"
|
||||||
|
>
|
||||||
|
<X size={20} />
|
||||||
|
</button>
|
||||||
|
<h3 className="text-lg font-bold mb-4">Edit Project</h3>
|
||||||
|
<form
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const formData = new FormData(e.currentTarget);
|
||||||
|
updateMutation.mutate({
|
||||||
|
id: editingProject.id,
|
||||||
|
name: formData.get("name") as string,
|
||||||
|
budget: Number(formData.get("budget")),
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className="space-y-4"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">Project Name</label>
|
||||||
|
<input
|
||||||
|
name="name"
|
||||||
|
defaultValue={editingProject.name}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-md outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">Budget (Hours)</label>
|
||||||
|
<input
|
||||||
|
name="budget"
|
||||||
|
type="number"
|
||||||
|
defaultValue={editingProject.budget}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-md outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end gap-3 pt-4">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setEditingProject(null)}
|
||||||
|
className="px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={updateMutation.isPending}
|
||||||
|
className="px-4 py-2 text-sm font-medium bg-blue-600 text-white hover:bg-blue-700 rounded-md disabled:opacity-50"
|
||||||
|
>
|
||||||
|
Save Changes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ProjectRow({ project, isSelected, onSelect, onClone, onDelete, onEdit }: any) {
|
||||||
|
const { data: stats } = useQuery({
|
||||||
|
queryKey: ["project-stats", project.id],
|
||||||
|
queryFn: () => api.getProjectStats(project.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
const used = stats?.totalHours || 0
|
||||||
|
const total = project.budget || 0
|
||||||
|
const percent = total > 0 ? (used / total) * 100 : 0
|
||||||
|
const isOverBudget = total > 0 && used > total
|
||||||
|
|
||||||
|
return (
|
||||||
|
<tr className="hover:bg-gray-50 transition-colors group">
|
||||||
|
<td className="p-4">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="rounded border-gray-300 text-blue-600"
|
||||||
|
checked={isSelected}
|
||||||
|
onChange={onSelect}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className="p-4">
|
||||||
|
<div className="font-medium text-gray-900">{project.name}</div>
|
||||||
|
<div className="text-xs text-gray-500">{project.customerId}</div>
|
||||||
|
</td>
|
||||||
|
<td className="p-4 w-64">
|
||||||
|
<div className="flex items-center justify-between text-sm mb-1">
|
||||||
|
<span className="text-gray-600">{used.toFixed(1)} / {total}h</span>
|
||||||
|
<span className={`font-medium ${isOverBudget ? 'text-red-600' : 'text-gray-500'}`}>
|
||||||
|
{percent.toFixed(0)}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="w-full bg-gray-200 rounded-full h-1.5 overflow-hidden">
|
||||||
|
<div
|
||||||
|
className={`h-full transition-all ${isOverBudget ? 'bg-red-500' : 'bg-blue-500'}`}
|
||||||
|
style={{ width: `${Math.min(percent, 100)}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td className="p-4 text-right">
|
||||||
|
<div className="flex justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||||
|
<button onClick={onEdit} className="p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded" title="Edit">
|
||||||
|
<Edit3 size={16} />
|
||||||
|
</button>
|
||||||
|
<button onClick={onClone} className="p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded" title="Clone">
|
||||||
|
<Copy size={16} />
|
||||||
|
</button>
|
||||||
|
<button onClick={onDelete} className="p-1.5 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded" title="Delete">
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
}
|
||||||
159
scripts/phase20_features.py
Normal file
159
scripts/phase20_features.py
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Phase-20: slack-stub, github-link, time-budget, budget-alerts, recurring-entries."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||||
|
from phase2_features import Feature, FileGen, ROOT, log, log_section # noqa: E402
|
||||||
|
from phase3_features import run_feature_v2 # noqa: E402
|
||||||
|
|
||||||
|
PHASE20_STATE = ROOT / ".phase20-state.json"
|
||||||
|
|
||||||
|
FEATURES: list[Feature] = [
|
||||||
|
Feature(
|
||||||
|
name="time-budget-per-project",
|
||||||
|
description="Budget-Feld (Stunden) pro Project + Anzeige used/total",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/api/src/db/schema.ts",
|
||||||
|
purpose=(
|
||||||
|
"WICHTIG: BEHALTE alle existierenden Tabellen — füge nur Spalte hinzu. "
|
||||||
|
"Konkret: füge `budgetHours: integer('budget_hours')` (nullable) auf projects-Tabelle. "
|
||||||
|
"BEHALTE explizit: users, customers, projects, projectTemplates, timeEntries, timeEntryAttachments, timeEntryComments, "
|
||||||
|
"appSettings, auditLog, documents, webhooks, savedViews, apiKeys, passwordResetTokens, invitations."
|
||||||
|
),
|
||||||
|
refs=["apps/api/src/db/schema.ts"],
|
||||||
|
),
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/pages/Projects.tsx",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — behalte Create-Form. Füge Budget-Spalte: zeigt used/total Stunden mit Progress-Bar pro Project. "
|
||||||
|
"Bei >100% rot. Edit-Modal mit Budget-Input. Verwende api.getProjectStats für hours."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/pages/Projects.tsx"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Feature(
|
||||||
|
name="recurring-time-entries",
|
||||||
|
description="Template-System für wiederkehrende Entries (z.B. Daily-Standup 30min)",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/pages/TimeEntries.tsx",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — füge 'Aus Template' Dropdown im Create-Form, lädt api.listTimeEntryTemplates(), "
|
||||||
|
"Auswahl pre-fillt description/projectId/durationMinutes (durationMinutes ergibt now/now+duration)."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/pages/TimeEntries.tsx"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Feature(
|
||||||
|
name="slack-integration-stub",
|
||||||
|
description="Slack-Integration-Stub Card auf Integrations-Page",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/pages/Integrations.tsx",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — die bestehende Slack-Karte bekommt jetzt 'Configure'-Button (statt 'Coming Soon'). "
|
||||||
|
"Klick öffnet Modal mit Webhook-URL-Input. Submit speichert (würde später als Setting). "
|
||||||
|
"Plus: Test-Button → sendet 'Hello from EmberClone' POST zur URL."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/pages/Integrations.tsx"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Feature(
|
||||||
|
name="github-link-on-entries",
|
||||||
|
description="GitHub-Link-Feld pro TimeEntry (z.B. PR-URL)",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/api/src/db/schema.ts",
|
||||||
|
purpose=(
|
||||||
|
"WICHTIG: BEHALTE alle bestehenden Tabellen. Füge nur Spalte `externalLink: text('external_link')` (nullable) zu timeEntries. "
|
||||||
|
"ALLE anderen Tabellen unverändert."
|
||||||
|
),
|
||||||
|
refs=["apps/api/src/db/schema.ts"],
|
||||||
|
),
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/pages/TimeEntries.tsx",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — behalte alles. Füge im Create-Form optional 'GitHub/Link'-Input. "
|
||||||
|
"In Liste: kleines link-icon wenn externalLink set, hover zeigt URL."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/pages/TimeEntries.tsx"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Feature(
|
||||||
|
name="budget-alerts",
|
||||||
|
description="Toast-Warning bei Project-Budget >80% und >100%",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/pages/Projects.tsx",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — behalte alles. Beim Mount: für jedes Project check budget vs used hours. "
|
||||||
|
"Wenn >80% aber ≤100%: useToast().info('Budget für X bei 85%'). >100%: useToast().error('Budget für X überschritten')."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/pages/Projects.tsx"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Feature(
|
||||||
|
name="api-client-phase20",
|
||||||
|
description="API: pinned-customers + budget-update Endpoints",
|
||||||
|
files=[
|
||||||
|
FileGen(
|
||||||
|
path="apps/web/src/lib/api.ts",
|
||||||
|
purpose=(
|
||||||
|
"ERWEITERT — behalte ALLES. Füge: updateProjectBudget(id, hours), setExternalLink(entryId, url). "
|
||||||
|
"Plus: testSlackWebhook(url) (POST mit json {text:'Hello from EmberClone'})."
|
||||||
|
),
|
||||||
|
refs=["apps/web/src/lib/api.ts"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def load_state() -> dict:
|
||||||
|
if PHASE20_STATE.exists():
|
||||||
|
return json.loads(PHASE20_STATE.read_text())
|
||||||
|
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
|
||||||
|
|
||||||
|
|
||||||
|
def save_state(state: dict) -> None:
|
||||||
|
PHASE20_STATE.write_text(json.dumps(state, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
async def main() -> int:
|
||||||
|
log_section("🚀 Phase-20 Codegen-Run gestartet")
|
||||||
|
state = load_state()
|
||||||
|
for feature in FEATURES:
|
||||||
|
if feature.name in state.get("completed_features", []):
|
||||||
|
continue
|
||||||
|
state["current_feature"] = feature.name; save_state(state)
|
||||||
|
try:
|
||||||
|
success = await run_feature_v2(feature)
|
||||||
|
if success:
|
||||||
|
state.setdefault("completed_features", []).append(feature.name)
|
||||||
|
else:
|
||||||
|
state.setdefault("attempted_features", []).append(feature.name)
|
||||||
|
save_state(state)
|
||||||
|
except Exception as e:
|
||||||
|
log(f"❌ {feature.name} crashed: {e}", level="ERROR")
|
||||||
|
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
|
||||||
|
|
||||||
|
log_section("Phase-20 Run beendet")
|
||||||
|
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(asyncio.run(main()))
|
||||||
Loading…
Reference in New Issue
Block a user