Skip to content

Commit

Permalink
Merge pull request #7072 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Nov 1, 2023
2 parents 5f421e7 + 8ad0e4a commit 1e130c8
Show file tree
Hide file tree
Showing 68 changed files with 5,314 additions and 597 deletions.
2 changes: 1 addition & 1 deletion apps/gauzy/src/app/@core/services/app-init-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AppInitService {
private readonly router: Router,
private readonly store: Store,
private readonly ngxPermissionsService: NgxPermissionsService
) {}
) { }

async init() {
try {
Expand Down
3 changes: 3 additions & 0 deletions apps/gauzy/src/app/@shared/workspaces/workspaces.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class WorkspacesComponent extends TranslationBaseComponent
}

getWorkspaces() {
if (!this.user.tenantId) {
return;
}
const { tenant } = this.user;
const workspace = {
id: tenant.id,
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy/src/app/@theme/layouts/public/public.layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PublicLayoutComponent implements OnInit, AfterViewInit {
private readonly store: Store,
private readonly usersService: UsersService,
private readonly themeService: NbThemeService
) {}
) { }
@ViewChild(NbLayoutComponent) layout: NbLayoutComponent;

user: any;
Expand Down
17 changes: 6 additions & 11 deletions apps/gauzy/src/app/pages/candidates/candidates.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,9 @@ export class CandidatesComponent extends PaginationFilterBaseComponent
if (!this.selectedCandidate) {
return;
}
this.router.navigate([
'/pages/employees/candidates/edit/' +
this.selectedCandidate.id +
'/profile'
]);

const candidateId = this.selectedCandidate.id;
this.router.navigate(['/pages/employees/candidates/edit/', candidateId, '/profile']);
}

async archive(selectedItem?: ICandidateViewModel) {
Expand Down Expand Up @@ -427,11 +425,8 @@ export class CandidatesComponent extends PaginationFilterBaseComponent
type: 'custom',
component: InputFilterComponent
},
filterFunction: (value) => {
this.setFilter({
field: 'user.firstName',
search: value
});
filterFunction: (value: string) => {
this.setFilter({ field: 'user.name', search: value });
}
},
email: {
Expand Down Expand Up @@ -606,5 +601,5 @@ export class CandidatesComponent extends PaginationFilterBaseComponent
}
}

ngOnDestroy() {}
ngOnDestroy() { }
}
6 changes: 3 additions & 3 deletions apps/gauzy/src/app/pages/contacts/contacts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ export class ContactsComponent extends PaginationFilterBaseComponent implements
contactType: this.contactType,
...(this.selectedEmployeeId
? {
members: [this.selectedEmployeeId]
}
members: [this.selectedEmployeeId]
}
: {}),
...(this.filters.where ? this.filters.where : {})
},
Expand Down Expand Up @@ -612,5 +612,5 @@ export class ContactsComponent extends PaginationFilterBaseComponent implements
return find ? find.country : row.country;
}

