Skip to content
Permalink
Browse files

Merge branch 'develop' into feature/additional-organization-settings

  • Loading branch information...
AlexTasev committed Oct 31, 2019
2 parents 6729e37 + dc4211f commit ae8d91d18c1aea4c6ea940216c01f2dd715ebb74
Showing with 806 additions and 257 deletions.
  1. +7 −1 apps/api/src/app/app.module.ts
  2. +37 −37 apps/api/src/app/core/core.module.ts
  3. +15 −1 apps/api/src/app/employee/employee.entity.ts
  4. +14 −4 apps/api/src/app/organization-projects/organization-projects.entity.ts
  5. +3 −0 apps/api/src/app/organization-teams/index.ts
  6. +42 −0 apps/api/src/app/organization-teams/organization-teams.controller.ts
  7. +38 −0 apps/api/src/app/organization-teams/organization-teams.entity.ts
  8. +13 −0 apps/api/src/app/organization-teams/organization-teams.module.ts
  9. +17 −0 apps/api/src/app/organization-teams/organization-teams.service.ts
  10. +62 −0 apps/gauzy/src/app/@core/services/organization-teams.service.ts
  11. +45 −5 apps/gauzy/src/app/@theme/components/header/header.component.html
  12. +35 −0 apps/gauzy/src/app/@theme/components/header/header.component.scss
  13. +24 −4 apps/gauzy/src/app/@theme/components/header/header.component.ts
  14. +2 −1 apps/gauzy/src/app/@theme/components/header/selectors/date/date.component.scss
  15. +122 −113 apps/gauzy/src/app/@theme/components/header/selectors/employee/employee.component.ts
  16. +10 −0 ...anizations/edit-organization/edit-organization-settings/edit-organization-settings.component.html
  17. +6 −2 ...s/organizations/edit-organization/edit-organization-settings/edit-organization-settings.module.ts
  18. +92 −0 ...ization/edit-organization-settings/edit-organization-teams/edit-organization-teams.component.html
  19. +111 −0 ...anization/edit-organization-settings/edit-organization-teams/edit-organization-teams.component.ts
  20. +23 −22 apps/gauzy/src/assets/i18n/bg.json
  21. +2 −1 apps/gauzy/src/assets/i18n/en.json
  22. +21 −19 apps/gauzy/src/assets/i18n/he.json
  23. +46 −44 apps/gauzy/src/assets/i18n/ru.json
  24. +0 −1 apps/gauzy/src/environments/environment.ts
  25. +1 −0 libs/models/src/index.ts
  26. +2 −2 libs/models/src/lib/organization-projects.model.ts
  27. +16 −0 libs/models/src/lib/organization-teams-model.ts
@@ -21,6 +21,7 @@ import { OrganizationClientsModule } from './organization-clients';
import { OrganizationPositionsModule } from './organization-positions';
import { OrganizationProjectsModule } from './organization-projects';
import { OrganizationVendorsModule } from './organization-vendors';
import { OrganizationTeamsModule } from './organization-teams';

@Module({
imports: [
@@ -74,6 +75,10 @@ import { OrganizationVendorsModule } from './organization-vendors';
{
path: '/employee-recurring-expense',
module: EmployeeRecurringExpenseModule
},
{
path: '/organization-teams',
module: OrganizationTeamsModule
}
]
}
@@ -95,7 +100,8 @@ import { OrganizationVendorsModule } from './organization-vendors';
OrganizationPositionsModule,
OrganizationProjectsModule,
OrganizationVendorsModule,
EmployeeRecurringExpenseModule
EmployeeRecurringExpenseModule,
OrganizationTeamsModule
],
controllers: [AppController],
providers: [AppService, SeedDataService],
@@ -1,4 +1,4 @@
// Modified code from https://github.com/xmlking/ngx-starter-kit.
// Modified code from https://github.com/xmlking/ngx-starter-kit.
// MIT License, see https://github.com/xmlking/ngx-starter-kit/blob/develop/LICENSE
// Copyright (c) 2018 Sumanth Chinthagunta

