mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-27 14:34:19 +01:00
cool new gui
This commit is contained in:
parent
416b4b0158
commit
9b57027053
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,5 @@ bower_components/
|
|||||||
.divshot-cache/
|
.divshot-cache/
|
||||||
node_modules/
|
node_modules/
|
||||||
test/
|
test/
|
||||||
|
testdata/
|
||||||
dist/
|
dist/
|
||||||
|
@ -10,35 +10,40 @@ gulp.task('css',function(){
|
|||||||
"bower_components/sweetalert/lib/sweet-alert.css",
|
"bower_components/sweetalert/lib/sweet-alert.css",
|
||||||
"bower_components/bootstrap/dist/css/bootstrap.css"]
|
"bower_components/bootstrap/dist/css/bootstrap.css"]
|
||||||
return gulp.src(cssFiles)
|
return gulp.src(cssFiles)
|
||||||
|
.pipe(gulp.dest('test/'))
|
||||||
.pipe(minifyCSS())
|
.pipe(minifyCSS())
|
||||||
.pipe(gulp.dest('dist/'))
|
.pipe(gulp.dest('dist/'))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('html',function(){
|
gulp.task('html',function(){
|
||||||
return gulp.src('src/*.html')
|
return gulp.src('src/*.html')
|
||||||
|
.pipe(gulp.dest('test/'))
|
||||||
.pipe(minifyHTML({ quotes: true }))
|
.pipe(minifyHTML({ quotes: true }))
|
||||||
.pipe(gulp.dest('dist/'))
|
.pipe(gulp.dest('dist/'))
|
||||||
})
|
})
|
||||||
gulp.task('js',function(){
|
gulp.task('js',function(){
|
||||||
jsFiles = ["src/*.js",
|
jsFiles = ["src/*.js",
|
||||||
"bower_components/jquery/dist/jquery.js",
|
"bower_components/jquery/dist/jquery.js",
|
||||||
|
"bower_components/moment/moment.js",
|
||||||
"bower_components/angular/angular.js",
|
"bower_components/angular/angular.js",
|
||||||
"bower_components/sweetalert/lib/sweet-alert.js",
|
"bower_components/sweetalert/lib/sweet-alert.js",
|
||||||
"bower_components/angular-ui-router/release/angular-ui-router.js",
|
"bower_components/angular-ui-router/release/angular-ui-router.js",
|
||||||
"bower_components/vis/dist/vis.min.js"]
|
"bower_components/vis/dist/vis.min.js"]
|
||||||
return gulp.src(jsFiles).pipe(uglify({ mangle: false }))
|
return gulp.src(jsFiles).pipe(gulp.dest('test/'))
|
||||||
|
.pipe(uglify({ mangle: false }))
|
||||||
.pipe(gulp.dest('dist/'))
|
.pipe(gulp.dest('dist/'))
|
||||||
|
|
||||||
})
|
})
|
||||||
gulp.task('coffee',function(){
|
gulp.task('coffee',function(){
|
||||||
return gulp.src('src/*.coffee')
|
return gulp.src('src/*.coffee')
|
||||||
.pipe(coffee({ bare: true }))
|
.pipe(coffee({ bare: true }))
|
||||||
|
.pipe(gulp.dest('test/'))
|
||||||
.pipe(uglify({ mangle: false }))
|
.pipe(uglify({ mangle: false }))
|
||||||
.pipe(gulp.dest('dist/'))
|
.pipe(gulp.dest('dist/'))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('clean',function(){
|
gulp.task('clean',function(){
|
||||||
return gulp.src('dist/*').pipe(clean())
|
return gulp.src(['dist/*','test/*']).pipe(clean())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('watch',function(){
|
gulp.task('watch',function(){
|
||||||
|
@ -17,18 +17,25 @@ pertApp.config ($stateProvider,$urlRouterProvider) ->
|
|||||||
controller: pertController
|
controller: pertController
|
||||||
|
|
||||||
|
|
||||||
pertController = ($scope) ->
|
$stateProvider.state 'gantt',
|
||||||
toDates = (list, startDay) ->
|
url: '/gantt'
|
||||||
list.map (i) ->
|
templateUrl: 'gantt.html'
|
||||||
r = content: ""+i.id, id: i.id
|
controller: pertController
|
||||||
if i.startDay? then r.start = moment(startDay).add(i.startDay, 'days').format 'YYYY-MM-DD'
|
|
||||||
if i.endDay? then r.end = moment(startDay).add(i.endDay, 'days').format 'YYYY-MM-DD'
|
$stateProvider.state 'table',
|
||||||
return r
|
url: '/table'
|
||||||
|
templateUrl: 'table.html'
|
||||||
|
controller: pertController
|
||||||
|
|
||||||
buildTimeline = (data) ->
|
pertApp.controller 'tableController', ($scope) ->
|
||||||
timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {}
|
$scope.list = []
|
||||||
|
ls = $scope.fromLocalStorage()
|
||||||
|
if ls?
|
||||||
|
$scope.list = ls.activities
|
||||||
|
|
||||||
buildGraph = (data) ->
|
pertApp.controller 'pertDiagController', ($scope) ->
|
||||||
|
$scope.buildGraph = (data) ->
|
||||||
|
if !data? then return
|
||||||
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) ->
|
||||||
@ -49,17 +56,29 @@ pertController = ($scope) ->
|
|||||||
edges:
|
edges:
|
||||||
style: 'arrow'
|
style: 'arrow'
|
||||||
network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options
|
network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options
|
||||||
|
$scope.buildGraph $scope.fromLocalStorage()
|
||||||
|
|
||||||
fromLocalStorage = ->
|
pertApp.controller 'ganttDiagController', ($scope) ->
|
||||||
data = localStorage.getItem 'ganttpert'
|
$scope.toDates = (list, startDay) ->
|
||||||
|
list.map (i) ->
|
||||||
|
r = content: ""+i.id, id: i.id
|
||||||
|
if i.startDay? then r.start = moment(startDay).add(i.startDay, 'days').format 'YYYY-MM-DD'
|
||||||
|
if i.endDay? then r.end = moment(startDay).add(i.endDay, 'days').format 'YYYY-MM-DD'
|
||||||
|
return r
|
||||||
|
$scope.buildTimeline = (data) ->
|
||||||
|
if !data? then return
|
||||||
|
timeline = new vis.Timeline (document.getElementById 'timeline'), ($scope.toDates data.activities), {}
|
||||||
|
$scope.buildTimeline $scope.fromLocalStorage()
|
||||||
|
|
||||||
|
pertController = ($scope) ->
|
||||||
|
$scope.fromLocalStorage = (item) ->
|
||||||
|
data = localStorage.getItem item || 'ganttpert'
|
||||||
if data
|
if data
|
||||||
try
|
try
|
||||||
jdata = JSON.parse data
|
jdata = JSON.parse data
|
||||||
catch e
|
catch e
|
||||||
return swal 'JSON Error', e, 'error'
|
return swal 'JSON Error', e, 'error'
|
||||||
if jdata
|
if jdata
|
||||||
buildGraph new Pert(jdata).calculate()
|
return new Pert(jdata).calculate()
|
||||||
else return swal 'Error', 'no JSON?', 'error'
|
else return swal 'Error', 'no JSON?', 'error'
|
||||||
else swal 'Error', 'no data to parse', 'error'
|
else swal 'Error', 'no data to parse', 'error'
|
||||||
|
|
||||||
fromLocalStorage()
|
|
||||||
|
3
src/gantt.html
Normal file
3
src/gantt.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<div ng-controller="ganttDiagController">
|
||||||
|
<div id="timeline"></div>
|
||||||
|
</div>
|
@ -1,5 +1,4 @@
|
|||||||
<div class="home">
|
<div class="home">
|
||||||
<textarea id="ta" class="form-control" rows="10">{{rawdata}}</textarea>
|
<textarea id="ta" class="form-control" rows="10">{{rawdata}}</textarea>
|
||||||
<button class="btn btn-primary" ng-click="saveData($event)">Save</button>
|
<button class="btn btn-primary" ng-click="saveData($event)">Save</button>
|
||||||
<a href="#/pert" class="btn btn-success">View Pert</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,10 +12,32 @@
|
|||||||
<script src="angular.js"></script>
|
<script src="angular.js"></script>
|
||||||
<script src="angular-ui-router.js"></script>
|
<script src="angular-ui-router.js"></script>
|
||||||
<script src="vis.min.js"></script>
|
<script src="vis.min.js"></script>
|
||||||
|
<script src="moment.js"></script>
|
||||||
<script src="pert.js"></script>
|
<script src="pert.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<nav class="navbar navbar-default navbar-fixed-top">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="#">Pert</a>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="#/">Edit</a></li>
|
||||||
|
<li><a href="#/table">Table</a></li>
|
||||||
|
<li><a href="#/pert">Pert</a></li>
|
||||||
|
<li><a href="#/gantt">Gantt</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
<div class="container" ui-view></div>
|
<div class="container" ui-view></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,6 +1 @@
|
|||||||
<div>
|
<div id="pert" ng-controller="pertDiagController"></div>
|
||||||
<div id="pert"></div>
|
|
||||||
<div class="text-center">
|
|
||||||
<a href="#/" class="btn btn-primary">Edit Data</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@ -2,9 +2,18 @@
|
|||||||
height: 600px;
|
height: 600px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
margin-bottom: 1em
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding-top: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ta {
|
#ta {
|
||||||
margin: 1em 0 1em 0
|
margin: 1em 0 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tab {
|
||||||
|
max-width: 40em;
|
||||||
|
margin: 0 auto 0 auto;
|
||||||
}
|
}
|
||||||
|
16
src/table.html
Normal file
16
src/table.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<table id="tab" class="table" ng-controller="tableController">
|
||||||
|
<tr>
|
||||||
|
<td><b>#</b></td>
|
||||||
|
<td><b>Duration (days)</b></td>
|
||||||
|
<td><b>Start Day</b></td>
|
||||||
|
<td><b>End Day</b></td>
|
||||||
|
<td><b>Possible Delay</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr ng-repeat="item in list">
|
||||||
|
<td>{{item.id}}</td>
|
||||||
|
<td>{{item.duration}}</td>
|
||||||
|
<td>{{item.startDay}}</td>
|
||||||
|
<td>{{item.endDay}} --- {{item.endDay + (item.permittedDelay || 0)}}</td>
|
||||||
|
<td>{{item.permittedDelay || 0}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
Loading…
Reference in New Issue
Block a user