From 3198c6c2474101623e3b95bd038effe210c176a8 Mon Sep 17 00:00:00 2001 From: THarley Date: Thu, 22 Feb 2018 17:19:08 +0000 Subject: Revert "Merge branch 'trh/error-middleware' into 'master'" This reverts merge request !13--- src/db/model/ContributorGroup.ts | 54 ---------------------------- src/db/model/File.ts | 47 ------------------------ src/db/model/Project.ts | 75 -------------------------------------- src/db/model/User.ts | 78 ---------------------------------------- src/db/model/UserGroup.ts | 52 --------------------------- src/db/model/UserJoinsProject.ts | 27 -------------- 6 files changed, 333 deletions(-) delete mode 100644 src/db/model/ContributorGroup.ts delete mode 100644 src/db/model/File.ts delete mode 100644 src/db/model/Project.ts delete mode 100644 src/db/model/User.ts delete mode 100644 src/db/model/UserGroup.ts delete mode 100644 src/db/model/UserJoinsProject.ts (limited to 'src/db/model') diff --git a/src/db/model/ContributorGroup.ts b/src/db/model/ContributorGroup.ts deleted file mode 100644 index 6bbcf4a..0000000 --- a/src/db/model/ContributorGroup.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { AllowNull, Column, DataType, HasMany, Model, Table - } from 'sequelize-typescript'; -import { default as UserJoinsProject } from './UserJoinsProject'; - -@Table -export default class ContributorGroup extends Model { - @AllowNull - @Column(DataType.TEXT) - public name: string | null = null; - - /* "Error: Foreign key for "ContributorGroup" - * is missing on "UserJoinsProject"." */ - @HasMany(() => UserJoinsProject, 'contributorGroupId') - public uses: UserJoinsProject[] = []; - - @Column - public canCreateFiles: boolean = false; - - @Column - public canDeleteFiles: boolean = false; - - @Column - public canViewFiles: boolean = false; - - @Column - public canAddUsers: boolean = false; - - @Column - public canRemoveUsers: boolean = false; - - @Column - public canEditUserPermissions: boolean = false; - - @AllowNull - @Column(DataType.TEXT) - public description: string | null = null; - - @Column - public isInternal: boolean = true; - - public getContributorGroupFullInfo(): ContributorGroupFullInfo { - return { - role: `${this.name}`, - description: `${this.description}`, - internal: this.isInternal - }; - } -} - -export interface ContributorGroupFullInfo { - role: string; - description: string; - internal: boolean; -} diff --git a/src/db/model/File.ts b/src/db/model/File.ts deleted file mode 100644 index 225512d..0000000 --- a/src/db/model/File.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { default as Project } from './Project'; -import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, - HasOne, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript'; -import { default as User } from './User'; - -@Table -export default class File extends Model { - @Column - public name: string = ''; - - @PrimaryKey - @Column - public uuid: string = ''; - - @Column - public mimetype: string = ''; - - @ForeignKey(() => File) - @AllowNull - @Column(DataType.TEXT) - public parentFolderId: string | null = null; - - @BelongsTo(() => File) - public parentFolder: File = new File(); - - @HasMany(() => File) - public containedFiles: File[] = []; - - @ForeignKey(() => User) - @AllowNull - @Column(DataType.TEXT) - public creatorName: string | null = null; - - @BelongsTo(() => User) - public creator: User = new User(); - - @HasOne(() => Project) - public rootFolderOf: Project = new Project(); - - @CreatedAt - @Column - public uploadDate: Date = new Date(); - - @UpdatedAt - @Column - public modifyDate: Date = new Date(); -} diff --git a/src/db/model/Project.ts b/src/db/model/Project.ts deleted file mode 100644 index 2c26a04..0000000 --- a/src/db/model/Project.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { default as ContributorGroup } from './ContributorGroup'; -import { default as File } from './File'; -import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey, - Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript'; -import { default as User } from './User'; -import { default as UserJoinsProject } from './UserJoinsProject'; - -@Table -export default class Project extends Model { - - @PrimaryKey - @Column - public name: string = ''; - - @BelongsToMany(() => User, () => UserJoinsProject) - public contributors: User[] = []; - - @ForeignKey(() => File) - @Column - public rootFolderId: string = ''; - - @BelongsTo(() => File) - public rootFolder: File = new File(); - - @CreatedAt - @Column - public creationDate: Date = new Date(); - - @UpdatedAt - @Column - public lastActivity: Date = new Date(); - - public getAccessLevel(user: User): ContributorGroup { - throw new Error(`unimplemented, ${this}`); - } - - public getUserInfo(user: User): UserInfo { - return { - username: user.username, - access_level: this.getAccessLevel(user) - .toString() - }; - } - - public getProjectFullInfo(): ProjectFullInfo { - return { - project_name: this.name, - users: this.contributors - .map( - (u: User) => this.getUserInfo(u) - ), - public_metadata: { - creation_date: this.creationDate - }, - // TODO: Check if we have anything to use these for yet? - private_metadata: {}, - admin_metadata: {} - }; - } -} - -interface Metadata {} - -interface UserInfo { - username: string; - access_level: string; -} - -export interface ProjectFullInfo { - project_name: string; - users: UserInfo[]; - public_metadata: Metadata; - private_metadata?: Metadata; - admin_metadata?: Metadata; -} diff --git a/src/db/model/User.ts b/src/db/model/User.ts deleted file mode 100644 index 5a9af07..0000000 --- a/src/db/model/User.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { default as File } from './File'; -import { default as Project } from './Project'; -import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey, HasMany, - Model, PrimaryKey, Table } from 'sequelize-typescript'; -import { default as UserGroup } from './UserGroup'; -import { default as UserJoinsProject } from './UserJoinsProject'; - -@Table -export default class User extends Model { - @PrimaryKey - @Column - public username: string = ''; - - @Column - public password: string = ''; - - @ForeignKey(() => UserGroup) - @Column - public userGroupId: number = 0; - - @BelongsTo(() => UserGroup) - public userGroup: UserGroup = new UserGroup(); - - @BelongsToMany(() => Project, () => UserJoinsProject) - public projects: Project[] = []; - - @HasMany(() => File) - public createdFiles: File[] = []; - - @CreatedAt - @Column - public creationDate: Date = new Date(); - - // TODO implement - public getAccessLevel(project: Project): string { - throw new Error(`unimplemented, ${this}`); - } - - public getProjectInfo(project: Project): ProjectInfo { - return { - project_name: project.name, - access_level: this.getAccessLevel(project) - }; - } - - public getUserFullInfo(): UserFullInfo { - return { - username : this.username, - privileges: [`${this.userGroup.name}`], - projects : this.projects.map( - (p: Project) => this.getProjectInfo(p) - ), - // TODO: Check if we have anything to use these for yet? - public_user_metadata: {}, - private_user_metadata: {}, - public_admin_metadata: {}, - private_admin_metadata: {} - }; - } -} - -// TODO MAKE PRETTY below -interface Metadata {} - -interface ProjectInfo { - project_name: string; - access_level: string; -} - -export interface UserFullInfo { - username: string; - privileges: string[]; - projects: ProjectInfo[]; - public_user_metadata: Metadata; - private_user_metadata: Metadata; - public_admin_metadata: Metadata; - private_admin_metadata: Metadata; -} diff --git a/src/db/model/UserGroup.ts b/src/db/model/UserGroup.ts deleted file mode 100644 index 865fbbc..0000000 --- a/src/db/model/UserGroup.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { AllowNull, Column, DataType, HasMany, Model, Table - } from 'sequelize-typescript'; -import { default as User } from './User'; - -interface UserPrivilege { - privilege: string; - description: string; - internal: boolean; -} - -@Table -export default class UserGroup extends Model { - @AllowNull - @Column(DataType.TEXT) - public name: string | null = null; - - @HasMany(() => User) - public users: User[] = []; - - @Column - public canCreateUsers: boolean = false; - - @Column - public canDeleteUsers: boolean = false; - - @Column - public canEditUsers: boolean = false; - - @Column - public canCreateProjects: boolean = false; - - @Column - public canDeleteProjects: boolean = false; - - @Column - public canEditProjects: boolean = false; - - @Column - public isInternal: boolean = true; - - @AllowNull - @Column(DataType.TEXT) - public description: string | null = null; - - public getPrivelege(): UserPrivilege { - return { - privilege : `${this.name}`, - description : `${this.description}`, - internal : this.isInternal - }; - } -} diff --git a/src/db/model/UserJoinsProject.ts b/src/db/model/UserJoinsProject.ts deleted file mode 100644 index 36a1591..0000000 --- a/src/db/model/UserJoinsProject.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { default as Project } from './Project'; -import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table - } from 'sequelize-typescript'; -import { default as User } from './User'; -import { default as ContributorGroup } from './UserGroup'; - -@Table -export default class UserJoinsProject extends Model { - @ForeignKey(() => User) - @Column - public username: string = ''; - - @ForeignKey(() => Project) - @Column - public projectName: string = ''; - - @CreatedAt - @Column - public joinDate: Date = new Date(); - - @ForeignKey(() => ContributorGroup) - @Column - public contributorGroupId: number = 0; - - @BelongsTo(() => ContributorGroup) - public contributorGroup: ContributorGroup = new ContributorGroup(); -} -- cgit v1.2.1