Commit 0a92516d authored by Bas Lijnse's avatar Bas Lijnse

Updated examples and tests to revised API for starting tasks

parent d428eacd
......@@ -35,11 +35,12 @@ import Incidone.DeviceBased.Tablet
Start :: *World -> *World
Start world = startEngine [publish "/" (\_ -> ccPerson)
,publish "/wall" (\_ -> viewVideoWallContent)
,publish "/wall-control" (\_ -> selectVideoWallContent)
,publish "/exercise-control" (\_ -> controlExercise)
] world
Start world = doTasks
[onRequest "/" (\_ -> ccPerson)
,onRequest "/wall" (\_ -> viewVideoWallContent)
,onRequest "/wall-control" (\_ -> selectVideoWallContent)
,onRequest "/exercise-control" (\_ -> controlExercise)
] world
where
//Main task for command center operators
ccPerson :: Task ()
......
......@@ -10,21 +10,24 @@ import C2.Framework.Logging
import C2.Apps.ShipAdventure.Core, C2.Apps.ShipAdventure.Types, C2.Apps.ShipAdventure.Editor, C2.Apps.ShipAdventure.Scripting
Start :: *World -> *World
Start world = startEngine [ publish "/" (\_ -> importDemoUsers >>| ccMain registerTasks continuousTasks alwaysOnTasks optionalTasks <<@ (Title "C2 System"))
, publish "/tonic" (\_ -> tonicDashboard [])
, publish "/debug" (\_ -> showDebug)
, publish "/adventure" (\_ -> importDemoUsersFlow >>| loginAndManageWorkList "Adventure" myTasks)
, publish "/tonic" (\_ -> tonicDashboard [])
, publish "/alarm" (\_ -> setSectionDetectors)
, publish "/log" (\_ -> showLog)
//, publish "/devices" (\_ -> manageDevices True)
, publish "/editor" (\_ -> shipEditorTabs)
, publish "/changeFire" (\_ -> changeFireScript)
, publish "/changeFlood" (\_ -> changeFloodScript)
, publish "/changeSmoke" (\_ -> changeSmokeScript)
, publish "/doffMap" (\_ -> dOffMap)
, publish "/test" (\_ -> editMaps2D)
] world
Start world = doTasks
[onStartup defaultValue importDemoUsers
,onStartup defaultValue importDemoUsersFlow
,onStartup defaultValue (installWorkflows myTasks)
,onRequest "/" (\_ -> ccMain registerTasks continuousTasks alwaysOnTasks optionalTasks <<@ (Title "C2 System"))
,onRequest "/tonic" (\_ -> tonicDashboard [])
,onRequest "/debug" (\_ -> showDebug)
,onRequest "/adventure" (\_ -> loginAndManageWork "Adventure")
,onRequest "/alarm" (\_ -> setSectionDetectors)
,onRequest "/log" (\_ -> showLog)
//,onRequest "/devices" (\_ -> manageDevices True)
,onRequest "/editor" (\_ -> shipEditorTabs)
,onRequest "/changeFire" (\_ -> changeFireScript)
,onRequest "/changeFlood" (\_ -> changeFloodScript)
,onRequest "/changeSmoke" (\_ -> changeSmokeScript)
,onRequest "/doffMap" (\_ -> dOffMap)
,onRequest "/test" (\_ -> editMaps2D)
] world
editMaps2D :: Task Maps2D
editMaps2D = updateSharedInformation "Edit map" [] maps2DShare
......
......@@ -7,8 +7,9 @@ import Task.Extensions
import iTasks.UI.Definition, iTasks.Extensions.Admin.UserAdmin
Start :: *World -> *World
Start world = startEngine
[ publish "/" (\_ -> loginAndManageWorkList "Welcome at the taxman" workflows <<@ ApplyLayout (setUIAttributes (titleAttr "The Taxman")))
Start world = doTasks
[onStartup defaultValue (installWorkflows workflows)
,onRequest "/" (\_ -> loginAndManageWork "The Taxman")
] world
workflows :: [Workflow]
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Enter a date and a time" enterDateTime
Start :: *World -> *World
Start world
= startEngine enterDateTime world
= doTasks enterDateTime world
enterDateTime :: Task [(Date, Time)]
enterDateTime
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Enter an Integer" enterInt
Start :: *World -> *World
Start world
= startEngine enterInt world
= doTasks enterInt world
enterInt :: Task Int
enterInt
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Enter a list of Integer numbers" enterListOfInt
Start :: *World -> *World
Start world
= startEngine enterListOfInt world
= doTasks enterListOfInt world
enterListOfInt :: Task [Int]
enterListOfInt
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Enter text" enterText
Start :: *World -> *World
Start world
= startEngine enterText world
= doTasks enterText world
enterText :: Task String
enterText
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Enter a Google map" googleMap
Start :: *World -> *World
Start world
= startEngine googleMap world
= doTasks googleMap world
googleMap :: Task GoogleMap
googleMap
......
......@@ -5,12 +5,12 @@ implementation module BasicAPIExamples.EditorsOnBasicAndPredefinedTypes.HelloWor
import iTasks
wf :: String -> Workflow
wf a = workflow a "Hello World!" helloWorld
wf a = workflow a "Hello, World!" helloWorld
Start :: *World -> *World
Start world
= startEngine helloWorld world
= doTasks helloWorld world
helloWorld :: Task String
helloWorld
= viewInformation "You have a message from iTasks:" [] "Hello world!"
= viewInformation "You have a message from iTasks:" [] "Hello, world!"
......@@ -24,7 +24,7 @@ derive class iTask Family, Person, Gender
Start :: *World -> *World
Start world
= startEngine enterFamily world
= doTasks enterFamily world
enterFamily :: Task Family
enterFamily
......
......@@ -19,7 +19,7 @@ derive class iTask Person, Gender
Start :: *World -> *World
Start world
= startEngine enterPerson world
= doTasks enterPerson world
enterPerson :: Task Person
enterPerson
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Browse a shared GoogleMap" browseAndViewGoogleMap
Start :: *World -> *World
Start world
= startEngine browseAndViewGoogleMap world
= doTasks browseAndViewGoogleMap world
browseAndViewGoogleMap :: Task GoogleMap
browseAndViewGoogleMap
......
......@@ -12,7 +12,7 @@ wf a = workflow a "View the current Date and Time" showDateAndTime
Start :: *World -> *World
Start world
= startEngine showDateAndTime world
= doTasks showDateAndTime world
showDateAndTime :: Task Time
showDateAndTime
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Edit a shared note as a list" sharedNoteAsList
Start :: *World -> *World
Start world
= startEngine sharedNoteAsList world
= doTasks sharedNoteAsList world
sharedNoteAsList :: Task String
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Edit a shared note" sharedNotes
Start :: *World -> *World
Start world
= startEngine sharedNotes world
= doTasks sharedNotes world
// Update and view shared notifications
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Edit a shared list of persons" enterSharedPersons
Start :: *World -> *World
Start world
= startEngine enterSharedPersons world
= doTasks enterSharedPersons world
:: Person =
{ name :: String
......
......@@ -8,7 +8,7 @@ wf :: String -> Workflow
wf a = workflow a "Run a process, e.g. /bin/bash" runProcess
Start :: *World -> *World
Start w = startEngine runProcess w
Start w = doTasks runProcess w
runProcess :: Task Int
runProcess = enterInformation "Command" [] -&&- enterInformation "Arguments" []
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Chat with other users" myExample
Start :: *World -> *World
Start world
= startEngine multiUserExample world
= doTasks multiUserExample world
multiUserExample
= set (map mkUserAccount players) userAccounts
......@@ -18,7 +18,8 @@ multiUserExample
(foldl (+++) "" (map (\n -> n +++ ", ") players))
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| loginAndManageWorkList "Chat_4_2 Example" [wf "chat"]
>>| installWorkflows [wf "chat"]
>>| loginAndManageWork "Chat_4_2 Example"
where
mkUserAccount name
= { credentials = { username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -13,7 +13,7 @@ wf a = workflow a "Plan a meeting" myExample
Start :: *World -> *World
Start world
= startEngine multiUserExample world
= doTasks multiUserExample world
multiUserExample
= set (map mkUserAccount players) userAccounts
......@@ -21,7 +21,8 @@ multiUserExample
(join ", " players)
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| loginAndManageWorkList "Meeting_4_3 Example" [wf "Meeting date"]
>>| installWorkflows [wf "Meeting date"]
>>| loginAndManageWork "Meeting_4_3 Example"
where
mkUserAccount name
= { credentials = { username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -13,7 +13,7 @@ wf a = workflow a "Chat with options" genChat
Start :: *World -> *World
Start world
= startEngine multiUserExample world
= doTasks multiUserExample world
multiUserExample
= set (map mkUserAccount logins) userAccounts
......@@ -21,7 +21,8 @@ multiUserExample
(foldl (+++) "" (map (\n -> n +++ ", ") logins))
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| loginAndManageWorkList "Chat_4_2 Example" [wf "Chat with options"]
>>| installWorkflows [wf "Chat with options"]
>>| loginAndManageWork "Chat_4_2 Example"
where
mkUserAccount name
= { credentials = { username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Tiny text editor" editWithStatistics
Start :: *World -> *World
Start world
= startEngine editWithStatistics world
= doTasks editWithStatistics world
:: Statistics = { lineCount :: Int
, wordCount :: Int
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Calculate sum in share" calculateSumInRecord
Start :: *World -> *World
Start world
= startEngine calculateSumInRecord world
= doTasks calculateSumInRecord world
:: MySum = {firstNumber :: Int, secondNumber :: Int, sum :: Int}
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Calculate the Sum Stepwise" calculateSumStepwise
Start :: *World -> *World
Start world
= startEngine calculateSumStepwise world
= doTasks calculateSumStepwise world
calculateSumStepwise :: Task Int
calculateSumStepwise
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Calculate Sum Stepwise and Back" calculateSumSteps
Start :: *World -> *World
Start world
= startEngine calculateSumSteps world
= doTasks calculateSumSteps world
calculateSumSteps :: Task Int
calculateSumSteps = step1 0 0
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Calculator" calculator
Start :: *World -> *World
Start world
= startEngine calculator world
= doTasks calculator world
:: CalculatorState = { display :: Int, n :: Int}
......
......@@ -10,7 +10,7 @@ wf a = workflow a "Calculator" coffeemachine
Start :: *World -> *World
Start world
= startEngine coffeemachine world
= doTasks coffeemachine world
coffeemachine :: Task (String,EUR)
coffeemachine
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Edit a list of Persons one by one" (person1by1 [])
Start :: *World -> *World
Start world
= startEngine (person1by1 []) world
= doTasks (person1by1 []) world
:: Person =
{ name :: String
......
......@@ -9,7 +9,7 @@ wf a = workflow a "Enter a palindrome" palindrome
Start :: *World -> *World
Start world
= startEngine palindrome world
= doTasks palindrome world
palindrome :: Task (Maybe String)
palindrome
......
......@@ -11,7 +11,7 @@ wf a = workflow "Enter a positive number" positiveNumber
Start :: *World -> *World
Start world
= startEngine positiveNumber world
= doTasks positiveNumber world
positiveNumber :: Task Int
positiveNumber
......
......@@ -39,11 +39,9 @@ makeExs i =
, join "\n" ["import qualified " +++ toDots i\\i<-i]
, "\n\n"
, "Start :: *World -> *World\n"
, "Start world = startEngine\n"
, "\t[ publish \"/\" (\\_->loginAndManageWorkList title basicAPIExamples <<@ ApplyLayout (setUIAttributes (titleAttr title)))\n"
, "\t] world\n"
, "Start world = doTasks {WorkflowCollection|name=name,workflows=basicAPIExamples} world\n"
, "where\n"
, "\ttitle = \"iTasks Example Collection\"\n"
, "\tname = \"iTasks Example Collection\"\n"
, "\n"
, "basicAPIExamples :: [Workflow]\n"
, "basicAPIExamples =\n"
......
......@@ -77,4 +77,4 @@ where
withMarkerFromCursor Nothing objects = objects
withMarkerFromCursor (Just position) objects = objects ++ [Marker {markerId = "CURSOR", position= position, title = Nothing, icon = Nothing, selected = False, popup = Nothing}]
Start world = startEngine playWithMaps world
Start world = doTasks playWithMaps world
......@@ -10,17 +10,18 @@ startMultiUserTasks workflows tasks world
] tasks world
startTask taskList tasks world
= startEngine [ publish "/" (\_-> browseExamples taskList)
: tasks
] world
= doTasks [ onStartup defaultValue (installWorkflows taskList)
, onRequest "/" (const browseExamples)
: tasks
] world
where
browseExamples taskList = forever (
browseExamples = forever (
enterInformation "Enter your credentials and login or press continue to remain anonymous" []
>>* [OnAction (Action "Login") (hasValue (browseAuthenticated taskList))
>>* [OnAction (Action "Login") (hasValue browseAuthenticated)
] )
browseAuthenticated taskList {Credentials|username,password}
browseAuthenticated {Credentials|username,password}
= authenticateUser username password
>>= \mbUser -> case mbUser of
Just user = workAs user (manageWorklist taskList)
Just user = workAs user manageWorkOfCurrentUser
Nothing = viewInformation (Title "Login failed") [] "Your username or password is incorrect" >>| return ()
......@@ -20,12 +20,13 @@ none = toSVGColor "none"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Basic Images" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const basic_images
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Basic Images"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const basic_images
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** basic_images model tags = image:
@image displays the basic Image shapes.
......
......@@ -15,13 +15,13 @@ none = toSVGColor "none"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Box" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const box2
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Box"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const box2
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** box2 model tags = image:
@image uses the pair function that uses @tags to display two images inside a rectangle that depends on each others dimensions.
......
......@@ -12,12 +12,13 @@ from StdList import repeat, repeatn
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Boxes" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const boxes
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Boxes"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const boxes
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
boxes :: m *TagSource -> Image m
boxes model tags
......
......@@ -19,13 +19,13 @@ white = toSVGColor "white"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "100% Clean!" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const clean
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "100% Clean!"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const clean
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** clean model tags = image:
@image is inspired by an image that was displayed by Marc Schoolderman during the lab session of friday afternoon, may 22 2015.
......
......@@ -17,13 +17,13 @@ lucida = normalFontDef "Lucida Console"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Grids" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const grids
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Grids"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const grids
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** grids model tags = image:
@image shows all grid-layout combinations.
......
......@@ -20,13 +20,13 @@ blue = toSVGColor "blue"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Linears" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const linears
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Linears"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const linears
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** linears model tags = image:
@image shows all beside and above combinations.
......
......@@ -10,12 +10,13 @@ from StdFunc import const, id
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Mask" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const image
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Mask"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const image
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** image model tags = image:
@image displays a triangle that is masked with a circle.
......
......@@ -19,13 +19,13 @@ white = toSVGColor "white"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (updateInformation "On Click" [UpdateUsing id (\_ v = v) (fromSVGEditor
{ initView = id
, renderImage = const count
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (updateInformation "On Click"
[UpdateUsing id (\_ v = v) (fromSVGEditor
{ initView = id
, renderImage = const count
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** count n tags = image:
@image displays the number of times that you've clicked on the text. The initial value is @n.
......
......@@ -17,12 +17,13 @@ lucida = normalFontDef "Lucida Console"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Overlays" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const overlays
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Overlays"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const overlays
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** overlays model tags = image:
@image shows all overlay-combinations.
......
......@@ -14,13 +14,13 @@ white = toSVGColor "white"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Polyline" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const polyline_in_host
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Polyline"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const polyline_in_host
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** polyline_in_host model tags = image:
@image shows a polyline within a host.
......
......@@ -18,12 +18,13 @@ white = toSVGColor "white"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Rose tree" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const roses
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Rose tree"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const roses
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** roses model tags = image:
......
......@@ -12,13 +12,13 @@ from StdFunc import id
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Rotates" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const rotates
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Rotates"
[ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const rotates
, updView = \m _ = m
, updModel = \_ v = v
})] 0) world
/** rotates model tags = image:
@image displays a sequence of rotated rectangles
......
......@@ -17,12 +17,13 @@ times = normalFontDef "Times New Roman"
Start :: *World -> *World
Start world
= startEngine [publish "/" (const (viewInformation "Transformations" [ViewUsing id (fromSVGEditor
{ initView = id
, renderImage = const transformed_images
, updView = \m _ = m
, updModel = \_ v = v
})] 0))] world
= doTasks (viewInformation "Transformations"
[ViewUsing id (fromSVGEditor
{ initView = id