mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-29 14:54:18 +01:00
fix #1 and performance improvements
This commit is contained in:
parent
ad3b97edd5
commit
265f3bc7f8
@ -1,13 +1,13 @@
|
|||||||
class Pert
|
class PBS
|
||||||
constructor: (@list, @verbose) ->
|
constructor: (@list, @verbose) ->
|
||||||
@verbose = true
|
|
||||||
@days = []
|
@days = []
|
||||||
@criticalPaths = []
|
@criticalPaths = []
|
||||||
|
|
||||||
log: (x...) ->
|
log: (x...) ->
|
||||||
if chalk?
|
if @verbose
|
||||||
console.log chalk.bold "[ Pert ]", x...
|
if chalk?
|
||||||
else console.log "[ Pert ]", x...
|
console.log chalk.bold "[ Pert ]", x...
|
||||||
|
else console.log "[ Pert ]", x...
|
||||||
err: (x...) ->
|
err: (x...) ->
|
||||||
if chalk?
|
if chalk?
|
||||||
console.log chalk.bold chalk.red("[ !Pert! ]"), x...
|
console.log chalk.bold chalk.red("[ !Pert! ]"), x...
|
@ -41,10 +41,12 @@ pertController = ($scope) ->
|
|||||||
if !data.push?
|
if !data.push?
|
||||||
return swal 'Error', 'data is not a list', 'error'
|
return swal 'Error', 'data is not a list', 'error'
|
||||||
try
|
try
|
||||||
console.log "Saving: "+data
|
sdata = JSON.stringify data
|
||||||
localStorage.setItem 'ganttpert', JSON.stringify data
|
console.log "Saving: "+sdata
|
||||||
|
localStorage.setItem 'ganttpert', sdata
|
||||||
unless options.silent
|
unless options.silent
|
||||||
swal 'Ok', 'Data updated', 'success'
|
swal 'Ok', 'Data updated', 'success'
|
||||||
|
$scope.pbs = new PBS(data).calculate()
|
||||||
$scope.$broadcast 'dataChanged'
|
$scope.$broadcast 'dataChanged'
|
||||||
catch e
|
catch e
|
||||||
swal 'Error', e, 'error'
|
swal 'Error', e, 'error'
|
||||||
@ -69,6 +71,5 @@ pertController = ($scope) ->
|
|||||||
#console.log 'Loading: '+jdata
|
#console.log 'Loading: '+jdata
|
||||||
return jdata
|
return jdata
|
||||||
else
|
else
|
||||||
r = new Pert(jdata).calculate()
|
#console.log 'Loading: '+$scope.pbs
|
||||||
#console.log 'Loading: '+r
|
return $scope.pbs ?= new PBS(jdata).calculate()
|
||||||
return r
|
|
||||||
|
@ -30,9 +30,11 @@ pertApp.controller 'pertDiagController', ($scope) ->
|
|||||||
edges:
|
edges:
|
||||||
style: 'arrow'
|
style: 'arrow'
|
||||||
network = new vis.Network (document.getElementById 'pertDiagram'), { nodes: nodes, edges: connections }, options
|
network = new vis.Network (document.getElementById 'pertDiagram'), { nodes: nodes, edges: connections }, options
|
||||||
$scope.$on 'dataChanged', ->
|
$scope.rebuild = ->
|
||||||
|
console.log 'rebuild'
|
||||||
$scope.buildGraph $scope.fromLocalStorage()
|
$scope.buildGraph $scope.fromLocalStorage()
|
||||||
$scope.buildGraph $scope.fromLocalStorage()
|
$scope.$on 'dataChanged', $scope.rebuild
|
||||||
|
$scope.rebuild()
|
||||||
|
|
||||||
pertApp.controller 'ganttDiagController', ($scope) ->
|
pertApp.controller 'ganttDiagController', ($scope) ->
|
||||||
$scope.toDates = (list, startDay) ->
|
$scope.toDates = (list, startDay) ->
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<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="moment.js"></script>
|
||||||
<script src="pert.js"></script>
|
<script src="PBSlib.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script src="controllers.js"></script>
|
<script src="controllers.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -1 +1,4 @@
|
|||||||
<div id="pertDiagram" ng-controller="pertDiagController"></div>
|
<div class="text-center" ng-controller="pertDiagController">
|
||||||
|
<button class="btn btn-primary" ng-click="rebuild()"><i class="fa fa-spinner"></i> Redraw</button>
|
||||||
|
<div id="pertDiagram" ></div>
|
||||||
|
</div>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
Loading…
Reference in New Issue
Block a user