mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-27 14:34:19 +01:00
bugfixing and improving...
This commit is contained in:
parent
d1414f2532
commit
bfbd4149f4
@ -95,16 +95,21 @@ class PBS
|
|||||||
|
|
||||||
calculateDelays: (item) =>
|
calculateDelays: (item) =>
|
||||||
if !item.dependant? or item.dependant.length is 0 then return no
|
if !item.dependant? or item.dependant.length is 0 then return no
|
||||||
lowestFDelay = 0; fDelay = no; cDelay = 0
|
|
||||||
for j,i of item.dependant
|
|
||||||
x = @toActivity i
|
|
||||||
if !isNaN(x.permittedDelay) or x.permittedDelay < lowestFDelay or fDelay is no
|
|
||||||
@log "activity", i, "dependant on", item.id, "has the lowest delay for now ("+(x.permittedDelay or 0)+")"
|
|
||||||
lowestFDelay = x.permittedDelay or 0
|
|
||||||
cDelay = x.chainedDelay or 0
|
|
||||||
fDelay = yes
|
|
||||||
olDelay = item.chainedDelay
|
olDelay = item.chainedDelay
|
||||||
item.chainedDelay = lowestFDelay + cDelay
|
if item.critical
|
||||||
|
@log item.id, 'is critical: no chained delays'
|
||||||
|
item.chainedDelay = 0
|
||||||
|
else
|
||||||
|
lowestFDelay = 0; fDelay = no; cDelay = 0
|
||||||
|
for j,i of item.dependant
|
||||||
|
x = @toActivity i
|
||||||
|
if !isNaN(x.permittedDelay) or x.permittedDelay < lowestFDelay or fDelay is no
|
||||||
|
@log "activity", i, "dependant on", item.id, "has the lowest delay for now ("+(x.permittedDelay or 0)+")"
|
||||||
|
lowestFDelay = x.permittedDelay or 0
|
||||||
|
cDelay = x.chainedDelay or 0
|
||||||
|
fDelay = yes
|
||||||
|
olDelay = item.chainedDelay
|
||||||
|
item.chainedDelay = lowestFDelay + cDelay
|
||||||
@log "chained delay of", item.id, "is", item.chainedDelay
|
@log "chained delay of", item.id, "is", item.chainedDelay
|
||||||
return item.chainedDelay isnt olDelay
|
return item.chainedDelay isnt olDelay
|
||||||
|
|
||||||
@ -142,10 +147,15 @@ class PBS
|
|||||||
return @
|
return @
|
||||||
|
|
||||||
calculate: (options,cb) ->
|
calculate: (options,cb) ->
|
||||||
h = @highestID()
|
# Calculate startDay, endDay, freeDelay
|
||||||
for x,i in @list
|
for x,i in @list
|
||||||
@log '('+x.id+'/'+h+')'
|
@log '('+i+'/'+@list.length+')'
|
||||||
@calculateEndDay x
|
@calculateEndDay x
|
||||||
|
# Calculate Critical Paths
|
||||||
|
for x,i in @list
|
||||||
|
if !x.depends? or x.depends.length is 0
|
||||||
|
@calculateCriticalPaths [x.id]
|
||||||
|
# Calculate chained Delays
|
||||||
finished = no; i = 0
|
finished = no; i = 0
|
||||||
while !finished
|
while !finished
|
||||||
i++; finished = yes
|
i++; finished = yes
|
||||||
@ -153,10 +163,9 @@ class PBS
|
|||||||
if @calculateDelays x
|
if @calculateDelays x
|
||||||
finished = no
|
finished = no
|
||||||
@log "Done calculating delays. Took", i, "iterations"
|
@log "Done calculating delays. Took", i, "iterations"
|
||||||
for x,i in @list
|
# Compile resource information
|
||||||
if !x.depends? or x.depends.length is 0
|
|
||||||
@calculateCriticalPaths [x.id]
|
|
||||||
@compileResources()
|
@compileResources()
|
||||||
|
# done
|
||||||
results =
|
results =
|
||||||
activities: @list
|
activities: @list
|
||||||
days: @days
|
days: @days
|
||||||
|
@ -42,9 +42,9 @@ pertApp.config ($stateProvider,$urlRouterProvider,$locationProvider) ->
|
|||||||
pertController = ($scope) ->
|
pertController = ($scope) ->
|
||||||
$scope.toLocalStorage = (data,options) ->
|
$scope.toLocalStorage = (data,options) ->
|
||||||
options ?= {}
|
options ?= {}
|
||||||
data ?= []
|
data ?= activities: [], resources: []
|
||||||
if !data.push? and !data.activities?.push?
|
if not data.activities?.push?
|
||||||
return swal 'Error', 'data is not a valid PBSlib object', 'error'
|
return swal 'Error', 'invalid data format. Try resetting', 'error'
|
||||||
try
|
try
|
||||||
sdata = JSON.stringify data
|
sdata = JSON.stringify data
|
||||||
console.log "Saving: "+sdata
|
console.log "Saving: "+sdata
|
||||||
|
@ -12,16 +12,16 @@ pertApp.controller 'tableController', ($scope) ->
|
|||||||
tableController $scope, (data) -> data.activities or []
|
tableController $scope, (data) -> data.activities or []
|
||||||
pertApp.controller 'resourceTableController', ($scope) ->
|
pertApp.controller 'resourceTableController', ($scope) ->
|
||||||
tableController $scope, (data) -> data.resources or []
|
tableController $scope, (data) -> data.resources or []
|
||||||
|
|
||||||
pertApp.controller 'pertDiagController', ($scope) ->
|
pertApp.controller 'pertDiagController', ($scope) ->
|
||||||
$scope.buildGraph = (data) ->
|
$scope.buildGraph = (data) ->
|
||||||
if !data? then return
|
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) ->
|
||||||
|
maxDuration = x.duration + (x.permittedDelay or 0) + (x.chainedDelay or 0)
|
||||||
connections.push
|
connections.push
|
||||||
from: x.startDay, to: x.endDay
|
from: x.startDay, to: x.endDay
|
||||||
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
|
label: x.id+" ("+(if maxDuration isnt x.duration then x.duration+"/"+maxDuration else x.duration)+")"
|
||||||
color: if x.critical then 'red' else if !x.permittedDelay then 'orange'
|
color: if x.critical then 'red' else if !x.permittedDelay then 'orange'
|
||||||
if x.permittedDelay > 0
|
if x.permittedDelay > 0
|
||||||
connections.push
|
connections.push
|
||||||
@ -55,17 +55,36 @@ pertApp.controller 'ganttDiagController', ($scope) ->
|
|||||||
$scope.buildTimeline $scope.fromLocalStorage()
|
$scope.buildTimeline $scope.fromLocalStorage()
|
||||||
$scope.buildTimeline $scope.fromLocalStorage()
|
$scope.buildTimeline $scope.fromLocalStorage()
|
||||||
|
|
||||||
|
areYouSure = (text,cb) ->
|
||||||
|
swal {
|
||||||
|
title: "Are you sure?"
|
||||||
|
text: text
|
||||||
|
type: "warning"
|
||||||
|
showCancelButton: true
|
||||||
|
confirmButtonColor: "#DD6B55"
|
||||||
|
confirmButtonText: "Yes"
|
||||||
|
closeOnConfirm: yes
|
||||||
|
}, cb
|
||||||
|
|
||||||
pertApp.controller 'rawEditorController', ($scope) ->
|
pertApp.controller 'rawEditorController', ($scope) ->
|
||||||
$scope.reset = ->
|
$scope.reset = (askConfirm) ->
|
||||||
$scope.toLocalStorage { activities: [], resources: [] }
|
doIt = -> $scope.toLocalStorage { activities: [], resources: [] }
|
||||||
$scope.saveData = ->
|
if askConfirm
|
||||||
|
areYouSure "ALL data will be lost!", doIt
|
||||||
|
else doIt()
|
||||||
|
$scope.saveData = (askConfirm) ->
|
||||||
try
|
try
|
||||||
data = JSON.parse $scope.taData
|
data = JSON.parse $scope.taData
|
||||||
catch e
|
catch e
|
||||||
swal 'Invalid Data', e, 'error'
|
return swal 'Invalid Data', e, 'error'
|
||||||
$scope.toLocalStorage data
|
doIt = -> $scope.toLocalStorage data
|
||||||
$scope.reloadData = ->
|
if askConfirm then areYouSure "Current saved data will be replaced by the data in the RawEditor", doIt
|
||||||
$scope.taData = JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes
|
else doIt()
|
||||||
|
$scope.reloadData = (askConfirm) ->
|
||||||
|
doIt = ->
|
||||||
|
$scope.taData = JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes
|
||||||
|
if askConfirm then areYouSure "Current saved data will be replaced by the data in the RawEditor", doIt
|
||||||
|
else doIt()
|
||||||
$scope.$on 'dataChanged', $scope.reloadData
|
$scope.$on 'dataChanged', $scope.reloadData
|
||||||
$scope.reloadData()
|
$scope.reloadData()
|
||||||
|
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
<div class="text-center" ng-controller="pertDiagController">
|
<div class="text-center" ng-controller="pertDiagController">
|
||||||
<button class="btn btn-primary" ng-click="rebuild()"><i class="fa fa-spinner"></i> Redraw</button>
|
<button class="btn btn-primary" ng-click="rebuild()"><i class="fa fa-spinner"></i> Redraw</button>
|
||||||
<div id="pertDiagram" ></div>
|
<div id="pertDiagram" ></div>
|
||||||
|
<h2>How to read the Graph</h2>
|
||||||
|
<b>Arrow:</b> every arrow is an activity and the ID and duration (in days) are shown over the arrow, like this: <code>activityID (minimumDuration/maximumDuration)</code>
|
||||||
|
<hr>
|
||||||
|
<p class="lead">The color of the arrow tells the type of the activity:</p>
|
||||||
|
<ul>
|
||||||
|
<li><b>Red Arrow:</b> critical activity</li>
|
||||||
|
<li><b>Green Arrow:</b> free delay of an activity, expressed this way: <code>activityID (freeDelay)</code></li>
|
||||||
|
<li><b>Yellow Arrow:</b> activity with a free delay of 0</li>
|
||||||
|
<li><b>Blue Arrow:</b> activity with a free delay over 0</li>
|
||||||
|
</ul>
|
||||||
|
<hr>
|
||||||
|
<p class="lead">Every circle represents the day of the start of one or more activities and/or the day of the end of one or more activities.</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
<p class="lead">The RawEditor is intended for importing, exporting your data
|
<p class="lead">The RawEditor is intended for importing, exporting your data
|
||||||
and debugging.<br>Keep backups outside of this application if you rely on your data</p>
|
and debugging.<br>Keep backups outside of this application if you rely on your data</p>
|
||||||
<textarea id="ta" class="form-control" ng-model="taData" rows="10"></textarea>
|
<textarea id="ta" class="form-control" ng-model="taData" rows="10"></textarea>
|
||||||
<button class="btn btn-primary" ng-click="saveData()">
|
<button class="btn btn-primary" ng-click="saveData(true)">
|
||||||
<i class="fa fa-check"></i> Save</button>
|
<i class="fa fa-check"></i> Save</button>
|
||||||
<button class="btn btn-info" ng-click="reloadData()">
|
<button class="btn btn-info" ng-click="reloadData(true)">
|
||||||
<i class="fa fa-refresh"></i> Reload</button>
|
<i class="fa fa-refresh"></i> Reload</button>
|
||||||
<button class="btn btn-warning" ng-click="reset()">
|
<button class="btn btn-warning" ng-click="reset(true)">
|
||||||
<i class="fa fa-bomb"></i> Reset</button>
|
<i class="fa fa-bomb"></i> Reset</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user