Skip to content

Commit

Permalink
fix: 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu-tro committed Sep 2, 2024
1 parent bf2e1f9 commit dc4b93a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/assets/img/lock-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/img/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,21 @@
.ant-form-item .ant-input{
background-color: transparent
}


.account-lock{
.lock-img-hover{
display: none
}
.lock-img{
display: block
}
&:hover{
.lock-img{
display: none
}
.lock-img-hover{
display: block
}
}
}
8 changes: 5 additions & 3 deletions src/components/Lock/AccountLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ const AccountLock = () => {
}, [theme]);

return (
<button onClick={lockAccount} className="ml-2 round-btn theme-round-btn ">
{theme === 'light' && <img src={require(`assets/img/lock.svg`).default} alt="" />}
{theme === 'dark' && <img src={require(`assets/img/lock-dark.svg`).default} alt="" />}
<button onClick={lockAccount} className="ml-2 round-btn theme-round-btn account-lock">
<img className="lock-img" src={require(`assets/img/lock.svg`).default} alt="" />
<img className="lock-img-hover " src={require(`assets/img/lock-dark.svg`).default} alt="" />
{//theme === 'dark' && <img src={require(`assets/img/lock-dark.svg`).default} alt="" />
}
</button>
);
};
Expand Down
41 changes: 6 additions & 35 deletions src/components/Login/Endpoint.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import React, { useContext,useState ,useRef,useEffect} from 'react';
import { mainContext } from 'reducer';
import { Dropdown, Menu } from 'antd';
import themeStyle from 'utils/themeStyle.js';
import React, {useState ,useRef,useEffect} from 'react';
import { QuestionCircleOutlined } from '@ant-design/icons';
import Emitter from 'utils/eventBus';

import { nodeStatusCheck, getPrivateKey, getRepo, setApiUrl } from 'services/otherService.js';
import { urlCheck } from 'utils/checks.js';

import { Tooltip } from 'antd';
import { Truncate } from 'utils/text.js';
import { t } from 'utils/text.js';
import ClipboardCopy from 'components/Utils/ClipboardCopy';




const Endpoint = ({ color }) => {
// const { dispatch, state } = useContext(mainContext);
// const { account } = state;
const inputRef = useRef(null);
const { dispatch, state } = useContext(mainContext);
const [endpoint, setEndpoint] = useState('');
const [loading, setLoading] = useState(false);


const getEndpoint = ()=>{
Expand All @@ -31,7 +19,6 @@ const Endpoint = ({ color }) => {
if(NODE_URL){
inputRef.current.value = NODE_URL;
}
// const isMainMode = await getPageMode();
}

const getNodeUrl = () => {
Expand All @@ -46,28 +33,11 @@ const Endpoint = ({ color }) => {
};

const save = async (e, wallet) => {
const node_url2 = getNodeUrl();
Emitter.emit('handleEndpoint', node_url2);
return
e.preventDefault();
e.stopPropagation();
const node_url = getNodeUrl();
if (!node_url) return;
let result = await nodeStatusCheck(node_url);
if (result) {
window.nodeStatus = true;
dispatch({
type: 'SET_NODE_STATUS',
nodeStatus: true,
});
// getPath();
// Emitter.emit('showMessageAlert', { message: 'setting_success', status: 'success', type: 'frontEnd' });
// Emitter.emit('getHostId')
Emitter.emit('handleEndpoint', node_url);
} else {
// setPath('');
// Emitter.emit('showMessageAlert', { message: 'setting_error', status: 'error', type: 'frontEnd' });
}
// Emitter.emit('handleEndpoint', {});
// Emitter.emit('handleEndpoint', { checked, parentIndex, childIndex });
Emitter.emit('handleEndpoint', node_url);
};

const handleChange = (e) => {
Expand Down Expand Up @@ -96,10 +66,11 @@ const Endpoint = ({ color }) => {
</div>
<input
type="text"
className="mr-2 common-input theme-bg theme-border-color"
className="mr-2 common-input theme-border-color"
defaultValue="http://localhost:5001"
ref={inputRef}
onChange={handleChange}
placeholder="http://localhost:5001"
/>
<button className="mt-5 common-btn theme-common-btn login-btn" type="button" onClick={save}>
{t('next')}
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ export default function Admin() {
return;
}
const isMainMode = await getPageMode();
if (!NODE_URL && !window.location.href.includes('/admin/settings')) {
history.push('/admin/settings');
} else {
// if (!NODE_URL && !window.location.href.includes('/admin/settings')) {
// history.push('/admin/settings');
// } else {
// check node status
window.loading = true;
let result = await nodeStatusCheck(NODE_URL, isMainMode);
Expand All @@ -138,7 +138,7 @@ export default function Admin() {
nodeStatus: false,
});
}
}
// }
window.body = document.getElementsByTagName('body')[0];
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ export const bttcScanLinkCheck = () => {

return BTTCSCAN_MAIN

};
};
27 changes: 14 additions & 13 deletions src/views/login/Login.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React, { useEffect, useContext, useState } from 'react';
import React, { useEffect, useState } from 'react';
import Emitter from 'utils/eventBus';
import { mainContext } from 'reducer';
import FilesStats from 'components/Stats/FilesStats.js';
import Endpoint from 'components/Login/Endpoint.js';
import SetPassword from 'components/Login/SetPassword.js';
import PasswordLogin from 'components/Login/PasswordLogin.js';
import MessageAlert from 'components/Alerts/MessageAlert';
import { checkLoginPassword } from 'services/login.js';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';

export default function Login(props) {
const [isReset, setIsReset] = useState(false);
const [endpoint, setEndpoint] = useState('');
const [hasPassword, setHasPassword] = useState(true);
const [loading, setLoading] = useState(false);

// const { state } = useContext(mainContext);
// const { theme } = state;
Expand All @@ -28,32 +26,35 @@ export default function Login(props) {
// // const isMainMode = await getPageMode();
// }

const checkLoginPassowrd = async () => {
const endpointChange = async val => {
if(loading)return;
setLoading(true)
try {
let res = await checkLoginPassword();
setLoading(false)
if(res.Type === 'error'){
Emitter.emit('showMessageAlert', { message: res.Message || 'error', status: 'error' });
return;
}
if (res && res.Success) {
setHasPassword(true);
setEndpoint(val);
} else if (res && !res.Success) {
// setHasPassword(false);
setHasPassword(false);
}
} catch (error) {
console.log(error,);
console.log(error);
}
};

const endpointChange = async val => {
await checkLoginPassowrd();
setEndpoint(val);
};

const lostPassword = () => {
// setlostPassword
setIsReset(true);
};

useEffect(() => {
Emitter.on('handleEndpoint', endpointChange);
Emitter.on('handleLostPassword', lostPassword);
document.documentElement.classList.remove('dark');
}, []);

return (
Expand Down

0 comments on commit dc4b93a

Please sign in to comment.