backend: microservices-oriented architecture, clean-architecture design pattern, spring-boot, spring cloud gateway, spring cloud eureka et spring cloud config. - frontend: angular, observer rxjs

sub-compo-company-printer.component.ts 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Router } from '@angular/router';
  2. import { CompanyEventPublisher } from '../../../../shared/events-publisher/events.publisher';
  3. import { Company } from '../../../../shared/models/company/company.model';
  4. import { Component, Input, OnInit } from '@angular/core';
  5. import { CompanyEvent } from 'src/app/shared/models/events.model';
  6. import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
  7. @Component({
  8. selector: 'app-sub-compo-company-printer',
  9. templateUrl: './sub-compo-company-printer.component.html',
  10. styleUrls: ['./sub-compo-company-printer.component.scss']
  11. })
  12. export class SubCompoCompanyPrinterComponent implements OnInit {
  13. constructor(private companyEventPublisher: CompanyEventPublisher,
  14. private companyService: CompanyService,
  15. private router : Router) { }
  16. @Input () companies!: Array<Company>;
  17. ngOnInit(): void {
  18. this.companyEventPublisher.companyEventObservable.subscribe((companyEvent: CompanyEvent)=>{
  19. switch(companyEvent) {
  20. case CompanyEvent.UPDATE_COMPANY_FORM:
  21. this.router.navigateByUrl('company-update/'+this.idToUpdate);
  22. console.log(companyEvent);
  23. break;
  24. case CompanyEvent.PROJECTS_ASSIGNEDTO_COMPANY:
  25. this.router.navigateByUrl('projects-assignedto-company/'+this.companyIDProjectsRelated);
  26. console.log(companyEvent);
  27. break;
  28. }
  29. })
  30. }
  31. idToUpdate!: string;
  32. onCompanyUpdate(company: Company){
  33. this.idToUpdate = company.companyID;
  34. this.companyEventPublisher.publishCompanyEvent(CompanyEvent.UPDATE_COMPANY_FORM)
  35. }
  36. onCompanyDelete(companyID: string){
  37. if(window.confirm('CONFIRM COMPANY DELETE')){
  38. this.companyService.deleteCompany(companyID).subscribe(
  39. ()=>{
  40. this.companyEventPublisher.publishCompanyEvent(CompanyEvent.REFRESH);
  41. }
  42. );
  43. }
  44. }
  45. companyIDProjectsRelated!: string;
  46. onPrintProjectsRelated(companyID: string){
  47. this.companyIDProjectsRelated = companyID;
  48. this.companyEventPublisher.publishCompanyEvent(CompanyEvent.PROJECTS_ASSIGNEDTO_COMPANY)
  49. }
  50. }

Powered by TurnKey Linux.