From 7feafb53b3823b7527d2bbf0343502f85793107b Mon Sep 17 00:00:00 2001 From: "jm.bardallo" Date: Tue, 14 May 2019 15:04:17 +0200 Subject: reforma formularios de cliente y repositorio Plantillas netboot y envio de comandos --- .../frontend/src/app/form-type/client.form-type.ts | 5 +- .../frontend/src/app/model/repository.ts | 6 +- .../pages/common/forms/form-input.component.html | 30 +- .../app/pages/common/forms/form-input.component.ts | 13 +- .../pages/netboot/edit/netboot-edit.component.html | 74 ++--- .../pages/netboot/edit/netboot-edit.component.ts | 127 ++++----- .../src/app/pages/netboot/netboot.component.ts | 178 ++++++------ .../app/pages/repository/repository.component.html | 2 +- .../app/pages/repository/repository.component.ts | 301 +++++++++++---------- .../src/app/serializer/client.serializer.ts | 4 +- .../frontend/src/environments/environment.ts | 6 +- admin/WebConsole3/frontend/src/styles.scss | 2 + 12 files changed, 383 insertions(+), 365 deletions(-) diff --git a/admin/WebConsole3/frontend/src/app/form-type/client.form-type.ts b/admin/WebConsole3/frontend/src/app/form-type/client.form-type.ts index 2ee85086..c082d264 100644 --- a/admin/WebConsole3/frontend/src/app/form-type/client.form-type.ts +++ b/admin/WebConsole3/frontend/src/app/form-type/client.form-type.ts @@ -11,7 +11,7 @@ export class ClientFormType extends GlobunetFormType { this.setFieldType(form, 'netboot', 'select'); this.getField(form, 'oglive').options = { label: 'iso', - value: 'iso' + value: 'directory' }; this.getField(form, 'repository').options = { label: 'name', @@ -20,9 +20,10 @@ export class ClientFormType extends GlobunetFormType { label: 'name', }; this.getField(form, 'netboot').options = { - label: 'name', + label: 'name' }; + return form; } } diff --git a/admin/WebConsole3/frontend/src/app/model/repository.ts b/admin/WebConsole3/frontend/src/app/model/repository.ts index 36838128..93a717db 100644 --- a/admin/WebConsole3/frontend/src/app/model/repository.ts +++ b/admin/WebConsole3/frontend/src/app/model/repository.ts @@ -3,7 +3,8 @@ import { Resource } from 'globunet-angular/core/models/api/resource'; export class Repository extends Resource { name: string; ip: string; - password: string; + randomId: string; + secret: string; description: string; info: any; @@ -11,7 +12,8 @@ export class Repository extends Resource { super(); this.name = ''; this.ip = ''; - this.password = ''; + this.randomId = ''; + this.secret = ''; this.description = ''; } } diff --git a/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.html b/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.html index d45463ba..7e010811 100644 --- a/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.html +++ b/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.html @@ -1,15 +1,15 @@ -
-
- -
- - - - -
-
-
+
+
+ +
+ + + + +
+
+
diff --git a/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.ts b/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.ts index 86412ad0..2cb113be 100644 --- a/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.ts +++ b/admin/WebConsole3/frontend/src/app/pages/common/forms/form-input.component.ts @@ -9,7 +9,7 @@ export class FormInputComponent { private _cols: number; @Input() model; - + @Input() set cols(cols) { this._cols = (typeof cols !== 'undefined') ? (12 / cols) : 6; @@ -43,4 +43,15 @@ export class FormInputComponent { } return result; } + + compareFn = (a, b) => { + let result = false; + if (a !== null && b !== null && typeof a === 'object' && typeof b === 'object') { + result = (a.id === b.id); + } else{ + result = (a === b); + } + return result; + } + } diff --git a/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.html b/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.html index 5b43af7e..bf8d9955 100644 --- a/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.html +++ b/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.html @@ -1,37 +1,37 @@ -
-

-

- -
-
-
-
-
- -
-
-
-
-
-
-
-
-
-

-
-
-
- - -
-
- -
-
-
-
+
+

+

+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+

