Kaynağa Gözat

profile wip

master
Daniel 1 yıl önce
ebeveyn
işleme
7c39ba7623
11 değiştirilmiş dosya ile 135 ekleme ve 198 silme
  1. +7
    -0
      matsen-tool/src/app/_services/account.service.ts
  2. +0
    -160
      matsen-tool/src/app/_views/home/home.component.ts
  3. +15
    -13
      matsen-tool/src/app/_views/profile/profile.component.html
  4. +21
    -21
      matsen-tool/src/app/_views/profile/profile.component.ts
  5. +4
    -2
      matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts
  6. +4
    -2
      matsen-tool/src/app/_views/sales/sale-summary/sale-summary.component.ts
  7. +13
    -0
      matsen-tool/src/app/_views/user/user/user.component.html
  8. +0
    -0
      matsen-tool/src/app/_views/user/user/user.component.scss
  9. +23
    -0
      matsen-tool/src/app/_views/user/user/user.component.spec.ts
  10. +46
    -0
      matsen-tool/src/app/_views/user/user/user.component.ts
  11. +2
    -0
      matsen-tool/src/app/app.module.ts

+ 7
- 0
matsen-tool/src/app/_services/account.service.ts Dosyayı Görüntüle

@@ -41,6 +41,13 @@ export class AccountService {
this.router.navigate(['/account/login']);
}

isUserAdmin(): boolean {
if (this.userValue && this.userValue?.roles) {
return this.userValue?.roles?.includes('ROLE_ADMIN');
}
return false;
}

register(user: User) {
return this.http.post(`${environment.apiUrl}/users/register`, user);
}


+ 0
- 160
matsen-tool/src/app/_views/home/home.component.ts Dosyayı Görüntüle

@@ -2,22 +2,6 @@

import {User} from '@app/_models';
import {AccountService} from '@app/_services';
import {Subscription} from "rxjs";
import {
PostJsonld,
PostService,
TaskJsonld,
TaskNoteJsonld,
TaskService,
UserJsonld,
UserService
} from "@app/core/api/v1";
import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator";
import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap";
import {MatTableDataSource} from "@angular/material/table";
import {NewTaskComponent} from "@app/_views/tasks/new-task/new-task.component";
import {ModalStatus} from "@app/_helpers/modal.states";
import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component";
import {AppHelperService} from "@app/_helpers/app-helper.service";
import {ToggleComponent} from "@app/_components/toggle/toggle.component";
import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component";
@@ -31,162 +15,18 @@ export class HomeComponent implements OnInit, AfterViewInit {
@ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent();
@ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent;

@ViewChild(MatPaginator) tasksPaginator: MatPaginator;

protected user: User | null;
protected postSub: Subscription;
protected posts: Array<PostJsonld>;

protected usersSub: Subscription;
protected users: Array<UserJsonld>;

protected userIsAdmin: boolean;

protected tasksSub: Subscription;
protected tasks: Array<TaskJsonld>;
protected tasksDataSource;
protected tasksLength: number;
protected tasksPageEvent: PageEvent;
protected tasksPageSize: number;
protected tasksPageIndex: number;

protected taskNotesVisibility: Map<string, boolean>;

protected modalOptions: NgbModalOptions = {
centered: true
};

constructor(
private modalService: NgbModal,
private accountService: AccountService,
private postService: PostService,
private userService: UserService,
private taskService: TaskService,
protected appHelperService: AppHelperService
) {
this.user = this.accountService.userValue;
// this.accountService.user.subscribe(x => this.user = x);
this.postSub = new Subscription();
this.posts = [];

this.usersSub = new Subscription();
this.users = [];

this.userIsAdmin = false;

this.tasksSub = new Subscription();
this.tasks = [];
this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype);
this.tasksDataSource = new MatTableDataSource<TaskJsonld>(this.tasks);
this.tasksLength = 0;
this.tasksPageEvent = new PageEvent();
this.tasksPageSize = 10;
this.tasksPageIndex = 0;
this.taskNotesVisibility = new Map<string, boolean>();
}

ngOnInit(): void {
if (this.user) {
this.userIsAdmin = this.user.roles ? this.user.roles.includes('ROLE_ADMIN') : false;
}
this.postSub = this.postService.postsGetCollection().subscribe(
data => {
this.posts = data["hydra:member"];
}
);

this.usersSub = this.userService.usersGetCollection().subscribe(
data => {
this.users = data["hydra:member"];
}
);
this.getTasksData();
}

ngAfterViewInit() {
this.tasksDataSource.paginator = this.tasksPaginator;
}

getTasksData() {
this.tasksSub = this.taskService.tasksGetCollection(
this.tasksPageIndex + 1,
this.tasksPageSize,
this.user?.id
).subscribe(
data => {
this.tasks = data["hydra:member"];
this.tasksLength = Number(data["hydra:totalItems"]);
this.tasks.forEach(task => {
if (task.id) {
this.taskNotesVisibility.set(task.id, false);
}
});
}
);
}