ngOnDestroy(): void {}
ngOnDestroy(): void { }
}
20 changes: 10 additions & 10 deletions apps/gauzy/src/app/pages/departments/departments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ import {
})
export class DepartmentsComponent
extends PaginationFilterBaseComponent
implements AfterViewInit, OnInit, OnDestroy
{
implements AfterViewInit, OnInit, OnDestroy {
@ViewChild('addEditTemplate')
addEditTemplate: TemplateRef<any>;
addEditDialogRef: NbDialogRef<any>;
Expand Down Expand Up @@ -158,15 +157,15 @@ export class DepartmentsComponent
.subscribe();
}

ngOnDestroy() {}
ngOnDestroy() { }

ngAfterViewInit() {}
ngAfterViewInit() { }

selectDepartment(department: any) {
if (department.data) department = department.data;
const res =
this.selected.department &&
department.id === this.selected.department.id
department.id === this.selected.department.id
? { state: !this.selected.state }
: { state: true };
this.disableButton = !res.state;
Expand Down Expand Up @@ -294,9 +293,9 @@ export class DepartmentsComponent
if (input.name) {
this.selectedDepartment
? await this.organizationDepartmentsService.update(
this.selectedDepartment.id,
input
)
this.selectedDepartment.id,
input
)
: await this.organizationDepartmentsService.create(input);

this.toastrService.success(
Expand Down Expand Up @@ -340,8 +339,9 @@ export class DepartmentsComponent
...(this.filters.join ? this.filters.join : {})
},
where: {
...{ organizationId, tenantId },
...this.filters.where
tenantId,
organizationId,
...(this.filters.where ? this.filters.where : {})
},
resultMap: (department: IOrganizationDepartment) => {
return department;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import { ExpenseCategoryMutationComponent } from './expense-category-mutation/ex
})
export class ExpenseCategoriesComponent
extends PaginationFilterBaseComponent
implements OnInit, OnDestroy
{
implements OnInit, OnDestroy {
loading: boolean = false;
disableButton: boolean = true;
smartTableSource: ServerDataSource;
Expand Down Expand Up @@ -306,7 +305,7 @@ export class ExpenseCategoriesComponent

const res =
this.selected.expenseCategory &&
expenseCategory === this.selected.expenseCategory
expenseCategory === this.selected.expenseCategory
? { state: !this.selected.state }
: { state: true };
this.selected.state = res.state;
Expand Down Expand Up @@ -353,5 +352,5 @@ export class ExpenseCategoriesComponent
.subscribe();
}

ngOnDestroy(): void {}
ngOnDestroy(): void { }
}
25 changes: 11 additions & 14 deletions apps/gauzy/src/app/pages/expenses/expenses.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ExpensesComponent extends PaginationFilterBaseComponent

organization: IOrganization;
expenses$: Subject<any> = this.subject$;
private _refresh$ : Subject<any> = new Subject();
private _refresh$: Subject<any> = new Subject();

expensesTable: Ng2SmartTableComponent;
@ViewChild('expensesTable') set content(content: Ng2SmartTableComponent) {
Expand Down Expand Up @@ -146,11 +146,11 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
)
.subscribe();
this._refresh$.pipe(
filter(() => this.dataLayoutStyle === ComponentLayoutStyleEnum.CARDS_GRID),
tap(() => this.refreshPagination()),
tap(() => this.expenses = []),
untilDestroyed(this)
).subscribe();
filter(() => this.dataLayoutStyle === ComponentLayoutStyleEnum.CARDS_GRID),
tap(() => this.refreshPagination()),
tap(() => this.expenses = []),
untilDestroyed(this)
).subscribe();

}

Expand Down Expand Up @@ -199,8 +199,8 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
? [ExpenseStatusesEnum.PAID].includes(value)
? 'success'
: [ExpenseStatusesEnum.INVOICED].includes(value)
? 'warning'
: 'danger'
? 'warning'
: 'danger'
: null;
return {
text: this.replacePipe.transform(value, '_', ' '),
Expand Down Expand Up @@ -283,7 +283,7 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
}
},
purpose: {
title: this.getTranslation('POP_UPS.PURPOSE'),
title: this.getTranslation('POP_UPS.PURPOSE'),
type: 'string',
class: 'align-row',
filter: {
Expand Down Expand Up @@ -491,9 +491,6 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
'project',
'organizationContact'
],
join: {
...(this.filters.join) ? this.filters.join : {}
},
where: {
organizationId,
tenantId,
Expand All @@ -519,7 +516,7 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
categoryName: expense.category ? expense.category.name : null,
projectName: expense.project ? expense.project.name : null,
statuses: this.statusMapper(expense.status),
employee: { ... employeeMapper(expense) }
employee: { ...employeeMapper(expense) }
});
},
finalize: () => {
Expand Down Expand Up @@ -598,5 +595,5 @@ export class ExpensesComponent extends PaginationFilterBaseComponent
) ? (employee.fullName).trim() : ALL_EMPLOYEES_SELECTED.firstName;
}