+
+
+
+ + +
+
+ +
+
+
+
diff --git a/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.ts b/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.ts index 8e74784f..360e8fff 100644 --- a/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.ts +++ b/admin/WebConsole3/frontend/src/app/pages/netboot/edit/netboot-edit.component.ts @@ -1,63 +1,64 @@ -import {Component, OnInit} from '@angular/core'; - -import { NetbootService } from 'src/app/api/netboot.service'; -import { Netboot } from 'src/app/model/netboot'; -import {OgSweetAlertService} from '../../../service/og-sweet-alert.service'; -import {ToasterService} from '../../../service/toaster.service'; -import {TranslateService} from '@ngx-translate/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {NetbootFormType} from '../../../form-type/netboot.form-type'; - -@Component({ - selector: 'app-netboot', - templateUrl: './netboot-edit.component.html', - styleUrls: [ './netboot-edit.component.scss' ] -}) -export class NetbootEditComponent implements OnInit { - private form: any[]; - public netboot: Netboot; - - // this tells the tabs component which Pages - // should be each tab's root Page - constructor(public netbootService: NetbootService, private router: Router, private activatedRoute: ActivatedRoute, private ogSweetAlert: OgSweetAlertService, private toaster: ToasterService, private translate: TranslateService) { - this.form = new NetbootFormType().getForm(); - } - - ngOnInit(): void { - this.activatedRoute.paramMap.subscribe( - (data: any) => { - if (data.params.id) { - this.netbootService.read(data.params.id).subscribe( - response => { - this.netboot = response; - }, - error => { - this.toaster.pop({type: 'error', title: 'error', body: error}); - } - ); - } else { - this.netboot = new Netboot(); - } - } - ); - - } - - - save() { - let request; - if (this.netboot.id === 0) { - request = this.netbootService.create(this.netboot); - } else { - request = this.netbootService.update(this.netboot); - } - request.subscribe( - data => { - this.router.navigate(['/app/netboots']); - }, - error => { - this.toaster.pop({type: 'error', title: 'error', body: error}); - } - ); - } -} +import {Component, OnInit} from '@angular/core'; + +import { NetbootService } from 'src/app/api/netboot.service'; +import { Netboot } from 'src/app/model/netboot'; +import {OgSweetAlertService} from '../../../service/og-sweet-alert.service'; +import {ToasterService} from '../../../service/toaster.service'; +import {TranslateService} from '@ngx-translate/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {NetbootFormType} from '../../../form-type/netboot.form-type'; + +@Component({ + selector: 'app-netboot', + templateUrl: './netboot-edit.component.html', + styleUrls: [ './netboot-edit.component.scss' ] +}) +export class NetbootEditComponent implements OnInit { + private form: any[]; + public netboot: Netboot; + + // this tells the tabs component which Pages + // should be each tab's root Page + constructor(public netbootService: NetbootService, private router: Router, private activatedRoute: ActivatedRoute, private ogSweetAlert: OgSweetAlertService, private toaster: ToasterService, private translate: TranslateService) { + this.form = new NetbootFormType().getForm(); + this.netboot = new Netboot(); + } + + ngOnInit(): void { + this.activatedRoute.paramMap.subscribe( + (data: any) => { + if (data.params.id) { + this.netbootService.read(data.params.id).subscribe( + response => { + this.netboot = response; + }, + error => { + this.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + } else { + this.netboot = new Netboot(); + } + } + ); + + } + + + save() { + let request; + if (this.netboot.id === 0) { + request = this.netbootService.create(this.netboot); + } else { + request = this.netbootService.update(this.netboot); + } + request.subscribe( + data => { + this.router.navigate(['/app/netboots']); + }, + error => { + this.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + } +} diff --git a/admin/WebConsole3/frontend/src/app/pages/netboot/netboot.component.ts b/admin/WebConsole3/frontend/src/app/pages/netboot/netboot.component.ts index 78718ca9..a275e0be 100644 --- a/admin/WebConsole3/frontend/src/app/pages/netboot/netboot.component.ts +++ b/admin/WebConsole3/frontend/src/app/pages/netboot/netboot.component.ts @@ -1,89 +1,89 @@ -import {Component, OnInit} from '@angular/core'; - -import { NetbootService } from 'src/app/api/netboot.service'; -import { Netboot } from 'src/app/model/netboot'; -import {OgSweetAlertService} from '../../service/og-sweet-alert.service'; -import {ToasterService} from '../../service/toaster.service'; -import {TranslateService} from '@ngx-translate/core'; -import {Router} from '@angular/router'; - -@Component({ - selector: 'app-netboot', - templateUrl: './netboot.component.html', - styleUrls: [ './netboot.component.scss' ] -}) -export class NetbootComponent implements OnInit { - searchText: any; - netboots: any[]; - tableOptions: any; - - // this tells the tabs component which Pages - // should be each tab's root Page - constructor(public netbootService: NetbootService, private router: Router, private ogSweetAlert: OgSweetAlertService, private toaster: ToasterService, private translate: TranslateService) { - this.tableOptions = { - override: false, - buttons: [ - { - action: 'edit' - }, - { - action: 'copy', - label: 'copy', - handler: (rowData) => this.goToNetbootCopy(rowData), - classes: 'btn-default' - }, - { - action: 'delete' - } - ] - }; - } - - ngOnInit(): void { - this.netbootService.list().subscribe( - response => { - this.netboots = response; - }, - error => { - this.toaster.pop({type: 'error', title: 'error', body: error}); - } - ); - } - - deleteNetboot(id) { - const self = this; - this.ogSweetAlert.question(this.translate.instant('sure_to_delete') + '?', this.translate.instant('action_cannot_be_undone'), function() { - self.netbootService.delete(id).subscribe( - (response) => { - self.toaster.pop({type: 'success', title: self.translate.instant('success'), body: self.translate.instant('successfully_deleted')}); - const index = self.netboots.findIndex((object) => object.id === id); - if (index !== -1) { - self.netboots.splice(index, 1); - } - }, - (error) => { - self.toaster.pop({type: 'error', title: 'error', body: error}); - } - ); - }); - } - - goToNetbootEdit(id) { - this.router.navigate(['/app/netboots/', id, 'edit']); - } - - goToNetbootCopy(template: Netboot) { - const copy = Object.assign({}, template); - this.netbootService.create(copy).subscribe( - data => { - // Comprobar que en data viene el id - const newId = data.id; - this.goToNetbootEdit(newId); - }, - error => { - this.toaster.pop({type: 'error', title: 'error', body: error}); - } - ); - - } -} +import {Component, OnInit} from '@angular/core'; + +import { NetbootService } from 'src/app/api/netboot.service'; +import { Netboot } from 'src/app/model/netboot'; +import {OgSweetAlertService} from '../../service/og-sweet-alert.service'; +import {ToasterService} from '../../service/toaster.service'; +import {TranslateService} from '@ngx-translate/core'; +import {Router} from '@angular/router'; + +@Component({ + selector: 'app-netboot', + templateUrl: './netboot.component.html', + styleUrls: [ './netboot.component.scss' ] +}) +export class NetbootComponent implements OnInit { + searchText: any; + netboots: any[]; + tableOptions: any; + + // this tells the tabs component which Pages + // should be each tab's root Page + constructor(public netbootService: NetbootService, private router: Router, private ogSweetAlert: OgSweetAlertService, private toaster: ToasterService, private translate: TranslateService) { + this.tableOptions = { + override: false, + buttons: [ + { + action: 'edit' + }, + { + action: 'copy', + label: 'copy', + handler: (rowData) => this.goToNetbootCopy(rowData), + classes: 'btn-default' + }, + { + action: 'delete', + } + ] + }; + } + + ngOnInit(): void { + this.netbootService.list().subscribe( + response => { + this.netboots = response; + }, + error => { + this.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + } + + deleteNetboot(id) { + const self = this; + this.ogSweetAlert.question(this.translate.instant('sure_to_delete') + '?', this.translate.instant('action_cannot_be_undone'), function() { + self.netbootService.delete(id).subscribe( + (response) => { + self.toaster.pop({type: 'success', title: self.translate.instant('success'), body: self.translate.instant('successfully_deleted')}); + const index = self.netboots.findIndex((object) => object.id === id); + if (index !== -1) { + self.netboots.splice(index, 1); + } + }, + (error) => { + self.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + }); + } + + goToNetbootEdit(id) { + this.router.navigate(['/app/netboots/', id, 'edit']); + } + + goToNetbootCopy(template: Netboot) { + const copy = Object.assign({}, template); + this.netbootService.create(copy).subscribe( + data => { + // Comprobar que en data viene el id + const newId = data.id; + this.goToNetbootEdit(newId); + }, + error => { + this.toaster.pop({type: 'error', title: 'error', body: error}); + } + ); + + } +} diff --git a/admin/WebConsole3/frontend/src/app/pages/repository/repository.component.html b/admin/WebConsole3/frontend/src/app/pages/repository/repository.component.html index a2d0cf28..a8d072f8 100644 --- a/admin/WebConsole3/frontend/src/app/pages/repository/repository.component.html +++ b/admin/WebConsole3/frontend/src/app/pages/repository/repository.component.html @@ -40,7 +40,7 @@