From f1c2f91a89a53c9ac644480f171522fb1cabf45d Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Tue, 6 Mar 2018 12:04:18 +0000 Subject: [PATCH] mgr/dashboard: Add modal component MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This component should be used each time you define a new modal. This will allows us to keep all modals with the same visual aspect. Signed-off-by: Tiago Melo Signed-off-by: Stephan Müller --- .../shared/components/components.module.ts | 10 ++++-- .../components/modal/modal.component.html | 13 +++++++ .../components/modal/modal.component.scss | 14 ++++++++ .../components/modal/modal.component.spec.ts | 29 +++++++++++++++ .../components/modal/modal.component.ts | 15 ++++++++ .../frontend/src/openattic-theme.scss | 36 +------------------ 6 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.scss create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts index 47f67825aff18..8f00efb6ff53b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts @@ -3,13 +3,14 @@ import { NgModule } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; -import { AlertModule, PopoverModule, TooltipModule } from 'ngx-bootstrap'; +import { AlertModule, ModalModule, PopoverModule, TooltipModule } from 'ngx-bootstrap'; import { PipesModule } from '../pipes/pipes.module'; import { DeleteConfirmationComponent } from './delete-confirmation-modal/delete-confirmation-modal.component'; import { HelperComponent } from './helper/helper.component'; +import { ModalComponent } from './modal/modal.component'; import { SparklineComponent } from './sparkline/sparkline.component'; import { SubmitButtonComponent } from './submit-button/submit-button.component'; import { UsageBarComponent } from './usage-bar/usage-bar.component'; @@ -24,6 +25,7 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; ChartsModule, ReactiveFormsModule, PipesModule, + ModalModule.forRoot() ], declarations: [ ViewCacheComponent, @@ -31,7 +33,8 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; HelperComponent, SubmitButtonComponent, UsageBarComponent, - DeleteConfirmationComponent + DeleteConfirmationComponent, + ModalComponent ], providers: [], exports: [ @@ -43,7 +46,8 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; DeleteConfirmationComponent ], entryComponents: [ - DeleteConfirmationComponent + DeleteConfirmationComponent, + ModalComponent ] }) export class ComponentsModule { } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html new file mode 100644 index 0000000000000..e1f69f64ddf73 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html @@ -0,0 +1,13 @@ + + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.scss new file mode 100644 index 0000000000000..2c9ad571c1e61 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.scss @@ -0,0 +1,14 @@ +@mixin hf { + border-bottom: 1px solid #cccccc; + background-color: #f5f5f5; +} + +.modal-header { + @include hf; + border-radius: 5px 5px 0 0; +} + +.modal-footer { + @include hf; + border-radius: 0 0 5px 5px; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.spec.ts new file mode 100644 index 0000000000000..72f26626ab860 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.spec.ts @@ -0,0 +1,29 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ModalModule } from 'ngx-bootstrap/modal'; + +import { ModalComponent } from './modal.component'; + +describe('ModalComponent', () => { + let component: ModalComponent; + let fixture: ComponentFixture; + + beforeEach( + async(() => { + TestBed.configureTestingModule({ + imports: [ModalModule.forRoot()], + declarations: [ModalComponent] + }).compileComponents(); + }) + ); + + beforeEach(() => { + fixture = TestBed.createComponent(ModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts new file mode 100644 index 0000000000000..9a748329cd26a --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts @@ -0,0 +1,15 @@ +import { Component, Input, TemplateRef } from '@angular/core'; + +import { BsModalService } from 'ngx-bootstrap/modal'; +import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; + +@Component({ + selector: 'cd-modal', + templateUrl: './modal.component.html', + styleUrls: ['./modal.component.scss'] +}) +export class ModalComponent { + @Input() modalRef: BsModalRef; + + constructor(private modalService: BsModalService) {} +} diff --git a/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss b/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss index fb03cc27aee42..1f9a72fa6c434 100755 --- a/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss +++ b/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss @@ -5,7 +5,7 @@ Buttons Dropdown Grid - Modal + Modal Table (Task Queue) Navbar Navs Notifications @@ -250,40 +250,6 @@ button.btn.btn-label>i.fa { padding-right: 30px; } -/* Modal */ -.modal-dialog { - margin: 30px auto !important; -} -.modal .modal-content .openattic-modal-header, -.modal .modal-content .openattic-modal-content, -.modal .modal-content .openattic-modal-footer { - padding: 10px 20px; -} -.modal .modal-content .openattic-modal-header { - border-bottom: 1px solid #cccccc; - border-radius: 5px 5px 0 0; - background-color: #f5f5f5; -} -.modal .modal-content .openattic-modal-content { - padding: 20px 20px 10px 20px; - overflow-x: auto; - max-height: 70vh; -} -.modal .modal-content .openattic-modal-content p { - margin-bottom: 10px; -} -.modal .modal-content .openattic-modal-content legend { - font-size: 1.833em; -} -.modal .modal-content .openattic-modal-footer { - border-top: 1px solid #cccccc; - border-radius: 0 0 5px 5px; - background-color: #f5f5f5; -} -.modal .modal-content .openattic-modal-header span { - display: block; - font-size: 16px; /* Same as .panel-title */ -} /* Modal Table (Task Queue) */ table.task-queue-table thead { -- 2.39.5