]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add modal component
authorTiago Melo <tmelo@suse.com>
Tue, 6 Mar 2018 12:04:18 +0000 (12:04 +0000)
committerStephan Müller <smueller@suse.com>
Tue, 24 Apr 2018 11:57:43 +0000 (13:57 +0200)
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 <tmelo@suse.com>
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.html [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.scss [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss

index 47f67825aff186f729b6149280e06b392beb499c..8f00efb6ff53bc19dded4c999a8facee0fb50177 100644 (file)
@@ -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 (file)
index 0000000..e1f69f6
--- /dev/null
@@ -0,0 +1,13 @@
+<div class="modal-header">
+  <h4 class="modal-title pull-left">
+    <ng-content select=".modal-title"></ng-content>
+  </h4>
+  <button type="button"
+          class="close pull-right"
+          aria-label="Close"
+          (click)="modalRef.hide()">
+    <span aria-hidden="true">&times;</span>
+  </button>
+</div>
+
+<ng-content select=".modal-content"></ng-content>
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 (file)
index 0000000..2c9ad57
--- /dev/null
@@ -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 (file)
index 0000000..72f2662
--- /dev/null
@@ -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<ModalComponent>;
+
+  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 (file)
index 0000000..9a74832
--- /dev/null
@@ -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) {}
+}
index fb03cc27aee42a5094676841e5792e106c40bafa..1f9a72fa6c43476ca85d68b99e5386295b3ef159 100755 (executable)
@@ -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 {