a lot of new stuff

This commit is contained in:
Enrico Fasoli 2015-03-31 18:13:29 +02:00
parent 6d71fb62a3
commit 917301391f
8 changed files with 23 additions and 81 deletions

View File

@ -3,13 +3,17 @@
<head>
<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">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="dist/style.css">
</head>
<body>
<textarea id="ta" class="form-control"></textarea>
<button id="save" class="btn btn-primary">Save</button>
<a href="pert.html" class="btn btn-success">view pert</a>
<div class="container">
<textarea id="ta" class="form-control" rows="10"></textarea>
<button id="save" class="btn btn-primary">Save</button>
<a href="pert.html" class="btn btn-success">View Pert</a>
</div>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="dist/index.js"></script>
</body>

View File

@ -3,15 +3,22 @@
<head>
<title>Pert</title>
<link rel="stylesheet" href="bower_components/vis/dist/vis.min.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="dist/style.css">
</head>
<body>
<div class="container">
<div id="pert"></div>
<div class="text-center">
<a href="index.html" class="btn btn-primary">Edit Data</a>
</div>
<!--<div id="timeline"></div>-->
</div>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/vis/dist/vis.min.js"></script>
<script src="bower_components/moment/moment.js"></script>
<div id="pert"></div>
<a href="index.html">edit data</a>
<!--<div id="timeline"></div>-->
<script src="dist/pert.js"></script>
<script src="dist/pert-ui.js"></script>
</body>

View File

@ -1,3 +0,0 @@
coffee -b -c --no-header -p src/pert.coffee > pert.js
coffee -b -c --no-header -p src/pert-ui.coffee > pert-ui.js
coffee -b -c --no-header -p src/index.coffee > index.js

View File

@ -1,2 +0,0 @@
#!/bin/bash
rm -r *.js

View File

@ -1,65 +0,0 @@
#!/usr/bin/env coffee
chalk = require 'chalk'
cli = require 'commander'
fs = require 'fs'
Pert = require '../lib/pert.js'
express = require 'express'
ex = [{id: 0, depends: [], duration: 2}, { id: 1, depends: [0], duration: 3},{id: 2, depends: [0,1], duration: 4}]
cli
.version '0.1'
.description 'loads activity data from JSON and computes the possible activity delays'
.usage '<command> [options] [args]'
.option '-v, --verbose', 'be verbose (for debugging)'
didSomething = no
cli
.command 'example'
.description 'show an example of the JSON data format'
.action ->
pert = new Pert ex, cli.verbose
didSomething = yes
console.log chalk.bold.green('Before:'), ex
console.log chalk.bold.green('After calculations:'), pert.calculate()
console.log chalk.green 'Tip:',chalk.bold 'optional fields can be freely included in the input data'
cli
.command 'calculate <file>'
.description 'calculate data on given JSON document'
.alias 'c'
.option '-j, --json', 'output json data'
.action (file,options) ->
didSomething = yes
fs.readFile file, (error,content) ->
if error then err error
else
pert = new Pert JSON.parse(content), cli.verbose
console.log pert.calculate options
cli
.command 'graph <file>'
.description 'serve HTTP GUI with pert graph of given JSON document'
.alias 'g'
.option '-r, --read-only', 'disallow data editing'
.action (file,options) ->
didSomething = yes
fs.readFile file, (error,content) ->
if error then err error
else
pert = new Pert JSON.parse(content), cli.verbose
data = pert.calculate()
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)
cli.parse process.argv
if !didSomething then console.log chalk.green('Tip:'), 'see', chalk.bold(cli.name()+' --help')

View File

@ -8,7 +8,6 @@ toDates = (list, startDay) ->
return r
buildTimeline = (data) ->
console.log toDates data.activities
timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {}
buildGraph = (data) ->
@ -25,8 +24,6 @@ buildGraph = (data) ->
to: x.endDay+x.permittedDelay
color: 'green'
label: x.id+" ("+x.permittedDelay+")"
console.log nodes
console.log connections
if network
network.setData { nodes: nodes, edges: edges }
else

0
src/pert.coffee Executable file → Normal file
View File

View File

@ -1,6 +1,10 @@
body { height: 100%; }
#pert {
height: 600px;
width: 100%;
border: 1px solid lightgray;
margin-bottom: 1em
}
#ta {
margin: 1em 0 1em 0
}