Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
mtharrison committed May 26, 2019
1 parent 302f86a commit e3d7a46
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
11 changes: 11 additions & 0 deletions frontend/src/actions.ts
Expand Up @@ -12,6 +12,7 @@ export const UPDATE_OUTPUT = 'UPDATE_OUTPUT'
export const UPDATE_EXAMPLES = 'UPDATE_EXAMPLES'
export const SELECT_EXAMPLE = 'SELECT_EXAMPLE'
export const UPDATE_CODE = 'UPDATE_CODE'
export const CLEAR_OUTPUT = 'CLEAR_OUTPUT'

// Action interfaces

Expand Down Expand Up @@ -54,20 +55,29 @@ interface SelectExampleAction {
selected: number
}

interface ClearOutputAction {
type: typeof CLEAR_OUTPUT
}

export type Action = LockAction
| UnlockAction
| ExecuteAction
| UpdateOutputAction
| UpdateExamplesAction
| SelectExampleAction
| UpdateCodeAction
| ClearOutputAction

// Action creators

export function lock(): Action {
return { type: LOCK };
}

export function clearOuput(): Action {
return { type: CLEAR_OUTPUT };
}

export function updateCode(code: string): Action {
return { type: UPDATE_CODE, code };
}
Expand Down Expand Up @@ -105,6 +115,7 @@ export const execute = (code: string) => (dispatch: Dispatch) => {

dispatch({ type: EXECUTE });
dispatch(lock());
dispatch(clearOuput());

fetch('/execute', {
method: 'POST',
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/editor.tsx
Expand Up @@ -21,6 +21,11 @@ class Editor extends React.Component<EditorProps> {
this.editor.setHighlightActiveLine(false);
this.editor.setShowPrintMargin(false);

this.editor.setOptions({
fontFamily: 'monospace',
fontSize: '14px'
});

let metaDown = false;
let enterDown = false;

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/header.tsx
Expand Up @@ -15,8 +15,7 @@ const Header = (props: HeaderProps) => {
<a href={props.url}><img width="80px" src="/images/deno.svg" alt={props.name}/></a>
<a href={props.url}><h1>{props.name}</h1></a>
<ul>
<li><a href="http://" target="_blank" rel="noopener noreferrer">About</a></li>
<li><a href="http://" target="_blank" rel="noopener noreferrer">Contribute</a></li>
<li><a href="https://github.com/mtharrison/deno-playground" target="_blank" rel="noopener noreferrer">Contribute</a></li>
</ul>
</header>
);
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/state.ts
@@ -1,7 +1,7 @@
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'

import { Action, Example, LOCK, UNLOCK, UPDATE_OUTPUT, UPDATE_EXAMPLES, SELECT_EXAMPLE, UPDATE_CODE } from './actions'
import { Action, Example, LOCK, UNLOCK, UPDATE_OUTPUT, UPDATE_EXAMPLES, SELECT_EXAMPLE, UPDATE_CODE, CLEAR_OUTPUT } from './actions'

export interface ApplicationState {
output: string,
Expand Down Expand Up @@ -40,6 +40,8 @@ function reducer(state = defaultState, action: Action): ApplicationState {
return Object.assign({}, state, { selectedExample: action.selected });
case UPDATE_CODE:
return Object.assign({}, state, { code: action.code });
case CLEAR_OUTPUT:
return Object.assign({}, state, { output: '// loading...' });
default:
return state;
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/static/examples/examples.json
Expand Up @@ -6,5 +6,9 @@
{
"name": "Set Timeout Timer",
"file": "set-timeout-timer.ts"
},
{
"name": "Load /etc",
"file": "load-etc.ts"
}
]
14 changes: 14 additions & 0 deletions frontend/static/examples/load-etc.ts
@@ -0,0 +1,14 @@
async function main() {

// create subprocess

const p = Deno.run({
args: ["ls", "-al", "/etc"]
});

// await its completion

await p.status();
}

main();
2 changes: 1 addition & 1 deletion frontend/static/js/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/static/js/bundle.js.map

Large diffs are not rendered by default.

0 comments on commit e3d7a46

Please sign in to comment.