diff options
| author | ivar <i@oiee.no> | 2024-04-28 22:37:30 +0200 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2024-04-28 22:37:30 +0200 |
| commit | ced66c5807575cd29f6aa5632e8ad02b38c8448a (patch) | |
| tree | 01760648ee293a2aef2288328014b5747d2192b4 /code/frontend/src/models | |
| parent | 691ad60d7bff5934053d87267c4e303ef3ed5f97 (diff) | |
| download | greatoffice-ced66c5807575cd29f6aa5632e8ad02b38c8448a.tar.xz greatoffice-ced66c5807575cd29f6aa5632e8ad02b38c8448a.zip | |
WIP new frontend
Diffstat (limited to 'code/frontend/src/models')
21 files changed, 229 insertions, 0 deletions
diff --git a/code/frontend/src/models/base/Customer.ts b/code/frontend/src/models/base/Customer.ts new file mode 100644 index 0000000..ff52fbd --- /dev/null +++ b/code/frontend/src/models/base/Customer.ts @@ -0,0 +1,21 @@ +import type {CustomerContact} from "./CustomerContact"; +import type {User} from "./User"; + +export type Customer = { + /** + * Guid id for customer + */ + id: string, + /** + * The name of the company + */ + name: string, + /** + * Responsible contact in the current tenant + */ + tenantContact: User, + /** + * The customers main contact + */ + mainContact: CustomerContact, +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/CustomerContact.ts b/code/frontend/src/models/base/CustomerContact.ts new file mode 100644 index 0000000..e8abea5 --- /dev/null +++ b/code/frontend/src/models/base/CustomerContact.ts @@ -0,0 +1,8 @@ +export type CustomerContact = { + firstName: string, + lastname: string, + email: string, + phone: string, + workTitle: string, + note: string +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/CustomerEvent.ts b/code/frontend/src/models/base/CustomerEvent.ts new file mode 100644 index 0000000..af86511 --- /dev/null +++ b/code/frontend/src/models/base/CustomerEvent.ts @@ -0,0 +1,6 @@ +export type CustomerEvent = { + /** + * A descriptive name for the occured event + */ + name: string, +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/SessionData.ts b/code/frontend/src/models/base/SessionData.ts new file mode 100644 index 0000000..015cbf3 --- /dev/null +++ b/code/frontend/src/models/base/SessionData.ts @@ -0,0 +1,5 @@ +export type SessionData = { + id: string, + username: string, + displayName: string, +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/Tenant.ts b/code/frontend/src/models/base/Tenant.ts new file mode 100644 index 0000000..6307efc --- /dev/null +++ b/code/frontend/src/models/base/Tenant.ts @@ -0,0 +1,8 @@ +import type {User} from "./User"; + +export type Tenant = { + id: string, + name: string, + description: string, + masterUser: User, +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/User.ts b/code/frontend/src/models/base/User.ts new file mode 100644 index 0000000..2b74d0e --- /dev/null +++ b/code/frontend/src/models/base/User.ts @@ -0,0 +1,13 @@ +import type {UserRole} from "./UserRole"; + +export type User = { + /** + * Guid id for user + */ + id: string, + firstName: string, + lastName: string, + role: UserRole, + username: string, + email: string +}
\ No newline at end of file diff --git a/code/frontend/src/models/base/UserRole.ts b/code/frontend/src/models/base/UserRole.ts new file mode 100644 index 0000000..ec32852 --- /dev/null +++ b/code/frontend/src/models/base/UserRole.ts @@ -0,0 +1,5 @@ +export enum UserRole { + REGULAR = "reg", + ADMINISTRATOR = "adm", + OWNER = "own" +}
\ No newline at end of file diff --git a/code/frontend/src/models/internal/FormError.ts b/code/frontend/src/models/internal/FormError.ts new file mode 100644 index 0000000..f6d8978 --- /dev/null +++ b/code/frontend/src/models/internal/FormError.ts @@ -0,0 +1,24 @@ +import type { KnownProblem } from "./KnownProblem"; + +export class FormError { + title: string; + subtitle: string; + constructor(title: string = "", subtitle: string = "") { + this.title = title; + this.title = subtitle; + } + + set(title: string = "", subtitle: string = "") { + this.title = title; + this.subtitle = subtitle; + } + + set_from_known_problem(knownProblem: KnownProblem) { + this.title = knownProblem.title ?? ""; + this.subtitle = knownProblem.subtitle ?? ""; + } + + has_error() { + return this.title?.length > 0 || this.subtitle?.length > 0; + } +}
\ No newline at end of file diff --git a/code/frontend/src/models/internal/IForm.ts b/code/frontend/src/models/internal/IForm.ts new file mode 100644 index 0000000..c14b770 --- /dev/null +++ b/code/frontend/src/models/internal/IForm.ts @@ -0,0 +1,15 @@ +import type { FormError } from "./FormError"; + +export interface IForm { + fields: Record<string, IFormField>; + error: FormError; + get_payload: Function; + submit_async: Function; + isLoading: boolean; + showError: boolean; +} + +export interface IFormField { + value: any; + errors: Array<string>; +} diff --git a/code/frontend/src/models/internal/KnownProblem.ts b/code/frontend/src/models/internal/KnownProblem.ts new file mode 100644 index 0000000..b6923d9 --- /dev/null +++ b/code/frontend/src/models/internal/KnownProblem.ts @@ -0,0 +1,10 @@ +export type KnownProblem = { + title: string, + subtitle: string, + errors: Record<string, string[]>, + traceId: string, +} + +export function is_known_problem(response: Response): boolean { + return response.headers.has("X-IsKnownProblem"); +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/Project.ts b/code/frontend/src/models/projects/Project.ts new file mode 100644 index 0000000..f265e67 --- /dev/null +++ b/code/frontend/src/models/projects/Project.ts @@ -0,0 +1,13 @@ +import type { Temporal } from "temporal-polyfill" +import type { ProjectMember } from "./ProjectMember" +import type { ProjectStatus } from "./ProjectStatus" + +export type Project = { + id: string, + name: string, + description?: string, + start: Temporal.PlainDate, + stop?: Temporal.PlainDate, + members: Array<ProjectMember>, + status: ProjectStatus +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/ProjectLabel.ts b/code/frontend/src/models/projects/ProjectLabel.ts new file mode 100644 index 0000000..59aa9d5 --- /dev/null +++ b/code/frontend/src/models/projects/ProjectLabel.ts @@ -0,0 +1,5 @@ +export type ProjectLabel = { + id: string, + name: string, + color: string +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/ProjectMember.ts b/code/frontend/src/models/projects/ProjectMember.ts new file mode 100644 index 0000000..de348ef --- /dev/null +++ b/code/frontend/src/models/projects/ProjectMember.ts @@ -0,0 +1,10 @@ +import type { ProjectRole } from "./ProjectRole" + +export type ProjectMember = { + id: string, + name: string, + role: ProjectRole, + email: string, + userId?: string, + customerId?: string +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/ProjectMeta.ts b/code/frontend/src/models/projects/ProjectMeta.ts new file mode 100644 index 0000000..c583b47 --- /dev/null +++ b/code/frontend/src/models/projects/ProjectMeta.ts @@ -0,0 +1,7 @@ +import type { Temporal } from "temporal-polyfill" +import type { User } from "../base/User" + +export type ProjectMeta = { + created: Temporal.PlainDateTime, + createdBy: User, +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/ProjectRole.ts b/code/frontend/src/models/projects/ProjectRole.ts new file mode 100644 index 0000000..0fa2347 --- /dev/null +++ b/code/frontend/src/models/projects/ProjectRole.ts @@ -0,0 +1,7 @@ +export enum ProjectRole { + EXTERNAL = "ext", + INTERNAL = "int", + RESOURCE = "res", + MANAGER = "man", + OWNER = "own" +}
\ No newline at end of file diff --git a/code/frontend/src/models/projects/ProjectStatus.ts b/code/frontend/src/models/projects/ProjectStatus.ts new file mode 100644 index 0000000..2df4b88 --- /dev/null +++ b/code/frontend/src/models/projects/ProjectStatus.ts @@ -0,0 +1,5 @@ +export enum ProjectStatus { + ACTIVE = "act", + EXPIRED = "exp", + IDLE = "idl" +}
\ No newline at end of file diff --git a/code/frontend/src/models/work/WorkCategory.ts b/code/frontend/src/models/work/WorkCategory.ts new file mode 100644 index 0000000..7dd85d5 --- /dev/null +++ b/code/frontend/src/models/work/WorkCategory.ts @@ -0,0 +1,5 @@ +export type WorkCategory = { + id: string, + name: string, + color: string +} diff --git a/code/frontend/src/models/work/WorkEntry.ts b/code/frontend/src/models/work/WorkEntry.ts new file mode 100644 index 0000000..2108b88 --- /dev/null +++ b/code/frontend/src/models/work/WorkEntry.ts @@ -0,0 +1,13 @@ +import type { WorkLabel } from "./WorkLabel"; +import type { WorkCategory } from "./WorkCategory"; +import type { Project } from "../projects/Project"; + +export type WorkEntry = { + id: string, + start: string, + stop: string, + description: string, + labels?: Array<WorkLabel>, + category?: WorkCategory, + project?: Project +} diff --git a/code/frontend/src/models/work/WorkEntryQueryResponse.ts b/code/frontend/src/models/work/WorkEntryQueryResponse.ts new file mode 100644 index 0000000..a6974f1 --- /dev/null +++ b/code/frontend/src/models/work/WorkEntryQueryResponse.ts @@ -0,0 +1,27 @@ +import type { WorkCategory } from "./WorkCategory"; +import type { WorkLabel } from "./WorkLabel"; +import type { Temporal } from "temporal-polyfill"; + +export interface WorkEntryQueryResponse { + duration: WorkEntryQueryDuration, + categories?: Array<WorkCategory>, + labels?: Array<WorkLabel>, + dateRange?: WorkEntryQueryDateRange, + specificDate?: Temporal.PlainDateTime + page: number, + pageSize: number +} + +export interface WorkEntryQueryDateRange { + from: Temporal.PlainDateTime, + to: Temporal.PlainDateTime +} + +export enum WorkEntryQueryDuration { + TODAY = 0, + THIS_WEEK = 1, + THIS_MONTH = 2, + THIS_YEAR = 3, + SPECIFIC_DATE = 4, + DATE_RANGE = 5, +} diff --git a/code/frontend/src/models/work/WorkLabel.ts b/code/frontend/src/models/work/WorkLabel.ts new file mode 100644 index 0000000..f7e2795 --- /dev/null +++ b/code/frontend/src/models/work/WorkLabel.ts @@ -0,0 +1,5 @@ +export interface WorkLabel { + id?: string, + name?: string, + color?: string +} diff --git a/code/frontend/src/models/work/WorkQuery.ts b/code/frontend/src/models/work/WorkQuery.ts new file mode 100644 index 0000000..93b0aa4 --- /dev/null +++ b/code/frontend/src/models/work/WorkQuery.ts @@ -0,0 +1,17 @@ +import type {WorkEntry} from "./WorkEntry"; + +export interface IWorkQuery { + results: Array<WorkEntry>, + page: number, + pageSize: number, + totalRecords: number, + totalPageCount: number, +} + +export class WorkQuery implements IWorkQuery { + results: WorkEntry[]; + page: number; + pageSize: number; + totalRecords: number; + totalPageCount: number; +} |
