diff --git a/.gitignore b/.gitignore index 1542f83..17b2671 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ bower_components/ .divshot-cache/ node_modules/ test/ +testdata/ dist/ diff --git a/gulpfile.js b/gulpfile.js index c885d46..4f40e5e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,35 +10,40 @@ gulp.task('css',function(){ "bower_components/sweetalert/lib/sweet-alert.css", "bower_components/bootstrap/dist/css/bootstrap.css"] return gulp.src(cssFiles) + .pipe(gulp.dest('test/')) .pipe(minifyCSS()) .pipe(gulp.dest('dist/')) }) gulp.task('html',function(){ return gulp.src('src/*.html') + .pipe(gulp.dest('test/')) .pipe(minifyHTML({ quotes: true })) .pipe(gulp.dest('dist/')) }) gulp.task('js',function(){ jsFiles = ["src/*.js", "bower_components/jquery/dist/jquery.js", + "bower_components/moment/moment.js", "bower_components/angular/angular.js", "bower_components/sweetalert/lib/sweet-alert.js", "bower_components/angular-ui-router/release/angular-ui-router.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/')) }) gulp.task('coffee',function(){ return gulp.src('src/*.coffee') .pipe(coffee({ bare: true })) + .pipe(gulp.dest('test/')) .pipe(uglify({ mangle: false })) .pipe(gulp.dest('dist/')) }) gulp.task('clean',function(){ - return gulp.src('dist/*').pipe(clean()) + return gulp.src(['dist/*','test/*']).pipe(clean()) }) gulp.task('watch',function(){ diff --git a/src/app.coffee b/src/app.coffee index 356fbba..6ab8967 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -17,18 +17,25 @@ pertApp.config ($stateProvider,$urlRouterProvider) -> controller: pertController -pertController = ($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 + $stateProvider.state 'gantt', + url: '/gantt' + templateUrl: 'gantt.html' + controller: pertController + + $stateProvider.state 'table', + url: '/table' + templateUrl: 'table.html' + controller: pertController - buildTimeline = (data) -> - timeline = new vis.Timeline (document.getElementById 'timeline'), (toDates data.activities), {} +pertApp.controller 'tableController', ($scope) -> + $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} connections = [] data.activities.forEach (x) -> @@ -49,17 +56,29 @@ pertController = ($scope) -> edges: style: 'arrow' network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options + $scope.buildGraph $scope.fromLocalStorage() - fromLocalStorage = -> - data = localStorage.getItem 'ganttpert' +pertApp.controller 'ganttDiagController', ($scope) -> + $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 try jdata = JSON.parse data catch e return swal 'JSON Error', e, 'error' if jdata - buildGraph new Pert(jdata).calculate() + return new Pert(jdata).calculate() else return swal 'Error', 'no JSON?', 'error' else swal 'Error', 'no data to parse', 'error' - - fromLocalStorage() diff --git a/src/gantt.html b/src/gantt.html new file mode 100644 index 0000000..77da73a --- /dev/null +++ b/src/gantt.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/src/home.html b/src/home.html index 3922255..e80eb9e 100644 --- a/src/home.html +++ b/src/home.html @@ -1,5 +1,4 @@
- View Pert
diff --git a/src/index.html b/src/index.html index 067606b..db3ce3c 100644 --- a/src/index.html +++ b/src/index.html @@ -12,10 +12,32 @@ + +
diff --git a/src/pert.html b/src/pert.html index 344fd8a..910f922 100644 --- a/src/pert.html +++ b/src/pert.html @@ -1,6 +1 @@ -
-
-
- Edit Data -
-
+
diff --git a/src/style.css b/src/style.css index 19c8926..406aa54 100644 --- a/src/style.css +++ b/src/style.css @@ -2,9 +2,18 @@ height: 600px; width: 100%; border: 1px solid lightgray; - margin-bottom: 1em + margin-bottom: 1em; +} + +.container { + padding-top: 4em; } #ta { - margin: 1em 0 1em 0 + margin: 1em 0 1em 0; +} + +#tab { + max-width: 40em; + margin: 0 auto 0 auto; } diff --git a/src/table.html b/src/table.html new file mode 100644 index 0000000..5fcabbe --- /dev/null +++ b/src/table.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
#Duration (days)Start DayEnd DayPossible Delay
{{item.id}}{{item.duration}}{{item.startDay}}{{item.endDay}} --- {{item.endDay + (item.permittedDelay || 0)}}{{item.permittedDelay || 0}}