Skip to content
Snippets Groups Projects
Commit 2611438e authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] server control

parent 9ce898e0
No related branches found
No related tags found
No related merge requests found
......@@ -100,19 +100,31 @@ var killer; // killer timeout
// --------------------------------------------------------------------------
export const buffer = new Buffer({ maxlines: 200 });
export const feedback = '' ;
// --------------------------------------------------------------------------
// --- Server Status
// --------------------------------------------------------------------------
/**
@summary Current Server `STATUS`.
@summary Current Server Status.
@return {STATUS} the current server status
@description
See [STATUS](module-frama-c_server.html#~STATUS) code definitions.
*/
export function getStatus() { return status; }
/**
@summary Hook on current server (Custom React Hook).
@return {STATUS} the current server status
@description
See [STATUS](module-frama-c_server.html#~STATUS) code definitions.
*/
export function useStatus() {
Dome.useUpdate(STATUS);
return status;
}
/** Return `FAILED` status message. */
export function getError() { return error; }
......@@ -443,6 +455,7 @@ function _close(error) {
if (error) {
_status(FAILED,error);
} else {
if (status === RESTART) setImmediate(start);
_status(IDLE);
}
}
......@@ -630,7 +643,8 @@ function _receive(resp) {
export default {
configure, buffer,
getStatus, getError, getPending, isRunning,
getStatus, useStatus,
getError, getPending, isRunning,
start, stop, kill, restart, clear,
sendGET, sendSET, sendEXEC,
onReady, onShutdown,
......
......@@ -35,7 +35,7 @@ export const PROJECT = 'frama-c.project' ;
export const STATE = 'frama-c.state.' ;
// --------------------------------------------------------------------------
// --- Current Project
// --- Synchronized Current Project
// --------------------------------------------------------------------------
var currentProject = undefined ;
......@@ -48,6 +48,12 @@ Server.onReady(() => {
});
});
Server.onShutdown(() => {
currentProject = undefined ;
globalStates = {} ;
Dome.emit(PROJECT);
});
// --------------------------------------------------------------------------
// --- Project API
// --------------------------------------------------------------------------
......
......@@ -34,6 +34,7 @@ export default (function() {
selected={sidebar}
onClick={flipSidebar}
/>
<Controller.Control/>
<Toolbar.Filler/>
<Toolbar.Button
icon='ITEMS.GRID'
......
......@@ -7,7 +7,7 @@ import Dome from 'dome' ;
import Server from 'frama-c/server' ;
import States from 'frama-c/states' ;
import { Filler, Button } from 'dome/layout/toolbars' ;
import { Filler, Button, ButtonGroup } from 'dome/layout/toolbars' ;
import { LED } from 'dome/controls/buttons' ;
import { Label, Code } from 'dome/controls/labels' ;
import { Text } from 'dome/text/editors' ;
......@@ -39,6 +39,36 @@ Dome.onCommand((argv,cwd) => {
Server.start();
});
// --------------------------------------------------------------------------
// --- Server Control
// --------------------------------------------------------------------------
export const Control = () => {
let status = Server.useStatus();
let play = { enabled: false } ;
let stop = { enabled: false } ;
let reload = { enabled: false } ;
switch(status) {
case 'IDLE':
play = { enabled: true, onClick:Server.start };
break;
case 'RUNNING':
stop = { enabled: true, onClick:Server.stop };
reload = { enabled: true, onClick:Server.restart };
break;
}
return (
<ButtonGroup>
<Button icon='MEDIA.PLAY' {...play}
title='Start the server' />
<Button icon='RELOAD' {...reload}
title='Re-start the server' />
<Button icon='MEDIA.STOP' {...stop}
title='Shut down the server'/>
</ButtonGroup>
);
};
// --------------------------------------------------------------------------
// --- Server Console
// --------------------------------------------------------------------------
......@@ -109,6 +139,6 @@ export const Stats = () => {
// --- Controller Exports
// --------------------------------------------------------------------------
export default { Console, Status, Stats };
export default { Control, Console, Status, Stats };
// --------------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment