Commit 7eb1c602 authored by Bas Lijnse's avatar Bas Lijnse

Made welcome and instruction texts in default workflow ui parameters

parent 37fb32d8
Pipeline #21579 failed with stage
in 1 minute and 53 seconds
......@@ -17,7 +17,7 @@ Start world = doTasks
,onRequest "/" (ccMain registerTasks continuousTasks alwaysOnTasks optionalTasks <<@ (Title "C2 System"))
,onRequest "/tonic" (tonicDashboard [])
,onRequest "/debug" showDebug
,onRequest "/adventure" (loginAndManageWork "Adventure" Nothing)
,onRequest "/adventure" (loginAndManageWork "Adventure" Nothing Nothing False)
,onRequest "/alarm" (setSectionDetectors)
,onRequest "/log" showLog
//,onRequest "/devices" (manageDevices True)
......
......@@ -9,7 +9,7 @@ import iTasks.UI.Definition, iTasks.Extensions.Admin.UserAdmin
Start :: *World -> *World
Start world = doTasks
[onStartup (installWorkflows workflows)
,onRequest "/" (loginAndManageWork "The Taxman" Nothing)
,onRequest "/" (loginAndManageWork "The Taxman" Nothing Nothing True)
] world
workflows :: [Workflow]
......
......@@ -18,7 +18,7 @@ multiUserExample
-||-
viewInformation "and then Select \"new\" to create a new Task..." [] ""
>>| installWorkflows [wf "chat"]
>>| loginAndManageWork "Chat_4_2 Example" Nothing
>>| loginAndManageWork "Chat_4_2 Example" Nothing Nothing False
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" Nothing
>>| loginAndManageWork "Meeting_4_3 Example" Nothing Nothing False
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" Nothing
>>| loginAndManageWork "Chat_4_2 Example" Nothing Nothing False
where
mkUserAccount name
= {UserAccount| credentials = {Credentials| username = Username name, password = Password name}, title = Nothing, roles = ["manager"] }
......
......@@ -41,21 +41,33 @@ makeExs i =
, join "\n" ["import qualified " +++ toDots i\\i<-i]
, "\n\n"
, "Start :: *World -> *World\n"
, "Start world = doTasks {WorkflowCollection|name=name,welcomeMessage=Just message,workflows=basicAPIExamples} world\n"
, "Start world = doTasks {WorkflowCollection|name=name,loginMessage=Just loginMessage,welcomeMessage=Just welcomeMessage,allowGuests=False,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"
, "\tloginMessage = DivTag []\n"
, "\t\t[Text \"iTasks is a framework to create information systems from task specifications.\",BrTag []\n"
, "\t\t,Text \"Although useful for support of individual tasks, information systems add even more value when a task \"\n"
, "\t\t,Text \"requires multiple people to work together to accomplish it.\"\n"
, "\t\t,Text \"Therefore this example application is a multi-user demonstration of tasks expressed in iTasks.\",BrTag [],BrTag[]\n"
, "\t\t,Text \"You can log in with a demonstration user account:\",BrTag []\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 \"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,LiTag [] [Text \"An administrator with full access (username: root, password: root)\"]\n"
, "\t\t\t\t]\n"
, "\t\t\t]\n"
, "\n"
, "\twelcomeMessage = DivTag []\n"
, "\t\t[H1Tag [] [Text \"Welcome\"],PTag []\n"
, "\t\t\t[Text \"In this generic application you can work on multiple tasks concurrently.\", BrTag []\n"
, "\t\t\t,Text \"In the list above you can see the set of ongoing tasks that you can choose to work on.\", BrTag []\n"
, "\t\t\t,Text \"Additionally you can add tasks to this list with the 'New' button. This will open a window with a collection of predefined tasks.\", BrTag []\n"
, "\t\t\t,Text \"These tasks range from simple TODO items, to complex multi-user workflows.\", BrTag []\n"
, "\t\t\t]\n"
, "\t\t]\n"
, "\n"
, "basicAPIExamples :: [Workflow]\n"
, "basicAPIExamples =\n"
, "\t[",join "\n\t," (defaultWfs ++ exampleWfs), "\n\t]\n"]
......
......@@ -108,7 +108,7 @@ startMode executable
>>- \role = case role of
DomainServer domain -> startAuthEngine domain
>>| installWorkflows (myTasks True)
>>| loginAndManageWork "Service engineer application" Nothing
>>| loginAndManageWork "Service engineer application" Nothing Nothing False
Server domain -> startAuthEngine domain >>| loginRemote (myTasks False)
_ -> viewInformation "Welcome" [] "Chose what this iTasks instance is."
>>* [ OnAction (Action "Domain server") (always (domainServer))
......@@ -127,7 +127,7 @@ where
>>= \domain -> set (DomainServer domain) serverRoleShare
>>| startAuthEngine domain
>>| installWorkflows (myTasks True)
>>| loginAndManageWork "Service engineer application" Nothing
>>| loginAndManageWork "Service engineer application" Nothing Nothing False
loginRemote :: ![Workflow] -> Task ()
loginRemote workflows
......
@import 'css/WorkflowAdmin.css';
.welcome-itasks-example-collection > div {
background-color: #76a2d0;
max-width: 600px;
border-radius: 5px;
padding: 5px 10px;
}
.welcome-itasks-example-collection h1 {
font-weight: normal;
font-size: 32pt;
color: #000;
}
......@@ -5,7 +5,7 @@
<title></title>
<link rel="stylesheet" href="/css/itasks.css" type="text/css" >
<link rel="stylesheet" href="/css/WorkflowAdmin.css" type="text/css" >
<link rel="stylesheet" href="/BasicAPIExamples.css" type="text/css" >
<!-- Sapl dependencies -->
<script type="text/javascript" src="/js/sapl-utils.js"></script>
......
......@@ -33,7 +33,9 @@ import iTasks
// Make the management framework startable
:: WorkflowCollection =
{ name :: !String
, loginMessage :: !Maybe HtmlTag
, welcomeMessage :: !Maybe HtmlTag
, allowGuests :: !Bool
, workflows :: ![Workflow]
}
......@@ -95,8 +97,8 @@ 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 !(Maybe HtmlTag) -> Task ()
manageWorkOfCurrentUser :: Task ()
loginAndManageWork :: !String !(Maybe HtmlTag) !(Maybe HtmlTag) !Bool -> Task ()
manageWorkOfCurrentUser :: !(Maybe HtmlTag) -> Task ()
/**
* Dynamically adds a workflow to the system.
......
......@@ -96,10 +96,10 @@ allowedPersistentWorkflows = mapRead (\wfs -> [wf \\ wf=:{Workflow|transient} <-
instance Startable WorkflowCollection
where
toStartable {WorkflowCollection|name,welcomeMessage,workflows} =
toStartable {WorkflowCollection|name,loginMessage,welcomeMessage,allowGuests,workflows} =
[onStartup (installWorkflows workflows)
,onStartup installDemoUsers
,onRequest "/" (loginAndManageWork name welcomeMessage)
,onRequest "/" (loginAndManageWork name loginMessage welcomeMessage allowGuests)
]
installWorkflows :: ![Workflow] -> Task ()
......@@ -115,41 +115,43 @@ installDemoUsers
= try (get users) (\(StoreReadBuildVersionError _) -> return [])
>>- \us -> if (length us <= 1) (importDemoUsersFlow @! ()) (return ()) //No users, or just a single root user
loginAndManageWork :: !String !(Maybe HtmlTag) -> Task ()
loginAndManageWork name welcomeMessage
loginAndManageWork :: !String !(Maybe HtmlTag) !(Maybe HtmlTag) !Bool -> Task ()
loginAndManageWork applicationName loginMessage welcomeMessage allowGuests
= forever
((( viewTitle name welcomeMessage
((( identifyApplication applicationName loginMessage
||-
(anyTask [
enterInformation ("Authenticated access","Enter your credentials and login") [] @ Just
>>* [OnAction (Action "Login") (hasValue return)]
,
viewInformation ("Guest access","Alternatively, you can continue anonymously as guest user") [] ()
>>| (return Nothing)
:if allowGuests
[viewInformation ("Guest access","Alternatively, you can continue anonymously as guest user") [] ()
>>| (return Nothing)
]
[]
] <<@ ArrangeHorizontal)
) <<@ ApplyLayout layout
>>- browse) //Compact layout before login, full screen afterwards
) <<@ Title name
) <<@ Title applicationName
where
browse (Just {Credentials|username,password})
= authenticateUser username password
>>= \mbUser -> case mbUser of
Just user = workAs user manageWorkOfCurrentUser
Just user = workAs user (manageWorkOfCurrentUser welcomeMessage)
Nothing = (viewInformation (Title "Login failed") [] "Your username or password is incorrect" >>| return ()) <<@ ApplyLayout frameCompact
browse Nothing
= workAs (AuthenticatedUser "guest" ["manager"] (Just "Guest user")) manageWorkOfCurrentUser
= workAs (AuthenticatedUser "guest" ["manager"] (Just "Guest user")) (manageWorkOfCurrentUser welcomeMessage)
viewTitle name welcomeMessage = viewInformation () [] html
identifyApplication name welcomeMessage = viewInformation () [] html
where
html = DivTag [] [H1Tag [] [Text name]:maybe [] (\msg -> [msg]) welcomeMessage]
html = DivTag [ClassAttr cssClass] [H1Tag [] [Text name]:maybe [] (\msg -> [msg]) welcomeMessage]
cssClass = "welcome-" +++ (toLowerCase $ replaceSubString " " "-" name)
layout = sequenceLayouts [layoutSubUIs (SelectByType UIAction) (setActionIcon ('DM'.fromList [("Login","login")])) ,frameCompact]
manageWorkOfCurrentUser :: Task ()
manageWorkOfCurrentUser
manageWorkOfCurrentUser :: !(Maybe HtmlTag) -> Task ()
manageWorkOfCurrentUser welcomeMessage
= ((manageSession -||
(chooseWhatToDo >&> withSelection
(chooseWhatToDo welcomeMessage >&> withSelection
(viewInformation () [] "Welcome!")
(\wf -> unwrapWorkflowTask wf.Workflow.task)
)
......@@ -181,13 +183,13 @@ manageSession =
where
view user = "Welcome " +++ toString user
chooseWhatToDo = updateChoiceWithShared (Title "Menu") [ChooseFromList workflowTitle] (mapRead addManageWork allowedTransientTasks) manageWorkWf
chooseWhatToDo welcomeMessage = updateChoiceWithShared (Title "Menu") [ChooseFromList workflowTitle] (mapRead addManageWork allowedTransientTasks) manageWorkWf
where
addManageWork wfs = [manageWorkWf:wfs]
manageWorkWf = transientWorkflow "My work" "Manage your worklist" manageWork
manageWorkWf = transientWorkflow "My Tasks" "Manage your worklist" (manageWork welcomeMessage)
manageWork :: Task ()
manageWork = parallel [(Embedded, manageList),(Embedded, const viewInstructions)] [] <<@ ApplyLayout layoutManageWork @! ()
manageWork :: (Maybe HtmlTag) -> Task ()
manageWork welcomeMessage = parallel [(Embedded, manageList):maybe [] (\html -> [(Embedded, const (viewWelcomeMessage html))]) welcomeMessage] [] <<@ ApplyLayout layoutManageWork @! ()
where
manageList taskList
= get currentUser @ userRoles
......@@ -216,27 +218,19 @@ where
layoutSubUIs (SelectByDepth 1) (setUIAttributes $ 'DM'.put "fullscreenable" (JSONBool True) 'DM'.newMap)
]
viewInstructions :: Task ()
viewInstructions = viewInformation (Title "Welcome") [] instructions @! ()
where
instructions = DivTag [] [H1Tag [] [Text "Welcome"],PTag [] (flatten (map (\t -> [Text t,BrTag []]) text))]
text = ["In this framework you can work on multiple tasks in a multi-user setting."
,"In the list above you can see the set of tasks that you can choose to work on."
,"You can add tasks to this list with the 'New' button. This will open a window with a collection of predefined tasks."
,"These tasks range from simple TODO items, to complex multi-user workflows."
]
viewWelcomeMessage :: HtmlTag -> Task ()
viewWelcomeMessage html = viewInformation (Title "Welcome") [] html @! ()
addNewTask :: !(SharedTaskList ()) -> Task ()
addNewTask list
= ((chooseWorkflow >&> viewWorkflowDetails) <<@ ArrangeHorizontal
>>* [OnAction (Action "Start task") (hasValue (\wf -> startWorkflow list wf @! ()))
,OnAction ActionCancel (always (return ()))
] ) <<@ Title "New work"
] ) <<@ Title "New task..."
chooseWorkflow :: Task Workflow
chooseWorkflow
= editSelectionWithShared [Att (Title "Tasks"), Att IconEdit] False (SelectInTree toTree fromTree) allowedPersistentWorkflows (const []) <<@ Title "Workflow Catalogue"
= editSelectionWithShared [Att (Title "Tasks"), Att IconEdit] False (SelectInTree toTree fromTree) allowedPersistentWorkflows (const [])
@? tvHd
where
//We assign unique negative id's to each folder and unique positive id's to each workflow in the list
......
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