From: Ricardo Marques Date: Thu, 28 Jun 2018 15:11:36 +0000 (+0100) Subject: mgr/dashboard: Add "About" modal X-Git-Tag: v14.0.1~944^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F22762%2Fhead;p=ceph.git mgr/dashboard: Add "About" modal Fixes: https://tracker.ceph.com/issues/24646 Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.html new file mode 100644 index 000000000000..ed570492a4dd --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.html @@ -0,0 +1,26 @@ + + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.scss new file mode 100644 index 000000000000..f80b0e1e1e29 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.scss @@ -0,0 +1,22 @@ +.product-versions { + margin-top: 30px; +} +.product-versions strong { + margin-right: 10px; +} +.modal-header { + border-bottom: none; +} +.modal-body { + padding-left: 80px; + padding-right: 80px; +} +.modal-footer { + border-top: none; +} +h1 { + font-size: 4em; +} +.ceph-logo { + width: 25%; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts new file mode 100644 index 000000000000..d2c53707f09e --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts @@ -0,0 +1,46 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BsModalRef } from 'ngx-bootstrap'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; + +import { SummaryService } from '../../../shared/services/summary.service'; +import { SharedModule } from '../../../shared/shared.module'; +import { configureTestBed } from '../../../shared/unit-test-helper'; +import { AboutComponent } from './about.component'; + +class SummaryServiceMock { + summaryData$ = Observable.of({ + version: + 'ceph version 14.0.0-855-gb8193bb4cd ' + + '(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) nautilus (dev)' + }); +} + +describe('AboutComponent', () => { + let component: AboutComponent; + let fixture: ComponentFixture; + + configureTestBed({ + imports: [SharedModule, HttpClientTestingModule], + declarations: [AboutComponent], + providers: [BsModalRef, { provide: SummaryService, useClass: SummaryServiceMock }] + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AboutComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should parse version', () => { + expect(component.versionNumber).toBe('14.0.0-855-gb8193bb4cd'); + expect(component.versionHash).toBe('(b8193bb4cda16ccc5b028c3e1df62bc72350a15d)'); + expect(component.versionName).toBe('nautilus (dev)'); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts new file mode 100644 index 000000000000..471e4cef98b3 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts @@ -0,0 +1,36 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; + +import { BsModalRef } from 'ngx-bootstrap'; +import { Subscription } from 'rxjs'; + +import { SummaryService } from '../../../shared/services/summary.service'; + +@Component({ + selector: 'cd-about', + templateUrl: './about.component.html', + styleUrls: ['./about.component.scss'] +}) +export class AboutComponent implements OnInit, OnDestroy { + versionNumber: string; + versionHash: string; + versionName: string; + subs: Subscription; + + constructor(public modalRef: BsModalRef, private summaryService: SummaryService) {} + + ngOnInit() { + this.subs = this.summaryService.summaryData$.subscribe((summary: any) => { + if (!summary) { + return; + } + const version = summary.version.replace('ceph version ', '').split(' '); + this.versionNumber = version[0]; + this.versionHash = version[1]; + this.versionName = version.slice(2, version.length).join(' '); + }); + } + + ngOnDestroy(): void { + this.subs.unsubscribe(); + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html index 629c62418a0f..b2f094569117 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html @@ -24,5 +24,11 @@ target="_blank">API +
  • + About + +
  • diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts index 74a554a177ec..563f9a24349b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts @@ -1,7 +1,10 @@ import { Component, OnInit } from '@angular/core'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap'; + import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe'; import { SummaryService } from '../../../shared/services/summary.service'; +import { AboutComponent } from '../about/about.component'; @Component({ selector: 'cd-dashboard-help', @@ -9,11 +12,14 @@ import { SummaryService } from '../../../shared/services/summary.service'; styleUrls: ['./dashboard-help.component.scss'] }) export class DashboardHelpComponent implements OnInit { - docsUrl: string; + modalRef: BsModalRef; - constructor(private summaryService: SummaryService, - private cephReleaseNamePipe: CephReleaseNamePipe) {} + constructor( + private summaryService: SummaryService, + private cephReleaseNamePipe: CephReleaseNamePipe, + private modalService: BsModalService + ) {} ngOnInit() { const subs = this.summaryService.summaryData$.subscribe((summary: any) => { @@ -25,4 +31,8 @@ export class DashboardHelpComponent implements OnInit { subs.unsubscribe(); }); } + + openAboutModal() { + this.modalRef = this.modalService.show(AboutComponent); + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts index 54bf549d2eee..aaf9bb91fe80 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts @@ -7,12 +7,14 @@ import { BsDropdownModule, CollapseModule, PopoverModule, TooltipModule } from ' import { AppRoutingModule } from '../../app-routing.module'; import { SharedModule } from '../../shared/shared.module'; import { AuthModule } from '../auth/auth.module'; +import { AboutComponent } from './about/about.component'; import { DashboardHelpComponent } from './dashboard-help/dashboard-help.component'; import { NavigationComponent } from './navigation/navigation.component'; import { NotificationsComponent } from './notifications/notifications.component'; import { TaskManagerComponent } from './task-manager/task-manager.component'; @NgModule({ + entryComponents: [AboutComponent], imports: [ CommonModule, AuthModule, @@ -25,6 +27,7 @@ import { TaskManagerComponent } from './task-manager/task-manager.component'; RouterModule ], declarations: [ + AboutComponent, NavigationComponent, NotificationsComponent, TaskManagerComponent, diff --git a/src/pybind/mgr/dashboard/frontend/src/assets/Ceph_Logo_Stacked_RGB_120411_fa_348x348.png b/src/pybind/mgr/dashboard/frontend/src/assets/Ceph_Logo_Stacked_RGB_120411_fa_348x348.png new file mode 100644 index 000000000000..d46bd73f7487 Binary files /dev/null and b/src/pybind/mgr/dashboard/frontend/src/assets/Ceph_Logo_Stacked_RGB_120411_fa_348x348.png differ