Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
dashboard
Project
Project
Details
Activity
Releases
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
shangbj
dashboard
Commits
4dd80b5d
Commit
4dd80b5d
authored
Jul 28, 2017
by
zhiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加淘车站点
parent
675debe8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
13 deletions
+50
-13
app.js
app.js
+12
-3
usage_default.json
usage_default.json
+1
-0
usepage.html
usepage.html
+37
-10
No files found.
app.js
View file @
4dd80b5d
'use strict'
;
const
fs
=
require
(
'fs'
)
const
express
=
require
(
'express'
)
const
bodyParser
=
require
(
'body-parser'
)
const
low
=
require
(
'lowdb'
)
const
exec
=
require
(
'child_process'
).
exec
const
db
=
low
(
'./usage.json'
)
const
usageFilePath
=
'./usage.json'
try
{
fs
.
statSync
(
usageFilePath
).
isFile
()
}
catch
(
e
)
{
fs
.
writeFileSync
(
usageFilePath
,
fs
.
readFileSync
(
usageFilePath
.
replace
(
'.json'
,
'_default.json'
)))
}
const
db
=
low
(
usageFilePath
)
const
app
=
express
()
app
.
use
(
bodyParser
.
json
())
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
...
...
@@ -41,12 +48,13 @@ app.all('/wiki/update', function(req, res){
})
app
.
post
(
'/register'
,
function
(
req
,
res
){
const
site
=
req
.
body
.
site
const
machine
=
req
.
body
.
machine
const
branch
=
req
.
body
.
branch
const
project
=
req
.
body
.
project
if
(
machine
&&
machine
.
length
){
machine
.
forEach
(
machine
=>
{
const
source
=
db
.
get
(
'machine'
).
find
({
name
:
machine
}).
get
(
'inUse'
)
const
source
=
db
.
get
(
'machine'
).
get
(
site
).
find
({
name
:
machine
}).
get
(
'inUse'
)
const
item
=
source
.
find
({
branch
})
if
(
item
.
value
()){
...
...
@@ -61,8 +69,9 @@ app.post('/register', function(req, res){
})
app
.
post
(
'/unregister'
,
function
(
req
,
res
){
const
site
=
req
.
body
.
site
const
branch
=
req
.
body
.
branch
const
machines
=
db
.
get
(
'machine'
)
const
machines
=
db
.
get
(
'machine'
)
.
get
(
site
)
if
(
branch
){
machines
.
value
().
forEach
(
machine
=>
{
const
source
=
machines
.
find
({
name
:
machine
.
name
}).
get
(
'inUse'
)
...
...
usage_default.json
0 → 100644
View file @
4dd80b5d
{
"machine"
:{
"taoche"
:[{
"name"
:
"dev1"
,
"inUse"
:[]},{
"name"
:
"dev2"
,
"inUse"
:[]},{
"name"
:
"beta1"
,
"inUse"
:[]},{
"name"
:
"beta2"
,
"inUse"
:[]}],
"daikuan"
:[{
"name"
:
"dev1"
,
"inUse"
:[]},{
"name"
:
"dev2"
,
"inUse"
:[]},{
"name"
:
"beta1"
,
"inUse"
:[]},{
"name"
:
"beta2"
,
"inUse"
:[]}]}}
\ No newline at end of file
usepage.html
View file @
4dd80b5d
...
...
@@ -12,6 +12,10 @@
padding
:
20px
0
;
font-size
:
30px
;
}
body
>
h3
{
width
:
800px
;
margin
:
40px
auto
10px
;
}
form
,
table
{
width
:
800px
;
margin
:
0
auto
;
...
...
@@ -40,6 +44,16 @@
<form
class=
"pure-form pure-form-stacked"
>
<fieldset>
<div
class=
"pure-g"
>
<div
class=
"pure-u-1 pure-u-md-1-3"
>
<label
for=
"site"
>
站点
</label>
<label
for=
"taoche"
class=
"inline"
>
<input
id=
"taoche"
type=
"radio"
name=
"site"
class=
"site"
checked
value=
"taoche"
>
taoche
</label>
<label
for=
"daikuan"
class=
"inline"
>
<input
id=
"daikuan"
type=
"radio"
name=
"site"
class=
"site"
value=
"daikuan"
>
daikuan
</label>
</div>
<div
class=
"pure-u-1 pure-u-md-1-3"
>
<label
for=
"branch"
>
分支
</label>
<input
id=
"branch"
class=
"pure-u-23-24"
type=
"text"
placeholder=
"master"
>
...
...
@@ -74,6 +88,21 @@
</fieldset>
</form>
<h3>
淘车
</h3>
<table
class=
"pure-table"
>
<thead>
<tr>
<th
width=
"100"
>
测试机
</th>
<th
width=
"200"
>
分支
</th>
<th>
项目
</th>
</tr>
</thead>
<tbody
id=
"taoche-list"
>
</tbody>
</table>
<h3>
贷款
</h3>
<table
class=
"pure-table"
>
<thead>
<tr>
...
...
@@ -83,7 +112,7 @@
</tr>
</thead>
<tbody
id=
"list"
>
<tbody
id=
"
daikuan-
list"
>
</tbody>
</table>
...
...
@@ -93,8 +122,6 @@
<script>
const
getList
=
()
=>
{
$
.
getJSON
(
'/usage'
,
res
=>
{
let
html
=
''
const
format
=
R
.
reduce
((
res
,
value
)
=>
`
${
res
}
<p>
${
value
}
</p>`
,
''
)
const
getBranches
=
R
.
pipe
(
...
...
@@ -108,17 +135,16 @@
format
)
res
.
machine
.
map
((
item
,
key
)
=>
{
html
+=
`
const
buildHtml
=
(
item
,
key
)
=>
`
<tr class="
${
key
%
2
===
0
?
'pure-table-odd'
:
''
}
">
<td>
${
item
.
name
}
</td>
<td>
${
getBranches
(
item
.
inUse
)}
</td>
<td>
${
getProjects
(
item
.
inUse
)}
</td>
</tr>
`
})
$
(
'#list'
).
html
(
html
)
$
(
'#taoche-list'
).
html
(
res
.
machine
.
taoche
.
reduce
((
html
,
item
,
key
)
=>
html
+
buildHtml
(
item
,
key
),
''
))
$
(
'#daikuan-list'
).
html
(
res
.
machine
.
daikuan
.
reduce
((
html
,
item
,
key
)
=>
html
+
buildHtml
(
item
,
key
),
''
))
})
}
...
...
@@ -128,7 +154,8 @@
return
{
branch
:
$
(
'#branch'
).
val
(),
project
:
(
$
(
'#project'
).
val
()
||
''
).
split
(
'+'
),
machine
:
R
.
reduce
((
res
,
input
)
=>
res
.
concat
(
input
.
name
),[])(
$
(
'.machine:checked'
))
machine
:
R
.
reduce
((
res
,
input
)
=>
res
.
concat
(
input
.
name
),[])(
$
(
'.machine:checked'
)),
site
:
$
(
'.site:checked'
).
val
()
}
}
...
...
@@ -141,7 +168,7 @@
$
.
post
(
'/register'
,
params
,
res
=>
{
if
(
res
.
ret
){
swal
(
'注册使用成功'
,
`分支:
${
params
.
branch
}
\n项目:
${
$
(
'#project'
).
val
()
||
''
}
`
)
swal
(
'注册使用成功'
,
`
站点:
${
params
.
site
}
\n
分支:
${
params
.
branch
}
\n项目:
${
$
(
'#project'
).
val
()
||
''
}
`
)
getList
()
}
})
...
...
@@ -157,7 +184,7 @@
$
.
post
(
'/unregister'
,
params
,
res
=>
{
if
(
res
.
ret
){
swal
(
'解除使用成功'
,
`分支:
${
params
.
branch
}
`
)
swal
(
'解除使用成功'
,
`
站点:
${
params
.
site
}
\n
分支:
${
params
.
branch
}
`
)
getList
()
}
})
...
...
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