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
90e10c55
Unverified
Commit
90e10c55
authored
Feb 12, 2018
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
9649aaa2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
344 deletions
+108
-344
app.js
app.js
+0
-336
app.module.ts
src/app/app.module.ts
+4
-1
leftbar.component.ts
src/app/elements/leftbar/leftbar.component.ts
+8
-2
email.component.html
src/app/setting-page/email/email.component.html
+58
-3
email.component.scss
src/app/setting-page/email/email.component.scss
+12
-0
email.component.ts
src/app/setting-page/email/email.component.ts
+26
-2
No files found.
app.js
deleted
100644 → 0
View file @
9649aaa2
/**
* Created by liuzheng on 7/17/16.
*/
var
server
=
{};
var
http
=
require
(
'http'
);
var
express
=
require
(
'express'
);
var
io
=
require
(
'socket.io'
);
var
pty
=
require
(
'pty.js'
);
// var terminal = require('term.js');
var
socket
;
var
term
;
var
buff
=
[];
server
.
run
=
function
(
options
)
{
// create shell process
term
=
pty
.
fork
(
process
.
env
.
SHELL
||
'sh'
,
[],
{
name
:
require
(
'fs'
).
existsSync
(
'/usr/share/terminfo/x/xterm-256color'
)
?
'xterm-256color'
:
'xterm'
,
cols
:
80
,
rows
:
24
,
cwd
:
process
.
env
.
HOME
}
);
//
// // store term's output into buffer or emit through socket
term
.
on
(
'data'
,
function
(
data
)
{
return
!
socket
?
buff
.
push
(
data
)
:
socket
.
emit
(
'data'
,
data
);
});
// console.log('Created shell with pty master/slave pair (master: %d, pid: %d)', term.fd, term.pid);
var
app
=
express
();
var
server
=
http
.
createServer
(
app
);
var
apis
=
express
.
Router
();
app
.
use
(
"/"
,
express
.
static
(
__dirname
+
'/dist/'
));
// 创建服务端
// app.use("/socket.io/", express.static(__dirname + '/api/')); // 创建服务端
// let term.js handle req/res
// app.use(terminal.middleware());
apis
.
route
(
'/browser'
)
.
post
(
function
(
req
,
res
)
{
// console.log(req);
// res.string('');
res
.
json
({
verified
:
true
,
csrf
:
"liuzheng"
})
});
apis
.
route
(
'/checklogin'
)
.
post
(
function
(
req
,
res
)
{
res
.
json
({
logined
:
true
,
id
:
1
,
username
:
"liuzheng"
,
name
:
"liuzheng"
})
})
.
get
(
function
(
req
,
res
)
{
res
.
json
({
logined
:
true
})
});
apis
.
route
(
'/nav'
)
.
get
(
function
(
req
,
res
)
{
res
.
json
([{
"id"
:
"File"
,
"name"
:
"Server"
,
"children"
:
[
{
"id"
:
"NewConnection"
,
"href"
:
"Aaaa"
,
"name"
:
"New connection"
,
"disable"
:
true
},
{
"id"
:
"Connect"
,
"href"
:
"Aaaa"
,
"name"
:
"Connect"
,
"disable"
:
true
},
{
"id"
:
"Disconnect"
,
"click"
:
"Disconnect"
,
"name"
:
"Disconnect"
},
{
"id"
:
"DisconnectAll"
,
"click"
:
"DisconnectAll"
,
"name"
:
"Disconnect all"
},
{
"id"
:
"Duplicate"
,
"href"
:
"Aaaa"
,
"name"
:
"Duplicate"
,
"disable"
:
true
},
{
"id"
:
"Upload"
,
"href"
:
"Aaaa"
,
"name"
:
"Upload"
,
"disable"
:
true
},
{
"id"
:
"Download"
,
"href"
:
"Aaaa"
,
"name"
:
"Download"
,
"disable"
:
true
},
{
"id"
:
" Search"
,
"href"
:
"Aaaa"
,
"name"
:
"Search"
,
"disable"
:
true
},
{
"id"
:
"Reload"
,
"click"
:
"ReloadLeftbar"
,
"name"
:
"Reload"
}
]
},
{
"id"
:
"View"
,
"name"
:
"View"
,
"children"
:
[
{
"id"
:
"HindLeftManager"
,
"click"
:
"HideLeft"
,
"name"
:
"Hind left manager"
},
{
"id"
:
"SplitVertical"
,
"href"
:
"Aaaa"
,
"name"
:
"Split vertical"
,
"disable"
:
true
},
{
"id"
:
"CommandBar"
,
"href"
:
"Aaaa"
,
"name"
:
"Command bar"
,
"disable"
:
true
},
{
"id"
:
"ShareSession"
,
"href"
:
"Aaaa"
,
"name"
:
"Share session (read/write)"
,
"disable"
:
true
},
{
"id"
:
"Language"
,
"href"
:
"Aaaa"
,
"name"
:
"Language"
,
"disable"
:
true
}]
},
{
"id"
:
"Help"
,
"name"
:
"Help"
,
"children"
:
[
{
"id"
:
"EnterLicense"
,
"click"
:
"EnterLicense"
,
"name"
:
"Enter License"
},
{
"id"
:
"Website"
,
"click"
:
"Website"
,
"name"
:
"Website"
},
{
"id"
:
"BBS"
,
"click"
:
"BBS"
,
"name"
:
"BBS"
}]
}])
});
apis
.
route
(
'/replay'
)
.
get
(
function
(
req
,
res
)
{
res
.
json
({
"type"
:
"json"
})
});
apis
.
route
(
'/perms/v1/user/my/asset-groups-assets/'
)
.
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"
:
"windows"
,
"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"
:
"linux"
,
"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
}
]
}
]
}
])
});
app
.
use
(
"/api"
,
apis
);
// let server listen on the port
options
=
options
||
{};
server
.
listen
(
options
.
port
||
3000
);
// let socket.io handle sockets
io
=
io
.
listen
(
server
,
{
log
:
false
});
io
.
sockets
.
on
(
'connection'
,
function
(
s
)
{
// when connect, store the socket
socket
=
s
;
// handme incoming data (client -> server)
socket
.
on
(
'data'
,
function
(
data
)
{
term
.
write
(
data
);
});
socket
.
on
(
'resize'
,
function
(
data
)
{
term
.
resize
(
data
[
0
],
data
[
1
]);
console
.
log
(
data
)
});
// handle connection lost
socket
.
on
(
'disconnect'
,
function
()
{
socket
=
null
;
});
// send buffer data to client
while
(
buff
.
length
)
{
socket
.
emit
(
'data'
,
buff
.
shift
());
}
});
};
server
.
run
({
port
:
3000
});
console
.
log
(
'Please open your browser with http://127.0.0.1:3000'
);
src/app/app.module.ts
View file @
90e10c55
...
...
@@ -64,6 +64,7 @@ import {SettingPageLdapComponent} from './setting-page/ldap/ldap.component';
import
{
SettingPageTerminalComponent
}
from
'./setting-page/terminal/terminal.component'
;
import
{
SettingPageS3Component
}
from
'./setting-page/s3/s3.component'
;
import
{
TransPipe
}
from
'./trans.pipe'
;
import
{
MAT_LABEL_GLOBAL_OPTIONS
}
from
'@angular/material'
;
@
NgModule
({
imports
:
[
...
...
@@ -136,7 +137,9 @@ import {TransPipe} from './trans.pipe';
LocalStorageService
,
DialogService
,
CookieService
,
NGXLogger
NGXLogger
,
{
provide
:
MAT_LABEL_GLOBAL_OPTIONS
,
useValue
:
{
float
:
'always'
}}
]
})
export
class
AppModule
{
...
...
src/app/elements/leftbar/leftbar.component.ts
View file @
90e10c55
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
FormBuilder
,
FormGroup
}
from
'@angular/forms'
;
import
{
Router
}
from
'@angular/router'
;
@
Component
({
selector
:
'app-element-leftbar'
,
...
...
@@ -95,7 +96,8 @@ export class ElementLeftbarComponent implements OnInit {
active
:
number
;
active2
:
number
;
constructor
(
fb
:
FormBuilder
)
{
constructor
(
fb
:
FormBuilder
,
private
_router
:
Router
)
{
this
.
options
=
fb
.
group
({
'fixed'
:
true
,
'top'
:
0
,
...
...
@@ -111,7 +113,11 @@ export class ElementLeftbarComponent implements OnInit {
gotoLink
(
link
:
string
,
index
:
number
,
index2
:
number
)
{
if
(
link
)
{
window
.
location
.
href
=
link
;
if
(
link
===
'/luna/setting'
)
{
this
.
_router
.
navigate
([
'setting'
]);
}
else
{
window
.
location
.
href
=
link
;
}
}
this
.
active
=
index
;
this
.
active2
=
index2
;
...
...
src/app/setting-page/email/email.component.html
View file @
90e10c55
<p>
email works!
</p>
<div
class=
"email-form"
>
<mat-form-field
hintLabel=
""
>
<input
matInput
#
input
maxlength=
"10"
placeholder=
"{{'SMTP host'|trans}}"
>
</mat-form-field>
<mat-form-field
hintLabel=
""
>
<input
matInput
#
input
maxlength=
"10"
placeholder=
"{{'SMTP port'|trans}}"
>
</mat-form-field>
<mat-form-field
hintLabel=
""
>
<input
matInput
#
input
maxlength=
"10"
[
formControl
]="
emailFormControl
"
[
errorStateMatcher
]="
matcher
"
placeholder=
"{{'SMTP user'|trans}}"
>
<mat-error
*
ngIf=
"emailFormControl.hasError('email') && !emailFormControl.hasError('required')"
>
{{'Please enter a valid email address'|trans}}
</mat-error>
<mat-error
*
ngIf=
"emailFormControl.hasError('required')"
>
<strong>
{{'Email is required'|trans}}
</strong>
</mat-error>
</mat-form-field>
<mat-form-field
hintLabel=
"{{'Some provider use token except password'|trans}}"
>
<input
matInput
#
input
maxlength=
"10"
[
type
]="
hide
?
'
password
'
:
'
text
'"
placeholder=
"{{'SMTP password'|trans}}"
>
<mat-icon
matSuffix
(
click
)="
hide =
!hide"
>
{{hide ? 'visibility' : 'visibility_off'}}
</mat-icon>
</mat-form-field>
<mat-form-field
[
hideRequiredMarker
]="
options
.
value
.
hideRequired
"
[
floatLabel
]="
options
.
value
.
floatLabel
"
>
<mat-select
required
>
<mat-option
value=
"yes"
>
{{'Yes'|trans}}
</mat-option>
<mat-option
value=
"no"
>
{{'No'|trans}}
</mat-option>
</mat-select>
<mat-placeholder>
<b>
{{'Use SSL'|trans}}
</b>
</mat-placeholder>
<mat-hint>
{{'If SMTP port is 465, may be select'|trans}}
</mat-hint>
</mat-form-field>
<mat-form-field
[
hideRequiredMarker
]="
options
.
value
.
hideRequired
"
[
floatLabel
]="
options
.
value
.
floatLabel
"
>
<mat-select
required
>
<mat-option
value=
"yes"
>
{{'Yes'|trans}}
</mat-option>
<mat-option
value=
"no"
>
{{'No'|trans}}
</mat-option>
</mat-select>
<mat-placeholder>
<b>
{{'Use TLS'|trans}}
</b>
</mat-placeholder>
<mat-hint>
{{'If SMTP port is 587, may be select'|trans}}
</mat-hint>
</mat-form-field>
<br>
<div
class=
"button-row"
>
<button
mat-raised-button
>
{{ 'Test connection' | trans }}
</button>
<button
mat-raised-button
>
{{ 'Reset' | trans }}
</button>
<button
mat-raised-button
color=
"primary"
>
{{ 'Submit' | trans }}
</button>
</div>
<br/>
</div>
src/app/setting-page/email/email.component.scss
View file @
90e10c55
.email-form
{
height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
max-width
:
400px
;
margin
:
auto
;
font-size
:
14pt
;
}
.email-form
>
*
{
width
:
100%
;
}
src/app/setting-page/email/email.component.ts
View file @
90e10c55
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
FormBuilder
,
FormControl
,
FormGroup
,
FormGroupDirective
,
NgForm
,
Validators
}
from
'@angular/forms'
;
import
{
ErrorStateMatcher
}
from
'@angular/material/core'
;
/** Error when invalid control is dirty, touched, or submitted. */
export
class
MyErrorStateMatcher
implements
ErrorStateMatcher
{
isErrorState
(
control
:
FormControl
|
null
,
form
:
FormGroupDirective
|
NgForm
|
null
):
boolean
{
const
isSubmitted
=
form
&&
form
.
submitted
;
return
!!
(
control
&&
control
.
invalid
&&
(
control
.
dirty
||
control
.
touched
||
isSubmitted
));
}
}
@
Component
({
selector
:
'app-sp-email'
,
...
...
@@ -7,7 +17,21 @@ import { Component, OnInit } from '@angular/core';
})
export
class
SettingPageEmailComponent
implements
OnInit
{
constructor
()
{
}
emailFormControl
=
new
FormControl
(
''
,
[
Validators
.
required
,
Validators
.
email
,
]);
matcher
=
new
MyErrorStateMatcher
();
hide
=
true
;
options
:
FormGroup
;
constructor
(
fb
:
FormBuilder
)
{
this
.
options
=
fb
.
group
({
hideRequired
:
false
,
floatLabel
:
'auto'
,
});
}
ngOnInit
()
{
}
...
...
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