@@ -18,56 +18,56 @@ import { UserOrganization } from '../user-organization';
import { OrganizationDepartment } from '../organization-department';
import { OrganizationRecurringExpense } from '../organization-recurring-expense';
import { EmployeeRecurringExpense } from '../employee-recurring-expense';
import { TerminusModule, TypeOrmHealthIndicator, DNSHealthIndicator } from '@nestjs/terminus';
import { getTerminusOptions } from './health/terminus-options.service';
import { OrganizationClients } from '../organization-clients';
import { OrganizationPositions } from '../organization-positions';
import { OrganizationVendors } from '../organization-vendors';
import { OrganizationProjects } from '../organization-projects';
import { OrganizationTeams } from '../organization-teams';

const entities = [
User,
Employee,
Role,
Organization,
Income,
Expense,
EmployeeSetting,
UserOrganization,
OrganizationDepartment,
OrganizationClients,
OrganizationPositions,
OrganizationProjects,
OrganizationVendors,
OrganizationRecurringExpense,
EmployeeRecurringExpense
User,
Employee,
Role,
Organization,
Income,
Expense,
EmployeeSetting,
UserOrganization,
OrganizationDepartment,
OrganizationClients,
OrganizationPositions,
OrganizationProjects,
OrganizationVendors,
OrganizationRecurringExpense,
EmployeeRecurringExpense,
OrganizationTeams
];

@Module({
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (config: ConfigService): TypeOrmModuleOptions => ({
...env.database,
entities,
// subscribers,
// migrations,
}),
inject: [ConfigService],
}),
/*
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (config: ConfigService): TypeOrmModuleOptions => ({
...env.database,
entities
// subscribers,
// migrations,
}),
inject: [ConfigService]
})
/*
TerminusModule.forRootAsync({
// Inject the TypeOrmHealthIndicator provided by nestjs/terminus
inject: [TypeOrmHealthIndicator, DNSHealthIndicator],
useFactory: (db, dns) => getTerminusOptions(db, dns)
})
*/
],
controllers: [],
providers: [],
],
controllers: [],
providers: []
})
export class CoreModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(RequestContextMiddleware).forRoutes('*');
}
}
configure(consumer: MiddlewareConsumer) {
consumer.apply(RequestContextMiddleware).forRoutes('*');
}
}
@@ -4,14 +4,17 @@ import {
JoinColumn,
OneToOne,
RelationId,
ManyToOne
ManyToOne,
ManyToMany,
JoinTable
} from 'typeorm';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { Base } from '../core/entities/base';
import { Employee as IEmployee } from '@gauzy/models';
import { IsDate, IsOptional } from 'class-validator';
import { User } from '../user';
import { Organization } from '../organization';
import { OrganizationTeams } from '../organization-teams/organization-teams.entity';

@Entity('employee')
export class Employee extends Base implements IEmployee {
@@ -48,4 +51,15 @@ export class Employee extends Base implements IEmployee {
@IsOptional()
@Column({ nullable: true })
endWork?: Date;

@ManyToMany((type) => OrganizationTeams)
@JoinTable({
name: 'organization_teams_members_employee',
joinColumn: { name: 'employeeId', referencedColumnName: 'id' },
inverseJoinColumn: {
name: 'organizationTeamId',
referencedColumnName: 'id'
}
})
teams: OrganizationTeams[];
}
@@ -7,10 +7,19 @@ import {
ManyToMany
} from 'typeorm';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsOptional, IsDate } from 'class-validator';
import {
IsNotEmpty,
IsString,
IsOptional,
IsDate,
IsEnum
} from 'class-validator';
import { Base } from '../core/entities/base';
import { Organization } from '../organization/organization.entity';
import { OrganizationProjects as IOrganizationProjects } from '@gauzy/models';
import {
OrganizationProjects as IOrganizationProjects,
CurrenciesEnum
} from '@gauzy/models';
import { OrganizationClients } from '../organization-clients';
import { Employee } from '../employee';

@@ -56,9 +65,10 @@ export class OrganizationProjects extends Base
@Column()
type: string;

@ApiModelProperty({ type: String })
@IsString()
@ApiModelProperty({ type: String, enum: CurrenciesEnum })
@IsEnum(CurrenciesEnum)
@IsNotEmpty()
@Index()
@Column()
currency: string;

