Skip to content

Commit

Permalink
Merge pull request #164 from Kanaries/login-support
Browse files Browse the repository at this point in the history
Login support
  • Loading branch information
QiMeng7m authored Nov 23, 2022
2 parents f2ac835 + 500dd9d commit e36ec26
Show file tree
Hide file tree
Showing 27 changed files with 1,964 additions and 118 deletions.
5 changes: 5 additions & 0 deletions packages/rath-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
"@kanaries/loa": "^0.0.16",
"@kanaries/web-data-loader": "0.1.7",
"@material-ui/core": "^5.0.0-beta.5",
"@types/js-cookie": "^2.2.6",
"airtable": "^0.11.4",
"ali-react-table": "^2.6.1",
"codemirror": "^6.0.1",
"d3-dag": "^0.11.5",
"d3-shape": "^3.1.0",
"dayjs": "^1.11.6",
"immer": "^9.0.6",
"js-cookie": "^2.2.1",
"localforage": "^1.10.0",
"mobx": "^6.6.2",
"mobx-react-lite": "^3.4.0",
Expand All @@ -36,6 +38,7 @@
"re-resizable": "^6.9.9",
"react": "^17.0.1",
"react-app-rewired": "^2.1.5",
"react-cropper": "^2.1.8",
"react-dom": "^17.0.1",
"react-grid-layout": "^1.3.4",
"react-intl-universal": "^2.6.6",
Expand All @@ -55,13 +58,15 @@
"@testing-library/jest-dom": "^5.11.8",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.0",
"@types/crypto-js": "^4.1.0",
"@types/d3-shape": "^3.1.0",
"@types/jest": "^26.0.20",
"@types/node": "^12.19.12",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.1",
"@types/react-grid-layout": "^1.3.2",
"@types/styled-components": "^5.1.7",
"crypto-js": "^4.1.1",
"customize-cra": "^1.0.0",
"jest": "^29.3.1",
"prettier": "2.7.1",
Expand Down
32 changes: 32 additions & 0 deletions packages/rath-client/public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,37 @@
"shortDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
"months": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
"shortMonths": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
"login": {
"clickLogin": "Click Login",
"haveSent": "Alredy Send",
"signIn": "Sign In",
"signOut": "Sign Out",
"preferences": "Preferences",
"phoneCert": "Phone",
"emailCert": "Email",
"passwordLog": "Password",
"account": "Account",
"header": "Head Portrait",
"info": "Info",
"setting": "Setting",
"login": "Login",
"loginAndRegister": "login/Register",
"getCertCode": "Send Cert Code",
"upload": "Upload custom avatar",
"AvatarImage": "Avatar Image",
"phone": {
"phoneNo": "Phone NO.",
"certCode": "Cert Code"
},
"email": {
"title": "Email",
"certCode": "Cert Code",
"errEmail": "not support email type"
},
"password": {
"userName": "UsernNme",
"password": "Password"
}
}
}
32 changes: 32 additions & 0 deletions packages/rath-client/public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,37 @@
"shortDays": ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
"months": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"shortMonths": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
},
"login": {
"clickLogin": "点击登录",
"haveSent": "已发送",
"signIn": "登录",
"signOut": "登出",
"preferences": "个人信息",
"phoneCert": "手机验证",
"emailCert": "邮箱验证",
"passwordLog": "密码登录",
"account": "账号",
"header": "头像",
"info": "信息",
"setting": "设置",
"login": "登录",
"loginAndRegister": "注册/登录",
"getCertCode": "获取验证码",
"upload": "上传自定义头像",
"AvatarImage": "头像",
"phone": {
"phoneNo": "手机号码",
"certCode": "验证码"
},
"email": {
"title": "邮箱地址",
"certCode": "验证码",
"errEmail": "不支持此类邮箱"
},
"password": {
"userName": "用户名",
"password": "密码"
}
}
}
2 changes: 1 addition & 1 deletion packages/rath-client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ h2, h3 {
/* position: fixed;
left: 0px;
bottom: 0px; */
flex-basis: 220px;
/* flex-basis: 220px; */
flex-grow: 0;
flex-shrink: 0;
background-color: #fff;
Expand Down
40 changes: 38 additions & 2 deletions packages/rath-client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,44 @@ import Collection from './pages/collection';
import Dashboard from './pages/dashboard';
import CausalPage from './pages/causal';
import PerformanceWindow from './components/performance-window';
import LoginInfo from './pages/loginInfo';
import Account from './pages/loginInfo/account';
import Info from './pages/loginInfo/info';
import Setup from './pages/loginInfo/setup';
import Header from './pages/loginInfo/header';

export enum PreferencesType {
Account = 'account',
Info = 'info',
Setting = 'setting',
Header = 'header'
}
export interface PreferencesListType {
key: PreferencesType;
name: PreferencesType;
icon: string;
element: () => JSX.Element;
}

const preferencesList: PreferencesListType[] = [
{ key: PreferencesType.Account, name: PreferencesType.Account, icon: 'Home', element: () => <Account /> },
// { key: PreferencesType.Info, name: PreferencesType.Info, icon: 'Info', element: () => <Info /> },
{ key: PreferencesType.Header, name: PreferencesType.Header, icon: 'Contact', element: () => <Header /> },
{ key: PreferencesType.Setting, name: PreferencesType.Setting, icon: 'Settings', element: () => <Setup /> },
];

function App() {
const { langStore, commonStore } = useGlobalStore();
const { appKey, navMode } = commonStore;

useEffect(() => {
initRathWorker(commonStore.computationEngine);
commonStore.updateAuthStatus().then((res) => {
if (res) {
commonStore.getPersonalInfo();
commonStore.getAvatarImgUrl()
}
});
return () => {
destroyRathWorker();
};
Expand All @@ -46,8 +77,13 @@ function App() {
return (
<div>
<div className="main-app-container">
<div className="main-app-nav" style={{ flexBasis: navMode === 'text' ? '220px' : '20px' }}>
<AppNav />
<div className="main-app-nav" style={{ flexBasis: navMode === 'text' ? '220px' : '3px' }}>
<LoginInfo
element={() => {
return <AppNav />;
}}
preferencesList={preferencesList}
/>
</div>
<div className="main-app-content">
<div className="message-container">
Expand Down
62 changes: 62 additions & 0 deletions packages/rath-client/src/components/actionTextField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';
import styled from 'styled-components';
import { PrimaryButton, TextField } from '@fluentui/react';

const ActionButton = styled.div`
> label {
font-weight: 600;
display: inline-block;
color: rgb(50, 49, 48);
font-size: 14px;
padding: 5px 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto,
'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
}
> div {
display: flex;
> div:first-child {
/* width: 200px; */
}
> div:last-child {
flex: 1;
margin-left: 10px;
}
}
`;
interface ActionTextFieldProps {
label: string;
placeholder?: string;
buttonLabel: string;
value: string;
buttonDisabled?: boolean;
isDisable: boolean;
onChange?: (val: string | undefined) => void;
onButtonClick?: () => void;
}
const ActionTextField: React.FC<ActionTextFieldProps> = (props) => {
const { label, placeholder, buttonLabel, value, isDisable, onButtonClick, onChange } = props;
return (
<ActionButton>
<label className="block text-gray-700">{label}</label>
<div className="flex">
<div>
<TextField
value={value}
placeholder={placeholder}
onChange={(e, data) => {
onChange && onChange(data);
}}
/>
</div>
<div>
<PrimaryButton className="w-full" disabled={isDisable} onClick={onButtonClick}>
{buttonLabel}
</PrimaryButton>
</div>
</div>
</ActionButton>
);
};

export default ActionTextField;
Loading

0 comments on commit e36ec26

Please sign in to comment.