tasksHandlePageEvent(e: PageEvent) {
this.tasksPageEvent = e;
this.tasksLength = e.length;
this.tasksPageIndex = e.pageIndex.valueOf();
this.tasksPageSize = e.pageSize.valueOf();
this.getTasksData();
}

openModalNewTask() {
const modalRefTask = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions());
let task: TaskJsonld = {} as TaskJsonld;
task.partner = null;
task.completed = false;
modalRefTask.componentInstance.task = task;
modalRefTask.componentInstance.submit.subscribe((modalStatus: ModalStatus) => {
if (modalStatus === ModalStatus.Submitted) {
modalRefTask.dismiss();
this.getTasksData();
}
});
}

openModalNewTaskNote(task: TaskJsonld) {
const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions());
let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld;
taskNote.task = task.id ?? null;
modalRefTaskNote.componentInstance.taskNote = taskNote;
modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => {
if (modalStatus === ModalStatus.Submitted) {
modalRefTaskNote.dismiss();
this.getTasksData();
}
});
}

openModalEditTask(task: TaskJsonld) {
const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions());
modalRefTaskEdit.componentInstance.task = task;
modalRefTaskEdit.componentInstance.dueAtValue = this.appHelperService.convertDate(task.dueAt);
modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => {
if (modalStatus === ModalStatus.Submitted) {
modalRefTaskEdit.dismiss();
this.getTasksData();
}
});
}

openModalEditTaskNote(taskNote: TaskNoteJsonld) {
const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions());
modalRefTaskNote.componentInstance.taskNote = taskNote;
modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => {
if (modalStatus === ModalStatus.Submitted) {
modalRefTaskNote.dismiss();
this.getTasksData();
}
});
}

showTaskNotes(task: TaskJsonld) {
if (task.id) {
const currentVisibility = this.taskNotesVisibility.get(task.id);
this.taskNotesVisibility.set(task.id, !currentVisibility);
}
}
}

+ 15
- 13
matsen-tool/src/app/_views/profile/profile.component.html Dosyayı Görüntüle

@@ -1,13 +1,15 @@
<div class="spt-container">
<div class="card">
<div class="card-body row">
<div class="col-4">
<h1>{{ user.firstName }} {{ user.lastName }}</h1>
<dl>
<dt>Email:</dt>
<dd>{{ user.email }}</dd>
</dl>
</div>
</div>
</div>
</div>
<app-user
[user]="user"
></app-user>

<app-toggle #toggleTasks [headline]="('user.my' | translate) + ' ' + ('basic.tasks' | translate)">
<app-task-list #taskListComponent
[user]="user">
</app-task-list>
</app-toggle>

<app-toggle #toggleSales [headline]="('user.my' | translate) + ' ' + ('basic.sales' | translate)">
<app-sale-list #saleListComponent
[user]="user">
</app-sale-list>
</app-toggle>

+ 21
- 21
matsen-tool/src/app/_views/profile/profile.component.ts Dosyayı Görüntüle

@@ -1,46 +1,46 @@
import {AfterViewInit, Component, OnInit} from '@angular/core';
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {User} from "@app/_models";
import {Router} from "@angular/router";
import {AccountService} from "@app/_services";
import {Subscription} from "rxjs";
import {PartnerJsonld, UserJsonld, UserService} from "@app/core/api/v1";
import {AppHelperService} from "@app/_helpers/app-helper.service";
import {PagingComponent} from "@app/_components/paging/paging.component";
import {UserComponent} from "@app/_views/user/user/user.component";
import {ToggleComponent} from "@app/_components/toggle/toggle.component";
import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component";
import {SaleListComponent} from "@app/_views/sales/sale-list/sale-list.component";

