diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts | 70 |
1 files changed, 70 insertions, 0 deletions
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 000000000..64b26bfc6 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.ts @@ -0,0 +1,70 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; + +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { detect } from 'detect-browser'; +import { Subscription } from 'rxjs'; + +import { UserService } from '~/app/shared/api/user.service'; +import { AppConstants } from '~/app/shared/constants/app.constants'; +import { Permission } from '~/app/shared/models/permissions'; +import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; +import { SummaryService } from '~/app/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 activeModal: NgbActiveModal, + private summaryService: SummaryService, + private userService: UserService, + private authStorageService: AuthStorageService + ) { + this.userPermission = this.authStorageService.getPermissions().user; + } + + ngOnInit() { + this.projectConstants = AppConstants; + this.hostAddr = window.location.hostname; + this.modalVariables = this.setVariables(); + this.subs = this.summaryService.subscribe((summary) => { + 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; + } +} |