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
c6814bfa
Commit
c6814bfa
authored
Nov 24, 2017
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: public
parent
767c99ac
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
369 additions
and
26 deletions
+369
-26
app.js
app.js
+118
-1
nav.component.css
src/app/BasicPage/nav/nav.component.css
+1
-0
nav.component.html
src/app/BasicPage/nav/nav.component.html
+0
-0
cleftbar.component.html
src/app/ControlPage/cleftbar/cleftbar.component.html
+1
-1
cleftbar.component.ts
src/app/ControlPage/cleftbar/cleftbar.component.ts
+30
-6
controlnav.component.ts
...pp/ControlPage/control/controlnav/controlnav.component.ts
+1
-2
rdp.component.html
src/app/ControlPage/control/rdp/rdp.component.html
+0
-1
ssh.component.css
src/app/ControlPage/control/ssh/ssh.component.css
+1
-1
ssh.component.ts
src/app/ControlPage/control/ssh/ssh.component.ts
+1
-1
controlpage.component.html
src/app/ControlPage/controlpage.component.html
+2
-2
search.component.ts
src/app/ControlPage/search/search.component.ts
+1
-1
app-routing.module.ts
src/app/app-routing.module.ts
+6
-2
app.component.html
src/app/app.component.html
+2
-2
app.component.ts
src/app/app.component.ts
+2
-2
app.module.ts
src/app/app.module.ts
+5
-1
app.service.ts
src/app/app.service.ts
+4
-3
rdppage.component.css
src/app/rdppage/rdppage.component.css
+0
-0
rdppage.component.html
src/app/rdppage/rdppage.component.html
+1
-0
rdppage.component.spec.ts
src/app/rdppage/rdppage.component.spec.ts
+25
-0
rdppage.component.ts
src/app/rdppage/rdppage.component.ts
+39
-0
termpage.component.css
src/app/termpage/termpage.component.css
+33
-0
termpage.component.html
src/app/termpage/termpage.component.html
+2
-0
termpage.component.spec.ts
src/app/termpage/termpage.component.spec.ts
+25
-0
termpage.component.ts
src/app/termpage/termpage.component.ts
+69
-0
No files found.
app.js
View file @
c6814bfa
...
@@ -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
,
...
...
src/app/BasicPage/nav/nav.component.css
View file @
c6814bfa
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
.dropdown-content
li
:hover
{
.dropdown-content
li
:hover
{
background-color
:
#3a3333
;
background-color
:
#3a3333
;
color
:
black
;
color
:
black
;
width
:
100%
;
}
}
.dropdown-content
li
.disabled
:hover
{
.dropdown-content
li
.disabled
:hover
{
...
...
src/app/BasicPage/nav/nav.component.html
View file @
c6814bfa
src/app/ControlPage/cleftbar/cleftbar.component.html
View file @
c6814bfa
...
@@ -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.host
name}}
</li>
</ul>
</ul>
</li>
</li>
</ul>
</ul>
...
...
src/app/ControlPage/cleftbar/cleftbar.component.ts
View file @
c6814bfa
...
@@ -45,9 +45,33 @@ export class CleftbarComponent implements OnInit {
...
@@ -45,9 +45,33 @@ export class CleftbarComponent implements OnInit {
}
}
static
Hide
()
{
static
Hide
()
{
DataStore
.
leftbarshow
=
false
;
DataStore
.
Nav
.
map
(
function
(
value
,
i
)
{
for
(
var
ii
in
value
[
"children"
])
{
if
(
DataStore
.
Nav
[
i
][
"children"
][
ii
][
"id"
]
===
"HindLeftManager"
)
{
DataStore
.
Nav
[
i
][
"children"
][
ii
]
=
{
"id"
:
"ShowLeftManager"
,
"click"
:
"ShowLeft"
,
"name"
:
"Show left manager"
}
}
}
})
}
}
static
Show
()
{
static
Show
()
{
DataStore
.
leftbarshow
=
true
;
DataStore
.
Nav
.
map
(
function
(
value
,
i
)
{
for
(
var
ii
in
value
[
"children"
])
{
if
(
DataStore
.
Nav
[
i
][
"children"
][
ii
][
"id"
]
===
"ShowLeftManager"
)
{
DataStore
.
Nav
[
i
][
"children"
][
ii
]
=
{
"id"
:
"HindLeftManager"
,
"click"
:
"HideLeft"
,
"name"
:
"Hind left manager"
}
}
}
})
}
}
constructor
(
private
_appService
:
AppService
,
constructor
(
private
_appService
:
AppService
,
...
@@ -61,7 +85,7 @@ export class CleftbarComponent implements OnInit {
...
@@ -61,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
;
...
@@ -71,10 +95,10 @@ export class CleftbarComponent implements OnInit {
...
@@ -71,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'
,
...
@@ -94,8 +118,8 @@ export class CleftbarComponent implements OnInit {
...
@@ -94,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
...
...
src/app/ControlPage/control/controlnav/controlnav.component.ts
View file @
c6814bfa
...
@@ -11,7 +11,6 @@ import {Component, OnInit} from '@angular/core';
...
@@ -11,7 +11,6 @@ import {Component, OnInit} from '@angular/core';
import
{
NavList
}
from
'../control.component'
import
{
NavList
}
from
'../control.component'
import
{
SshComponent
}
from
'../ssh/ssh.component'
import
{
SshComponent
}
from
'../ssh/ssh.component'
import
{
RdpComponent
}
from
'../rdp/rdp.component'
import
{
RdpComponent
}
from
'../rdp/rdp.component'
import
{
NavComponent
}
from
"../../../BasicPage/nav/nav.component"
;
declare
let
jQuery
:
any
;
declare
let
jQuery
:
any
;
...
@@ -19,7 +18,7 @@ declare let jQuery: any;
...
@@ -19,7 +18,7 @@ declare let jQuery: any;
@
Component
({
@
Component
({
selector
:
'app-controlnav'
,
selector
:
'app-controlnav'
,
templateUrl
:
'./controlnav.component.html'
,
templateUrl
:
'./controlnav.component.html'
,
styleUrls
:
[
'./controlnav.component.css'
]
styleUrls
:
[
'./controlnav.component.css'
]
,
})
})
export
class
ControlnavComponent
implements
OnInit
{
export
class
ControlnavComponent
implements
OnInit
{
setActive
=
ControlnavComponent
.
setActive
;
setActive
=
ControlnavComponent
.
setActive
;
...
...
src/app/ControlPage/control/rdp/rdp.component.html
View file @
c6814bfa
...
@@ -2,6 +2,5 @@
...
@@ -2,6 +2,5 @@
<div
*
ngFor=
"let m of NavList.List;let i=index"
<div
*
ngFor=
"let m of NavList.List;let i=index"
[
ngClass
]="{'
disconnected
'
:
!
m
.
connected
,'
hidden
'
:
m
.
hide
,'
hidden
'
:m
.
type
!='
rdp
'}"
id=
"rdp-{{i}}"
>
[
ngClass
]="{'
disconnected
'
:
!
m
.
connected
,'
hidden
'
:
m
.
hide
,'
hidden
'
:m
.
type
!='
rdp
'}"
id=
"rdp-{{i}}"
>
<canvas
id=
"canvas-{{i}}"
></canvas>
<canvas
id=
"canvas-{{i}}"
></canvas>
</div>
</div>
</div>
</div>
src/app/ControlPage/control/ssh/ssh.component.css
View file @
c6814bfa
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
}
}
#term
>
div
{
#term
>
div
{
height
:
100%
;
height
:
100%
;
}
}
.terminal
{
.terminal
{
...
...
src/app/ControlPage/control/ssh/ssh.component.ts
View file @
c6814bfa
...
@@ -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
.
host
name
;
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
;
...
...
src/app/ControlPage/controlpage.component.html
View file @
c6814bfa
<div
class=
"container-fluid row"
>
<div
class=
"container-fluid row"
>
<app-cleftbar
class=
"col-md-2"
></app-cleftbar>
<app-cleftbar
class=
"col-md-2"
*
ngIf=
"DataStore.leftbarshow"
></app-cleftbar>
<app-control
class=
"col-md-10"
></app-control>
<app-control
[
ngClass
]="{'
col-md-10
'
:DataStore
.
leftbarshow
,'
col-md-12
'
:
!
DataStore
.
leftbarshow
}"
></app-control>
</div>
</div>
src/app/ControlPage/search/search.component.ts
View file @
c6814bfa
...
@@ -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
;
...
...
src/app/app-routing.module.ts
View file @
c6814bfa
...
@@ -13,13 +13,17 @@ import {IndexPageComponent} from './IndexPage/index-page.component';
...
@@ -13,13 +13,17 @@ import {IndexPageComponent} from './IndexPage/index-page.component';
import
{
NotFoundComponent
}
from
'./BasicPage/not-found/not-found.component'
;
import
{
NotFoundComponent
}
from
'./BasicPage/not-found/not-found.component'
;
import
{
LoginComponent
}
from
'./BasicPage/login/login.component'
;
import
{
LoginComponent
}
from
'./BasicPage/login/login.component'
;
import
{
ControlPageComponent
}
from
'./ControlPage/controlpage.component'
;
import
{
ControlPageComponent
}
from
'./ControlPage/controlpage.component'
;
import
{
RdppageComponent
}
from
"./rdppage/rdppage.component"
;
import
{
TermpageComponent
}
from
"./termpage/termpage.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
:
'rdp/:token'
,
component
:
RdppageComponent
},
{
path
:
'term/:token'
,
component
:
TermpageComponent
},
{
path
:
''
,
redirectTo
:
'/control'
,
pathMatch
:
'full'
},
{
path
:
'**'
,
component
:
NotFoundComponent
}
{
path
:
'**'
,
component
:
NotFoundComponent
}
];
];
...
...
src/app/app.component.html
View file @
c6814bfa
<app-nav></app-nav>
<app-nav
*
ngIf=
"DataStore.NavShow"
></app-nav>
<nav></nav>
<nav
*
ngIf=
"DataStore.NavShow"
></nav>
<router-outlet></router-outlet>
<router-outlet></router-outlet>
src/app/app.component.ts
View file @
c6814bfa
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* @author liuzheng <liuzheng712@gmail.com>
* @author liuzheng <liuzheng712@gmail.com>
*/
*/
import
{
Component
}
from
'@angular/core'
;
import
{
Component
}
from
'@angular/core'
;
import
{
AppService
,
HttpService
}
from
'./app.service'
;
import
{
AppService
,
HttpService
,
DataStore
}
from
'./app.service'
;
@
Component
({
@
Component
({
selector
:
'app-root'
,
selector
:
'app-root'
,
...
@@ -17,5 +17,5 @@ import {AppService, HttpService} from './app.service';
...
@@ -17,5 +17,5 @@ import {AppService, HttpService} from './app.service';
})
})
export
class
AppComponent
{
export
class
AppComponent
{
//
DataStore = DataStore;
DataStore
=
DataStore
;
}
}
src/app/app.module.ts
View file @
c6814bfa
...
@@ -34,6 +34,8 @@ import {ControlPageComponent} from './ControlPage/controlpage.component';
...
@@ -34,6 +34,8 @@ import {ControlPageComponent} from './ControlPage/controlpage.component';
import
{
IndexPageComponent
}
from
'./IndexPage/index-page.component'
;
import
{
IndexPageComponent
}
from
'./IndexPage/index-page.component'
;
import
{
NotFoundComponent
}
from
'./BasicPage/not-found/not-found.component'
;
import
{
NotFoundComponent
}
from
'./BasicPage/not-found/not-found.component'
;
import
{
PopupComponent
}
from
'./BasicPage/popup/popup.component'
;
import
{
PopupComponent
}
from
'./BasicPage/popup/popup.component'
;
import
{
RdppageComponent
}
from
'./rdppage/rdppage.component'
;
import
{
TermpageComponent
}
from
'./termpage/termpage.component'
;
@
NgModule
({
@
NgModule
({
...
@@ -60,7 +62,9 @@ import {PopupComponent} from './BasicPage/popup/popup.component';
...
@@ -60,7 +62,9 @@ import {PopupComponent} from './BasicPage/popup/popup.component';
ControlPageComponent
,
ControlPageComponent
,
IndexPageComponent
,
IndexPageComponent
,
NotFoundComponent
,
NotFoundComponent
,
PopupComponent
PopupComponent
,
RdppageComponent
,
TermpageComponent
,
// HeroListComponent,
// HeroListComponent,
// CrisisListComponent,
// CrisisListComponent,
],
],
...
...
src/app/app.service.ts
View file @
c6814bfa
...
@@ -57,20 +57,22 @@ export let User: {
...
@@ -57,20 +57,22 @@ export let User: {
export
let
DataStore
:
{
export
let
DataStore
:
{
socket
:
any
;
socket
:
any
;
Nav
:
Array
<
{}
>
;
Nav
:
Array
<
{}
>
;
NavShow
:
boolean
;
Path
:
{};
Path
:
{};
error
:
{};
error
:
{};
msg
:
{};
msg
:
{};
loglevel
:
number
;
loglevel
:
number
;
leftbar
hide
:
boolean
;
leftbar
show
:
boolean
;
windowsize
:
Array
<
number
>
;
windowsize
:
Array
<
number
>
;
}
=
{
}
=
{
socket
:
io
.
connect
(),
socket
:
io
.
connect
(),
Nav
:
[{}],
Nav
:
[{}],
NavShow
:
true
,
Path
:
{},
Path
:
{},
error
:
{},
error
:
{},
msg
:
{},
msg
:
{},
loglevel
:
0
,
loglevel
:
0
,
leftbar
hide
:
fals
e
,
leftbar
show
:
tru
e
,
windowsize
:
[],
windowsize
:
[],
};
};
export
let
CSRF
:
string
=
''
;
export
let
CSRF
:
string
=
''
;
...
@@ -264,7 +266,6 @@ export class AppService implements OnInit {
...
@@ -264,7 +266,6 @@ export class AppService implements OnInit {
}
}
//
//
//
//
// HideLeft() {
// HideLeft() {
...
...
src/app/rdppage/rdppage.component.css
0 → 100644
View file @
c6814bfa
src/app/rdppage/rdppage.component.html
0 → 100644
View file @
c6814bfa
<canvas
id=
"canvas"
></canvas>
src/app/rdppage/rdppage.component.spec.ts
0 → 100644
View file @
c6814bfa
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
RdppageComponent
}
from
'./rdppage.component'
;
describe
(
'RdppageComponent'
,
()
=>
{
let
component
:
RdppageComponent
;
let
fixture
:
ComponentFixture
<
RdppageComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
RdppageComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
RdppageComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/rdppage/rdppage.component.ts
0 → 100644
View file @
c6814bfa
/**
* RDP页面
*
* @date 2017-11-24
* @author liuzheng <liuzheng712@gmail.com>
*/
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ActivatedRoute
,
Params
}
from
'@angular/router'
;
import
{
DataStore
}
from
"../app.service"
;
declare
let
Mstsc
:
any
;
@
Component
({
selector
:
'app-rdppage'
,
templateUrl
:
'./rdppage.component.html'
,
styleUrls
:
[
'./rdppage.component.css'
]
})
export
class
RdppageComponent
implements
OnInit
{
constructor
(
private
activatedRoute
:
ActivatedRoute
)
{
DataStore
.
NavShow
=
false
;
}
ngOnInit
()
{
let
token
:
string
;
this
.
activatedRoute
.
params
.
subscribe
((
params
:
Params
)
=>
{
token
=
params
[
'token'
];
});
let
canvas
=
Mstsc
.
$
(
"canvas"
);
canvas
.
style
.
display
=
'inline'
;
canvas
.
width
=
window
.
innerWidth
;
canvas
.
height
=
window
.
innerHeight
;
let
client
=
Mstsc
.
client
.
create
(
Mstsc
.
$
(
"canvas"
));
client
.
connect
(
token
,
"socket.io"
);
}
}
src/app/termpage/termpage.component.css
0 → 100644
View file @
c6814bfa
#term
{
width
:
100%
;
height
:
100%
;
}
#term
>
div
{
height
:
100%
;
}
.terminal
{
border
:
#000
solid
5px
;
color
:
#f0f0f0
;
box-shadow
:
rgba
(
0
,
0
,
0
,
0.8
)
2px
2px
20px
;
white-space
:
nowrap
;
display
:
inline-block
;
width
:
100%
;
height
:
100%
;
background-color
:
black
;
}
#term
.terminal
div
span
{
min-width
:
12px
;
}
#liuzheng
{
position
:
fixed
;
top
:
0
;
left
:
0
;
z-index
:
-1
;
font-size
:
11px
!important
;
padding-bottom
:
16px
!important
;
font-family
:
'Monaco'
,
iosevka
!important
;
}
src/app/termpage/termpage.component.html
0 → 100644
View file @
c6814bfa
<span
id=
"liuzheng"
>
liuzheng
</span>
<div
id=
"term"
></div>
src/app/termpage/termpage.component.spec.ts
0 → 100644
View file @
c6814bfa
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
TermpageComponent
}
from
'./termpage.component'
;
describe
(
'TermpageComponent'
,
()
=>
{
let
component
:
TermpageComponent
;
let
fixture
:
ComponentFixture
<
TermpageComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
TermpageComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
TermpageComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/termpage/termpage.component.ts
0 → 100644
View file @
c6814bfa
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ActivatedRoute
,
Params
}
from
'@angular/router'
;
import
{
DataStore
}
from
"../app.service"
;
import
*
as
io
from
'socket.io-client'
;
declare
let
jQuery
:
any
;
declare
let
Terminal
:
any
;
@
Component
({
selector
:
'app-termpage'
,
templateUrl
:
'./termpage.component.html'
,
styleUrls
:
[
'./termpage.component.css'
]
})
export
class
TermpageComponent
implements
OnInit
{
constructor
(
private
activatedRoute
:
ActivatedRoute
)
{
DataStore
.
NavShow
=
false
;
}
ngOnInit
()
{
let
token
:
string
;
this
.
activatedRoute
.
params
.
subscribe
((
params
:
Params
)
=>
{
token
=
params
[
'token'
];
});
let
socket
=
io
.
connect
();
let
term
=
new
Terminal
({
cols
:
'80'
,
rows
:
'24'
,
useStyle
:
true
,
screenKeys
:
true
,
});
socket
.
on
(
'connect'
,
function
()
{
socket
.
emit
(
'token'
,
token
);
term
.
on
(
'data'
,
function
(
data
)
{
socket
.
emit
(
'data'
,
data
);
});
socket
.
on
(
'data'
,
function
(
data
)
{
term
.
write
(
data
);
});
socket
.
on
(
'disconnect'
,
function
()
{
term
.
destroy
();
});
window
.
onresize
=
function
()
{
let
col
=
Math
.
floor
(
jQuery
(
'#term'
).
width
()
/
jQuery
(
'#liuzheng'
).
width
()
*
8
)
-
3
;
let
row
=
Math
.
floor
(
jQuery
(
'#term'
).
height
()
/
jQuery
(
'#liuzheng'
).
height
())
-
5
;
let
rows
=
24
;
let
cols
=
80
;
if
(
col
<
80
)
col
=
80
;
if
(
row
<
24
)
row
=
24
;
if
(
cols
==
col
&&
row
==
rows
)
{
}
else
{
socket
.
emit
(
'resize'
,
[
col
,
row
]);
term
.
resize
(
col
,
row
);
}
};
jQuery
(
window
).
resize
();
});
}
}
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