From: Mart Lubbers Date: Tue, 14 Feb 2017 17:16:50 +0000 (+0100) Subject: layout is working, now up to the communication X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=68e65ffa79b10fc6762a0f7989a268126fc20c1b;p=mTask.git layout is working, now up to the communication --- diff --git a/miTask.icl b/miTask.icl index 9af815e..efff14d 100644 --- a/miTask.icl +++ b/miTask.icl @@ -69,38 +69,43 @@ derive class iTask MTaskDeviceStatus, MTaskDevice mTaskManager :: Task () mTaskManager = anyTask [ viewmTasks @! () + , viewShares , whileUnchanged deviceStore viewDevices - , addDevice deviceStore - , viewChannels deviceStore ] <<@ ApplyLayout layout -// ||- whileUnchanged deviceStore (\m->if (isEmpty m) -// (viewInformation "No devices yet" [] "" @! ()) (connectDevice m)) @! () -// ) where isValue (Value _ _) = True isValue _ = False - viewmTasks = viewInformation "MTasks" [] "" + viewmTasks = enterChoice "Available mTasks" [ChooseFromList id] ["ledder", "ledon", "ledoff"] + >>= viewInformation "" [] layout = sequenceLayouts [ arrangeWithSideBar 0 LeftSide 260 True , arrangeSplit Vertical True - , layoutSubs (SelectByPath [1, 0]) arrangeWithTabs ] - viewChannels :: (Shared [MTaskDevice]) -> Task () - viewChannels sh = whileUnchanged sh (\d->if (isEmpty d) - (viewInformation "No channels yet" [] "") - (viewInformation "Channels available" [] "")) @! () + viewShares :: Task () + viewShares = viewInformation () [] () - viewDevices :: [MTaskDevice] -> [Task ()] - viewDevices [] = viewInformation "No devices yet" [] "" @! () - viewDevices ds = [viewInformation "Device" [] d <<@ Title d.deviceName\\d<-ds] + viewDevices :: [MTaskDevice] -> Task () + viewDevices ds = anyTask [ + addDevice deviceStore <<@ Title "Add new device" @! (): + [viewDevice d <<@ Title d.deviceName\\d<-ds]] + <<@ ArrangeWithTabs @! () + + viewDevice :: MTaskDevice -> Task () + viewDevice d = (viewInformation "Device settings" [] d + ||- (case d.deviceConnected of + Just s = viewSharedInformation "Channels" [] (channels d.deviceName) @! () + Nothing = viewInformation "No channels yet" [] "" @! () + )) <<@ ArrangeHorizontal + + channels :: String -> Shared Channels + channels s = sdsFocus s $ memoryStore "" $ Just ([], [], False) addDevice :: (Shared [MTaskDevice]) -> Task () addDevice devices = enterInformation "Device type and name" [] - >>= \(name, ty)->get randomInt - >>= \ident->treturn (name +++ toString ident) + >>= \(name, ty)->get randomInt @ ((+++) name o toString) >>= \realname->let ch = channels realname in case ty of TCPDevice = enterInformation "Hostname and port" [] >>= \(host, port)->cont realname name ||- syncNetworkChannel host port ch @@ -111,9 +116,6 @@ mTaskManager = anyTask cont rn nm = (upd (\l->[dev rn nm:l]) devices >>| addDevice devices) dev rn nm = {deviceConnected=Just rn,deviceName=nm} - channels :: String -> Shared Channels - channels s = sdsFocus s $ memoryStore "" $ Just ([], [], False) - getDevices :: !*World -> *(![String], !*World) getDevices w = case readDirectory "/dev" w of (Error (errcode, errmsg), w) = abort errmsg