diff options
author | devega <ma.devega@globunet.com> | 2019-05-13 10:58:04 +0200 |
---|---|---|
committer | devega <ma.devega@globunet.com> | 2019-05-13 10:58:04 +0200 |
commit | d619dddd6bc80694096090337e331dc51e7c5ea4 (patch) | |
tree | be46a3b2acce9b617f77eca5fc4c06315be8f82f /admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts | |
parent | d624c25993a589197a09ca7998764bd7727eaf08 (diff) | |
parent | 992e7e507c33cde23b494cc3d5b3e1e24fab0480 (diff) |
Merge remote-tracking branch 'origin/webconsole3' into webconsole3
Diffstat (limited to 'admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts')
-rw-r--r-- | admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts b/admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts index a7ef127f..4b4306af 100644 --- a/admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts +++ b/admin/WebConsole3/frontend/src/app/pages/hardware-component/hardware-component.component.ts @@ -1,17 +1,48 @@ -import { Component } from '@angular/core';
-
-import { HardwareComponentService } from 'src/app/api/hardware-component.service';
-import { HardwareComponent } from 'src/app/model/hardware-component';
-
-@Component({
- selector: 'app-hardware-component',
- templateUrl: './hardware-component.component.html',
- styleUrls: [ './hardware-component.component.scss' ]
-})
-export class HardwareComponentComponent {
- // this tells the tabs component which Pages
- // should be each tab's root Page
- constructor(public hardwareComponentService: HardwareComponentService) {
- }
-
-}
+import { Component } from '@angular/core'; + +import { HardwareComponentService } from 'src/app/api/hardware-component.service'; +import { HardwareComponent } from 'src/app/model/hardware-component'; +import {Observable} from 'rxjs'; +import {ToasterService} from '../../service/toaster.service'; +import {TranslateService} from '@ngx-translate/core'; +import {Router} from '@angular/router'; + +@Component({ + selector: 'app-hardware-component', + templateUrl: './hardware-component.component.html', + styleUrls: [ './hardware-component.component.scss' ] +}) +export class HardwareComponentComponent { + // this tells the tabs component which Pages + public hardwareComponent: HardwareComponent; + formType: any; + // should be each tab's root Page + constructor(public hardwareComponentService: HardwareComponentService, private toaster: ToasterService, private translate: TranslateService, private router: Router) { + this.hardwareComponent = new HardwareComponent(); + this.formType = [{ + field: 'description', + name: 'description', + label: 'description', + type: 'textarea' + }]; + } + + save() { + let request: Observable<HardwareComponent>; + if (this.hardwareComponent.id !== 0) { + request = this.hardwareComponentService.update(this.hardwareComponent); + } else { + request = this.hardwareComponentService.create(this.hardwareComponent); + } + + request.subscribe( + (response) => { + this.toaster.pop({type: this.translate.instant('success'), title: this.translate.instant('success'), body: this.translate.instant('successfully_saved')}); + this.router.navigate(['/app/hardware']); + }, + (error) => { + this.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + } +} |