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