Commit 4d0f2502 authored by Bas Lijnse's avatar Bas Lijnse

More work on restoring incidone

parent 0f53486f
......@@ -9,6 +9,7 @@ import Incidone.DeviceBased.VideoWall
import Incidone.Extensions.CrewLists //For demo
import qualified Data.Map as DM
import Text, Text.HTML
import iTasks.UI.Editor.Builtin
CONVERT_BIN :== "/opt/local/bin/convert"
//CONVERT_BIN :== "/usr/bin/convert"
......@@ -29,42 +30,55 @@ where
selectContactFromLists :: (Shared (Maybe (Either ContactNo MMSI))) -> Task (Either ContactNo MMSI)
selectContactFromLists sel
= enterInformation "FIXME" []
= anyTask [editSharedSelectionWithShared (Title "Involved in open incidents") False
(SelectInTree groupByIncident select) contactsOfOpenIncidentsShort (selIds sel)
,editSharedSelectionWithShared (Title "Available for help") False
(SelectInTree groupByGroup select) contactsProvidingHelpShort (selIds sel)
,editSharedSelectionWithShared (Title "All contacts") False
(SelectInTree groupByGroup select) allContactsShort (selIds sel)
/*
= anyTask [(editSharedSelectionWithShared (Title "Involved in open incidents")
[SelectInTree groupByIncident] contactsOfOpenIncidentsShort (Left o fromOpenOption)) sel
,(editSharedSelectionWithShared (Title "Available for help")
[SelectInTree groupByGroup] contactsProvidingHelpShort (Left o contactIdentity)) sel
,(editSharedSelectionWithShared (Title "All contacts")
[SelectInTree groupByGroup] allContactsShort (Left o contactIdentity)) sel
,(editSharedSelectionWithShared (Title "AIS")
[SelectInTree ungrouped] (mapRead (sortBy (\x y -> contactTitle x < contactTitle y) o map aisToContact) allAISContacts) (Right o contactIdentity)) sel
] @? tvHd //<<@ (ArrangeSplit Horizontal True)
,(editSharedSelectionWithShared (Title "AIS") False
(SelectInTree ungrouped) (mapRead (sortBy (\x y -> contactTitle x < contactTitle y) o map aisToContact) allAISContacts) (Right o contactIdentity)) sel
*/ ] <<@ (ArrangeSplit Horizontal True) @? tvHd
*/
fromOpenOption {ContactShortWithIncidents|contactNo} = contactNo
fromOpenOption [{ContactShortWithIncidents|contactNo}] = contactNo
selIds sel = mapReadWrite (toPrj,fromPrj) sel
where
toPrj Nothing = []
toPrj (Just (Left contactNo)) = [contactNo]
toPrj (Just (Right mmsi)) = [~ mmsi]
fromPrj [s] _ = Just (Just (if (s > 0) (Left s) (Right (~s))))
fromPrj _ _ = Just Nothing
//Organize contacts into a tree
groupByIncident contacts expanded
= []
/*
= [{ChoiceTree|label=label c,icon=Just (contactIcon {Contact|defaultValue&type=c.ContactShortWithIncidents.type}),value=ChoiceNode i,type=LeafNode} \\ (i,c) <- contacts]
groupByIncident contacts
= [{ChoiceNode|id=c.ContactShortWithIncidents.contactNo, label=label c
,icon=Just (contactIcon {Contact|defaultValue&type=c.ContactShortWithIncidents.type})
,expanded=False,children=[]} \\ c <- contacts]
where
label {ContactShortWithIncidents|name,incidents}
= fromMaybe "-" name +++ " (" +++ join "," [fromMaybe "-" title\\{IncidentShort|title}<-incidents] +++ ")"
*/
ungrouped contacts expanded = [] //[{ChoiceTree|label=contactTitle c,icon=Just (contactIcon c),value=ChoiceNode i,type=LeafNode} \\ (i,c) <- contacts]
groupByGroup contacts expanded
= []
/*
= [{ChoiceTree|label=group,icon=Nothing,value=GroupNode group,type=ifExpandedGroup group expanded items} \\(group,items) <- 'DM'.toList (foldl group 'DM'.newMap contacts)]
groupByGroup contacts
= [{ChoiceNode|id=0,label=group,icon=Nothing,expanded=True,children=
[{ChoiceNode|id=c.ContactShort.contactNo, label=fromMaybe "-" c.ContactShort.name
,icon=Just (contactIcon c)
,expanded=False,children=[]} \\ c <- items]} \\ (group,items) <- 'DM'.toList (foldl group 'DM'.newMap contacts)]
where
group groups (i,c=:{ContactShort|group})
label {ContactShort|name} = fromMaybe "-" name
group groups c=:{ContactShort|group}
# g = fromMaybe "Uncategorized" group
= 'DM'.put g (fromMaybe [] ('DM'.get g groups) ++ [{ChoiceTree|label=contactTitle c,icon=Just (contactIcon c),value=ChoiceNode i, type=LeafNode}]) groups
*/
= 'DM'.put g (fromMaybe [] ('DM'.get g groups) ++ [c]) groups
ungrouped contacts =
[{ChoiceNode|id=c.ContactShort.contactNo, label=fromMaybe "-" c.ContactShort.name, icon=Just (contactIcon c),expanded=False,children=[]} \\ c <- contacts]
select _ [0] = []
select _ [s] = [if (s > 0) (Left s) (Right (~s))]
select _ _ = []
manageContactInformation :: Workspace ContactNo -> Task ()
manageContactInformation ws contactNo
......
......@@ -144,7 +144,7 @@ where
>&> withSelection viewNoSelection manageContactAccess
)<<@ ArrangeWithSideBar 0 LeftSide 200 True
viewNoSelection = return () //FIXME
viewNoSelection = viewInformation "Select a user" [] ()
addUser
= enterInformation (Title "Add user") []
>>? \newUser -> (createContact newUser @! ())
......@@ -156,9 +156,8 @@ where
) (\_ -> viewInformation "Failed to import contacts" [] ())
) <<@ Title "Import contacts"
where
instructions = toString (PTag [] [Text "Please select a CSV file to upload.",BrTag []
,Text "The file needs to be formatted like ",ATag [HrefAttr "/demo-content/contacts.csv",TargetAttr "_blank"] [Text "this example file"]
])
instructions = "Please select a CSV file to upload.\n" +++
"The file needs to be formatted like the example /demo-content/contacts.csv file."
setAdminPassword = (
enterPasswords -&&- get adminPassword
......
......@@ -54,15 +54,15 @@ where
doAuthenticated :: (User -> Task a) -> Task a | iTask a
doAuthenticated task
= ( enterCredentials
= ( enterCredentials
>>* [OnAction (Action "Login")
(hasValue (\cred -> verifyCredentials cred >>- executeTask task))
] ) /*<<@ Title "Login"*/ <<@ ApplyLayout (beforeStep frameCompact) //Compact layout before login, full screen afterwards
] ) <<@ ApplyLayout (beforeStep (sequenceLayouts (setUIAttributes (titleAttr "Login")) frameCompact)) //Compact layout before login, full screen afterwards
where
enterCredentials :: Task Credentials
enterCredentials
= viewInformation () [] (DivTag [ClassAttr "identify-app",StyleAttr "width: 350px; height: 55px; margin-bottom: 5px"] [])
||- enterInformation (Title "Log in") []
||- enterInformation () []
verifyCredentials :: Credentials -> Task (Maybe User)
verifyCredentials credentials=:{Credentials|username,password}
......
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title></title>
<link rel="stylesheet" href="/css/itasks-theme-gray.css" type="text/css" >
<!-- Default iTasks styles -->
<link rel="stylesheet" href="/theme.css" type="text/css" >
<!-- Additional Incidone css -->
<link rel="stylesheet" href="/Incidone.css" type="text/css" >
<!-- Sapl dependencies -->
<script type="text/javascript" src="/js/sapl-utils.js"></script>
......@@ -25,8 +25,6 @@
<script type="text/javascript" src="/js/itasks-components-container.js"></script>
<script type="text/javascript" src="/js/itasks-js-interface.js"></script>
<!-- Additional Incidone css -->
<link rel="stylesheet" href="/Incidone.css" type="text/css" >
<!-- load iTasks viewport -->
<script type="text/javascript">
......
$canvas-base-color: #eeeeee;
$canvas-text-color: #000000;
$panel-header-base-color: #fb7322;
$panel-header-text-color: #ffffff;
$panel-border-color: #fb7322;
$window-header-base-color: #004584;
$window-header-text-color: #ffffff;
$window-border-color: #fb7322;
$button-base-color: $canvas-base-color;
$button-text-color: $canvas-text-color;
$tab-base-color: $canvas-base-color;
$tab-text-color: $canvas-text-color;
$tab-border-color: #ccc;
$select-base-color: #004584;
$select-text-color: #ffffff;
//Style the user interface for use on a touch screen
//For example, larger buttons and controls
$touchscreen: true
/* Icon definitions */
.icon-help {
background-image: url('icons/help.png');
}
.icon-hint {
background-image: url('icons/information.png') !important;
}
.icon-valid {
background-image: url('icons/accept.png') !important;
}
.icon-warning {
background-image: url('icons/warning.png') !important;
}
.icon-invalid {
background-image: url('icons/exclamation.png') !important;
}
.icon-continue {
background-image: url('icons/arrow_right.png');
}
.icon-login, .icon-log-in {
background-image: url('icons/tick.png');
}
.icon-logout, .icon-log-out {
background-image: url('icons/door_in.png');
}
.icon-view {
background-image: url('icons/page.png') !important;
}
.icon-edit {
background-image: url('icons/pencil.png') !important;
}
.icon-delete {
background-image: url('icons/trash.png') !important;
}
.icon-refresh {
background-image: url('icons/refresh.png') !important;
}
.icon-up {
background-image: url('icons/move-up.png') !important;
}
.icon-down {
background-image: url('icons/move-down.png') !important;
}
.icon-add, .icon-new {
background-image: url('icons/add.png') !important;
}
.icon-remove {
background-image: url('icons/delete.png') !important;
}
.icon-ok {
background-image: url('icons/tick.png') !important;
}
.icon-cancel {
background-image: url('icons/cancel.png') !important;
}
.icon-open {
background-image: url('icons/document-open.png') !important;
}
.icon-save {
background-image: url('icons/document-save.png') !important;
}
.icon-close {
background-image: url('icons/cancel.png') !important;
}
.icon-previous {
background-image: url('icons/arrow_left.png') !important;
}
.icon-next {
background-image: url('icons/arrow_right.png') !important;
}
.icon-preferences {
background-image: url('icons/cog.png') !important;
}
//Style the user interface for use on a touch screen
//For example, larger buttons and controls
$touchscreen: false
/* Icon definitions */
.icon-help {
background-image: url('#{$icon-path}help.png');
}
.icon-info {
background-image: url('#{$icon-path}information.png') !important;
}
.icon-valid {
background-image: url('#{$icon-path}accept.png') !important;
}
.icon-warning {
background-image: url('#{$icon-path}warning.png') !important;
}
.icon-invalid {
background-image: url('#{$icon-path}exclamation.png') !important;
}
.icon-continue {
background-image: url('#{$icon-path}arrow_right.png');
}
.icon-login, .icon-log-in {
background-image: url('#{$icon-path}tick.png');
}
.icon-logout, .icon-log-out {
background-image: url('#{$icon-path}door_in.png');
}
.icon-view {
background-image: url('#{$icon-path}page.png') !important;
}
.icon-edit {
background-image: url('#{$icon-path}pencil.png') !important;
}
.icon-delete {
background-image: url('#{$icon-path}trash.png') !important;
}
.icon-refresh {
background-image: url('#{$icon-path}refresh.png') !important;
}
.icon-up {
background-image: url('#{$icon-path}move-up.png') !important;
}
.icon-down {
background-image: url('#{$icon-path}move-down.png') !important;
}
.icon-add, .icon-new {
background-image: url('#{$icon-path}add.png') !important;
}
.icon-remove {
background-image: url('#{$icon-path}delete.png') !important;
}
.icon-ok {
background-image: url('#{$icon-path}tick.png') !important;
}
.icon-cancel {
background-image: url('#{$icon-path}cancel.png') !important;
}
.icon-open {
background-image: url('#{$icon-path}document-open.png') !important;
}
.icon-save {
background-image: url('#{$icon-path}document-save.png') !important;
}
.icon-close {
background-image: url('#{$icon-path}cancel.png') !important;
}
.icon-previous {
background-image: url('#{$icon-path}arrow_left.png') !important;
}
.icon-next {
background-image: url('#{$icon-path}arrow_right.png') !important;
}
.icon-preferences {
background-image: url('#{$icon-path}cog.png') !important;
}
.#{$prefix}button {
@if $touchscreen {
font-size: 24px;
padding: 10px;
font-weight: bold;
}
@else {
font-size: 8pt;
padding: 3px;
}
background: -moz-linear-gradient(top, $button-base-color + #101010, $button-base-color);
background: -webkit-linear-gradient(top, $button-base-color + #101010, $button-base-color);
background-repeat: none;
border: 1px solid ($button-base-color - #333);
border-radius: 3px;
display: flex;
display: -webkit-flex;
flex-direction: row;
-webkit-flex-direction: row;
align-items: center;
-webkit-align-items: center;
text-decoration: none;
color: $button-text-color;
flex-shrink: 0;
&:hover {
border-color: $button-base-color - #333;
}
}
.#{$prefix}button-label {
margin: 0 4px;
@if not $touchscreen {
height: 16px;
}
}
.#{$prefix}button-icon {
width: 16px;
height: 16px;
}
.#{$prefix}button-disabled {
color: $button-text-color + #aaa;
background: -moz-linear-gradient(top, $button-base-color + #101010, $button-base-color - #222);
background: -webkit-linear-gradient(top, $button-base-color + #101010, $button-base-color - #222);
}
.#{$prefix}button-disabled:hover {
border-color: $button-base-color - #333;
}
.#{$prefix}button-disabled .#{$prefix}button-icon {
opacity: 0.5;
}
.#{$prefix}icon {
width: 16px;
height: 16px;
}
.#{$prefix}button {
@if $touchscreen {
font-size: 24px;
padding: 10px;
font-weight: bold;
}
@else {
font-size: 8pt;
padding: 3px;
}
background: -moz-linear-gradient(top, $button-base-color + #101010, $button-base-color);
background: -webkit-linear-gradient(top, $button-base-color + #101010, $button-base-color);
background-repeat: none;
border: 1px solid ($button-base-color - #333);
border-radius: 3px;
display: flex;
display: -webkit-flex;
flex-direction: row;
align-items: center;
text-decoration: none;
color: $button-text-color;
flex-shrink: 0;
&:hover {
border-color: $button-base-color - #333;
}
}
.#{$prefix}button-label {
margin: 0 4px;
@if not $touchscreen {
height: 16px;
}
}
.#{$prefix}button-icon {
width: 16px;
height: 16px;
}
.#{$prefix}button-disabled {
color: $button-text-color + #aaa;
background: -moz-linear-gradient(top, $button-base-color + #101010, $button-base-color - #222);
background: -webkit-linear-gradient(top, $button-base-color + #101010, $button-base-color - #222);
}
.#{$prefix}button-disabled:hover {
border-color: $button-base-color - #333;
}
.#{$prefix}button-disabled .#{$prefix}button-icon {
opacity: 0.5;
}
/* Styles for unlayouted content */
.#{$prefix}raw-record
, .#{$prefix}raw-cons
, .#{$prefix}raw-var-cons
, .#{$prefix}raw-interact
, .#{$prefix}