@@ -0,0 +1,3 @@
export { OrganizationTeamsModule } from './organization-teams.module';
export { OrganizationTeams } from './organization-teams.entity';
export { OrganizationTeamsService } from './organization-teams.service';
@@ -0,0 +1,42 @@
import { Controller, Get, HttpStatus, Query } from '@nestjs/common';
import { ApiUseTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { CrudController } from '../core/crud/crud.controller';
import { OrganizationTeamsService } from './organization-teams.service';
import { OrganizationTeams } from './organization-teams.entity';
import { IPagination } from '../core';

@ApiUseTags('Organization-Teams')
@Controller()
export class OrganizationTeamsController extends CrudController<
OrganizationTeams
> {
constructor(
private readonly organizationTeamsService: OrganizationTeamsService
) {
super(organizationTeamsService);
}

@ApiOperation({
title: 'Find all organization Teams.'
})
@ApiResponse({
status: HttpStatus.OK,
description: 'Found Teams',
type: OrganizationTeams
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Record not found'
})
@Get()
async findAllEmployees(
@Query('data') data: string
): Promise<IPagination<OrganizationTeams>> {
const { relations, findInput } = JSON.parse(data);

return this.organizationTeamsService.findAll({
where: findInput,
relations
});
}
}
@@ -0,0 +1,38 @@
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
ManyToMany,
JoinTable
} from 'typeorm';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsOptional, IsDate } from 'class-validator';
import { Base } from '../core/entities/base';
import { OrganizationTeams as IOrganizationTeams } from '@gauzy/models';
import { Employee } from '../employee';

@Entity('organization_teams')
export class OrganizationTeams extends Base implements IOrganizationTeams {
@ApiModelProperty({ type: String })
@IsString()
@IsNotEmpty()
@Index()
@Column()
name: string;

@ApiModelProperty({ type: String })
@IsString()
@IsNotEmpty()
@Column()
organizationId: string;

@ManyToMany((type) => Employee)
@JoinTable({
name: 'organization_team_employee',
joinColumn: { name: 'organizationTeamId', referencedColumnName: 'id' },
inverseJoinColumn: { name: 'employeeId', referencedColumnName: 'id' }
})
employees: Employee[];
}
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { OrganizationTeams } from './organization-teams.entity';
import { OrganizationTeamsController } from './organization-teams.controller';
import { OrganizationTeamsService } from './organization-teams.service';

@Module({
imports: [TypeOrmModule.forFeature([OrganizationTeams])],
controllers: [OrganizationTeamsController],
providers: [OrganizationTeamsService],
exports: [OrganizationTeamsService]
})
export class OrganizationTeamsModule {}
@@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { CrudService } from '../core/crud/crud.service';
import { OrganizationTeams } from './organization-teams.entity';

@Injectable()
export class OrganizationTeamsService extends CrudService<OrganizationTeams> {
constructor(
@InjectRepository(OrganizationTeams)
private readonly organizationTeamsRepository: Repository<
OrganizationTeams
>
) {
super(organizationTeamsRepository);
}
}
@@ -0,0 +1,62 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {
OrganizationTeams,
OrganizationTeamFindInput,
OrganizationTeamCreateInput
} from '@gauzy/models';
import { first } from 'rxjs/operators';

@Injectable({
providedIn: 'root'
})
export class OrganizationTeamsService {
constructor(private http: HttpClient) {}

// TODO: Implement logic to proceed the fowolling requests:
// 1) Get all employees of selected Organization and put in in the select as options;
// 2) Create a team with name and members (employees involved);
// 3) Edit team- simillar with create;
// 4) Delete a team
// 5) Display all teams: show team name and members - avatar + full name for each member;

create(
createInput: OrganizationTeamCreateInput
): Promise<OrganizationTeams> {
return this.http
.post<OrganizationTeams>('/api/organization-teams', createInput)
.pipe(first())
.toPromise();
}

getAll(
relations?: string[],
findInput?: OrganizationTeamFindInput
): Promise<{ items: any[]; total: number }> {
const data = JSON.stringify({ relations, findInput });

return this.http
.get<{ items: OrganizationTeams[]; total: number }>(
`/api/organization-teams`,
{
params: { data }
}
)
.pipe(first())
.toPromise();
}

update(id: string, updateInput: any): Promise<any> {
return this.http
.put(`/api/organization-teams/${id}`, updateInput)
.pipe(first())
.toPromise();
}

delete(id: string): Promise<any> {
return this.http
.delete(`/api/organization-teams/${id}`)
.pipe(first())
.toPromise();
}
}

0 comments on commit ae8d91d

Please sign in to comment.
You can’t perform that action at this time.