Commit 1f0d906c authored by Bas Lijnse's avatar Bas Lijnse

Added an optional welcome message to the default workflow management ui

parent adceb398
......@@ -18,7 +18,7 @@ multiUserExample
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| installWorkflows [wf "chat"]
>>| loginAndManageWork "Chat_4_2 Example"
>>| loginAndManageWork "Chat_4_2 Example" Nothing
where
mkUserAccount name
= {UserAccount| credentials = {Credentials| username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -21,7 +21,7 @@ multiUserExample
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| installWorkflows [wf "Meeting date"]
>>| loginAndManageWork "Meeting_4_3 Example"
>>| loginAndManageWork "Meeting_4_3 Example" Nothing
where
mkUserAccount name
= {UserAccount| credentials = {Credentials| username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -21,7 +21,7 @@ multiUserExample
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| installWorkflows [wf "Chat with options"]
>>| loginAndManageWork "Chat_4_2 Example"
>>| loginAndManageWork "Chat_4_2 Example" Nothing
where
mkUserAccount name
= {UserAccount| credentials = {Credentials| username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -35,14 +35,26 @@ makeExs i =
[ "module BasicAPIExamples\n"
, "\n"
, "import iTasks\n"
, "import Text.HTML\n"
, "import qualified iTasks.Extensions.Admin.UserAdmin\n"
, "\n"
, join "\n" ["import qualified " +++ toDots i\\i<-i]
, "\n\n"
, "Start :: *World -> *World\n"
, "Start world = doTasks {WorkflowCollection|name=name,workflows=basicAPIExamples} world\n"
, "Start world = doTasks {WorkflowCollection|name=name,welcomeMessage=Just message,workflows=basicAPIExamples} world\n"
, "where\n"
, "\tname = \"iTasks Example Collection\"\n"
, "\tmessage = DivTag []\n"
, "\t\t[Text \"If you want to try the examples in a multi user setting, you can log in with one of the demo users\"\n"
, "\t\t,BrTag []\n"
, "\t\t,Text \"For example:\"\n"
, "\t\t\t,UlTag []\n"
, "\t\t\t\t[LiTag [] [Text \"Administrator (username: root, password: root)\"]\n"
, "\t\t\t\t,LiTag [] [Text \"Alice (username: alice, password: alice)\"]\n"
, "\t\t\t\t,LiTag [] [Text \"Bob (username: bob, password: bob)\"]\n"
, "\t\t\t\t,LiTag [] [Text \"Carol (username: carol, password: carol)\"]\n"
, "\t\t\t\t]\n"
, "\t\t\t]\n"
, "\n"
, "basicAPIExamples :: [Workflow]\n"
, "basicAPIExamples =\n"
......
......@@ -32,8 +32,9 @@ import iTasks
// Make the management framework startable
:: WorkflowCollection =
{ name :: !String
, workflows :: ![Workflow]
{ name :: !String
, welcomeMessage :: !Maybe HtmlTag
, workflows :: ![Workflow]
}
instance Startable WorkflowCollection
......@@ -94,7 +95,7 @@ instance toWorkflow (ParamWorkflowContainer a b) | iTask a & iTask b
* and let's them create instances of these tasks and work on instances.
*/
installWorkflows :: ![Workflow] -> Task ()
loginAndManageWork :: !String -> Task ()
loginAndManageWork :: !String !(Maybe HtmlTag) -> Task ()
manageWorkOfCurrentUser :: Task ()
/**
......
......@@ -96,10 +96,10 @@ allowedPersistentWorkflows = mapRead (\wfs -> [wf \\ wf=:{Workflow|transient} <-
instance Startable WorkflowCollection
where
toStartable {WorkflowCollection|name,workflows} =
toStartable {WorkflowCollection|name,welcomeMessage,workflows} =
[onStartup (installWorkflows workflows)
,onStartup installDemoUsers
,onRequest "/" (loginAndManageWork name)
,onRequest "/" (loginAndManageWork name welcomeMessage)
]
installWorkflows :: ![Workflow] -> Task ()
......@@ -115,10 +115,10 @@ installDemoUsers
= try (get users) (\(StoreReadBuildVersionError _) -> return [])
>>- \us -> if (length us <= 1) (importDemoUsersFlow @! ()) (return ()) //No users, or just a single root user
loginAndManageWork :: !String -> Task ()
loginAndManageWork welcome
loginAndManageWork :: !String !(Maybe HtmlTag) -> Task ()
loginAndManageWork name welcomeMessage
= forever
((( viewTitle welcome
((( viewTitle name welcomeMessage
||-
(anyTask [
enterInformation ("Authenticated access","Enter your credentials and login") [] @ Just
......@@ -129,16 +129,21 @@ loginAndManageWork welcome
] <<@ ApplyLayout (setUIAttributes (directionAttr Horizontal)))
) <<@ ApplyLayout layout
>>- browse) //Compact layout before login, full screen afterwards
) <<@ ApplyLayout (setUIAttributes (titleAttr welcome))
) <<@ Title name
where
browse (Just {Credentials|username,password})
= authenticateUser username password
>>= \mbUser -> case mbUser of
Just user = workAs user manageWorkOfCurrentUser
Nothing = viewInformation (Title "Login failed") [] "Your username or password is incorrect" >>| return ()
Nothing = (viewInformation (Title "Login failed") [] "Your username or password is incorrect" >>| return ()) <<@ ApplyLayout frameCompact
browse Nothing
= workAs (AuthenticatedUser "guest" ["manager"] (Just "Guest user")) manageWorkOfCurrentUser
viewTitle name welcomeMessage = viewInformation () [] html
where
html = DivTag [] [H1Tag [] [Text name]:maybe [] (\msg -> [msg]) welcomeMessage]
layout = sequenceLayouts [layoutSubUIs (SelectByType UIAction) (setActionIcon ('DM'.fromList [("Login","login")])) ,frameCompact]
manageWorkOfCurrentUser :: Task ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment