Commit c69bea51 authored by Carlos Herrero's avatar Carlos Herrero

Merge branch 'development' into 'master'

Development

See merge request !1
parents d620a081 43415c9f
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
Popover, Popover,
Position, Position,
Avatar, Avatar,
Portal,
Button, Button,
toaster, toaster,
CornerDialog, CornerDialog,
...@@ -16,12 +15,6 @@ import { ...@@ -16,12 +15,6 @@ import {
import { import {
FullCircleIcon, FullCircleIcon,
UngroupObjectsIcon, UngroupObjectsIcon,
RefreshIcon,
SwapVerticalIcon,
FullscreenIcon,
MinimizeIcon,
LogOutIcon,
CogIcon,
ErrorIcon, ErrorIcon,
DisableIcon, DisableIcon,
} from 'evergreen-ui'; } from 'evergreen-ui';
...@@ -132,7 +125,6 @@ const Console = (props: RouteComponentProps) => { ...@@ -132,7 +125,6 @@ const Console = (props: RouteComponentProps) => {
const _t = sessionStorage.getItem(Config.jwt.tokenName); const _t = sessionStorage.getItem(Config.jwt.tokenName);
if (_t === null) { if (_t === null) {
toaster.danger(t('console:web_socket_expire')); toaster.danger(t('console:web_socket_expire'));
// setConnecting(ConnStatus.ConnectionLost)
props.history.push('/signin'); props.history.push('/signin');
return; return;
} }
...@@ -153,11 +145,26 @@ const Console = (props: RouteComponentProps) => { ...@@ -153,11 +145,26 @@ const Console = (props: RouteComponentProps) => {
setConnecting(ConnStatus.ConnectionAlive); setConnecting(ConnStatus.ConnectionAlive);
}; };
ws.onclose = () => { ws.onclose = (ev) => {
term.setOption('cursorBlink', false); term.setOption('cursorBlink', false);
sessionStorage.removeItem(Config.jwt.tokenName); sessionStorage.removeItem(Config.jwt.tokenName);
setConnecting(ConnStatus.ConnectionLost); setConnecting(ConnStatus.ConnectionLost);
setShowCornerDialog(true); setShowCornerDialog(true);
send(ev);
};
const send = (e: CloseEvent) => {
e.preventDefault();
if (window && window.parent) {
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
}; };
sshWebSocket.bindTerminal(term, ws!, true, -1); sshWebSocket.bindTerminal(term, ws!, true, -1);
...@@ -219,16 +226,6 @@ const Console = (props: RouteComponentProps) => { ...@@ -219,16 +226,6 @@ const Console = (props: RouteComponentProps) => {
</Menu.Item> </Menu.Item>
</Menu.Group> </Menu.Group>
<Menu.Divider /> <Menu.Divider />
<Menu.Group>
<Menu.Item
icon={LogOutIcon}
intent="danger"
onSelect={() => {
toaster.notify('under develop!', { id: 'dev' });
}}>
{t('console:nav_user_exit')}
</Menu.Item>
</Menu.Group>
</Menu> </Menu>
}> }>
<Avatar <Avatar
...@@ -266,14 +263,6 @@ const Console = (props: RouteComponentProps) => { ...@@ -266,14 +263,6 @@ const Console = (props: RouteComponentProps) => {
<Button intent="success" onClick={() => setSideSheetShwon(true)}> <Button intent="success" onClick={() => setSideSheetShwon(true)}>
SFTP SFTP
</Button> </Button>
<Button
intent="none"
marginLeft="0.05rem"
onClick={() => {
toaster.notify('under develop!', { id: 'dev' });
}}>
Paste
</Button>
<Pane flex="1"></Pane> <Pane flex="1"></Pane>
<Text marginRight="0.4rem">active time: 0:00:00</Text> <Text marginRight="0.4rem">active time: 0:00:00</Text>
</Pane> </Pane>
...@@ -295,55 +284,6 @@ const Console = (props: RouteComponentProps) => { ...@@ -295,55 +284,6 @@ const Console = (props: RouteComponentProps) => {
onCloseComplete={() => setShowCornerDialog(false)}> onCloseComplete={() => setShowCornerDialog(false)}>
{t('console:ssh_disconn_dialog_text')} {t('console:ssh_disconn_dialog_text')}
</CornerDialog> </CornerDialog>
<Portal>
<Pane
className="toolbar"
zIndex={10}
borderRadius={4}
display="flex"
flexDirection="column"
background="#2d8cf0"
padding={0}
position="fixed"
top={120}
right={64}>
<Button
appearance="minimal"
marginY={8}
className="toolbar-item"
onClick={() => {
toaster.notify('under develop!', { id: 'dev' });
}}>
<RefreshIcon color="white" size={10} />
</Button>
<Button
appearance="minimal"
marginY={8}
className="toolbar-item"
onClick={() => setSideSheetShwon(true)}>
<SwapVerticalIcon color="white" size={10} />
</Button>
<Button
appearance="minimal"
marginY={8}
className="toolbar-item"
onClick={() => {
setFullscreen(!fullscreen);
}}>
{!fullscreen && <FullscreenIcon color="white" size={10} />}
{fullscreen && <MinimizeIcon color="white" size={10} />}
</Button>
<Button
appearance="minimal"
marginY={8}
className="toolbar-item"
onClick={() => {
toaster.notify('under develop!', { id: 'dev' });
}}>
<CogIcon color="white" size={10} />
</Button>
</Pane>
</Portal>
</Pane> </Pane>
); );
}; };
......
...@@ -3,7 +3,6 @@ import { NavLink, Route, Switch } from 'react-router-dom'; ...@@ -3,7 +3,6 @@ import { NavLink, Route, Switch } from 'react-router-dom';
import { Button, Pane, Heading } from 'evergreen-ui'; import { Button, Pane, Heading } from 'evergreen-ui';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import Footer from './layout/Footer';
import Header from './layout/Header'; import Header from './layout/Header';
import Signin from './Signin'; import Signin from './Signin';
...@@ -48,14 +47,10 @@ const Home = () => { ...@@ -48,14 +47,10 @@ const Home = () => {
</header> </header>
<main className="home-content-main main-content-container"> <main className="home-content-main main-content-container">
<Switch> <Switch>
<Route exact path={`/`} component={MainPage} /> <Route exact path={`/`} component={Signin} />
<Route path={`/signin`} component={Signin} /> <Route path={`/signin`} component={Signin} />
</Switch> </Switch>
</main> </main>
{/*<footer className="home-content-footer">
<Footer />
</footer>
*/}
</div> </div>
); );
}; };
......
import React, { useState } from 'react'; import React from 'react';
import { RouteComponentProps } from 'react-router-dom'; import { RouteComponentProps } from 'react-router-dom';
import { import { Pane, Heading, toaster } from 'evergreen-ui';
//Button,
Pane,
Heading,
//TextInputField,
//GeolocationIcon,
//FormField,
toaster,
} from 'evergreen-ui';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import Config from '../config/config'; import Config from '../config/config';
import Utils from '../libs/utils'; import Utils from '../libs/utils';
import apiRouters from '../config/api_routers'; import apiRouters from '../config/api_routers';
{
/*interface FieldState {
isInvalid: boolean;
validationMessage: string | undefined;
value: string;
}
const checkHostFormat = (host: string) => {
if (!host || host === '') {
return [false, '', 22];
}
const hostList = host.split(':');
if (hostList.length === 1) {
return [true, host, 22];
}
const ok =
hostList.length === 2 &&
hostList[1].length !== 0 &&
!isNaN(Number(hostList[1]));
if (ok) {
return [true, hostList[0], parseInt(hostList[1])];
} else {
return [false, host, 22];
}
};*/
}
const Signin = (props: RouteComponentProps) => { const Signin = (props: RouteComponentProps) => {
React.useEffect(() => { React.useEffect(() => {
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
if (event.origin !== process.env.REACT_APP_CLUSTER_URL) return; const baseUrl = process.env.REACT_APP_CLUSTER_URL as string;
console.log(event.origin);
console.log(process.env.REACT_APP_CLUSTER_URL);
console.log('-----');
console.log(!event.origin.includes(baseUrl));
console.log('-----');
console.log(event.data);
console.log('-----');
if (!event.origin.includes(process.env.REACT_APP_CLUSTER_URL!)) return;
doSignin(event.data); doSignin(event.data);
}); });
}, []); }, []);
const { t } = useTranslation(['signin']); const { t } = useTranslation(['signin']);
const doSignin = (data: Record<string, string>) => { const doSignin = (data: Record<string, string>) => {
console.log(data);
Utils.axiosInstance Utils.axiosInstance
.post(Utils.loadUrl(apiRouters.router.sign_in, null), { .post(Utils.loadUrl(apiRouters.router.sign_in, null), {
// _xsrf: Utils.base64Decode(xsrf.split("|")[0]), // todo
host: data.host, host: data.host,
port: data.port, port: data.port,
username: data.username, username: data.username,
passwd: data.password, passwd: data.password,
}) })
.then((response) => { .then((response) => {
console.log(response);
try { try {
if (!response.data || response.data.has_error) { if (!response.data || response.data.has_error) {
// self.$Loading.error();
switch (response.data.message) { switch (response.data.message) {
case 0: case 0:
console.log(t('signin:form_has_error'));
toaster.danger(t('signin:form_has_error')); toaster.danger(t('signin:form_has_error'));
break; break;
case 1: case 1:
console.log(t('signin:form_error_passport'));
toaster.danger(t('signin:form_error_passport')); toaster.danger(t('signin:form_error_passport'));
break; break;
case 2: case 2:
console.log(t('signin:form_error_ssh_login'));
toaster.danger(t('signin:form_error_ssh_login')); toaster.danger(t('signin:form_error_ssh_login'));
break; break;
} }
if (window && window.parent) {
console.log('Send Message has error');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
} else { } else {
if (!response.data.addition) { if (!response.data.addition) {
// self.$Loading.error();
toaster.danger(t('signin:form_error_remote_server')); toaster.danger(t('signin:form_error_remote_server'));
if (window && window.parent) {
console.log('Send Message Else');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
} else { } else {
// self.$Loading.finish();
toaster.success(t('signin:signin_success')); toaster.success(t('signin:signin_success'));
localStorage.setItem('user.host', data.host); localStorage.setItem('user.host', data.host);
localStorage.setItem('user.username', data.username); localStorage.setItem('user.username', data.username);
...@@ -95,13 +87,33 @@ const Signin = (props: RouteComponentProps) => { ...@@ -95,13 +87,33 @@ const Signin = (props: RouteComponentProps) => {
} }
} }
} catch (e) { } catch (e) {
// self.$Loading.error(); console.log(e.message);
toaster.danger(t('signin:form_error_ssh_login')); toaster.danger(t('signin:form_error_ssh_login'));
if (window && window.parent) {
console.log('Send Message Error 1');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
} }
}) })
.catch((e: Error) => { .catch((e: Error) => {
// self.$Loading.error(); console.log(e.message);
toaster.danger(t('signin:form_error_ssh_login') + ': ' + e.message); toaster.danger(t('signin:form_error_ssh_login') + ': ' + e.message);
if (window && window.parent) {
console.log('Send Message Error 2');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
}); });
}; };
...@@ -116,65 +128,7 @@ const Signin = (props: RouteComponentProps) => { ...@@ -116,65 +128,7 @@ const Signin = (props: RouteComponentProps) => {
<Heading marginBottom="0.6rem" marginTop="0.6rem" size={700}> <Heading marginBottom="0.6rem" marginTop="0.6rem" size={700}>
{t('signin:form_title')} {t('signin:form_title')}
</Heading> </Heading>
{/* <span>Waiting for loging - Test 8</span>!
<form
onSubmit={(event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
doSignin();
return false;
}}>
<Pane textAlign="left">
<TextInputField
value={hostField.value}
isInvalid={hostField.isInvalid}
validationMessage={hostField.validationMessage}
label={t('signin:form_fullhost_label')}
onChange={onHostChanged}
onBlur={onHostChanged}
placeholder={t('signin:form_fullhost_ph')}
marginBottom="8px"
/>
<TextInputField
value={unameField.value}
isInvalid={unameField.isInvalid}
label={t('signin:form_username_label')}
onChange={onUsernameChanged}
onBlur={onUsernameChanged}
placeholder={t('signin:form_username_ph')}
validationMessage={unameField.validationMessage}
marginBottom="8px"
/>
<TextInputField
label={t('signin:form_passwd_label')}
type="password"
placeholder={t('signin:form_passwd_ph')}
marginBottom="24px"
onChange={onPasswdChanged}
onBlur={onPasswdChanged}
onKeyDown={(event: React.KeyboardEvent<HTMLDivElement>): void => {
// 'keypress' event misbehaves on mobile so we track 'Enter' key via 'keydown' event
if (event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
doSignin();
}
}}
/>
</Pane>
<FormField>
<Button
isLoading={submitLoading}
type="submit"
width="100%"
appearance="primary"
justifyContent="center"
intent="success"
iconBefore={GeolocationIcon}>
{t('signin:form_submit_btn')}
</Button>
</FormField>
</form>
*/}
</div> </div>
</Pane> </Pane>
); );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment