parent b3e74b68
...@@ -16,6 +16,7 @@ import {ElementServerMenuComponent} from '../../elements/server-menu/server-menu ...@@ -16,6 +16,7 @@ import {ElementServerMenuComponent} from '../../elements/server-menu/server-menu
import {NavList, View} from '../control/control.component'; import {NavList, View} from '../control/control.component';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material'; import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import {FormControl, Validators} from '@angular/forms'; import {FormControl, Validators} from '@angular/forms';
import {DialogService} from '../../elements/dialog/dialog.service';
export interface HostGroup { export interface HostGroup {
...@@ -84,7 +85,8 @@ export class CleftbarComponent implements OnInit { ...@@ -84,7 +85,8 @@ export class CleftbarComponent implements OnInit {
private _search: SearchComponent, private _search: SearchComponent,
private _logger: LogService, private _logger: LogService,
private _menu: ElementServerMenuComponent, private _menu: ElementServerMenuComponent,
public _dialog: MatDialog) { public _dialog: MatDialog,
private _layer: DialogService) {
this._logger.log('nav.ts:NavComponent'); this._logger.log('nav.ts:NavComponent');
// this._appService.getnav() // this._appService.getnav()
} }
...@@ -98,19 +100,34 @@ export class CleftbarComponent implements OnInit { ...@@ -98,19 +100,34 @@ export class CleftbarComponent implements OnInit {
} }
autologin() { autologin() {
const id = this._appService.getQueryString('id'); const asset_id = this._appService.getQueryString('asset_id');
if (id) { const user_id = this._appService.getQueryString('user_id');
let tag = false;
if (asset_id) {
for (let g of this.HostGroups) { for (let g of this.HostGroups) {
if (g['assets_granted']) { if (g['assets_granted']) {
g['assets_granted'].forEach((v, k) => { for (let host of g['assets_granted']) {
if (v.id.toSource() === id.toString()) { if (host.id.toString() === asset_id) {
this.Connect(v); if (user_id) {
return; host['system_users_granted'].forEach((user, kk) => {
if (user.id.toString() === user_id.toString()) {
this.login(host, user);
tag = true;
return;
}
});
} else {
this.Connect(host);
tag = true;
return;
}
} }
}); }
} }
} }
}
if (!tag) {
this._layer.alert('Maybe you do not have permission on that host');
} }
} }
......
...@@ -18,7 +18,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; ...@@ -18,7 +18,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
// service // service
import {AppService, HttpService, LogService, UUIDService} from './app.service'; import {AppService, HttpService, LogService, UUIDService} from './app.service';
import {DialogService} from './elements/dialog/dialog.service'; import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service';
// Elements // Elements
import {ElementFooterComponent} from './elements/footer/footer.component'; import {ElementFooterComponent} from './elements/footer/footer.component';
...@@ -79,6 +79,7 @@ import {ElementTableComponent} from './elements/table/table.component'; ...@@ -79,6 +79,7 @@ import {ElementTableComponent} from './elements/table/table.component';
ElementRdpComponent, ElementRdpComponent,
ElementServerMenuComponent, ElementServerMenuComponent,
ElementIframeComponent, ElementIframeComponent,
ElementDialogAlertComponent,
LoginComponent, LoginComponent,
SearchComponent, SearchComponent,
SearchFilter, SearchFilter,
...@@ -104,6 +105,7 @@ import {ElementTableComponent} from './elements/table/table.component'; ...@@ -104,6 +105,7 @@ import {ElementTableComponent} from './elements/table/table.component';
], ],
entryComponents: [ entryComponents: [
CleftbarDialogComponent, CleftbarDialogComponent,
ElementDialogAlertComponent,
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
providers: [ providers: [
......
<div class="alert">
<h1 mat-dialog-title>Alert</h1>
<p>{{data.msg}}</p>
<button mat-raised-button (click)="onNoClick()">Close</button>
</div>
h1 {
border-bottom: 1px solid #eee;
width: 100%;
}
button {
float: right;
bottom: 0;
}
.alert {
height: 100%;
}
import {Injectable} from '@angular/core'; import {Component, Inject, Injectable, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import {LogService} from '../../app.service';
import {FormControl, Validators} from '@angular/forms';
// import * as layer from 'layui-layer/src/layer.js'; // import * as layer from 'layui-layer/src/layer.js';
@Injectable() @Injectable()
export class DialogService { export class DialogService {
constructor() { constructor(public _dialog: MatDialog) {
} }
open(options: any) { open(options: any) {
...@@ -24,11 +28,33 @@ export class DialogService { ...@@ -24,11 +28,33 @@ export class DialogService {
loading() { loading() {
} }
alert() { alert(msg: string) {
// alert('sss'); this._dialog.open(ElementDialogAlertComponent, {
height: '200px',
width: '300px',
data: {msg: msg}
});
} }
close(index: any) { close(index: any) {
// layer.close(index); // layer.close(index);
} }
} }
@Component({
selector: 'app-alert',
templateUrl: 'alert.html',
styleUrls: ['./alert.scss']
})
export class ElementDialogAlertComponent {
constructor(public dialogRef: MatDialogRef<ElementDialogAlertComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private _logger: LogService) {
}
onNoClick(): void {
this.dialogRef.close();
}
}
This diff is collapsed.
...@@ -29,7 +29,7 @@ export class ElementServerMenuComponent implements OnInit { ...@@ -29,7 +29,7 @@ export class ElementServerMenuComponent implements OnInit {
m.type = 'lll'; m.type = 'lll';
line.type = 'line'; line.type = 'line';
this.MenuList = [m, m, line, m, m]; this.MenuList = [m, m, line, m, m];
this._dialog.alert(); this._dialog.alert('sss');
} }
public contextmenu(top: number, left: number) { public contextmenu(top: number, left: number) {
......
...@@ -9,7 +9,6 @@ import {Video, DataStore} from '../globals'; ...@@ -9,7 +9,6 @@ import {Video, DataStore} from '../globals';
styleUrls: ['./replay-page.component.css'] styleUrls: ['./replay-page.component.css']
}) })
export class ReplayPageComponent implements OnInit { export class ReplayPageComponent implements OnInit {
Video = Video;
constructor(private activatedRoute: ActivatedRoute, constructor(private activatedRoute: ActivatedRoute,
private _http: HttpService, private _http: HttpService,
......
<h2 mat-dialog-title>Delete all</h2>
<mat-dialog-content>Are you sure?</mat-dialog-content>
<mat-dialog-actions>
<button mat-button mat-dialog-close>No</button>
<!-- The mat-dialog-close directive optionally accepts a value as a result for the dialog. -->
<button mat-button [mat-dialog-close]="true">Yes</button>
</mat-dialog-actions>
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
[columns]="columns" [columns]="columns"
[config]="config" [config]="config"
></app-element-table> ></app-element-table>
<button mat-raised-button (click)="test()">Test</button>
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {DataStore} from '../globals'; import {DataStore} from '../globals';
import {Config} from '../elements/table/table.component'; import {Config} from '../elements/table/table.component';
import {DialogService} from '../elements/dialog/dialog.service';
// import {Mats, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; // import {Mats, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
...@@ -22,7 +23,7 @@ export class TestPageComponent implements OnInit { ...@@ -22,7 +23,7 @@ export class TestPageComponent implements OnInit {
]; ];
config = Config; config = Config;
constructor() { constructor(private _layer: DialogService) {
DataStore.NavShow = false; DataStore.NavShow = false;
this.config.search = true; this.config.search = true;
this.config.scrollbarH = true; this.config.scrollbarH = true;
...@@ -31,4 +32,7 @@ export class TestPageComponent implements OnInit { ...@@ -31,4 +32,7 @@ export class TestPageComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
test() {
this._layer.alert('sss');
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment