diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts index dc61dc5ab67..b6ae76a66be 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts @@ -9,7 +9,9 @@ import { CheckboxModule, ButtonModule, GridModule, - ProgressIndicatorModule + ProgressIndicatorModule, + InputModule, + ModalModule } from 'carbon-components-angular'; import { TreeModule } from '@circlon/angular-tree-component'; @@ -102,7 +104,9 @@ import { MultiClusterDetailsComponent } from './multi-cluster/multi-cluster-deta CheckboxModule, GridModule, ProgressIndicatorModule, - ButtonModule + ButtonModule, + InputModule, + ModalModule ], declarations: [ HostsComponent, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.html index af09b9a4fef..9b751d69c5a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.html @@ -1,108 +1,104 @@ - - {{ action | titlecase }} {{ resource | upperFirst }} - - - -
-
- - - - -
+ + +

{{ action | titlecase }} {{ resource | upperFirst }}

+
+ +
+
+ +
+ Hostname + + + + + This field is required. + + + The chosen hostname is already in use. + + + + To add multiple hosts at once, you can enter: +
    +
  • a comma-separated list of hostnames (e.g.: example-01,example-02,example-03),
  • +
  • a range expression (e.g.: example-[01-03].ceph),
  • +
  • a comma separated range expression (e.g.: example-[01-05].lab.com,example2-[1-4].lab.com,example3-[001-006].lab.com)
  • +
+
+
+ +
+ Network address + + + + + The value is not a valid IP address. + + +
+ +
+ + + +
+ +
+ Maintenance Mode + +
- - + + +
+
+
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts index ed85d96cb1b..8097bb26018 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts @@ -10,6 +10,7 @@ import { LoadingPanelComponent } from '~/app/shared/components/loading-panel/loa import { SharedModule } from '~/app/shared/shared.module'; import { configureTestBed, FormHelper } from '~/testing/unit-test-helper'; import { HostFormComponent } from './host-form.component'; +import { InputModule, ModalModule } from 'carbon-components-angular'; describe('HostFormComponent', () => { let component: HostFormComponent; @@ -23,7 +24,9 @@ describe('HostFormComponent', () => { HttpClientTestingModule, RouterTestingModule, ReactiveFormsModule, - ToastrModule.forRoot() + ToastrModule.forRoot(), + InputModule, + ModalModule ], declarations: [HostFormComponent], providers: [NgbActiveModal] @@ -45,7 +48,7 @@ describe('HostFormComponent', () => { it('should open the form in a modal', () => { const nativeEl = fixture.debugElement.nativeElement; - expect(nativeEl.querySelector('cd-modal')).not.toBe(null); + expect(nativeEl.querySelector('cds-modal')).not.toBe(null); }); it('should validate the network address is valid', fakeAsync(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.ts index 240a0a7bebb..166ab013e73 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.ts @@ -1,8 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { UntypedFormControl, Validators } from '@angular/forms'; -import { Router } from '@angular/router'; - -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { ActivatedRoute, Router } from '@angular/router'; import expand from 'brace-expansion'; import { HostService } from '~/app/shared/api/host.service'; @@ -15,6 +13,7 @@ import { CdValidators } from '~/app/shared/forms/cd-validators'; import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context'; import { FinishedTask } from '~/app/shared/models/finished-task'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; +import { Location } from '@angular/common'; @Component({ selector: 'cd-host-form', @@ -22,6 +21,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; styleUrls: ['./host-form.component.scss'] }) export class HostFormComponent extends CdForm implements OnInit { + open: boolean = false; hostForm: CdFormGroup; action: string; resource: string; @@ -46,7 +46,8 @@ export class HostFormComponent extends CdForm implements OnInit { private actionLabels: ActionLabelsI18n, private hostService: HostService, private taskWrapper: TaskWrapperService, - public activeModal: NgbActiveModal + private route: ActivatedRoute, + private location: Location ) { super(); this.resource = $localize`host`; @@ -54,9 +55,7 @@ export class HostFormComponent extends CdForm implements OnInit { } ngOnInit() { - if (this.router.url.includes('hosts')) { - this.pageURL = 'hosts'; - } + this.open = this.route.outlet === 'modal'; this.createForm(); const hostContext = new CdTableFetchDataContext(() => undefined); this.hostService.list(hostContext.toParams(), 'false').subscribe((resp: any[]) => { @@ -69,7 +68,7 @@ export class HostFormComponent extends CdForm implements OnInit { this.hostService.getLabels().subscribe((resp: string[]) => { const uniqueLabels = new Set(resp.concat(this.hostService.predefinedLabels)); this.labelsOption = Array.from(uniqueLabels).map((label) => { - return { enabled: true, name: label, selected: false, description: null }; + return { enabled: true, name: label, content: label, selected: false, description: null }; }); }); } @@ -94,7 +93,7 @@ export class HostFormComponent extends CdForm implements OnInit { validators: [CdValidators.ip()] }), labels: new UntypedFormControl([]), - maintenance: new UntypedFormControl(false) + maintenance: new UntypedFormControl() }); } @@ -166,9 +165,13 @@ export class HostFormComponent extends CdForm implements OnInit { complete: () => { this.pageURL === 'hosts' ? this.router.navigate([this.pageURL, { outlets: { modal: null } }]) - : this.activeModal.close(); + : this.location.back(); } }); }); } + + closeModal(): void { + this.location.back(); + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index adb89e6cd5c..c26d24177fd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -29,7 +29,6 @@ import { Permissions } from '~/app/shared/models/permissions'; import { EmptyPipe } from '~/app/shared/pipes/empty.pipe'; import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; import { CdTableServerSideService } from '~/app/shared/services/cd-table-server-side.service'; -import { ModalService } from '~/app/shared/services/modal.service'; import { NotificationService } from '~/app/shared/services/notification.service'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { URLBuilderService } from '~/app/shared/services/url-builder.service'; @@ -125,7 +124,6 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit private emptyPipe: EmptyPipe, private hostService: HostService, private actionLabels: ActionLabelsI18n, - private modalService: ModalService, private taskWrapper: TaskWrapperService, private router: Router, private notificationService: NotificationService, @@ -153,7 +151,7 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit click: () => this.router.url.includes('/hosts') ? this.router.navigate([BASE_URL, { outlets: { modal: [URLVerbs.ADD] } }]) - : (this.bsModalRef = this.modalService.show(HostFormComponent, { + : (this.bsModalRef = this.cdsModalService.show(HostFormComponent, { hideMaintenance: this.hideMaintenance })), disable: (selection: CdTableSelection) => this.getDisable('add', selection)