mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-26 14:24:20 +01:00
angular and angular-ui-router now functional
This commit is contained in:
parent
8e0fa6c3ff
commit
8848860014
@ -20,6 +20,8 @@
|
||||
"jquery": "~2.1.3",
|
||||
"moment": "~2.9.0",
|
||||
"bootstrap": "~3.3.4",
|
||||
"sweetalert": "~0.5.0"
|
||||
"sweetalert": "~0.5.0",
|
||||
"angular": "~1.3.15",
|
||||
"angular-ui-router": "~0.2.13"
|
||||
}
|
||||
}
|
||||
|
12
gulpfile.js
12
gulpfile.js
@ -1,5 +1,6 @@
|
||||
var gulp = require('gulp')
|
||||
var minifyCSS = require('gulp-minify-css')
|
||||
var minifyHTML = require('gulp-minify-html')
|
||||
var coffee = require('gulp-coffee')
|
||||
var uglify = require('gulp-uglify')
|
||||
var clean = require('gulp-clean')
|
||||
@ -10,10 +11,16 @@ gulp.task('css',function(){
|
||||
.pipe(gulp.dest('dist/'))
|
||||
})
|
||||
|
||||
gulp.task('html',function(){
|
||||
return gulp.src('src/*.html')
|
||||
.pipe(minifyHTML({ quotes: true }))
|
||||
.pipe(gulp.dest('dist/'))
|
||||
})
|
||||
|
||||
gulp.task('coffee',function(){
|
||||
return gulp.src('src/*.coffee')
|
||||
.pipe(coffee({ bare: true }))
|
||||
.pipe(uglify())
|
||||
.pipe(uglify({ mangle: false }))
|
||||
.pipe(gulp.dest('dist/'))
|
||||
})
|
||||
|
||||
@ -24,5 +31,6 @@ gulp.task('clean',function(){
|
||||
gulp.task('watch',function(){
|
||||
gulp.watch('src/*.coffee',['coffee'])
|
||||
gulp.watch('src/*.css',['css'])
|
||||
gulp.watch('src/*.html',['html'])
|
||||
})
|
||||
gulp.task('default',['css','coffee'])
|
||||
gulp.task('default',['html','css','coffee'])
|
||||
|
18
index.html
18
index.html
@ -1,21 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html ng-app="pertApp">
|
||||
<head>
|
||||
<title>Pert</title>
|
||||
<meta charset="utf-8">
|
||||
<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">
|
||||
<script src="bower_components/jquery/dist/jquery.js"></script>
|
||||
<script src="bower_components/angular/angular.js"></script>
|
||||
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
|
||||
<script src="bower_components/vis/dist/vis.min.js"></script>
|
||||
<script src="dist/pert.js"></script>
|
||||
<script src="dist/app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<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>
|
||||
<div class="container" ui-view></div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -6,6 +6,7 @@
|
||||
"gulp-clean": "^0.3.1",
|
||||
"gulp-coffee": "^2.3.1",
|
||||
"gulp-minify-css": "^1.0.0",
|
||||
"gulp-minify-html": "^1.0.2",
|
||||
"gulp-uglify": "^1.1.0"
|
||||
},
|
||||
"repository": {
|
||||
|
28
pert.html
28
pert.html
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pert</title>
|
||||
<meta charset="utf-8">
|
||||
<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="bower_components/sweetalert/lib/sweet-alert.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/sweetalert/lib/sweet-alert.js"></script>
|
||||
<script src="bower_components/vis/dist/vis.min.js"></script>
|
||||
<script src="bower_components/moment/moment.js"></script>
|
||||
<script src="dist/pert.js"></script>
|
||||
<script src="dist/pert-ui.js"></script>
|
||||
</body>
|
||||
</html>
|
67
src/app.coffee
Normal file
67
src/app.coffee
Normal file
@ -0,0 +1,67 @@
|
||||
pertApp = angular.module 'pertApp', ['ui.router']
|
||||
|
||||
pertApp.config ($stateProvider,$urlRouterProvider) ->
|
||||
$urlRouterProvider.otherwise '/'
|
||||
$stateProvider.state 'home',
|
||||
url: '/'
|
||||
templateUrl: 'dist/home.html'
|
||||
controller: ($scope) ->
|
||||
$scope.rawdata = localStorage.getItem 'ganttpert'
|
||||
|
||||
$stateProvider.state 'pert',
|
||||
url: '/pert'
|
||||
templateUrl: 'dist/pert.html'
|
||||
controller: pertController
|
||||
|
||||
|
||||
$('#save').click ->
|
||||
console.log 'save'
|
||||
localStorage.setItem 'ganttpert', $('#ta').val()
|
||||
|
||||
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
|
||||
|
||||
pertController = ($scope) ->
|
||||
console.log 'controller'
|
||||
buildTimeline = (data) ->
|
||||
timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {}
|
||||
|
||||
buildGraph = (data) ->
|
||||
nodes = data.days.map (x) -> {id: x, label: ""+x}
|
||||
connections = []
|
||||
data.activities.forEach (x) ->
|
||||
connections.push
|
||||
from: x.startDay, to: x.endDay
|
||||
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
|
||||
color: if !x.permittedDelay then 'red'
|
||||
if x.permittedDelay > 0
|
||||
connections.push
|
||||
from: x.endDay
|
||||
to: x.endDay+x.permittedDelay
|
||||
color: 'green'
|
||||
label: x.id+" ("+x.permittedDelay+")"
|
||||
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
|
||||
|
||||
fromLocalStorage = ->
|
||||
data = localStorage.getItem 'ganttpert'
|
||||
if data
|
||||
try
|
||||
jdata = JSON.parse data
|
||||
catch e
|
||||
return swal 'JSON Error', e, 'error'
|
||||
if jdata
|
||||
buildGraph new Pert(jdata).calculate()
|
||||
else return swal 'Error', 'no JSON?', 'error'
|
||||
else swal 'Error', 'no data to parse', 'error'
|
||||
|
||||
fromLocalStorage()
|
5
src/home.html
Normal file
5
src/home.html
Normal file
@ -0,0 +1,5 @@
|
||||
<div class="home">
|
||||
<textarea id="ta" class="form-control" rows="10">{{rawdata}}</textarea>
|
||||
<button id="save" class="btn btn-primary">Save</button>
|
||||
<a href="#/pert" class="btn btn-success">View Pert</a>
|
||||
</div>
|
@ -1,7 +0,0 @@
|
||||
console.log 'Pert ui'
|
||||
|
||||
$('#ta').val localStorage.getItem 'ganttpert'
|
||||
|
||||
$('#save').click ->
|
||||
console.log 'save'
|
||||
localStorage.setItem 'ganttpert', $('#ta').val()
|
@ -1,47 +0,0 @@
|
||||
console.log 'Pert ui'
|
||||
|
||||
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
|
||||
|
||||
buildTimeline = (data) ->
|
||||
timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {}
|
||||
|
||||
buildGraph = (data) ->
|
||||
nodes = data.days.map (x) -> {id: x, label: ""+x}
|
||||
connections = []
|
||||
data.activities.forEach (x) ->
|
||||
connections.push
|
||||
from: x.startDay, to: x.endDay
|
||||
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
|
||||
color: if !x.permittedDelay then 'red'
|
||||
if x.permittedDelay > 0
|
||||
connections.push
|
||||
from: x.endDay
|
||||
to: x.endDay+x.permittedDelay
|
||||
color: 'green'
|
||||
label: x.id+" ("+x.permittedDelay+")"
|
||||
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
|
||||
|
||||
fromLocalStorage = ->
|
||||
data = localStorage.getItem 'ganttpert'
|
||||
if data
|
||||
try
|
||||
jdata = JSON.parse data
|
||||
catch e
|
||||
return swal 'JSON Error', e, 'error'
|
||||
if jdata
|
||||
buildGraph new Pert(jdata).calculate()
|
||||
else return swal 'Error', 'no JSON?', 'error'
|
||||
else swal 'Error', 'no data to parse', 'error'
|
||||
|
||||
fromLocalStorage()
|
@ -72,5 +72,4 @@ class Pert
|
||||
else
|
||||
if cb? then cb(results)
|
||||
results
|
||||
|
||||
if module? then module.exports = Pert
|
||||
|
6
src/pert.html
Normal file
6
src/pert.html
Normal file
@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<div id="pert"></div>
|
||||
<div class="text-center">
|
||||
<a href="#/" class="btn btn-primary">Edit Data</a>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user