latest work #20

Merged
philipp merged 233 commits from dev into main 2020-12-09 18:49:33 +00:00
27 changed files with 156 additions and 140 deletions
Showing only changes of commit 658009c401 - Show all commits

No files matched your search

+1 -1
View File
@@ -8,5 +8,5 @@ export default {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
entities: ["src/models/*.ts"]
entities: ["src/models/entities/*.ts"]
};
+2 -2
View File
@@ -2,9 +2,9 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Runner } from '../models/Runner';
import { Runner } from '../models/entities/Runner';
import { RunnerGroupNeededError, RunnerGroupNotFoundError, RunnerIdsNotMatchingError, RunnerNotFoundError, RunnerOnlyOneGroupAllowedError } from '../errors/RunnerErrors';
import { CreateRunner } from '../models/CreateRunner';
import { CreateRunner } from '../models/creation/CreateRunner';
@JsonController('/runners')
@@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { RunnerOrganisation } from '../models/RunnerOrganisation';
import { RunnerOrganisation } from '../models/entities/RunnerOrganisation';
import { RunnerOrganisationIdsNotMatchingError, RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors';
import { CreateRunnerOrganisation } from '../models/CreateRunnerOrganisation';
import { RunnerGroup } from '../models/RunnerGroup';
import { CreateRunnerOrganisation } from '../models/creation/CreateRunnerOrganisation';
import { RunnerGroup } from '../models/entities/RunnerGroup';
@JsonController('/organisations')
+2 -2
View File
@@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, NotFoundError, OnU
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Track } from '../models/Track';
import { Track } from '../models/entities/Track';
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
import { CreateTrack } from '../models/CreateTrack';
import { CreateTrack } from '../models/creation/CreateTrack';
@JsonController('/tracks')
//@Authorized("TRACKS:read")
@@ -1,11 +1,11 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsPositive, IsString } from 'class-validator';
import { Runner } from '../models/Runner';
import { Runner } from '../entities/Runner';
import { getConnectionManager, Repository } from 'typeorm';
import { group } from 'console';
import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../errors/RunnerErrors';
import { RunnerOrganisation } from './RunnerOrganisation';
import { RunnerTeam } from './RunnerTeam';
import { RunnerGroup } from './RunnerGroup';
import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../../errors/RunnerErrors';
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
import { RunnerTeam } from '../entities/RunnerTeam';
import { RunnerGroup } from '../entities/RunnerGroup';
import { Address } from 'cluster';
export class CreateRunner {
@@ -1,5 +1,5 @@
import { IsString } from 'class-validator';
import { RunnerOrganisation } from './RunnerOrganisation';
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
export class CreateRunnerOrganisation {
@IsString()
@@ -1,5 +1,5 @@
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
import { Track } from './Track';
import { Track } from '../entities/Track';
export class CreateTrack {
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,7 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm";
import {
IsBoolean,
IsEAN,
IsInt,
IsNotEmpty,
IsOptional,
@@ -32,12 +33,12 @@ export class RunnerCard {
/**
* The card's code.
* This has to be able to being converted to something barcode compatible.
* Probably gonna be autogenerated.
* could theoretically be autogenerated
*/
@Column()
@IsEAN()
@IsString()
@IsNotEmpty()
//TODO: Generate this
code: string;
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -43,4 +43,12 @@ export abstract class Scan {
@Column()
@IsBoolean()
valid: boolean = true;
/**
* seconds since last scan
*/
@IsInt()
@IsOptional()
secondsSinceLastScan: number;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
+130 -123
View File
@@ -1,123 +1,130 @@
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup';
import { Permission } from './Permission';
import { UserAction } from './UserAction';
/**
* Defines a admin user.
*/
@Entity()
export class User {
/**
* autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* autogenerated uuid
*/
@IsOptional()
@IsInt()
@Generated("uuid")
uuid: string;
/**
* user email
*/
@IsEmail()
email: string;
/**
* username
*/
@IsString()
username: string;
/**
* firstname
*/
@IsString()
@IsNotEmpty()
firstname: string;
/**
* middlename
*/
@IsString()
@IsOptional()
middlename: string;
/**
* lastname
*/
@IsString()
@IsNotEmpty()
lastname: string;
/**
* password
*/
@IsString()
@IsNotEmpty()
password: string;
/**
* permissions
*/
@ManyToOne(() => Permission, permission => permission.users, { nullable: true })
permissions: Permission[];
/**
* groups
*/
@ManyToMany(() => UserGroup)
@JoinTable()
groups: UserGroup[];
/**
* is user enabled?
*/
@IsBoolean()
enabled: boolean;
/**
* jwt refresh count
*/
@IsInt()
@Column({ default: 1 })
refreshTokenCount: number;
/**
* profilepic
*/
@IsString()
profilepic: string;
/**
* actions
*/
@OneToMany(() => UserAction, action => action.user)
actions: UserAction
/**
* calculate all permissions
*/
public get calc_permissions(): Permission[] {
let final_permissions = []
this.groups.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
this.permissions.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
return final_permissions
}
}
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup';
import { Permission } from './Permission';
import { UserAction } from './UserAction';
/**
* Defines a admin user.
*/
@Entity()
export class User {
/**
* autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* autogenerated uuid
*/
@IsOptional()
@IsInt()
@Generated("uuid")
uuid: string;
/**
* user email
*/
@IsEmail()
email: string;
/**
* user phone
*/
@IsPhoneNumber("ZZ")
@IsOptional()
phone: string;
/**
* username
*/
@IsString()
username: string;
/**
* firstname
*/
@IsString()
@IsNotEmpty()
firstname: string;
/**
* middlename
*/
@IsString()
@IsOptional()
middlename: string;
/**
* lastname
*/
@IsString()
@IsNotEmpty()
lastname: string;
/**
* password
*/
@IsString()
@IsNotEmpty()
password: string;
/**
* permissions
*/
@ManyToOne(() => Permission, permission => permission.users, { nullable: true })
permissions: Permission[];
/**
* groups
*/
@ManyToMany(() => UserGroup)
@JoinTable()
groups: UserGroup[];
/**
* is user enabled?
*/
@IsBoolean()
enabled: boolean;
/**
* jwt refresh count
*/
@IsInt()
@Column({ default: 1 })
refreshTokenCount: number;
/**
* profilepic
*/
@IsString()
profilepic: string;
/**
* actions
*/
@OneToMany(() => UserAction, action => action.user)
actions: UserAction
/**
* calculate all permissions
*/
public get calc_permissions(): Permission[] {
let final_permissions = []
this.groups.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
this.permissions.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
return final_permissions
}
}
File renamed without changes.
File renamed without changes.