Commit bbcd3353 authored by liuzheng712's avatar liuzheng712

feat: fit to jms api

parent f637f7eb
...@@ -170,8 +170,125 @@ server.run = function (options) { ...@@ -170,8 +170,125 @@ server.run = function (options) {
}] }]
}]) }])
}); });
apis.route('/hostlist') apis.route('/perms/v1/user/my/asset-groups-assets/')
.get(function (req, res) { .get(function (req, res) {
res.json([
{
"id": 0,
"name": "ungrouped",
"assets": []
},
{
"id": 1,
"name": "Default",
"comment": "Default asset group",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": true
}
]
},
{
"id": 4,
"hostname": "testserver123",
"ip": "123.57.183.135",
"port": 8022,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": true
}
]
}
]
},
{
"id": 4,
"name": "java",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": true
}
]
}
]
},
{
"id": 3,
"name": "数据库",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": true
}
]
}
]
},
{
"id": 2,
"name": "运维组",
"comment": "",
"assets": [
{
"id": 2,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system_users": [
{
"id": 1,
"name": "web",
"username": "web",
"protocol": "ssh",
"auth_method": "P",
"auto_push": true
}
]
}
]
}
]);
res.json([{ res.json([{
"name": "测试服务器组1", "name": "测试服务器组1",
"id": 1, "id": 1,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<input type="checkbox" id="hostgroup-{{i}}"> <input type="checkbox" id="hostgroup-{{i}}">
<label for="hostgroup-{{i}}">{{hostGroup.name}}</label> <label for="hostgroup-{{i}}">{{hostGroup.name}}</label>
<ul> <ul>
<li *ngFor="let host of hostGroup.children | SearchFilter: q" (click)="Connect(host)">{{host.name}}</li> <li *ngFor="let host of hostGroup.assets | SearchFilter: q" (click)="Connect(host)">{{host.hostname}}</li>
</ul> </ul>
</li> </li>
</ul> </ul>
......
...@@ -85,7 +85,7 @@ export class CleftbarComponent implements OnInit { ...@@ -85,7 +85,7 @@ export class CleftbarComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this._http.get('/api/hostlist') this._http.get('/api/perms/v1/user/my/asset-groups-assets/')
.map(res => res.json()) .map(res => res.json())
.subscribe(response => { .subscribe(response => {
this.HostGroups = response; this.HostGroups = response;
...@@ -95,10 +95,10 @@ export class CleftbarComponent implements OnInit { ...@@ -95,10 +95,10 @@ export class CleftbarComponent implements OnInit {
Connect(host) { Connect(host) {
console.log(host); console.log(host);
let username: string; let username: string;
if (host.users.length > 1) { if (host.system_users.length > 1) {
let options = ""; let options = "";
for (let u of host.users) { for (let u of host.system_users) {
options += "<option value='" + u + "'>" + u + "</option>" options += "<option value='" + u.username + "'>" + u.username + "</option>"
} }
layer.open({ layer.open({
title: 'Please Choose a User', title: 'Please Choose a User',
...@@ -118,8 +118,8 @@ export class CleftbarComponent implements OnInit { ...@@ -118,8 +118,8 @@ export class CleftbarComponent implements OnInit {
//return false 开启该代码可禁止点击该按钮关闭 //return false 开启该代码可禁止点击该按钮关闭
} }
}); });
} else if (host.users.length === 1) { } else if (host.system_users.length === 1) {
username = host.users[0] username = host.system_users[0].username
} }
if (username === "") { if (username === "") {
return return
......
...@@ -47,7 +47,7 @@ export class SshComponent implements OnInit { ...@@ -47,7 +47,7 @@ export class SshComponent implements OnInit {
let id = NavList.List.length - 1; let id = NavList.List.length - 1;
NavList.List[id].nick = host.name; NavList.List[id].nick = host.hostname;
NavList.List[id].connected = true; NavList.List[id].connected = true;
NavList.List[id].edit = false; NavList.List[id].edit = false;
NavList.List[id].closed = false; NavList.List[id].closed = false;
......
...@@ -64,7 +64,7 @@ export class SearchFilter implements PipeTransform { ...@@ -64,7 +64,7 @@ export class SearchFilter implements PipeTransform {
if (input) { if (input) {
input = input.toLowerCase(); input = input.toLowerCase();
return value.filter(function (el: any) { return value.filter(function (el: any) {
return el.name.toLowerCase().indexOf(input) > -1; return el.name.toLowerCase().indexOf(input) > -1 || el.comment.toLocaleLowerCase().indexOf(input) > -1;
}) })
} }
return value; return value;
......
...@@ -16,10 +16,10 @@ import {ControlPageComponent} from './ControlPage/controlpage.component'; ...@@ -16,10 +16,10 @@ import {ControlPageComponent} from './ControlPage/controlpage.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
// { path: 'crisis-center', component: CrisisListComponent }, // { path: 'crisis-center', component: CrisisListComponent },
{path: 'welcome', component: IndexPageComponent}, // <-- delete this line // {path: 'welcome', component: IndexPageComponent}, // <-- delete this line
{path: 'login', component: LoginComponent}, {path: 'login', component: LoginComponent},
{path: 'control', component: ControlPageComponent}, {path: 'control', component: ControlPageComponent},
{path: '', redirectTo: '/welcome', pathMatch: 'full'}, {path: '', redirectTo: '/control', pathMatch: 'full'},
{path: '**', component: NotFoundComponent} {path: '**', component: NotFoundComponent}
]; ];
......
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