parent b3e74b68
......@@ -16,6 +16,7 @@ import {ElementServerMenuComponent} from '../../elements/server-menu/server-menu
import {NavList, View} from '../control/control.component';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import {FormControl, Validators} from '@angular/forms';
import {DialogService} from '../../elements/dialog/dialog.service';
export interface HostGroup {
......@@ -84,7 +85,8 @@ export class CleftbarComponent implements OnInit {
private _search: SearchComponent,
private _logger: LogService,
private _menu: ElementServerMenuComponent,
public _dialog: MatDialog) {
public _dialog: MatDialog,
private _layer: DialogService) {
this._logger.log('nav.ts:NavComponent');
// this._appService.getnav()
}
......@@ -98,19 +100,34 @@ export class CleftbarComponent implements OnInit {
}
autologin() {
const id = this._appService.getQueryString('id');
if (id) {
const asset_id = this._appService.getQueryString('asset_id');
const user_id = this._appService.getQueryString('user_id');
let tag = false;
if (asset_id) {
for (let g of this.HostGroups) {
if (g['assets_granted']) {
g['assets_granted'].forEach((v, k) => {
if (v.id.toSource() === id.toString()) {
this.Connect(v);
return;
for (let host of g['assets_granted']) {
if (host.id.toString() === asset_id) {
if (user_id) {
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';
// 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
import {ElementFooterComponent} from './elements/footer/footer.component';
......@@ -79,6 +79,7 @@ import {ElementTableComponent} from './elements/table/table.component';
ElementRdpComponent,
ElementServerMenuComponent,
ElementIframeComponent,
ElementDialogAlertComponent,
LoginComponent,
SearchComponent,
SearchFilter,
......@@ -104,6 +105,7 @@ import {ElementTableComponent} from './elements/table/table.component';
],
entryComponents: [
CleftbarDialogComponent,
ElementDialogAlertComponent,
],
bootstrap: [AppComponent],
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';
@Injectable()
export class DialogService {
constructor() {
constructor(public _dialog: MatDialog) {
}
open(options: any) {
......@@ -24,11 +28,33 @@ export class DialogService {
loading() {
}
alert() {
// alert('sss');
alert(msg: string) {
this._dialog.open(ElementDialogAlertComponent, {
height: '200px',
width: '300px',
data: {msg: msg}
});
}
close(index: any) {
// 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 {
m.type = 'lll';
line.type = 'line';
this.MenuList = [m, m, line, m, m];
this._dialog.alert();
this._dialog.alert('sss');
}
public contextmenu(top: number, left: number) {
......
......@@ -9,7 +9,6 @@ import {Video, DataStore} from '../globals';
styleUrls: ['./replay-page.component.css']
})
export class ReplayPageComponent implements OnInit {
Video = Video;
constructor(private activatedRoute: ActivatedRoute,
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 @@
[columns]="columns"
[config]="config"
></app-element-table>
<button mat-raised-button (click)="test()">Test</button>
import {Component, OnInit} from '@angular/core';
import {DataStore} from '../globals';
import {Config} from '../elements/table/table.component';
import {DialogService} from '../elements/dialog/dialog.service';
// import {Mats, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
......@@ -22,7 +23,7 @@ export class TestPageComponent implements OnInit {
];
config = Config;
constructor() {
constructor(private _layer: DialogService) {
DataStore.NavShow = false;
this.config.search = true;
this.config.scrollbarH = true;
......@@ -31,4 +32,7 @@ export class TestPageComponent implements OnInit {
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