From 94c5a5e5371c335dd7892762c40d4b23edf14e16 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Wed, 28 Feb 2018 13:46:21 +0000 Subject: [PATCH] mgr/dashboard: Add helper component Signed-off-by: Ricardo Marques --- src/pybind/mgr/dashboard/HACKING.rst | 19 +++++++++++++ .../shared/components/components.module.ts | 10 +++++-- .../components/helper/helper.component.html | 11 ++++++++ .../components/helper/helper.component.scss | 6 ++++ .../helper/helper.component.spec.ts | 28 +++++++++++++++++++ .../components/helper/helper.component.ts | 14 ++++++++++ .../frontend/src/openattic-theme.scss | 6 ---- 7 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.scss create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.ts diff --git a/src/pybind/mgr/dashboard/HACKING.rst b/src/pybind/mgr/dashboard/HACKING.rst index 2a33e022837f..6dc5fae628c9 100644 --- a/src/pybind/mgr/dashboard/HACKING.rst +++ b/src/pybind/mgr/dashboard/HACKING.rst @@ -120,6 +120,25 @@ Example: import { Credentials } from '../../../shared/models/credentials.model'; import { HostService } from './services/host.service'; +Frontend components +~~~~~~~~~~~~~~~~~~~ + +There are several components that can be reused on different pages. +This components are declared on the components module: +`src/pybind/mgr/dashboard/frontend/src/app/shared/components`. + +Helper +...... + +This component should be used to provide additional information to the user. + +Example: + +.. code:: html + + + Some helper html text + Backend Development ------------------- 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 fe65bea599bb..7094e1e24cc5 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 @@ -2,8 +2,9 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { ChartsModule } from 'ng2-charts/ng2-charts'; -import { AlertModule } from 'ngx-bootstrap'; +import { AlertModule, PopoverModule } from 'ngx-bootstrap'; +import { HelperComponent } from './helper/helper.component'; import { SparklineComponent } from './sparkline/sparkline.component'; import { ViewCacheComponent } from './view-cache/view-cache.component'; @@ -11,16 +12,19 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; imports: [ CommonModule, AlertModule.forRoot(), + PopoverModule.forRoot(), ChartsModule ], declarations: [ ViewCacheComponent, - SparklineComponent + SparklineComponent, + HelperComponent ], providers: [], exports: [ ViewCacheComponent, - SparklineComponent + SparklineComponent, + HelperComponent ] }) export class ComponentsModule { } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html new file mode 100644 index 000000000000..408e47c2aa6a --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html @@ -0,0 +1,11 @@ + +
+ +
+ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.scss new file mode 100644 index 000000000000..a26cbbb8a14a --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.scss @@ -0,0 +1,6 @@ +@import '../../../../defaults'; + +i { + color: $oa-color-blue; + cursor: pointer; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.spec.ts new file mode 100644 index 000000000000..1c29c50260d3 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.spec.ts @@ -0,0 +1,28 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PopoverModule } from 'ngx-bootstrap'; + +import { HelperComponent } from './helper.component'; + +describe('HelperComponent', () => { + let component: HelperComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ PopoverModule.forRoot() ], + declarations: [ HelperComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HelperComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.ts new file mode 100644 index 000000000000..2fc9eba8c4e0 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.ts @@ -0,0 +1,14 @@ +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'cd-helper', + templateUrl: './helper.component.html', + styleUrls: ['./helper.component.scss'] +}) +export class HelperComponent { + + @Input() html: any; + + constructor() { } + +} diff --git a/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss b/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss index aa819a2f49e0..d4eee695ac8e 100755 --- a/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss +++ b/src/pybind/mgr/dashboard/frontend/src/openattic-theme.scss @@ -1078,12 +1078,6 @@ uib-accordion .panel-title, color: #d04437; } -/* oa-helper */ -oa-helper i { - color: $oa-color-blue; - cursor: pointer; -} - .page-footer { font-size: 12px; color: #777; -- 2.47.3