Adds terminal resizing on hosts.

Adds terminal resizing on popped out windows
This commit is contained in:
Simon Howe
2016-10-31 18:11:10 +01:00
parent 305bf7680a
commit 487635cb62
6 changed files with 17 additions and 11 deletions

View File

@@ -580,16 +580,17 @@ export function receiveControlNodeRemoved(nodeId) {
};
}
export function receiveControlPipeFromParams(pipeId, rawTty) {
export function receiveControlPipeFromParams(pipeId, rawTty, resizeTtyControl) {
// TODO add nodeId
return {
type: ActionTypes.RECEIVE_CONTROL_PIPE,
pipeId,
rawTty
rawTty,
resizeTtyControl
};
}
export function receiveControlPipe(pipeId, nodeId, rawTty) {
export function receiveControlPipe(pipeId, nodeId, rawTty, resizeTtyControl) {
return (dispatch, getState) => {
const state = getState();
if (state.get('nodeDetails').last()
@@ -608,7 +609,8 @@ export function receiveControlPipe(pipeId, nodeId, rawTty) {
type: ActionTypes.RECEIVE_CONTROL_PIPE,
nodeId,
pipeId,
rawTty
rawTty,
resizeTtyControl
});
updateRoute(getState);

View File

@@ -38,7 +38,6 @@ class EmeddedTerminal extends React.Component {
const nodeId = pipe.get('nodeId');
const node = details.get(nodeId);
const d = node && node.details;
const control = d && d.controls && d.controls[0];
const titleBarColor = d && getNodeColorDark(d.rank, d.label, d.pseudo);
const statusBarColor = d && brightenColor(titleBarColor);
const title = d && d.label;
@@ -54,7 +53,6 @@ class EmeddedTerminal extends React.Component {
<Terminal
key={pipe.get('id')}
pipe={pipe}
control={control}
connect={this.state.animated}
titleBarColor={titleBarColor}
statusBarColor={statusBarColor}

View File

@@ -13,7 +13,8 @@ class TerminalApp extends React.Component {
const paramString = window.location.hash.split('/').pop();
const params = JSON.parse(decodeURIComponent(paramString));
this.props.receiveControlPipeFromParams(params.pipe.id, null, params.pipe.raw, false);
this.props.receiveControlPipeFromParams(params.pipe.id, params.pipe.raw,
params.pipe.resizeTtyControl);
this.state = {
title: params.title,

View File

@@ -261,7 +261,7 @@ class Terminal extends React.Component {
const cols = Math.floor(width / this.state.characterWidth);
const rows = Math.floor(height / this.state.characterHeight);
doResizePipe(this.getPipeId(), this.props.control, cols, rows)
doResizePipe(this.getPipeId(), this.props.pipe.get('resizeTtyControl'), cols, rows)
.then(() => this.setState({cols, rows}));
}

View File

@@ -466,7 +466,8 @@ export function rootReducer(state = initialState, action) {
return state.setIn(['controlPipes', action.pipeId], makeOrderedMap({
id: action.pipeId,
nodeId: action.nodeId,
raw: action.rawTty
raw: action.rawTty,
resizeTtyControl: action.resizeTtyControl,
}));
}

View File

@@ -232,7 +232,11 @@ export function doControlRequest(nodeId, control, dispatch) {
if (res) {
if (res.pipe) {
dispatch(blurSearch());
dispatch(receiveControlPipe(res.pipe, nodeId, res.raw_tty, true));
dispatch(receiveControlPipe(
res.pipe,
nodeId,
res.raw_tty,
{id: res.resize_tty_control, probeId: control.probeId, nodeId: control.nodeId}));
}
if (res.removedNode) {
dispatch(receiveControlNodeRemoved(nodeId));
@@ -251,7 +255,7 @@ export function doControlRequest(nodeId, control, dispatch) {
export function doResizePipe(pipeId, control, cols, rows) {
const url = `api/control/${encodeURIComponent(control.probeId)}/`
+ `${encodeURIComponent(control.nodeId)}/docker_resize_exec_tty`;
+ `${encodeURIComponent(control.nodeId)}/${control.id}`;
return reqwest({
method: 'POST',