File
Implements
Metadata
selector |
cd-about |
styleUrls |
./about.component.scss |
templateUrl |
./about.component.html |
Methods
ngOnDestroy
|
ngOnDestroy()
|
|
|
setVariables
|
setVariables()
|
|
|
Public
modalRef
|
Type : BsModalRef
|
|
modalVariables
|
Type : any
|
|
import { Component, OnDestroy, OnInit } from '@angular/core';
import { detect } from 'detect-browser';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { Subscription } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { UserService } from '../../../shared/api/user.service';
import { AppConstants } from '../../../shared/constants/app.constants';
import { Permission } from '../../../shared/models/permissions';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';
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 {
modalVariables: any;
versionNumber: string;
versionHash: string;
versionName: string;
subs: Subscription;
userPermission: Permission;
projectConstants: typeof AppConstants;
hostAddr: string;
copyright: string;
constructor(
public modalRef: BsModalRef,
private summaryService: SummaryService,
private userService: UserService,
private authStorageService: AuthStorageService
) {
this.userPermission = this.authStorageService.getPermissions().user;
}
ngOnInit() {
this.copyright = 'Copyright(c) ' + environment.year + ' Ceph contributors.';
this.projectConstants = AppConstants;
this.hostAddr = window.location.hostname;
this.modalVariables = this.setVariables();
this.subs = this.summaryService.subscribe((summary: any) => {
if (!summary) {
return;
}
const version = summary.version.replace('ceph version ', '').split(' ');
this.hostAddr = summary.mgr_host.replace(/(^\w+:|^)\/\//, '').replace(/\/$/, '');
this.versionNumber = version[0];
this.versionHash = version[1];
this.versionName = version.slice(2, version.length).join(' ');
});
}
ngOnDestroy(): void {
this.subs.unsubscribe();
}
setVariables() {
const project = {} as any;
project.user = localStorage.getItem('dashboard_username');
project.role = 'user';
if (this.userPermission.read) {
this.userService.get(project.user).subscribe((data: any) => {
project.role = data.roles;
});
}
const browser = detect();
project.browserName = browser && browser.name ? browser.name : 'Not detected';
project.browserVersion = browser && browser.version ? browser.version : 'Not detected';
project.browserOS = browser && browser.os ? browser.os : 'Not detected';
return project;
}
}
<div class="modal-header">
<button type="button"
class="close pull-right"
aria-label="Close"
(click)="modalRef.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h2>
<img src="assets/Ceph_Logo_Stacked_RGB_120411_fa_348x348.png"
class="ceph-logo"
alt="{{ projectConstants.organization }}">
{{ projectConstants.organization }}
</h2>
<h3>
<strong>{{ projectConstants.projectName }}</strong>
</h3>
<div class="product-versions">
<strong>Version</strong>
<br>
{{ versionNumber }}
{{ versionHash }}
<br>
{{ versionName }}
</div>
<br>
<ul class="list-unstyled">
<li class="row">
<strong class="col-xs-6 col-sm-4">Ceph Manager</strong>
<span class="col-xs-4 col-sm-4">{{ hostAddr }}</span>
</li>
<li class="row">
<strong class="col-xs-6 col-sm-4">User</strong>
<span class="col-xs-4 col-sm-4">{{ modalVariables.user }}</span>
</li>
<li class="row">
<strong class="col-xs-6 col-sm-4">User Role</strong>
<span class="col-xs-4 col-sm-4">{{ modalVariables.role }}</span>
</li>
<li class="row">
<strong class="col-xs-6 col-sm-4">Browser</strong>
<span class="col-xs-4 col-sm-4">{{ modalVariables.browserName }}</span>
</li>
<li class="row">
<strong class="col-xs-6 col-sm-4">Browser Version</strong>
<span class="col-xs-4 col-sm-4">{{ modalVariables.browserVersion }}</span>
</li>
<li class="row">
<strong class="col-xs-6 col-sm-4">Browser OS</strong>
<span class="col-xs-4 col-sm-4">{{ modalVariables.browserOS }}</span>
</li>
</ul>
</div>
<div class="modal-footer">
<div class="text-left">
{{ copyright }}
{{ projectConstants.license }}
</div>
</div>
.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;
}
h2 {
font-size: 3em;
}
.ceph-logo {
width: 10%;
}
.list-unstyled li {
margin-top: 5px;
}
.modal-footer {
padding: 15px 80px 35px 80px;
}
.modal-body {
margin-top: 0;
padding-top: 0;
h2 {
margin-top: 0;
}
}
Legend
Html element with directive