feat: 直接登陆

parent 02a2d7f1
......@@ -104,7 +104,7 @@ def asset_groups_assets():
"comment": "Default asset group",
"assets_granted": [
{
"id": 2,
"id": 1,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
......
......@@ -92,9 +92,28 @@ export class CleftbarComponent implements OnInit {
.map(res => res.json())
.subscribe(response => {
this.HostGroups = response;
this.autologin();
});
}
autologin() {
const id = this._appService.getQueryString('id');
if (id) {
for (let g of this.HostGroups) {
if (g['assets_granted']) {
for (let u of g['assets_granted']) {
if (u.id.toString() === id.toString()) {
this.Connect(u);
return;
}
}
}
}
}
}
Connect(host) {
// console.log(host);
let userid: string;
......
......@@ -77,11 +77,11 @@ export class SshComponent implements OnInit {
screenKeys: true,
});
NavList.List.push(new View());
for (let _i = 0; _i < NavList.List.length; _i++) {
if (id === _i) {
for (let i = 0; i < NavList.List.length; i++) {
if (id === i) {
NavList.List[id].hide = false;
} else {
NavList.List[_i].hide = true;
NavList.List[i].hide = true;
}
}
......
......@@ -13,6 +13,7 @@ import {Logger} from 'angular2-logger/core';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import {DataStore, User, Browser} from './globals';
declare function unescape(s: string): string;
@Injectable()
export class HttpService {
......@@ -174,6 +175,14 @@ export class AppService implements OnInit {
this._http.post('/api/browser', JSON.stringify(Browser)).map(res => res.json()).subscribe();
}
getQueryString(name) {
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
const r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
//
//
......
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