[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
mobile[app] 04 - Mobile workspace
Description
The tool let you connect to a mobile/remote s8 server and send expressions to be evaluated by the server.
It is used to evaluate commands on mobile devices.
How to run this tool?
- Start the Cmd8 server
Note:The Cmd8 server is included as demostration of a node.js S8 server (See node framework files).
- Open the U8 environment with media tools
- Evaluate the following expression (showIt/doIt) in a workspace
SwikiCodeRobot @> 'swiki:s8-media/81'
How we built this tool?
This tool is built from a draft specificacion of the UI.
The draft is used to implement the UI as an spec of Mobile framework.
The Mobile framework is loaded in the system (if not already present) and the UI is instantiated from the spec.
The server side code is already implemented, and has been tested (but... needs more testing in real world).
The server includes a chat system where users can communicate sending texts and/or evaluating S8 code remotelly.
Draft of the UI
On server side we do not need UI nor extended functionality.
The UI for client side (user) environments has three major stages:
- Connecting to a server
- Identification (as a chat user)
- Sending texts and chunks to other users to change multiple/remote systems.
Client side UI has 5 levels of cascading:
- ConnectTo page: Let the user enter the URL of the server to access
Two fields are presented:
- Server URL with default contents of http://localhost:8080
- Nickname with default contents given by U8Configuration userName (if it exists in the systrem)
- Targets page
- Let the user define one or more targets to chat with
- Presents
- an entry with defaults to #all
- a text help explaining that the field can state nicknames separated by comma; and if #all is used will broadcast to all clients (also the sender)
- Tools page
- Present a list of tools to interact with target(s)
- The list (by now) will contain access to:
- Workspace tool >
- Chat tool >
- Workspace tool page
- Preset text to enter s8 commands to send to target(s)
- Buttons for actions (doIt, showIt, eval, fileIn), that will send actions commands to targets when pressed
- Upon reception of results from clients, the workspace selection is appended with result (and client's nickname if possible)
- Chat tool page
- Present a text edit (multiline)
- Button to send text in edit box
- upon reception of results the selection in text edit will be appended with text (and client's nickname if possible)
Note | The list of tools will grow inteh future with more remote tools like browsers, system analyzers, debuggers, etc |
Implementation
to load robot and mobile frameworks:
1- place the following js files from http://u8.smalltalking.net/profile/aleReimondo/Swiki/ and http://u8.smalltalking.net/profile/aleReimondo/Mobile/
then in image workspace:
'swiki.st.js' fileContents is not nil
Compiler new eval: 'swiki.st.js' fileContents
'Mobile.core.js' fileContents is not nil
Compiler new eval: 'Mobile.core.js' fileContents
'Mobile.st.js' fileContents is not nil
Compiler new eval: 'Mobile.st.js' fileContents
'Mobile.web.js' fileContents is not nil
Compiler new eval: 'Mobile.web.js' fileContents
'MobileDevice.st.js' fileContents is not nil
Compiler new eval: 'MobileDevice.st.js' fileContents"
"Ensure Mobile framework is loaded and verify we are running in a supported platform"
(SwikiCodeRobot @ #mobile) process: #s8-media tagged: #core.
"Ensure connectivity layer and Cmd8Client is loaded"
self require: #WebSocket.
self require: #Cmd8Client in: #( 'u8:aleReimondo/Node/Cmd8.st.js' ).
"Creating Cmd8Tool"
Smalltalk at: #WebSocket ifAbsent: [
self alert: 'WebSockets required'.
self abort
]!
Object
subclass: #Cmd8Tool
instanceVariableNames: ' targets outboundCmd answer '
category: #Cmd8 !
! Cmd8Tool methodsFor: #accessing !
answer
"Implementation note: receiver's anser could be a set of answers of many responding cmdClients"
^answer! !
! Cmd8Tool methodsFor: #accessing !
outboundCmd
" Answer receiver's outbound command"
^outboundCmd ! !
! Cmd8Tool methodsFor: #accessing !
outboundCmd: aCommand
" Set receiver's command"
"Implementation note: aCommand is a chunk, text, an expression, a javascript"
outboundCmd:= aCommand! !
! Cmd8Tool methodsFor: #accessing !
setTargets: aCollection
" Set receiver targets"
" Implementation Note: a collection of target Cmd8Clients"
targets:= aCollection! !
! Cmd8Tool methodsFor: #accessing !
source
" Implementation Note: the Cmd8Client initiating communication"
^Cmd8Client current! !
! Cmd8Tool methodsFor: #accessing !
targets
" Answer communication targets"
" Implementation Note: a collection of target Cmd8Clients"
targets isNil ifTrue: [targets:= Array new].
^targets! !
"Compiling spec and open the UI"
| spec tab |
tab := (
(#tool -> 'server' ),
(#coordinator ->
(
(#class -> #MobileEditor ),
(#configuration ->
(
(#title -> 'Mobile workspace'),
(#navigationBar -> (
(#right ->
(#add -> [:coordinator |
(coordinator @ #targets) done.
coordinator applicationModel
targets: (coordinator @ #targets ) text trimBlanks;
yourself.
coordinator thread next: (coordinator newTemplateAt: #ToolsMenu) ])
))
),
(#widgets -> (
(#cmd8Label -> (
(#type -> #label ),
(#configuration -> (
(#order -> 1 ),
(#height -> 40),
"(#backgroundColor -> 'white'),"
(#text -> 'Cmd8')",
(#color -> 'blue')"
))
)),
(#targets -> (
(#type -> #textField ),
(#configuration -> (
(#order -> 2 ),
(#height -> 40),
(#defaultText -> ''),
(#width -> 300),
(#background -> 'white'),
(#color -> 'black'),
(#keyboardType -> 'numberPad'),
(#border -> 'roundedRect'),
(#autocapitalizationType -> #none),
(#autocorrectionType -> #none),
(#spellCheckingType -> #none),
(#returnKeyType -> #done),
(#listeners -> (
(#done: -> [:coordinator :field | coordinator applicationModel targets: (coordinator @ #targets) text. ])
))
))
)),
(#separator -> (
(#type -> #line ),
(#configuration -> (
(#order -> 3 ),
(#height -> 10),
(#background -> 'blue')
))
)),
(#targetsLabel -> (
(#type -> #label ),
(#configuration -> (
(#order -> 4 ),
(#height -> 40),
"(#backgroundColor -> 'white'),"
(#text -> 'Targets')",
(#color -> 'blue')"
))
)),
(#listeners -> (
(#built: -> [:coordinator | self print: coordinator applicationModel toString.
(coordinator @ #targets) text: (coordinator applicationModel targets).
])
))
)
)
)
)
).
spec := (
(#threads -> ((1 -> tab)) ),
(#templates -> (
(#ToolsMenu -> toolsMenuView),
(#WorkspaceTool -> workspaceToolView),
(#ChatTool -> chatToolView)
)),
(#listeners -> (#needsModel -> [ Cmd8Tool new yourself. ])
(#opened -> [:application | application current coordinator application model ensureConnectivity]
)
) json.
MobileApplication open: spec.