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
4678ff4c
Unverified
Commit
4678ff4c
authored
Jan 16, 2018
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
ae020d43
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
9 deletions
+27
-9
mock.py
mock.py
+13
-3
control.component.ts
src/app/ControlPage/control/control.component.ts
+8
-2
term.component.ts
src/app/elements/term/term.component.ts
+6
-4
No files found.
mock.py
View file @
4678ff4c
...
...
@@ -24,10 +24,12 @@ class SSHws(Namespace):
# self.chan.settimeout(0.1)
self
.
socketio
.
start_background_task
(
self
.
sent_data
,
self
,
self
.
clients
[
request
.
sid
][
"chan"
][
connection
],
self
.
clients
[
request
.
sid
][
"room"
],
connection
)
connection
,
request
.
sid
)
def
sent_data
(
self
,
s
,
chan
,
room
,
connection
):
def
sent_data
(
self
,
s
,
chan
,
room
,
connection
,
sid
):
while
True
:
if
connection
not
in
s
.
clients
[
sid
][
"chan"
]
.
keys
():
return
try
:
data
=
chan
.
recv
(
2048
)
.
decode
(
'utf-8'
,
'replace'
)
s
.
emit
(
event
=
'data'
,
data
=
{
"data"
:
data
,
"room"
:
connection
},
room
=
room
)
...
...
@@ -61,8 +63,8 @@ class SSHws(Namespace):
def
on_host
(
self
,
message
):
connection
=
str
(
uuid
.
uuid4
())
self
.
ssh_with_password
(
connection
)
self
.
emit
(
'room'
,
{
'room'
:
connection
,
'secret'
:
message
[
'secret'
]})
self
.
ssh_with_password
(
connection
)
def
on_resize
(
self
,
message
):
self
.
clients
[
request
.
sid
][
"cols"
]
=
message
.
get
(
'cols'
,
80
)
...
...
@@ -84,11 +86,19 @@ class SSHws(Namespace):
def
on_disconnect
(
self
):
print
(
"disconnect"
)
for
connection
in
self
.
clients
[
request
.
sid
][
"chan"
]:
self
.
on_logout
(
connection
)
pass
def
on_leave
(
self
):
leave_room
(
self
.
room
)
def
on_logout
(
self
,
connection
):
print
(
"logout"
,
connection
)
if
connection
:
self
.
clients
[
request
.
sid
][
"chan"
][
connection
]
.
close
()
del
self
.
clients
[
request
.
sid
][
"chan"
][
connection
]
@app.route
(
'/luna/<path:path>'
)
def
send_js
(
path
):
...
...
src/app/ControlPage/control/control.component.ts
View file @
4678ff4c
...
...
@@ -8,6 +8,7 @@
*/
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
TermWS
}
from
'../../globals'
;
// export class Term {
// machine: string;
...
...
@@ -30,6 +31,7 @@ export class View {
closed
:
boolean
;
host
:
any
;
user
:
any
;
room
:
string
;
Rdp
:
Rdp
;
Term
:
any
;
}
...
...
@@ -63,8 +65,12 @@ export class ControlComponent implements OnInit {
}
static
TerminalDisconnect
(
id
)
{
NavList
.
List
[
id
].
connected
=
false
;
NavList
.
List
[
id
].
Term
.
write
(
'
\
r
\
n
\
x1b[31mBye Bye!
\
x1b[m
\
r
\
n'
);
console
.
log
(
id
);
if
(
NavList
.
List
[
id
].
connected
)
{
NavList
.
List
[
id
].
connected
=
false
;
NavList
.
List
[
id
].
Term
.
write
(
'
\
r
\
n
\
x1b[31mBye Bye!
\
x1b[m
\
r
\
n'
);
TermWS
.
emit
(
'logout'
,
NavList
.
List
[
id
].
room
);
}
}
static
RdpDisconnect
(
id
)
{
...
...
src/app/elements/term/term.component.ts
View file @
4678ff4c
...
...
@@ -15,7 +15,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@
Input
()
host
:
any
;
@
Input
()
userid
:
any
;
@
Input
()
index
:
number
;
@
Input
()
room
:
string
;
//
@Input() room: string;
@
ViewChild
(
'term'
)
el
:
ElementRef
;
secret
:
string
;
term
:
any
;
...
...
@@ -31,6 +31,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
useStyle
:
true
,
screenKeys
:
true
,
});
// NavList.List[this.index].room = this.room;
}
ngAfterViewInit
()
{
...
...
@@ -74,11 +75,11 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TermWS
.
emit
(
'host'
,
{
'uuid'
:
this
.
host
.
id
,
'userid'
:
this
.
userid
,
'secret'
:
this
.
secret
});
this
.
term
.
on
(
'data'
,
function
(
data
)
{
TermWS
.
emit
(
'data'
,
{
'data'
:
data
,
'room'
:
that
.
room
});
TermWS
.
emit
(
'data'
,
{
'data'
:
data
,
'room'
:
NavList
.
List
[
that
.
index
]
.
room
});
});
TermWS
.
on
(
'data'
,
function
(
data
)
{
if
(
data
[
'room'
]
===
that
.
room
)
{
if
(
data
[
'room'
]
===
NavList
.
List
[
that
.
index
]
.
room
)
{
that
.
term
.
write
(
data
[
'data'
]);
}
});
...
...
@@ -88,7 +89,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
});
TermWS
.
on
(
'room'
,
function
(
data
)
{
if
(
data
[
'secret'
]
===
that
.
secret
)
{
that
.
room
=
data
[
'room'
];
NavList
.
List
[
that
.
index
]
.
room
=
data
[
'room'
];
}
});
}
...
...
@@ -97,5 +98,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TerminalDisconnect
()
{
NavList
.
List
[
this
.
index
].
connected
=
false
;
this
.
term
.
write
(
'
\
r
\
n
\
x1b[31mBye Bye!
\
x1b[m
\
r
\
n'
);
TermWS
.
emit
(
'logout'
,
NavList
.
List
[
this
.
index
].
room
);
}
}
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