import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
-import { FormsModule } from '@angular/forms';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
+import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
+import { ModalModule } from 'ngx-bootstrap/modal';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { SharedModule } from '../../shared/shared.module';
import { MonitorComponent } from './monitor/monitor.component';
import { OsdDetailsComponent } from './osd/osd-details/osd-details.component';
import { OsdListComponent } from './osd/osd-list/osd-list.component';
-import {
- OsdPerformanceHistogramComponent
-} from './osd/osd-performance-histogram/osd-performance-histogram.component';
+import { OsdPerformanceHistogramComponent } from './osd/osd-performance-histogram/osd-performance-histogram.component';
+import { OsdScrubModalComponent } from './osd/osd-scrub-modal/osd-scrub-modal.component';
@NgModule({
entryComponents: [
TabsModule.forRoot(),
SharedModule,
RouterModule,
- FormsModule
+ FormsModule,
+ ReactiveFormsModule,
+ BsDropdownModule.forRoot(),
+ ModalModule.forRoot()
],
declarations: [
HostsComponent,
ConfigurationComponent,
OsdListComponent,
OsdDetailsComponent,
- OsdPerformanceHistogramComponent
+ OsdPerformanceHistogramComponent,
+ OsdScrubModalComponent
]
})
export class ClusterModule {}
--- /dev/null
+<cd-modal [modalRef]="bsModalRef">
+ <ng-container class="modal-title"
+ i18n>
+ OSDs {{ deep ? 'Deep ' : '' }}Scrub
+ </ng-container>
+
+ <ng-container class="modal-content">
+ <form name="scrubForm"
+ class="form-horizontal"
+ #formDir="ngForm"
+ [formGroup]="scrubForm"
+ novalidate>
+ <div class="modal-body">
+ <div *ngIf="selected.length === 1">
+ <p i18n>
+ You are about to apply a {{ deep ? 'deep ' : '' }}scrub to the OSD
+ <strong>{{ selected[0].id }}</strong>.
+ </p>
+ </div>
+ </div>
+
+ <div class="modal-footer">
+ <cd-submit-button (submitAction)="scrub()"
+ [form]="scrubForm"
+ i18n>
+ Submit
+ </cd-submit-button>
+
+ <button class="btn btn-link btn-sm"
+ (click)="bsModalRef.hide()"
+ i18n>
+ Cancel
+ </button>
+ </div>
+ </form>
+ </ng-container>
+</cd-modal>
--- /dev/null
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { ReactiveFormsModule } from '@angular/forms';
+
+import { BsModalRef } from 'ngx-bootstrap';
+
+import { OsdService } from '../../../../shared/api/osd.service';
+import { NotificationService } from '../../../../shared/services/notification.service';
+import { OsdScrubModalComponent } from './osd-scrub-modal.component';
+
+describe('OsdScrubModalComponent', () => {
+ let component: OsdScrubModalComponent;
+ let fixture: ComponentFixture<OsdScrubModalComponent>;
+
+ const fakeService = {
+ list: () => {
+ return new Promise(function(resolve, reject) {
+ return {};
+ });
+ },
+ scrub: (data: any) => {
+ return new Promise(function(resolve, reject) {
+ return {};
+ });
+ },
+ scrub_many: (data: any) => {
+ return new Promise(function(resolve, reject) {
+ return {};
+ });
+ }
+ };
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [ReactiveFormsModule],
+ declarations: [OsdScrubModalComponent],
+ schemas: [NO_ERRORS_SCHEMA],
+ providers: [
+ BsModalRef,
+ { provide: OsdService, useValue: fakeService },
+ { provide: NotificationService, useValue: fakeService }
+ ]
+ }).compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(OsdScrubModalComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
--- /dev/null
+import { Component, OnInit } from '@angular/core';
+import { FormGroup } from '@angular/forms';
+
+import { BsModalRef } from 'ngx-bootstrap';
+
+import { OsdService } from '../../../../shared/api/osd.service';
+import { NotificationType } from '../../../../shared/enum/notification-type.enum';
+import { NotificationService } from '../../../../shared/services/notification.service';
+
+@Component({
+ selector: 'cd-osd-scrub-modal',
+ templateUrl: './osd-scrub-modal.component.html',
+ styleUrls: ['./osd-scrub-modal.component.scss']
+})
+export class OsdScrubModalComponent implements OnInit {
+ deep: boolean;
+ selected = [];
+ scrubForm: FormGroup;
+
+ constructor(
+ public bsModalRef: BsModalRef,
+ private osdService: OsdService,
+ private notificationService: NotificationService
+ ) {}
+
+ ngOnInit() {
+ this.scrubForm = new FormGroup({});
+ }
+
+ scrub() {
+ const id = this.selected[0].id;
+
+ this.osdService.scrub(id, this.deep).subscribe(
+ (res) => {
+ const operation = this.deep ? 'Deep scrub' : 'Scrub';
+
+ this.notificationService.show(
+ NotificationType.success,
+ `${operation} was initialized in the following OSD: ${id}`
+ );
+
+ this.bsModalRef.hide();
+ },
+ () => {
+ this.bsModalRef.hide();
+ }
+ );
+ }
+}
ChartsModule,
ReactiveFormsModule,
PipesModule,
- ModalModule.forRoot()
+ ModalModule.forRoot(),
],
declarations: [
ViewCacheComponent,
ErrorPanelComponent,
LoadingPanelComponent,
InfoPanelComponent,
- UsageBarComponent
+ UsageBarComponent,
+ ModalComponent
],
entryComponents: [
ModalComponent,