1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import { detect } from 'detect-browser';
4 import { BsModalRef } from 'ngx-bootstrap/modal';
5 import { Subscription } from 'rxjs';
6 import { environment } from '../../../../environments/environment';
7 import { UserService } from '../../../shared/api/user.service';
8 import { AppConstants } from '../../../shared/constants/app.constants';
9 import { Permission } from '../../../shared/models/permissions';
10 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
11 import { SummaryService } from '../../../shared/services/summary.service';
15 templateUrl: './about.component.html',
16 styleUrls: ['./about.component.scss']
18 export class AboutComponent implements OnInit, OnDestroy {
20 versionNumber: string;
24 userPermission: Permission;
25 projectConstants: typeof AppConstants;
30 public modalRef: BsModalRef,
31 private summaryService: SummaryService,
32 private userService: UserService,
33 private authStorageService: AuthStorageService
35 this.userPermission = this.authStorageService.getPermissions().user;
39 this.copyright = 'Copyright(c) ' + environment.year + ' Ceph contributors.';
40 this.projectConstants = AppConstants;
41 this.hostAddr = window.location.hostname;
42 this.modalVariables = this.setVariables();
43 this.subs = this.summaryService.subscribe((summary) => {
44 const version = summary.version.replace('ceph version ', '').split(' ');
45 this.hostAddr = summary.mgr_host.replace(/(^\w+:|^)\/\//, '').replace(/\/$/, '');
46 this.versionNumber = version[0];
47 this.versionHash = version[1];
48 this.versionName = version.slice(2, version.length).join(' ');
53 this.subs.unsubscribe();
57 const project = {} as any;
58 project.user = localStorage.getItem('dashboard_username');
59 project.role = 'user';
60 if (this.userPermission.read) {
61 this.userService.get(project.user).subscribe((data: any) => {
62 project.role = data.roles;
65 const browser = detect();
66 project.browserName = browser && browser.name ? browser.name : 'Not detected';
67 project.browserVersion = browser && browser.version ? browser.version : 'Not detected';
68 project.browserOS = browser && browser.os ? browser.os : 'Not detected';