ngOnDestroy() {}
ngOnDestroy() { }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<nb-card class="card-scroll">
<nb-card-header class="d-flex">
<ngx-back-navigation
(click)="navigateToIntegrations()"
[haveLink]="true"
class="float-left"
></ngx-back-navigation>
<h5>{{ 'MENU.GAUZY_AI' | translate }}</h5>
<nb-card-header class="card-header-title">
<div class="card-header-title">
<h5>
<ngx-back-navigation
class="float-left"
[haveLink]="true"
(click)="navigateToIntegrations()"
></ngx-back-navigation>
{{ 'MENU.GAUZY_AI' | translate }}
</h5>
</div>
</nb-card-header>
<nb-card-body>
<div class="col-xl-6 col-12">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { GauzyAIAuthorizationComponent } from './authorization.component';

describe('GauzyAIAuthorizationComponent', () => {
let component: GauzyAIAuthorizationComponent;
let fixture: ComponentFixture<GauzyAIAuthorizationComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [GauzyAIAuthorizationComponent],
teardown: { destroyAfterEach: false }
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(GauzyAIAuthorizationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { ActivatedRoute, Data, Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators, FormGroupDirective } from '@angular/forms';
import { filter, tap } from 'rxjs/operators';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { IIntegrationTenant, IOrganization } from '@gauzy/contracts';
import { GauzyAIService, Store } from './../../../../../@core/services';

@UntilDestroy({ checkProperties: true })
@Component({
selector: 'ngx-gauzy-ai-authorization',
templateUrl: './authorization.component.html',
styleUrls: ['./authorization.component.scss'],
})
export class GauzyAIAuthorizationComponent implements OnInit, OnDestroy {

public organization: IOrganization;

readonly form: FormGroup = GauzyAIAuthorizationComponent.buildForm(this._formBuilder);
static buildForm(fb: FormBuilder): FormGroup {
return fb.group({
client_id: [null, Validators.required],
client_secret: [null, Validators.required],
});
}

@ViewChild('formDirective') formDirective: FormGroupDirective;

constructor(
private readonly _formBuilder: FormBuilder,
private readonly _router: Router,
private readonly _activatedRoute: ActivatedRoute,
private readonly _store: Store,
private readonly _gauzyAIService: GauzyAIService
) { }

ngOnInit(): void {
this._activatedRoute.data
.pipe(
tap(({ integration }: Data) => {
if (integration) {
this._redirectToGauzyAIIntegration(integration.id);
}
}),
untilDestroyed(this) // Ensure that subscriptions are automatically unsubscribed on component destruction.
)
.subscribe();
this._store.selectedOrganization$
.pipe(
filter((organization: IOrganization) => !!organization),
tap((organization: IOrganization) => (this.organization = organization)),
untilDestroyed(this)
)
.subscribe();
}

ngOnDestroy(): void { }

/**
* Gauzy AI integration remember state API call
*/
private _redirectToGauzyAIIntegration(integrationId: string) {
this._router.navigate(['pages/integrations/gauzy-ai', integrationId]);
}

/**
*
* @returns
*/
async onSubmit() {
if (!this.organization || this.form.invalid) {
return;
}
try {
const { client_id, client_secret } = this.form.value;
const { id: organizationId, tenantId } = this.organization;

this._gauzyAIService.addIntegration({
client_id,
client_secret,
organizationId,
tenantId
}).pipe(
tap((integration: IIntegrationTenant) => {
this._redirectToGauzyAIIntegration(integration.id);
}),
untilDestroyed(this)
).subscribe();
} catch (error) {
console.log('Error while creating new integration for Gauzy AI', error);
}
}

/**
* Navigate to the "Integrations" page.
*/
navigateToIntegrations(): void {
this._router.navigate(['/pages/integrations']);
}
}
Loading

0 comments on commit 1e130c8

Please sign in to comment.