]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts
bump version to 15.2.4-pve1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / navigation / about / about.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core';
2
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';
12
13 @Component({
14 selector: 'cd-about',
15 templateUrl: './about.component.html',
16 styleUrls: ['./about.component.scss']
17 })
18 export class AboutComponent implements OnInit, OnDestroy {
19 modalVariables: any;
20 versionNumber: string;
21 versionHash: string;
22 versionName: string;
23 subs: Subscription;
24 userPermission: Permission;
25 projectConstants: typeof AppConstants;
26 hostAddr: string;
27 copyright: string;
28
29 constructor(
30 public modalRef: BsModalRef,
31 private summaryService: SummaryService,
32 private userService: UserService,
33 private authStorageService: AuthStorageService
34 ) {
35 this.userPermission = this.authStorageService.getPermissions().user;
36 }
37
38 ngOnInit() {
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: any) => {
44 if (!summary) {
45 return;
46 }
47 const version = summary.version.replace('ceph version ', '').split(' ');
48 this.hostAddr = summary.mgr_host.replace(/(^\w+:|^)\/\//, '').replace(/\/$/, '');
49 this.versionNumber = version[0];
50 this.versionHash = version[1];
51 this.versionName = version.slice(2, version.length).join(' ');
52 });
53 }
54
55 ngOnDestroy(): void {
56 this.subs.unsubscribe();
57 }
58
59 setVariables() {
60 const project = {} as any;
61 project.user = localStorage.getItem('dashboard_username');
62 project.role = 'user';
63 if (this.userPermission.read) {
64 this.userService.get(project.user).subscribe((data: any) => {
65 project.role = data.roles;
66 });
67 }
68 const browser = detect();
69 project.browserName = browser && browser.name ? browser.name : 'Not detected';
70 project.browserVersion = browser && browser.version ? browser.version : 'Not detected';
71 project.browserOS = browser && browser.os ? browser.os : 'Not detected';
72 return project;
73 }
74 }