Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
luna
Commits
c1b5702e
Commit
c1b5702e
authored
Nov 17, 2017
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update connect with coco in /api/hostlist
parent
f9f842f0
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
103 additions
and
31 deletions
+103
-31
popup.component.css
src/app/BasicPage/popup/popup.component.css
+0
-0
popup.component.html
src/app/BasicPage/popup/popup.component.html
+3
-0
popup.component.spec.ts
src/app/BasicPage/popup/popup.component.spec.ts
+25
-0
popup.component.ts
src/app/BasicPage/popup/popup.component.ts
+15
-0
cleftbar.component.css
src/app/ControlPage/cleftbar/cleftbar.component.css
+0
-1
cleftbar.component.html
src/app/ControlPage/cleftbar/cleftbar.component.html
+3
-3
cleftbar.component.ts
src/app/ControlPage/cleftbar/cleftbar.component.ts
+35
-5
rdp.component.ts
src/app/ControlPage/control/rdp/rdp.component.ts
+4
-3
ssh.component.ts
src/app/ControlPage/control/ssh/ssh.component.ts
+2
-2
app.module.ts
src/app/app.module.ts
+3
-1
app.service.ts
src/app/app.service.ts
+13
-16
No files found.
src/app/BasicPage/popup/popup.component.css
0 → 100644
View file @
c1b5702e
src/app/BasicPage/popup/popup.component.html
0 → 100644
View file @
c1b5702e
<p>
popup works!
</p>
src/app/BasicPage/popup/popup.component.spec.ts
0 → 100644
View file @
c1b5702e
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
PopupComponent
}
from
'./popup.component'
;
describe
(
'PopupComponent'
,
()
=>
{
let
component
:
PopupComponent
;
let
fixture
:
ComponentFixture
<
PopupComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
PopupComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
PopupComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should be created'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/BasicPage/popup/popup.component.ts
0 → 100644
View file @
c1b5702e
import
{
Component
,
OnInit
}
from
'@angular/core'
;
@
Component
({
selector
:
'app-popup'
,
templateUrl
:
'./popup.component.html'
,
styleUrls
:
[
'./popup.component.css'
]
})
export
class
PopupComponent
implements
OnInit
{
constructor
()
{
}
ngOnInit
()
{
}
}
src/app/ControlPage/cleftbar/cleftbar.component.css
View file @
c1b5702e
...
...
@@ -58,4 +58,3 @@
background-size
:
33px
63px
;
}
}
src/app/ControlPage/cleftbar/cleftbar.component.html
View file @
c1b5702e
<div
id=
"sidebar"
>
<app-search></app-search>
<ul
class=
"filetree"
>
<li
*
ngFor=
"let hostGroup of HostGroups"
>
<input
type=
"checkbox"
id=
"
level1-1
"
>
<label
for=
"
level1-1
"
>
{{hostGroup.name}}
</label>
<li
*
ngFor=
"let hostGroup of HostGroups
; let i = index
"
>
<input
type=
"checkbox"
id=
"
hostgroup-{{i}}
"
>
<label
for=
"
hostgroup-{{i}}
"
>
{{hostGroup.name}}
</label>
<ul>
<li
*
ngFor=
"let host of hostGroup.children"
(
click
)="
Connect
(
host
)"
>
{{host.name}}
</li>
</ul>
...
...
src/app/ControlPage/cleftbar/cleftbar.component.ts
View file @
c1b5702e
...
...
@@ -14,11 +14,12 @@ import {AppService, DataStore, HttpService} from '../../app.service';
import
{
SshComponent
}
from
'../control/ssh/ssh.component'
;
import
{
RdpComponent
}
from
"../control/rdp/rdp.component"
;
declare
let
layer
:
any
;
declare
let
jQuery
:
any
;
export
class
HostGroup
{
name
:
string
;
id
:
string
;
id
:
number
;
children
:
Array
<
Host
>
;
}
...
...
@@ -26,8 +27,6 @@ export class Host {
name
:
string
;
uuid
:
string
;
type
:
string
;
token
:
string
;
machine
:
string
;
}
@
Component
({
...
...
@@ -68,14 +67,45 @@ export class CleftbarComponent implements OnInit {
Connect
(
host
)
{
console
.
log
(
host
);
let
username
:
string
;
if
(
host
.
users
.
length
>
1
)
{
let
options
=
""
;
for
(
let
u
of
host
.
users
)
{
options
+=
"<option value='"
+
u
+
"'>"
+
u
+
"</option>"
}
layer
.
open
({
title
:
'Please Choose a User'
,
scrollbar
:
false
,
moveOut
:
true
,
moveType
:
1
,
btn
:
[
"确定"
,
"取消"
],
content
:
"<select id='selectuser'>"
+
options
+
"</select>"
,
yes
:
function
(
index
,
layero
)
{
username
=
jQuery
(
"#selectuser"
).
val
();
layer
.
close
(
index
);
},
btn2
:
function
(
index
,
layero
)
{
},
cancel
:
function
()
{
//右上角关闭回调
//return false 开启该代码可禁止点击该按钮关闭
}
});
}
else
if
(
host
.
users
.
length
===
1
)
{
username
=
host
.
users
[
0
]
}
if
(
username
===
""
)
{
return
}
if
(
host
.
type
===
'ssh'
)
{
jQuery
(
"app-ssh"
).
show
();
jQuery
(
"app-rdp"
).
hide
();
this
.
_term
.
TerminalConnect
(
host
);
this
.
_term
.
TerminalConnect
(
host
,
username
);
}
else
{
jQuery
(
"app-ssh"
).
hide
();
jQuery
(
"app-rdp"
).
show
();
this
.
_rdp
.
Connect
(
host
);
this
.
_rdp
.
Connect
(
host
,
username
);
}
}
...
...
src/app/ControlPage/control/rdp/rdp.component.ts
View file @
c1b5702e
...
...
@@ -24,7 +24,7 @@ export class RdpComponent implements OnInit {
ngOnInit
()
{
}
Connect
(
host
)
{
Connect
(
host
,
username
)
{
let
id
=
NavList
.
List
.
length
-
1
;
let
canvas
=
Mstsc
.
$
(
"canvas-"
+
id
);
...
...
@@ -39,7 +39,7 @@ export class RdpComponent implements OnInit {
NavList
.
List
[
id
].
type
=
"rdp"
;
NavList
.
List
[
id
].
Rdp
=
new
Rdp
;
NavList
.
List
[
id
].
Rdp
.
token
=
host
.
token
;
NavList
.
List
[
id
].
Rdp
.
machine
=
host
.
machine
;
NavList
.
List
[
id
].
Rdp
.
machine
=
host
.
uuid
;
NavList
.
List
[
id
].
Rdp
.
client
=
Mstsc
.
client
.
create
(
Mstsc
.
$
(
"canvas-"
+
id
));
NavList
.
List
[
id
].
Rdp
.
client
.
connect
(
host
.
token
,
"rdp/socket.io"
);
...
...
@@ -60,7 +60,8 @@ export class RdpComponent implements OnInit {
// document.getElementById("templatesrc").remove();
}
static
DisconnectAll
(){
static
DisconnectAll
()
{
}
...
...
src/app/ControlPage/control/ssh/ssh.component.ts
View file @
c1b5702e
...
...
@@ -32,7 +32,7 @@ export class SshComponent implements OnInit {
ngOnInit
()
{
}
TerminalConnect
(
host
)
{
TerminalConnect
(
host
,
username
)
{
let
socket
=
io
.
connect
();
let
cols
=
'80'
;
let
rows
=
'24'
;
...
...
@@ -53,7 +53,7 @@ export class SshComponent implements OnInit {
NavList
.
List
[
id
].
closed
=
false
;
NavList
.
List
[
id
].
type
=
"ssh"
;
NavList
.
List
[
id
].
Term
=
new
Term
;
NavList
.
List
[
id
].
Term
.
machine
=
'localhost'
;
NavList
.
List
[
id
].
Term
.
machine
=
host
.
uuid
;
NavList
.
List
[
id
].
Term
.
socket
=
socket
;
NavList
.
List
[
id
].
Term
.
term
=
new
Terminal
({
cols
:
cols
,
...
...
src/app/app.module.ts
View file @
c1b5702e
...
...
@@ -33,6 +33,7 @@ import {SshComponent} from './ControlPage/control/ssh/ssh.component';
import
{
ControlPageComponent
}
from
'./ControlPage/controlpage.component'
;
import
{
IndexPageComponent
}
from
'./IndexPage/index-page.component'
;
import
{
NotFoundComponent
}
from
'./BasicPage/not-found/not-found.component'
;
import
{
PopupComponent
}
from
'./BasicPage/popup/popup.component'
;
@
NgModule
({
...
...
@@ -57,7 +58,8 @@ import { NotFoundComponent } from './BasicPage/not-found/not-found.component';
ControlnavComponent
,
ControlPageComponent
,
IndexPageComponent
,
NotFoundComponent
NotFoundComponent
,
PopupComponent
// HeroListComponent,
// CrisisListComponent,
],
...
...
src/app/app.service.ts
View file @
c1b5702e
...
...
@@ -5,8 +5,9 @@
* @date 2017-11-07
* @author liuzheng <liuzheng712@gmail.com>
*/
import
{
Injectable
}
from
'@angular/core'
;
import
{
Injectable
,
OnInit
}
from
'@angular/core'
;
import
{
Http
,
RequestOptionsArgs
,
Headers
}
from
'@angular/http'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Cookie
}
from
'ng2-cookies/ng2-cookies'
;
import
{
Logger
}
from
'angular2-logger/core'
;
import
'rxjs/add/operator/map'
;
...
...
@@ -15,7 +16,7 @@ import 'rxjs/add/operator/catch';
declare
let
jQuery
:
any
;
// declare var Clipboard: any;
import
*
as
io
from
'socket.io-client'
;
import
{
Router
}
from
'@angular/router
'
;
import
{
environment
}
from
'../environments/environment
'
;
export
class
Group
{
id
:
number
;
...
...
@@ -97,6 +98,12 @@ export let Browser: {
vendor
:
navigator
.
vendor
,
};
export
class
wsEvent
{
event
:
string
;
data
:
any
;
}
@
Injectable
()
export
class
HttpService
{
headers
=
new
Headers
();
...
...
@@ -171,7 +178,7 @@ export class HttpService {
}
@
Injectable
()
export
class
AppService
{
export
class
AppService
implements
OnInit
{
// user:User = user ;
searchrequest
:
any
;
...
...
@@ -196,22 +203,13 @@ export class AppService {
// this._logger.level = parseInt(Cookie.getCookie('loglevel'));
this
.
_logger
.
level
=
0
;
}
DataStore
.
socket
.
on
(
'connect'
,
function
()
{
console
.
log
(
'DatsStore socket connected'
);
DataStore
.
socket
.
on
(
'nav'
,
function
(
data
)
{
DataStore
.
Nav
=
JSON
.
parse
(
data
);
});
DataStore
.
socket
.
on
(
'leftbar'
,
function
(
data
)
{
});
// DataStore.socket.on('popup', function (data) {
// layer.msg(data);
// });
// DataStore.socket.emit('api', 'all');
});
this
.
checklogin
();
}
ngOnInit
()
{
}
checklogin
()
{
this
.
_logger
.
log
(
'service.ts:AppService,checklogin'
);
...
...
@@ -263,7 +261,6 @@ export class AppService {
}
browser
()
{
this
.
_http
.
post
(
'/api/browser'
,
JSON
.
stringify
(
Browser
)).
map
(
res
=>
res
.
json
()).
subscribe
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment