mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-27 14:34:19 +01:00
bugfix and cleanup
This commit is contained in:
parent
2f0a9a8da1
commit
d551a9c6db
@ -38,6 +38,8 @@ pertController = ($scope) ->
|
|||||||
$scope.toLocalStorage = (data,options) ->
|
$scope.toLocalStorage = (data,options) ->
|
||||||
options ?= {}
|
options ?= {}
|
||||||
data ?= []
|
data ?= []
|
||||||
|
if !data.push?
|
||||||
|
return swal 'Error', 'data is not a list', 'error'
|
||||||
try
|
try
|
||||||
console.log "Saving: "+data
|
console.log "Saving: "+data
|
||||||
localStorage.setItem 'ganttpert', JSON.stringify data
|
localStorage.setItem 'ganttpert', JSON.stringify data
|
||||||
@ -50,21 +52,23 @@ pertController = ($scope) ->
|
|||||||
$scope.fromLocalStorage = (options) ->
|
$scope.fromLocalStorage = (options) ->
|
||||||
options = options || {}
|
options = options || {}
|
||||||
data = localStorage.getItem options.name || 'ganttpert'
|
data = localStorage.getItem options.name || 'ganttpert'
|
||||||
|
if data is null then data = "[]"
|
||||||
try
|
try
|
||||||
jdata = JSON.parse data
|
jdata = JSON.parse data
|
||||||
|
if jdata is null then jdata = []
|
||||||
catch e
|
catch e
|
||||||
unless options.silent
|
unless options.silent
|
||||||
swal 'JSON Error', e, 'error'
|
swal 'JSON Error', e, 'error'
|
||||||
if options.raw
|
if options.raw
|
||||||
console.log 'Loading: []'
|
#console.log 'Loading: []'
|
||||||
return []
|
return []
|
||||||
else
|
else
|
||||||
console.log 'Loading: {list: [], days: []}'
|
#console.log 'Loading: {list: [], days: []}'
|
||||||
return list: [], days: []
|
return list: [], days: []
|
||||||
if options.raw
|
if options.raw
|
||||||
console.log 'Loading: '+jdata
|
#console.log 'Loading: '+jdata
|
||||||
return jdata
|
return jdata
|
||||||
else
|
else
|
||||||
r = new Pert(jdata).calculate()
|
r = new Pert(jdata).calculate()
|
||||||
console.log 'Loading: '+r
|
#console.log 'Loading: '+r
|
||||||
return r
|
return r
|
||||||
|
@ -12,7 +12,6 @@ pertApp.controller 'pertDiagController', ($scope) ->
|
|||||||
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 = []
|
||||||
console.log data.criticalPaths
|
|
||||||
data.activities.forEach (x) ->
|
data.activities.forEach (x) ->
|
||||||
connections.push
|
connections.push
|
||||||
from: x.startDay, to: x.endDay
|
from: x.startDay, to: x.endDay
|
||||||
@ -101,18 +100,16 @@ pertApp.controller 'editorController', ($scope) ->
|
|||||||
catch e
|
catch e
|
||||||
return swal 'Error', 'duration must be an integer', 'error'
|
return swal 'Error', 'duration must be an integer', 'error'
|
||||||
try
|
try
|
||||||
id = parseInt id
|
unless isNaN id
|
||||||
catch e
|
id = parseInt id
|
||||||
return
|
|
||||||
for i,dep of deps
|
for i,dep of deps
|
||||||
try
|
try
|
||||||
deps[i] = parseInt dep
|
unless isNaN dep
|
||||||
|
deps[i] = parseInt dep
|
||||||
catch e
|
catch e
|
||||||
return
|
|
||||||
newdata = $scope.fromLocalStorage silent: yes, raw: yes
|
newdata = $scope.fromLocalStorage silent: yes, raw: yes
|
||||||
if !newdata? or newdata is null or !newdata.push?
|
if !newdata? or newdata is null or !newdata.push?
|
||||||
newdata = []
|
newdata = []
|
||||||
console.log newdata
|
|
||||||
newdata.push { id: id, duration: dur, depends: deps }
|
newdata.push { id: id, duration: dur, depends: deps }
|
||||||
$scope.toLocalStorage newdata, silent: yes
|
$scope.toLocalStorage newdata, silent: yes
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ class Pert
|
|||||||
finished = no
|
finished = no
|
||||||
@log "Done calculating delays. Took", i, "iterations"
|
@log "Done calculating delays. Took", i, "iterations"
|
||||||
for x,i in @list
|
for x,i in @list
|
||||||
console.log x
|
|
||||||
if !x.depends? or x.depends.length is 0
|
if !x.depends? or x.depends.length is 0
|
||||||
@calculateCriticalPaths [x.id]
|
@calculateCriticalPaths [x.id]
|
||||||
results = activities: @list, days: @days, criticalPaths: @criticalPaths
|
results = activities: @list, days: @days, criticalPaths: @criticalPaths
|
||||||
|
Loading…
Reference in New Issue
Block a user