mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-03 16:00:44 +00:00
This commit is contained in:
parent
eb7da2f565
commit
823e9a4b59
@ -56,6 +56,7 @@ import { ConsoleGuard } from './guards/console-guard';
|
|||||||
import { LoginGuard } from './guards/login-guard';
|
import { LoginGuard } from './guards/login-guard';
|
||||||
import { DefaultLayoutComponent } from './layouts/default-layout/default-layout.component';
|
import { DefaultLayoutComponent } from './layouts/default-layout/default-layout.component';
|
||||||
import { ServerResolve } from './resolvers/server-resolve';
|
import { ServerResolve } from './resolvers/server-resolve';
|
||||||
|
import { LoggedUserComponent } from './components/users/logged-user/logged-user.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -66,6 +67,7 @@ const routes: Routes = [
|
|||||||
{ path: 'servers', component: ServersComponent },
|
{ path: 'servers', component: ServersComponent },
|
||||||
{ path: 'bundled', component: BundledServerFinderComponent },
|
{ path: 'bundled', component: BundledServerFinderComponent },
|
||||||
{ path: 'server/:server_id/login', component: LoginComponent },
|
{ path: 'server/:server_id/login', component: LoginComponent },
|
||||||
|
{ path: 'server/:server_id/loggeduser', component: LoggedUserComponent },
|
||||||
{
|
{
|
||||||
path: 'server/:server_id/projects',
|
path: 'server/:server_id/projects',
|
||||||
component: ProjectsComponent,
|
component: ProjectsComponent,
|
||||||
|
@ -274,10 +274,13 @@ import { MarkedDirective } from './directives/marked.directive';
|
|||||||
import { LoginComponent } from './components/login/login.component';
|
import { LoginComponent } from './components/login/login.component';
|
||||||
import { LoginService } from './services/login.service';
|
import { LoginService } from './services/login.service';
|
||||||
import { HttpRequestsInterceptor } from './interceptors/http.interceptor';
|
import { HttpRequestsInterceptor } from './interceptors/http.interceptor';
|
||||||
|
import { UserService } from './services/user.service';
|
||||||
|
import { LoggedUserComponent } from './components/users/logged-user/logged-user.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
|
LoggedUserComponent,
|
||||||
ProjectMapComponent,
|
ProjectMapComponent,
|
||||||
LoginComponent,
|
LoginComponent,
|
||||||
ServersComponent,
|
ServersComponent,
|
||||||
@ -558,7 +561,8 @@ import { HttpRequestsInterceptor } from './interceptors/http.interceptor';
|
|||||||
Title,
|
Title,
|
||||||
ApplianceService,
|
ApplianceService,
|
||||||
UpdatesService,
|
UpdatesService,
|
||||||
LoginService
|
LoginService,
|
||||||
|
UserService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
<div class="content">
|
||||||
|
<div class="default-header">
|
||||||
|
<div class="row">
|
||||||
|
<h1 class="col">Logged user info</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="default-content">
|
||||||
|
<mat-card *ngIf="user">
|
||||||
|
<mat-list>
|
||||||
|
<mat-list-item> Username: {{user.username}} </mat-list-item>
|
||||||
|
<mat-list-item> Full name: {{user.full_name}} </mat-list-item>
|
||||||
|
<mat-list-item> Email: {{user.email}} </mat-list-item>
|
||||||
|
</mat-list>
|
||||||
|
|
||||||
|
<div class="buttons-bar">
|
||||||
|
<button mat-raised-button color="primary" class="full_width" (click)="copyToken()">Click to copy access token</button><br />
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
.full_width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ServerService } from '../../../services/server.service';
|
||||||
|
import { UserService } from '../../../services/user.service';
|
||||||
|
import { ToasterService } from '../../../services/toaster.service';
|
||||||
|
import { User } from '../../../models/users/user';
|
||||||
|
import { Server } from '../../../models/server';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-logged-user',
|
||||||
|
templateUrl: './logged-user.component.html',
|
||||||
|
styleUrls: ['./logged-user.component.scss'],
|
||||||
|
})
|
||||||
|
export class LoggedUserComponent implements OnInit {
|
||||||
|
public user: User;
|
||||||
|
public server: Server;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private serverService: ServerService,
|
||||||
|
private userService: UserService,
|
||||||
|
private toasterService: ToasterService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
let serverId = this.route.snapshot.paramMap.get('server_id');
|
||||||
|
this.serverService.get(+serverId).then((server: Server) => {
|
||||||
|
this.server = server;
|
||||||
|
this.userService.getInformationAboutLoggedUser(server).subscribe((response: any) => {
|
||||||
|
this.user = response;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
copyToken() {
|
||||||
|
const selBox = document.createElement('textarea');
|
||||||
|
selBox.style.position = 'fixed';
|
||||||
|
selBox.style.left = '0';
|
||||||
|
selBox.style.top = '0';
|
||||||
|
selBox.style.opacity = '0';
|
||||||
|
selBox.value = this.server.authToken;
|
||||||
|
document.body.appendChild(selBox);
|
||||||
|
selBox.focus();
|
||||||
|
selBox.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(selBox);
|
||||||
|
|
||||||
|
this.toasterService.success('Token copied');
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,10 @@
|
|||||||
<mat-icon>help</mat-icon>
|
<mat-icon>help</mat-icon>
|
||||||
<span>Help</span>
|
<span>Help</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-menu-item (click)="goToUserInfo()">
|
||||||
|
<mat-icon>person</mat-icon>
|
||||||
|
<span>User info</span>
|
||||||
|
</button>
|
||||||
<button mat-menu-item (click)="logout()">
|
<button mat-menu-item (click)="logout()">
|
||||||
<mat-icon>highlight_off</mat-icon>
|
<mat-icon>highlight_off</mat-icon>
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
|
@ -8,6 +8,7 @@ import { ProgressService } from '../../common/progress/progress.service';
|
|||||||
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
||||||
import { ServerManagementService } from '../../services/server-management.service';
|
import { ServerManagementService } from '../../services/server-management.service';
|
||||||
import { ToasterService } from '../../services/toaster.service';
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
|
import { UserService } from '../../services/user.service';
|
||||||
import { version } from './../../version';
|
import { version } from './../../version';
|
||||||
import { Server } from '../../models/server';
|
import { Server } from '../../models/server';
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private serverService: ServerService
|
private serverService: ServerService,
|
||||||
|
private userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -68,6 +70,13 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
this.shouldStopServersOnClosing = this.electronService.isElectronApp;
|
this.shouldStopServersOnClosing = this.electronService.isElectronApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goToUserInfo() {
|
||||||
|
let serverId = this.router.url.split("/server/")[1].split("/")[0];
|
||||||
|
this.serverService.get(+serverId).then((server: Server) => {
|
||||||
|
this.router.navigate(['/server', server.id, 'loggeduser']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
checkIfUserIsLoginPage() {
|
checkIfUserIsLoginPage() {
|
||||||
if (this.router.url.includes("login")) {
|
if (this.router.url.includes("login")) {
|
||||||
this.isLoginPage = true;
|
this.isLoginPage = true;
|
||||||
|
10
src/app/models/users/user.ts
Normal file
10
src/app/models/users/user.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export interface User {
|
||||||
|
created_at: string;
|
||||||
|
email: string;
|
||||||
|
full_name: string;
|
||||||
|
is_active: boolean;
|
||||||
|
is_superadmin: boolean;
|
||||||
|
updated_at: string;
|
||||||
|
user_id: string;
|
||||||
|
username: string;
|
||||||
|
}
|
16
src/app/services/user.service.ts
Normal file
16
src/app/services/user.service.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { Server } from '../models/server';
|
||||||
|
import { HttpServer } from './http-server.service';
|
||||||
|
import { User } from '../models/users/user';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserService {
|
||||||
|
constructor(
|
||||||
|
private httpServer: HttpServer
|
||||||
|
) {}
|
||||||
|
|
||||||
|
getInformationAboutLoggedUser(server: Server) {
|
||||||
|
return this.httpServer.get<User>(server, '/users/me/');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user