@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrl: './profile.component.scss'
})
export class ProfileComponent implements OnInit {
export class ProfileComponent implements OnInit, AfterViewInit {

protected userSub: Subscription;
protected user: UserJsonld;
@ViewChild("userComponent", { static: false }) userComponent!: UserComponent;
@ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent();
@ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent;
@ViewChild("toggleSales", { static: true }) toggleSales: ToggleComponent = new ToggleComponent();
@ViewChild("saleListComponent", { static: false }) saleListComponent!: SaleListComponent;

protected user!: UserJsonld;

constructor(
private router: Router,
private accountService: AccountService,
private userService: UserService,
protected appHelperService: AppHelperService
) {
this.userSub = new Subscription();
this.user = {} as UserJsonld;
if (this.accountService.userValue?.userResource) {
this.user = this.accountService.userValue?.userResource;
}

}

ngOnInit() {
this.getUserData();
}

getUserData() {
const user = this.accountService.userValue;
if (user?.id !== null && user?.id !== undefined) {
this.userSub = this.userService.usersIdGet(
this.appHelperService.extractId(user.id)
).subscribe(
data => {
this.user = data;
}
);
}
ngAfterViewInit(): void {
}



}

+ 4
- 2
matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts Dosyayı Görüntüle

@@ -1,6 +1,6 @@
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
import {Subscription} from "rxjs";
import {SaleJsonld, SaleService, SaleSummaryJsonld} from "@app/core/api/v1";
import {SaleJsonld, SaleService, SaleSummaryJsonld, UserJsonld} from "@app/core/api/v1";
import {TranslateService} from "@ngx-translate/core";
import {Router} from "@angular/router";
import {AppHelperService} from "@app/_helpers/app-helper.service";
@@ -18,6 +18,7 @@ import {AccountService} from "@app/_services";
})
export class SaleListComponent implements OnInit, AfterViewInit {

@Input() public user!: UserJsonld;
@ViewChild(MatSort) sort;
@ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent;

@@ -56,6 +57,7 @@ export class SaleListComponent implements OnInit, AfterViewInit {
this.salesSub = this.saleService.salesGetCollection(
this.pagingComponent.getPageIndex(),
this.pagingComponent.getPageSize(),
this.user !== undefined ? this.user.id : undefined
).subscribe(
data => {
this.sales = data["hydra:member"];


+ 4
- 2
matsen-tool/src/app/_views/sales/sale-summary/sale-summary.component.ts Dosyayı Görüntüle

@@ -1,6 +1,6 @@
import {AfterViewInit, Component, OnInit} from '@angular/core';
import {AfterViewInit, Component, Input, OnInit} from '@angular/core';
import {Subscription} from "rxjs";
import {SaleSummaryJsonld, SaleSummaryService} from "@app/core/api/v1";
import {SaleSummaryJsonld, SaleSummaryService, UserJsonld} from "@app/core/api/v1";

@Component({
selector: 'app-sale-summary',
@@ -9,6 +9,8 @@ import {SaleSummaryJsonld, SaleSummaryService} from "@app/core/api/v1";
})
export class SaleSummaryComponent implements OnInit, AfterViewInit {

@Input() public user!: UserJsonld;

protected readonly Number = Number;
protected salesSummarySub: Subscription;
protected saleSummaries: Array<SaleSummaryJsonld>;


+ 13
- 0
matsen-tool/src/app/_views/user/user/user.component.html Dosyayı Görüntüle

@@ -0,0 +1,13 @@
<div class="spt-container">
<div class="card">
<div class="card-body row">
<div class="col-4">
<h1>{{ user.firstName }} {{ user.lastName }}</h1>
<dl>
<dt>Email:</dt>
<dd>{{ user.email }}</dd>
</dl>
</div>
</div>
</div>
</div>

+ 0
- 0
matsen-tool/src/app/_views/user/user/user.component.scss Dosyayı Görüntüle


+ 23
- 0
matsen-tool/src/app/_views/user/user/user.component.spec.ts Dosyayı Görüntüle

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UserComponent } from './user.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [UserComponent]
})
.compileComponents();
fixture = TestBed.createComponent(UserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

+ 46
- 0
matsen-tool/src/app/_views/user/user/user.component.ts Dosyayı Görüntüle

@@ -0,0 +1,46 @@
import {AfterViewInit, Component, Input, OnInit} from '@angular/core';
import {Subscription} from "rxjs";
import {UserJsonld, UserService} from "@app/core/api/v1";
import {AccountService} from "@app/_services";
import {AppHelperService} from "@app/_helpers/app-helper.service";

@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrl: './user.component.scss'
})
export class UserComponent implements OnInit, AfterViewInit {

@Input() public user!: UserJsonld;
protected userSub: Subscription;

constructor(
private accountService: AccountService,
private userService: UserService,
protected appHelperService: AppHelperService
) {
this.userSub = new Subscription();
}

ngOnInit() {

}

ngAfterViewInit(): void {
this.getData();
}

getData() {
const user = this.accountService.userValue;
if (user?.id !== null && user?.id !== undefined) {
this.userSub = this.userService.usersIdGet(
this.appHelperService.extractId(user.id)
).subscribe(
data => {
this.user = data;
}
);
}
}

}

+ 2
- 0
matsen-tool/src/app/app.module.ts Dosyayı Görüntüle

@@ -59,6 +59,7 @@ import { ProductListComponent } from './_views/products/product-list/product-lis
import { DocumentListComponent } from './_views/documents/document-list/document-list.component';
import { SaleListComponent } from './_views/sales/sale-list/sale-list.component';
import { SaleSummaryComponent } from './_views/sales/sale-summary/sale-summary.component';
import { UserComponent } from './_views/user/user/user.component';

export function apiConfigFactory(): Configuration {
const params: ConfigurationParameters = {
@@ -139,6 +140,7 @@ export function HttpLoaderFactory(http: HttpClient) {
DocumentListComponent,
SaleListComponent,
SaleSummaryComponent,
UserComponent,
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},


Yükleniyor…
İptal
Kaydet