選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

82 行
3.6 KiB

  1. import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
  2. import {UserJsonld, UserService} from "@app/core/api/v1";
  3. import {Subscription} from "rxjs";
  4. import {AccountService} from "@app/_services";
  5. import {AppHelperService} from "@app/_helpers/app-helper.service";
  6. import {UsersComponent} from "@app/_views/user/users.component";
  7. import {ToggleComponent} from "@app/_components/toggle/toggle.component";
  8. import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component";
  9. import {SaleListComponent} from "@app/_views/sales/sale-list/sale-list.component";
  10. import {ProductListComponent} from "@app/_views/products/product-list/product-list.component";
  11. import {PartnerListComponent} from "@app/_views/partners/partner-list/partner-list.component";
  12. import {PostListComponent} from "@app/_views/posts/post-list/post-list.component";
  13. import {SaleSummaryComponent} from "@app/_views/sales/sale-summary/sale-summary.component";
  14. import {ActivatedRoute} from "@angular/router";
  15. @Component({
  16. selector: 'app-user-detail',
  17. templateUrl: './user-detail.component.html',
  18. styleUrl: './user-detail.component.scss'
  19. })
  20. export class UserDetailComponent implements OnInit, AfterViewInit {
  21. @Input() public user!: UserJsonld;
  22. @ViewChild("togglePosts", { static: true }) togglePosts!: ToggleComponent;
  23. @ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent;
  24. @ViewChild("toggleTasks", { static: true }) toggleTasks!: ToggleComponent;
  25. @ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent;
  26. @ViewChild("toggleSales", { static: true }) toggleSales!: ToggleComponent;
  27. @ViewChild("saleSummaryComponent", { static: false }) saleSummaryComponent!: SaleSummaryComponent;
  28. @ViewChild("saleListComponent", { static: false }) saleListComponent!: SaleListComponent;
  29. @ViewChild("toggleProducts", { static: true }) toggleProducts!: ToggleComponent;
  30. @ViewChild("productListComponent", { static: false }) productListComponent!: ProductListComponent;
  31. @ViewChild("toggleCustomers", { static: true }) toggleCustomers!: ToggleComponent;
  32. @ViewChild("customerListComponent", { static: false }) customerListComponent!: PartnerListComponent;
  33. @ViewChild("toggleSuppliers", { static: true }) toggleSuppliers!: ToggleComponent;
  34. @ViewChild("suppliersListComponent", { static: false }) suppliersListComponent!: PartnerListComponent;
  35. @ViewChild("toggleServices", { static: true }) toggleServices!: ToggleComponent;
  36. @ViewChild("servicesListComponent", { static: false }) servicesListComponent!: PartnerListComponent;
  37. protected userSub: Subscription;
  38. protected isCurrentUser: boolean;
  39. protected userId!: string;
  40. constructor(
  41. private accountService: AccountService,
  42. private userService: UserService,
  43. protected appHelperService: AppHelperService,
  44. private route: ActivatedRoute,
  45. ) {
  46. this.userSub = new Subscription();
  47. this.isCurrentUser = false;
  48. }
  49. ngOnInit() {
  50. this.route.params.subscribe(params => {
  51. this.userId = params['id'];
  52. });
  53. console.log(this.userId);
  54. }
  55. ngAfterViewInit(): void {
  56. if (this.accountService.userValue?.userResource) {
  57. let user = this.accountService.userValue?.userResource;
  58. this.isCurrentUser = this.userId == user?.id;
  59. }
  60. this.getData();
  61. }
  62. getData() {
  63. this.userSub = this.userService.usersIdGet(
  64. this.userId
  65. ).subscribe(
  66. data => {
  67. this.user = data;
  68. }
  69. );
  70. }
  71. }