Skip to content

Commit

Permalink
fix: css
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu-tro committed Sep 10, 2024
1 parent 2807775 commit dd82b19
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 50 deletions.
8 changes: 4 additions & 4 deletions src/APIClient/APIClient10.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ class APIClient10 {
login(arg){
return this.request(`/api/v1/dashboard/login?arg=${arg}`);
}
loginValidate(arg,token){
return this.request(`/api/v1/dashboard/validate?arg=${arg}&token=${token}`);
loginValidate(arg){
return this.request(`/api/v1/dashboard/validate?arg=${arg}`);
}
changePassword(arg,newpassword,token){
return this.request(`/api/v1/dashboard/change?arg=${arg}&arg=${newpassword}&token=${token}`);
changePassword(arg,newpassword){
return this.request(`/api/v1/dashboard/change?arg=${arg}&arg=${newpassword}`);
}
resetLoginPassword(privateKey, password){
return this.request(`/api/v1/dashboard/reset?arg=${privateKey}&arg=${password}`);
Expand Down
13 changes: 3 additions & 10 deletions src/components/Cards/CardSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import { Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { mainContext } from 'reducer';
import Emitter from 'utils/eventBus';
import Cookies from 'js-cookie';
import { useHistory } from 'react-router-dom';

import { nodeStatusCheck, getPrivateKey, getRepo, setApiUrl } from 'services/otherService.js';
import { t } from 'utils/text.js';
import { urlCheck } from 'utils/checks.js';
import PathConfirmModal from 'components/Modals/PathConfirmModal.js';
import LogoutConfirmModal from 'components/Modals/LogoutComfirmModal';
import CardConfig from './CardConfig';
import ConfigConfirmModal from 'components/Modals/ConfigConfirmModal';
import ClipboardCopy from 'components/Utils/ClipboardCopy';
import S3CardConfig from './S3CardConfig';
import { getParameterByName } from 'utils/BTFSUtil.js';
import { MAIN_PAGE_MODE } from 'utils/constants';

import { logout } from 'services/login.js';

export default function CardSettings({ color }) {
const apiUrl = getParameterByName('api', window.location.href);
Expand All @@ -28,7 +26,6 @@ export default function CardSettings({ color }) {
setApiUrl(apiUrl);
NODE_URL = apiUrl;
}
const history = useHistory();
const inputRef = useRef(null);
const { state } = useContext(mainContext);
const { pageMode } = state;
Expand Down Expand Up @@ -77,12 +74,7 @@ export default function CardSettings({ color }) {
};

const handleLogout = async () => {
await logout();
let NODE_URL = localStorage.getItem('NODE_URL')
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
Cookies.remove(NODE_URL);
history.push('/login');
Emitter.emit('openLogoutConfirmModal', {});
};

const changePath = async e => {
Expand Down Expand Up @@ -188,6 +180,7 @@ export default function CardSettings({ color }) {

<PathConfirmModal />
<ConfigConfirmModal />
<LogoutConfirmModal />
</div>
);
}
49 changes: 24 additions & 25 deletions src/components/Login/Endpoint.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
import React, {useRef,useEffect} from 'react';
import { QuestionCircleOutlined } from '@ant-design/icons';
import React, { useRef, useEffect } from 'react';
// import { QuestionCircleOutlined } from '@ant-design/icons';
import Emitter from 'utils/eventBus';
import { setApiUrl } from 'services/otherService.js';
import { urlCheck } from 'utils/checks.js';
import { Tooltip } from 'antd';
// import { Tooltip } from 'antd';
import { t } from 'utils/text.js';
import { getParameterByName } from 'utils/BTFSUtil.js';




const Endpoint = ({ color }) => {
const inputRef = useRef(null);

const getEndpoint = ()=>{
const getEndpoint = () => {
const apiUrl = getParameterByName('api', window.location.href);
let NODE_URL = localStorage.getItem('NODE_URL')
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
if (apiUrl && urlCheck(apiUrl) && NODE_URL !== apiUrl) {
NODE_URL = apiUrl;
}
if(NODE_URL){
if (NODE_URL) {
inputRef.current.value = NODE_URL;
}
}
};

const getNodeUrl = () => {
const getNodeUrl = () => {
let node_url = inputRef.current.value.replace(/\s*/g, '');
if (node_url.charAt(node_url.length - 1) === '/') {
node_url = node_url.substr(0, node_url.length - 1);
node_url = node_url.substr(0, node_url.length - 1);
}
if (!urlCheck(node_url)) {
return null;
return null;
}
return node_url;
};
};

const save = async (e, wallet) => {
e.preventDefault();
Expand All @@ -52,25 +49,27 @@ const Endpoint = ({ color }) => {
// };

useEffect(() => {
getEndpoint()
getEndpoint();
}, []);

return (
<div className="flex flex-col max-w-450px justify-center login-form-w ">
<div className=" min-h-400">
<div className="login-title theme-text-main">{t('login')}</div>
<div className="text-gray-900 text-sm font-bold mb-12 theme-text-sub-main">
{t('login_endpoint_desc')}
{t('login_endpoint_desc')}
</div>
<div className="mb-2 setting-header">
<h5 className="font-bold theme-text-main" htmlFor="grid-password">
API {t('endpoint')}
</h5>
<Tooltip overlayInnerStyle={{ width: '340px' }} placement="top" title={<p>{t('copy_url_tips')}</p>}>
{/* <i className="far fa-question-circle ml-1 text-xs"></i> */}
<QuestionCircleOutlined className="inline-flex items-center ml-1 text-xs" />
</Tooltip>
</div>
<h5 className="font-bold theme-text-main" htmlFor="grid-password">
API {t('endpoint')}
</h5>
{
// <Tooltip overlayInnerStyle={{ width: '340px' }} placement="top" title={<p>{t('copy_url_tips')}</p>}>
// {/* <i className="far fa-question-circle ml-1 text-xs"></i> */}
// <QuestionCircleOutlined className="inline-flex items-center ml-1 text-xs" />
// </Tooltip>
}
</div>
<input
type="text"
className="mr-2 common-input theme-bg theme-border-color theme-text-main login-form-w-334px"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Login/SetPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const Endpoint = ({ endpoint, isReset }) => {
<span onClick={backPrevious} className="cursor-pointer pr-2">
<ArrowLeftOutlined style={{ fontSize: 20 }} className="align-middle" />
</span>
{t('set_login_password')}
{t(`${isReset?'re':''}set_login_password`)}
</div>
<div className="text-gray-900 text-sm font-bold mb-12">{t('set_login_password_desc')}</div>
<div className="text-gray-900 text-sm font-bold mb-12">{t(`${isReset?'re':''}set_login_password_desc`)}</div>

<Form
name="basic"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modals/ChangePasswordModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function ChangePasswordModal({ color }) {
autoComplete="off">
<Form.Item
label={
<div className="font-bold theme-text-main">API {t('enter_old_password')}</div>
<div className="font-bold theme-text-main">{t('enter_old_password')}</div>
}
name="oldpassword"
rules={[
Expand Down
59 changes: 59 additions & 0 deletions src/components/Modals/LogoutComfirmModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { useState, useEffect } from 'react';
import Emitter from 'utils/eventBus';
import Cookies from 'js-cookie';
import { logout } from 'services/login.js';
import { t } from 'utils/text.js';
import { useHistory } from 'react-router-dom';
import CommonModal from './CommonModal';

export default function LogoutConfirmModal({ color }) {
const [showModal, setShowModal] = useState(false);
const history = useHistory();

useEffect(() => {
const set = function (params) {
openModal();
};
Emitter.on('openLogoutConfirmModal', set);
return () => {
Emitter.removeListener('openLogoutConfirmModal');
};
}, []);

const openModal = () => {
setShowModal(true);
};

const closeModal = () => {
setShowModal(false);
};

const handleLogout = async () => {
// Emitter.emit('handleResetConfig', {});

await logout();
let NODE_URL = localStorage.getItem('NODE_URL')
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
Cookies.remove(NODE_URL);
history.push('/login');
closeModal();
};

return (
<CommonModal width={520} visible={showModal} onCancel={closeModal}>
<div className="common-modal-wrapper theme-bg">
<header className="common-modal-header theme-text-main">{t('lougout_comfirm_modal_title')}</header>
<main className="mb-8 theme-text-main">{t('lougout_comfirm_modal_desc')}</main>
<footer className="common-modal-footer">
<button className="mr-4 common-btn theme-danger-btn " onClick={closeModal}>
{t('cancel')}
</button>
<button className="common-btn theme-common-btn" onClick={handleLogout}>
{t('confirm')}
</button>
</footer>
</div>
</CommonModal>
);
}
7 changes: 4 additions & 3 deletions src/components/Modals/PasswordVerifyModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Spin, } from 'antd';
import Emitter from 'utils/eventBus';
import { t } from 'utils/text.js';
import CommonModal from './CommonModal';
import Cookies from 'js-cookie';
// import Cookies from 'js-cookie';


import { aseEncode } from 'utils/BTFSUtil';
Expand Down Expand Up @@ -76,6 +76,7 @@ export default function PasswordVerifyModal({ color }) {
const handleSubmit = async () => {
if (!password) {
setValidateMsg(t('password_validate_required'));
return;
}
if (password && !checkPassword(password)) {
setValidateMsg(t('password_validate_pattern'));
Expand All @@ -86,9 +87,9 @@ export default function PasswordVerifyModal({ color }) {
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
let asePassowrd = aseEncode(password, NODE_URL);
const token = Cookies.get(NODE_URL)
// const token = Cookies.get(NODE_URL)
try {
let res = await loginValidate(asePassowrd,token);
let res = await loginValidate(asePassowrd);
setLoading(false);
if (res && res.Success) {
callbackFn.current();
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function Sidebar() {
'theme-sidebar-link md:block text-left md:pb-2 mr-0 inline-block whitespace-nowrap text-sm uppercase font-bold p-4 px-0'
}
to="/">
BTFS 3.0.0
BTFS 3.1.0
</Link>
</div>
<div className="w-4/12 flex flex-row-reverse">
Expand Down Expand Up @@ -187,7 +187,7 @@ export default function Sidebar() {
{/* Navigation */}
<ul className="md:flex-col md:min-w-full flex flex-col list-none mb-4">
<li className="items-center">
<a className={'sidebar-link theme-sidebar-link'}>{t('version')} 3.0.0</a>
<a className={'sidebar-link theme-sidebar-link'}>{t('version')} 3.1.0</a>
</li>

<li className="items-center">
Expand Down
6 changes: 4 additions & 2 deletions src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,10 @@ const en_US = {
logout: "Logout",


reset_password_success:'密码重置成功',
set_password_success:'密码设置成功',
reset_password_success:'Password has been successfully set',
set_password_success:'Password has been successfully set',
lougout_comfirm_modal_title:'Logout',
lougout_comfirm_modal_desc:'Are you sure you want to log out of the current node?'

};

Expand Down
3 changes: 2 additions & 1 deletion src/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ const zh_CN = {

reset_password_success:'密码重置成功',
set_password_success:'密码设置成功',

lougout_comfirm_modal_title:'退出登录',
lougout_comfirm_modal_desc:'确认要退出当前节点登录吗?'

};

Expand Down

0 comments on commit dd82b19

Please sign in to comment.