From 22ee53e9db2b7394ef9f0f11441909283b464919 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 28 Jan 2025 07:43:34 +0100 Subject: [PATCH] Fixed test --- ogWebconsole/src/app/app-routing.module.ts | 4 +- ogWebconsole/src/app/app.module.ts | 4 +- .../create-image/create-image.component.html | 2 +- .../create-image.component.spec.ts | 77 ------------------- .../create-image/create-image.component.ts | 56 +------------- .../deploy-image/deploy-image.component.html | 4 +- .../deploy-image.component.spec.ts | 2 + .../deploy-image/deploy-image.component.ts | 2 +- .../groups/groups.component.spec.ts | 5 +- .../app/components/groups/groups.component.ts | 35 +-------- ogWebconsole/src/locale/en.json | 1 + ogWebconsole/src/locale/es.json | 1 + 12 files changed, 19 insertions(+), 174 deletions(-) delete mode 100644 ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.spec.ts diff --git a/ogWebconsole/src/app/app-routing.module.ts b/ogWebconsole/src/app/app-routing.module.ts index 29f3474..c87b1d9 100644 --- a/ogWebconsole/src/app/app-routing.module.ts +++ b/ogWebconsole/src/app/app-routing.module.ts @@ -31,7 +31,7 @@ import { } from "./components/groups/components/client-main-view/partition-assistant/partition-assistant.component"; import {RepositoriesComponent} from "./components/repositories/repositories.component"; import { - CreateImageComponent + CreateClientImageComponent } from "./components/groups/components/client-main-view/create-image/create-image.component"; import { DeployImageComponent @@ -66,7 +66,7 @@ const routes: Routes = [ { path: 'clients/deploy-image', component: DeployImageComponent }, { path: 'clients/partition-assistant', component: PartitionAssistantComponent }, { path: 'clients/:id', component: ClientMainViewComponent }, - { path: 'clients/:id/create-image', component: CreateImageComponent }, + { path: 'clients/:id/create-image', component: CreateClientImageComponent }, { path: 'images', component: ImagesComponent }, { path: 'repositories', component: RepositoriesComponent }, { path: 'repository/:id', component: MainRepositoryViewComponent }, diff --git a/ogWebconsole/src/app/app.module.ts b/ogWebconsole/src/app/app.module.ts index da98482..d620284 100644 --- a/ogWebconsole/src/app/app.module.ts +++ b/ogWebconsole/src/app/app.module.ts @@ -101,6 +101,7 @@ import {MatSliderModule} from '@angular/material/slider'; import { ClientMainViewComponent } from './components/groups/components/client-main-view/client-main-view.component'; import { ImagesComponent } from './components/images/images.component'; import { CreateImageComponent } from './components/images/create-image/create-image.component'; +import { CreateClientImageComponent} from './components/groups/components/client-main-view/create-image/create-image.component'; import { PartitionAssistantComponent } from './components/groups/components/client-main-view/partition-assistant/partition-assistant.component'; import { SoftwareComponent } from './components/software/software.component'; import { CreateSoftwareComponent } from './components/software/create-software/create-software.component'; @@ -172,6 +173,7 @@ export function HttpLoaderFactory(http: HttpClient) { CreateCommandComponent, CalendarComponent, CreateCalendarComponent, + CreateClientImageComponent, CreateCalendarRuleComponent, CommandsGroupsComponent, CommandsTaskComponent, @@ -203,7 +205,7 @@ export function HttpLoaderFactory(http: HttpClient) { EnvVarsComponent, MenusComponent, CreateMenuComponent, - CreateMultipleClientComponent + CreateMultipleClientComponent, ], bootstrap: [AppComponent], imports: [BrowserModule, diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html index b885c6f..8f02096 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html @@ -1,6 +1,6 @@
-

+

Crear imagen desde {{ clientName }}

diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.spec.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.spec.ts deleted file mode 100644 index 1cb70ef..0000000 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.spec.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { CreateImageComponent } from './create-image.component'; -import { provideHttpClient } from '@angular/common/http'; -import { provideHttpClientTesting } from '@angular/common/http/testing'; -import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatCheckboxModule } from '@angular/material/checkbox'; -import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatInputModule } from '@angular/material/input'; -import { MatPaginatorModule } from '@angular/material/paginator'; -import { MatTableModule } from '@angular/material/table'; -import { MatTabsModule } from '@angular/material/tabs'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { ActivatedRoute } from '@angular/router'; -import { TranslateModule } from '@ngx-translate/core'; -import { ToastrModule, ToastrService } from 'ngx-toastr'; -import { of } from 'rxjs'; - -describe('CreateImageComponent', () => { - let component: CreateImageComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ - CreateImageComponent, - ReactiveFormsModule, - MatDialogModule, - MatFormFieldModule, - MatInputModule, - MatCheckboxModule, - MatButtonModule, - MatTabsModule, - MatTableModule, - MatPaginatorModule, - BrowserAnimationsModule, - ToastrModule.forRoot(), - TranslateModule.forRoot() - ], - providers: [ - FormBuilder, - ToastrService, - provideHttpClient(), - provideHttpClientTesting(), - { - provide: MatDialogRef, - useValue: {} - }, - { - provide: MAT_DIALOG_DATA, - useValue: {} - }, - { - provide: ActivatedRoute, - useValue: { - snapshot: { - paramMap: { - get: (key: string) => 'valorSimulado' - } - }, - params: of({ id: 'valorSimulado' }) - } - } - ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CreateImageComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.ts index 88a478e..08d95b1 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.ts @@ -2,65 +2,14 @@ import {Component, EventEmitter, Output} from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {ToastrService} from "ngx-toastr"; import {ActivatedRoute, Router} from "@angular/router"; -import {MatButton} from "@angular/material/button"; -import {MatDivider} from "@angular/material/divider"; -import {NgForOf, NgIf} from "@angular/common"; -import {FormsModule, ReactiveFormsModule} from "@angular/forms"; -import { - MatCell, MatCellDef, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, - MatTable, - MatTableDataSource -} from "@angular/material/table"; -import {MatChip} from "@angular/material/chips"; -import {MatCheckbox} from "@angular/material/checkbox"; +import {MatTableDataSource} from "@angular/material/table"; import {SelectionModel} from "@angular/cdk/collections"; -import {MatRadioButton, MatRadioGroup} from "@angular/material/radio"; -import {MatFormField, MatLabel} from "@angular/material/form-field"; -import {MatOption} from "@angular/material/autocomplete"; -import {MatSelect} from "@angular/material/select"; -import {MatInput} from "@angular/material/input"; -import {JoyrideModule} from "ngx-joyride"; -import {TranslatePipe} from "@ngx-translate/core"; - @Component({ selector: 'app-create-image', templateUrl: './create-image.component.html', - standalone: true, - imports: [ - MatButton, - MatDivider, - NgForOf, - NgIf, - ReactiveFormsModule, - MatTable, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, - MatCell, - MatCellDef, - MatChip, - MatHeaderRow, - MatRow, - MatHeaderRowDef, - MatRowDef, - MatCheckbox, - MatRadioGroup, - MatRadioButton, - MatFormField, - MatLabel, - MatOption, - MatSelect, - MatInput, - FormsModule, - JoyrideModule, - TranslatePipe - ], styleUrl: './create-image.component.css' }) -export class CreateImageComponent { +export class CreateClientImageComponent { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; @Output() dataChange = new EventEmitter(); @@ -114,7 +63,6 @@ export class CreateImageComponent { ngOnInit() { this.clientId = this.route.snapshot.paramMap.get('id'); - this.loadPartitions(); this.loadImages(); } diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html index 472670e..d7582a9 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html @@ -1,7 +1,7 @@
-

- Despliegue de imagen +

+ {{ 'deployImage' | translate }}

diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.spec.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.spec.ts index a6a2e2b..94ead75 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.spec.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.spec.ts @@ -17,6 +17,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ToastrModule, ToastrService } from 'ngx-toastr'; import { provideRouter } from '@angular/router'; import { MatSelectModule } from '@angular/material/select'; +import {MatExpansionModule} from "@angular/material/expansion"; describe('DeployImageComponent', () => { let component: DeployImageComponent; @@ -32,6 +33,7 @@ describe('DeployImageComponent', () => { MatFormFieldModule, MatInputModule, MatCheckboxModule, + MatExpansionModule, MatButtonModule, MatTableModule, MatDividerModule, diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts index 4d127bf..50684eb 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts @@ -100,7 +100,7 @@ export class DeployImageComponent { ) { const navigation = this.router.getCurrentNavigation(); this.clientData = navigation?.extras?.state?.['clientData']; - this.clientId = this.clientData[0]['@id']; + this.clientId = this.clientData?.[0]['@id']; this.loadImages(); this.loadPartitions() } diff --git a/ogWebconsole/src/app/components/groups/groups.component.spec.ts b/ogWebconsole/src/app/components/groups/groups.component.spec.ts index 96b59f4..3da4b0e 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.spec.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.spec.ts @@ -25,6 +25,7 @@ import { JoyrideModule } from 'ngx-joyride'; import { MatMenuModule } from '@angular/material/menu'; import { MatTreeModule } from '@angular/material/tree'; import { TreeNode } from './model/model'; +import {ExecuteCommandComponent} from "../commands/main-commands/execute-command/execute-command.component"; describe('GroupsComponent', () => { let component: GroupsComponent; @@ -32,7 +33,7 @@ describe('GroupsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [GroupsComponent], + declarations: [GroupsComponent, ExecuteCommandComponent], imports: [ HttpClientTestingModule, ToastrModule.forRoot(), @@ -120,4 +121,4 @@ describe('GroupsComponent', () => { component.expandPathToNode(node); expect(component.expandPathToNode).toHaveBeenCalledWith(node); }); -}); \ No newline at end of file +}); diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 775caca..08b7283 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -253,7 +253,7 @@ export class GroupsComponent implements OnInit, OnDestroy { }); } - private expandPathToNode(node: TreeNode): void { + expandPathToNode(node: TreeNode): void { const path: TreeNode[] = []; let currentNode: TreeNode | null = node; @@ -318,23 +318,6 @@ export class GroupsComponent implements OnInit, OnDestroy { }); } - getNodeIcon(node: TreeNode): string { - switch (node.type) { - case NodeType.OrganizationalUnit: - return 'apartment'; - case NodeType.ClassroomsGroup: - return 'doors'; - case NodeType.Classroom: - return 'school'; - case NodeType.ClientsGroup: - return 'lan'; - case NodeType.Client: - return 'computer'; - default: - return 'group'; - } - } - addOU(event: MouseEvent, parent: TreeNode | null = null): void { event.stopPropagation(); const dialogRef = this.dialog.open(CreateOrganizationalUnitComponent, { @@ -486,22 +469,6 @@ export class GroupsComponent implements OnInit, OnDestroy { ); } - fetchCommands(): void { - this.commandsLoading = true; - this.subscriptions.add( - this.http.get<{ 'hydra:member': Command[] }>(`${this.baseUrl}/commands?page=1&itemsPerPage=30`).subscribe( - (response) => { - this.commands = response['hydra:member']; - this.commandsLoading = false; - }, - (error) => { - console.error('Error fetching commands:', error); - this.commandsLoading = false; - } - ) - ); - } - executeCommand(command: Command, selectedNode: TreeNode | null): void { if (!selectedNode) { diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json index 2f3e361..047eb32 100644 --- a/ogWebconsole/src/locale/en.json +++ b/ogWebconsole/src/locale/en.json @@ -268,6 +268,7 @@ "diskUsedLabel": "Used", "diskTotalLabel": "Total", "diskImageAssistantTitle": "Disk image assistant", + "deployImage": "Deploy image", "partitionColumn": "Partition", "isoImageColumn": "ISO Image", "ogliveColumn": "OgLive", diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json index 30e4b65..66eb9b7 100644 --- a/ogWebconsole/src/locale/es.json +++ b/ogWebconsole/src/locale/es.json @@ -273,6 +273,7 @@ "isoImageColumn": "Imagen ISO", "ogliveColumn": "OgLive", "selectImageOption": "Seleccionar imagen", + "deployImage": "Desplegar imagen", "selectOgLiveOption": "Seleccionar OgLive", "saveAssociationsButton": "Guardar Asociaciones", "partitionAssistantTitle": "Asistente de particionado",