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

Started to restore incidone

parent 9e596270
implementation module Incidone.Configuration
import iTasks, iTasks.API.Extensions.SQLDatabase
import iTasks, iTasks.API.Extensions.SQLDatabase, iTasks.API.Extensions.Web
derive class iTask DBConfig, AISConfig, AsteriskConfig, SMTPConfig, WebLinksConfig, WebLink
......
implementation module Incidone.ContactPosition
import iTasks, iTasks.UI.Editor, iTasks.UI.Editor.Builtin, iTasks.UI.Editor.Combinators, iTasks.UI.Definition
import qualified Data.Map as DM
import Data.Functor, Text
import Data.Functor, Data.List, Text
import qualified Text.Parsers.ZParsers.ParsersKernel as PK
import qualified Text.Parsers.ZParsers.ParsersDerived as PD
import qualified Control.Applicative as CA
from Control.Applicative import class Alternative, class Applicative
from Text.Parsers.ZParsers.ParsersKernel import :: Parser, instance Alternative Parser, instance Applicative Parser, instance Functor Parser
import iTasks.API.Extensions.GIS.LeafletNavalIcons
import Incidone.OP.Concepts
import Incidone.Util.TaskPatterns
......@@ -133,20 +134,21 @@ hasLatLng _ = False
toLeafletMap :: ContactMap -> LeafletMap
toLeafletMap {ContactMap|perspective,layers}
= {LeafletMap|perspective = toLeafletPerspective perspective
,icons = [icon i \\ i <- [1..250]]
,layers = map toLeafletLayer layers
,tilesUrl = tilesUrl layers
,icons = shipIcons
,objects = []
}
where
tilesUrl layers = listToMaybe [url \\ {ContactMapLayer|def=CMTileLayer url} <- layers]
convMarkers markers = [conv m \\ m=:{ContactMapMarker|position} <- markers | hasLatLng position]
conv {ContactMapMarker|markerId,title,position,heading,type,selected}
= Marker {LeafletMarker|markerId = markerId, title = title, position = pos position, icon = fmap (\t -> iconIndex heading t selected) type, selected = selected}
= Marker {LeafletMarker|markerId = markerId, title = title, position = pos position, icon = Nothing /* fmap (\t -> iconIndex heading t selected) type */, selected = selected}
pos (PositionLatLng (lat,lng)) = {LeafletLatLng|lat=lat,lng=lng}
pos (PositionDescription _ (Just(lat,lng))) = {LeafletLatLng|lat=lat,lng=lng}
icon i = {LeafletIcon|iconUrl ="/ship-icons/"+++toString i+++".png",iconSize=(24,24)}
iconIndex heading type selected = (cat type + ( (maybe 24 (\d -> d / 15) heading) + (if selected 25 0)) * 5)
/*
toLeafletLayer :: ContactMapLayer -> LeafletLayer
toLeafletLayer {ContactMapLayer|def=CMTileLayer url} = TileLayer url
toLeafletLayer {ContactMapLayer|def=CMRegionsLayer regions}
......@@ -177,6 +179,7 @@ where
pos (PositionDescription _ (Just(lat,lng))) = {LeafletLatLng|lat=lat,lng=lng}
iconIndex heading type selected = (cat type + ( (maybe 24 (\d -> d / 15) heading) + (if selected 25 0)) * 5)
*/
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
toLeafletPerspective {ContactMapPerspective|center,zoom,cursor,bounds}
......@@ -192,13 +195,14 @@ fromLeafletMap :: ContactMap LeafletMap -> ContactMap
fromLeafletMap contactMap leafletMap
= {ContactMap|contactMap
&perspective = fromLeafletPerspective leafletMap.LeafletMap.perspective
,layers = [fromLeafletLayer cl ll \\ cl <- contactMap.ContactMap.layers & ll <- leafletMap.LeafletMap.layers]
/*,layers = [fromLeafletLayer cl ll \\ cl <- contactMap.ContactMap.layers & ll <- leafletMap.LeafletMap.layers]*/
}
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
fromLeafletPerspective {LeafletPerspective|center,cursor,zoom,bounds}
= {ContactMapPerspective|center=fromLeafletLatLng center,zoom=zoom,cursor=fmap fromLeafletLatLng cursor,bounds=fmap fromLeafletBounds bounds}
/*
fromLeafletLayer :: ContactMapLayer LeafletLayer -> ContactMapLayer
fromLeafletLayer cl=:{ContactMapLayer|def=CMMarkersLayer markers} (ObjectLayer objects)
= {ContactMapLayer|cl & def = CMMarkersLayer (map updateMarker markers)}
......@@ -209,12 +213,10 @@ where
indexedLeafletMarkers = 'DM'.fromList [(markerId,m) \\ Marker m=:{LeafletMarker|markerId} <- objects]
fromLeafletLayer cl ll = cl
*/
selectionFromLeafletMap :: LeafletMap -> [String]
selectionFromLeafletMap {LeafletMap|layers} = flatten (map selection layers)
where
selection (ObjectLayer markers) = [markerId \\ Marker {LeafletMarker|markerId,selected} <- markers | selected]
selection _ = []
selectionFromLeafletMap {LeafletMap|objects} = [markerId \\ Marker {LeafletMarker|markerId,selected} <- objects | selected]
fromLeafletLatLng :: !LeafletLatLng -> (!Real,!Real)
fromLeafletLatLng {LeafletLatLng|lat,lng} = (lat,lng)
......
......@@ -22,7 +22,7 @@ selectContact = withShared Nothing
(selectContactFromLists sel <<@ Title "Browse")
-||-
(viewContactsOnMap mapContacts sel <<@ Title "Map")
<<@ LazyRefresh <<@ ArrangeWithTabs
<<@ ArrangeWithTabs
)
where
mapContacts = mapRead (\(x,y) -> x++y) (contactsOfOpenIncidentsGeo |+| contactsProvidingHelpGeo)
......
......@@ -12,6 +12,7 @@ import Incidone.ActionManagementTasks
import Incidone.Util.TaskPatterns
import iTasks.API.Extensions.Admin.ServerAdmin
import iTasks.API.Extensions.Dashboard
import iTasks.UI.Layout, iTasks.UI.Definition
import Text.HTML
:: DatabaseProblem
......@@ -221,10 +222,11 @@ configureMaps
where
previewMapLayers :: Task ContactMapPerspective
previewMapLayers = withShared defaultValue
\perspective -> updateSharedInformation (Title "Preview") [UpdateAs toPrj fromPrj] (perspective >+| standardMapLayers) @ fst /* <<@ AfterLayout (tweakUI fill) */ //FIXME
\perspective -> updateSharedInformation (Title "Preview") [UpdateAs toPrj fromPrj] (perspective >*| standardMapLayers) <<@ ApplyLayout flexMap @ fst
where
toPrj (perspective,layers) = toLeafletMap {ContactMap|defaultValue & perspective=perspective,layers=layers}
fromPrj _ {LeafletMap|perspective} = fromLeafletPerspective perspective
flexMap = layoutSubUIs (SelectByPath [1]) (setUIAttributes (sizeAttr FlexSize FlexSize))
configureWebLinks :: Task ()
configureWebLinks
......
......@@ -27,7 +27,7 @@ browseCommunications ws
] @! ()
where
selectCommunication
= enterChoiceWithSharedAs [Att (Icon "communication"),Att (Title "Communication")] [] allCommunications communicationIdentity
= enterChoiceWithSharedAs [Att (Icon "communication"),Att (Title "Communication")] [ChooseFromGrid id] allCommunications communicationIdentity
openCommunication ws communicationNo
= addToWorkspace ((doOrClose (updateCommunication communicationNo)) <<@ InWindow) ws @! ()
......@@ -52,15 +52,15 @@ browseIncidents ws
]
)
( withSelection viewNoSelection viewIncidentDetails
) <<@ LazyRefresh <<@ (ArrangeWithSideBar 1 RightSide 300 True) <<@ (Icon "incidents") <<@ (Title "Incidents")
) <<@ (ArrangeWithSideBar 1 RightSide 300 True) <<@ (Icon "incidents") <<@ (Title "Incidents")
@! ()
where
selectIncident
= ( (enterChoiceWithSharedAs (Title "Open incidents")
[] openIncidentsDetails (\{IncidentDetails|incidentNo} -> incidentNo) /* <<@ AfterLayout (tweakUI fill) */) //FIXME
[ChooseFromGrid id] openIncidentsDetails (\{IncidentDetails|incidentNo} -> incidentNo) /* <<@ AfterLayout (tweakUI fill) */) //FIXME
-||-
(enterChoiceWithSharedAs (Title "Recent incidents")
[] recentIncidentsDetails (\{IncidentDetails|incidentNo} -> incidentNo) /* <<@ AfterLayout (tweakUI fill) */) //FIXME
[ChooseFromGrid id] recentIncidentsDetails (\{IncidentDetails|incidentNo} -> incidentNo) /* <<@ AfterLayout (tweakUI fill) */) //FIXME
) <<@ ArrangeWithTabs
browseContacts :: Workspace -> Task ()
......@@ -74,7 +74,7 @@ browseContacts ws
]
)
( withSelection viewNoSelection viewDetails
) <<@ LazyRefresh <<@ (ArrangeWithSideBar 1 RightSide 300 True) <<@ (Icon "contacts") <<@ (Title "Contacts")
) <<@ (ArrangeWithSideBar 1 RightSide 300 True) <<@ (Icon "contacts") <<@ (Title "Contacts")
@! ()
where
viewDetails (Left contactNo) = viewContactDetails contactNo
......
implementation module Incidone.Util.Notification
import iTasks
from iTasks._Framework.Util import datetimeToTimestamp
import Text
import Incidone.Util.TaskPatterns
......@@ -9,11 +10,13 @@ notifications = sharedStore "notifications" []
//Only show notifications added in the last 5 seconds
currentNotifications :: ReadOnlyShared [String]
currentNotifications = mapRead prj (currentDateTime |+| notifications)
currentNotifications = mapRead prj (currentDateTime |*| notifications)
where
prj (now,notifications) = [msg \\ (dt,msg) <- notifications /* | now - dt < limit*/]
//limit = DateTime {Date|day=0,mon=0,year=0} {Time|hour=0,min=0,sec=5}
prj (now,notifications) = [toString dt +++ msg \\ (dt,msg) <- notifications | limit now dt ]
limit t1 t2
# (Timestamp s1) = datetimeToTimestamp t1
# (Timestamp s2) = datetimeToTimestamp t2
= s1 - s2 < 3
addNotification :: String -> Task ()
addNotification msg
......
......@@ -57,7 +57,7 @@ doAuthenticated task
= ( enterCredentials
>>* [OnAction (Action "Login")
(hasValue (\cred -> verifyCredentials cred >>- executeTask task))
] ) <<@ Title "Login" <<@ ApplyLayout (beforeStep frameCompact) //Compact layout before login, full screen afterwards
] ) /*<<@ Title "Login"*/ <<@ ApplyLayout (beforeStep frameCompact) //Compact layout before login, full screen afterwards
where
enterCredentials :: Task Credentials
enterCredentials
......@@ -94,7 +94,7 @@ where
[moveSubUIs (SelectByPath [0,0]) [] 1
,moveSubUIs (SelectByPath [0,0]) [] 2
,removeSubUIs (SelectByPath [0])
,layoutSubUIs SelectChildren actionToButton
,layoutSubUIs (SelectByType UIAction) actionToButton
,setUIAttributes ('DM'.unions [directionAttr Horizontal,paddingAttr 2 2 2 250, baseClsAttr "summary-bar"])
,setUIType UIPanel
,setUIType UIContainer
]
<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" >
<!-- Sapl dependencies -->
<script type="text/javascript" src="/js/sapl-utils.js"></script>
<script type="text/javascript" src="/js/sapl-builtin.js"></script>
<script type="text/javascript" src="/js/sapl-dynamic.js"></script>
<script type="text/javascript" src="/js/sapl-itasks.js"></script>
<script type="text/javascript" src="/js/sapl-rt.js"></script>
<script type="text/javascript" src="/js/sapl-support.js"></script>
<!-- iTasks framework -->
<script type="text/javascript" src="/js/itasks-core.js"></script>
<script type="text/javascript" src="/js/itasks-components-raw.js"></script>
<script type="text/javascript" src="/js/itasks-components-form.js"></script>
<script type="text/javascript" src="/js/itasks-components-display.js"></script>
<script type="text/javascript" src="/js/itasks-components-selection.js"></script>
<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">
window.onload = function() {
itasks.viewport({syncTitle: true}, document.body);
};
</script>
</head>
<body style="width: 100%; height: 100%">
</body>
</html>
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