aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/models
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2023-02-25 13:15:44 +0100
committerivarlovlie <git@ivarlovlie.no>2023-02-25 13:15:44 +0100
commit900bb5e845c3ad44defbd427cae3d44a4a43321f (patch)
treedf3d96a93771884add571e82336c29fc3d9c7a1c /code/app/src/models
downloadgreatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.tar.xz
greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.zip
feat: Initial commit
Diffstat (limited to 'code/app/src/models')
-rw-r--r--code/app/src/models/base/Customer.ts21
-rw-r--r--code/app/src/models/base/CustomerContact.ts8
-rw-r--r--code/app/src/models/base/CustomerEvent.ts6
-rw-r--r--code/app/src/models/base/SessionData.ts5
-rw-r--r--code/app/src/models/base/Tenant.ts8
-rw-r--r--code/app/src/models/base/User.ts13
-rw-r--r--code/app/src/models/base/UserRole.ts5
-rw-r--r--code/app/src/models/internal/FormError.ts24
-rw-r--r--code/app/src/models/internal/IForm.ts15
-rw-r--r--code/app/src/models/internal/KnownProblem.ts10
-rw-r--r--code/app/src/models/projects/Project.ts13
-rw-r--r--code/app/src/models/projects/ProjectLabel.ts5
-rw-r--r--code/app/src/models/projects/ProjectMember.ts10
-rw-r--r--code/app/src/models/projects/ProjectMeta.ts7
-rw-r--r--code/app/src/models/projects/ProjectRole.ts7
-rw-r--r--code/app/src/models/projects/ProjectStatus.ts5
-rw-r--r--code/app/src/models/work/WorkCategory.ts5
-rw-r--r--code/app/src/models/work/WorkEntry.ts13
-rw-r--r--code/app/src/models/work/WorkEntryQueryResponse.ts27
-rw-r--r--code/app/src/models/work/WorkLabel.ts5
-rw-r--r--code/app/src/models/work/WorkQuery.ts17
21 files changed, 229 insertions, 0 deletions
diff --git a/code/app/src/models/base/Customer.ts b/code/app/src/models/base/Customer.ts
new file mode 100644
index 0000000..ff52fbd
--- /dev/null
+++ b/code/app/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/app/src/models/base/CustomerContact.ts b/code/app/src/models/base/CustomerContact.ts
new file mode 100644
index 0000000..e8abea5
--- /dev/null
+++ b/code/app/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/app/src/models/base/CustomerEvent.ts b/code/app/src/models/base/CustomerEvent.ts
new file mode 100644
index 0000000..af86511
--- /dev/null
+++ b/code/app/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/app/src/models/base/SessionData.ts b/code/app/src/models/base/SessionData.ts
new file mode 100644
index 0000000..015cbf3
--- /dev/null
+++ b/code/app/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/app/src/models/base/Tenant.ts b/code/app/src/models/base/Tenant.ts
new file mode 100644
index 0000000..6307efc
--- /dev/null
+++ b/code/app/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/app/src/models/base/User.ts b/code/app/src/models/base/User.ts
new file mode 100644
index 0000000..2b74d0e
--- /dev/null
+++ b/code/app/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/app/src/models/base/UserRole.ts b/code/app/src/models/base/UserRole.ts
new file mode 100644
index 0000000..ec32852
--- /dev/null
+++ b/code/app/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/app/src/models/internal/FormError.ts b/code/app/src/models/internal/FormError.ts
new file mode 100644
index 0000000..f6d8978
--- /dev/null
+++ b/code/app/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/app/src/models/internal/IForm.ts b/code/app/src/models/internal/IForm.ts
new file mode 100644
index 0000000..c14b770
--- /dev/null
+++ b/code/app/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/app/src/models/internal/KnownProblem.ts b/code/app/src/models/internal/KnownProblem.ts
new file mode 100644
index 0000000..b6923d9
--- /dev/null
+++ b/code/app/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/app/src/models/projects/Project.ts b/code/app/src/models/projects/Project.ts
new file mode 100644
index 0000000..f265e67
--- /dev/null
+++ b/code/app/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/app/src/models/projects/ProjectLabel.ts b/code/app/src/models/projects/ProjectLabel.ts
new file mode 100644
index 0000000..59aa9d5
--- /dev/null
+++ b/code/app/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/app/src/models/projects/ProjectMember.ts b/code/app/src/models/projects/ProjectMember.ts
new file mode 100644
index 0000000..de348ef
--- /dev/null
+++ b/code/app/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/app/src/models/projects/ProjectMeta.ts b/code/app/src/models/projects/ProjectMeta.ts
new file mode 100644
index 0000000..c583b47
--- /dev/null
+++ b/code/app/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/app/src/models/projects/ProjectRole.ts b/code/app/src/models/projects/ProjectRole.ts
new file mode 100644
index 0000000..0fa2347
--- /dev/null
+++ b/code/app/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/app/src/models/projects/ProjectStatus.ts b/code/app/src/models/projects/ProjectStatus.ts
new file mode 100644
index 0000000..2df4b88
--- /dev/null
+++ b/code/app/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/app/src/models/work/WorkCategory.ts b/code/app/src/models/work/WorkCategory.ts
new file mode 100644
index 0000000..7dd85d5
--- /dev/null
+++ b/code/app/src/models/work/WorkCategory.ts
@@ -0,0 +1,5 @@
+export type WorkCategory = {
+ id: string,
+ name: string,
+ color: string
+}
diff --git a/code/app/src/models/work/WorkEntry.ts b/code/app/src/models/work/WorkEntry.ts
new file mode 100644
index 0000000..2108b88
--- /dev/null
+++ b/code/app/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/app/src/models/work/WorkEntryQueryResponse.ts b/code/app/src/models/work/WorkEntryQueryResponse.ts
new file mode 100644
index 0000000..a6974f1
--- /dev/null
+++ b/code/app/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/app/src/models/work/WorkLabel.ts b/code/app/src/models/work/WorkLabel.ts
new file mode 100644
index 0000000..f7e2795
--- /dev/null
+++ b/code/app/src/models/work/WorkLabel.ts
@@ -0,0 +1,5 @@
+export interface WorkLabel {
+ id?: string,
+ name?: string,
+ color?: string
+}
diff --git a/code/app/src/models/work/WorkQuery.ts b/code/app/src/models/work/WorkQuery.ts
new file mode 100644
index 0000000..93b0aa4
--- /dev/null
+++ b/code/app/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;
+}