mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-29 14:54:18 +01:00
some improvements
This commit is contained in:
parent
c768f74c39
commit
12172f34c4
@ -16,6 +16,7 @@
|
|||||||
"tests"
|
"tests"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vis": "~3.11.0"
|
"vis": "~3.11.0",
|
||||||
|
"jquery": "~2.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
<title>Pert</title>
|
<title>Pert</title>
|
||||||
<link rel="stylesheet" href="bower_components/vis/dist/vis.min.css">
|
<link rel="stylesheet" href="bower_components/vis/dist/vis.min.css">
|
||||||
<style>
|
<style>
|
||||||
|
body { height: 100%; }
|
||||||
#pert {
|
#pert {
|
||||||
width: 400px;
|
height: 600px;
|
||||||
height: 400px;
|
width: 100%;
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -42,7 +42,8 @@ cli
|
|||||||
.command 'graph <file>'
|
.command 'graph <file>'
|
||||||
.description 'serve HTTP GUI with pert graph of given JSON document'
|
.description 'serve HTTP GUI with pert graph of given JSON document'
|
||||||
.alias 'g'
|
.alias 'g'
|
||||||
.action (file) ->
|
.option '-r, --read-only', 'disallow data editing'
|
||||||
|
.action (file,options) ->
|
||||||
didSomething = yes
|
didSomething = yes
|
||||||
fs.readFile file, (error,content) ->
|
fs.readFile file, (error,content) ->
|
||||||
if error then err error
|
if error then err error
|
||||||
@ -52,6 +53,9 @@ cli
|
|||||||
app = express()
|
app = express()
|
||||||
app.use express.static 'client'
|
app.use express.static 'client'
|
||||||
app.get '/data', (req,res) -> res.json data
|
app.get '/data', (req,res) -> res.json data
|
||||||
|
if !options.readOnly then app.post '/data', (req,res) ->
|
||||||
|
data = req.body
|
||||||
|
pert.setData(data).calculate()
|
||||||
app.listen 3000
|
app.listen 3000
|
||||||
console.log chalk.green('Started Web Server'), 'on port', chalk.bold(3000)
|
console.log chalk.green('Started Web Server'), 'on port', chalk.bold(3000)
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
$.get 'data', (data) ->
|
$.get 'data', (d) ->
|
||||||
console.log data
|
# Serve the server data
|
||||||
i = 0
|
list = d
|
||||||
|
console.log list
|
||||||
|
buildGraph list
|
||||||
|
|
||||||
|
buildGraph = (data) ->
|
||||||
nodes = data.days.map (x) -> {id: x, label: ""+x}
|
nodes = data.days.map (x) -> {id: x, label: ""+x}
|
||||||
connections = []
|
connections = []
|
||||||
data.activities.forEach (x) ->
|
data.activities.forEach (x) ->
|
||||||
@ -8,10 +12,17 @@ $.get 'data', (data) ->
|
|||||||
from: x.startDay, to: x.endDay
|
from: x.startDay, to: x.endDay
|
||||||
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
|
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
|
||||||
if x.permittedDelay > 0
|
if x.permittedDelay > 0
|
||||||
connections.push from: x.endDay, to: x.endDay+x.permittedDelay, color: 'green', label: "("+x.permittedDelay+")"
|
connections.push
|
||||||
|
from: x.endDay
|
||||||
|
to: x.endDay+x.permittedDelay
|
||||||
|
color: 'green'
|
||||||
|
label: x.id+" ("+x.permittedDelay+")"
|
||||||
console.log nodes
|
console.log nodes
|
||||||
console.log connections
|
console.log connections
|
||||||
options =
|
if network
|
||||||
edges:
|
network.setData { nodes: nodes, edges: edges }
|
||||||
style: 'arrow'
|
else
|
||||||
network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options
|
options =
|
||||||
|
edges:
|
||||||
|
style: 'arrow'
|
||||||
|
network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options
|
||||||
|
@ -57,8 +57,14 @@ module.exports = class Pert
|
|||||||
if day is d then return
|
if day is d then return
|
||||||
@days.push day
|
@days.push day
|
||||||
|
|
||||||
calculate: (options) ->
|
setData: (data) ->
|
||||||
@calculateEndDay @toActivity @highestID()
|
@list = data
|
||||||
results = activities: @list, days: @days
|
return @
|
||||||
if options?.json then JSON.stringify results else results
|
|
||||||
|
|
||||||
|
calculate: (options) ->
|
||||||
|
h = @highestID()
|
||||||
|
@list.forEach (x) =>
|
||||||
|
@log '('+x.id+'/'+h+')'
|
||||||
|
@calculateEndDay x
|
||||||
|
results = activities: @list, days: @days
|
||||||
|
if options?.json then JSON.stringify results else results
|
||||||
|
Loading…
Reference in New Issue
Block a user