Advertisement
Guest User

Untitled

a guest
May 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2016-2017 by Teradata Corporation. All rights reserved.
  3. * TERADATA CORPORATION CONFIDENTIAL AND TRADE SECRET
  4. */
  5.  
  6. import { Component, AfterViewInit, OnInit } from '@angular/core';
  7. import { Router, ActivatedRoute } from '@angular/router';
  8.  
  9. import { TdLoadingService } from '@covalent/core';
  10.  
  11. import { SystemsService, ISystem, IAddSystemApi, REGION_TYPES,
  12. RegionType, ErrorService, ToastService } from '../../../services';
  13.  
  14. @Component({
  15. selector: 'system-form',
  16. templateUrl: './form.component.html',
  17. styleUrls: ['./form.component.scss'],
  18. viewProviders: [ SystemsService ],
  19. })
  20. export class SystemsFormComponent implements AfterViewInit, OnInit {
  21.  
  22. system: ISystem
  23. types: RegionType[] = REGION_TYPES;
  24. tested: boolean = false;
  25. temp: any = {
  26. username: '',
  27. password: '',
  28. };
  29.  
  30. constructor(private _systemsService: SystemsService,
  31. private _errorService: ErrorService,
  32. private _toastService: ToastService,
  33. private _route: ActivatedRoute,
  34. private _router: Router,
  35. private _loadingService: TdLoadingService) {}
  36. ngOnInit(): void {
  37. this._route.params.subscribe((params: {id: string}) => {
  38. let systemId: string = params.id;
  39. if (systemId) {
  40. this._loadingService.register('system.form');
  41. this._systemsService.query({'system_id': systemId})
  42. .subscribe((system: ISystem) => {
  43. this.system = system;
  44. console.log(this.system);
  45. this._loadingService.resolve('system.form');
  46. }, (error: any) => {
  47. this._errorService.open(error);
  48. this._loadingService.resolve('system.form');
  49. });
  50. }
  51. });
  52. }
  53.  
  54. ngAfterViewInit(): void {
  55.  
  56. }
  57.  
  58. goBack(): void {
  59. this._router.navigate(['/syst']);
  60. }
  61.  
  62.  
  63.  
  64. isDatabaseRequired(): boolean {
  65. switch (this.system.region_type) {
  66. case RegionType.Region1:
  67. return true;
  68. default:
  69. return false;
  70. }
  71. }
  72.  
  73. isDefaultDatabaseSupport(): boolean {
  74. switch (this.system.region_type) {
  75. case RegionType.Region1:
  76. case RegionType.Region2:
  77. return true;
  78. default:
  79. return false;
  80. }
  81. }
  82.  
  83. resetTest(): void {
  84. this.tested = false;
  85. }
  86.  
  87.  
  88.  
  89. save(): void {
  90. let system: IAddSystemApi = {
  91. AddSystem: {
  92. system: {
  93. address: "system.address",
  94. name: "system.name",
  95. }
  96.  
  97.  
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement