Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.2.0 #85

Merged
merged 9 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/APIClient/APIClient10.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ class APIClient10 {
return this.request(`/api/v1/dashboard/logout`);
}

getFileBlackList(){
return this.request(`/api/v1/cidstore/list`);
}

addFileBlackList(arg,batch){
return this.request(`/api/v1/cidstore/add?arg=${arg}&batch=${batch}`);
}

}

const Client10 = new APIClient10();
Expand Down
Binary file added src/assets/img/cid-blacklist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,5 @@
}

}


2 changes: 1 addition & 1 deletion src/assets/styles/themeLight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
color: $base-color;
&:focus {
background-color: $white;
border-color: $white;
border-color:$base-color; //$white;
color: $base-color;
}
&:hover {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Lock/AccountLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { useHistory } from 'react-router-dom';
import Cookies from 'js-cookie';
// import { mainContext } from 'reducer';
// import Emitter from 'utils/eventBus';
import Emitter from 'utils/eventBus';


const AccountLock = () => {
Expand All @@ -20,6 +20,8 @@ const AccountLock = () => {
? localStorage.getItem('NODE_URL')
: 'http://localhost:5001';
Cookies.remove(NODE_URL);

Emitter.emit('showMessageAlert', { message: 'lock_success', status: 'success', type: 'frontEnd' });
history.push({pathname:'/login',state:{back:true}});
};

Expand Down
190 changes: 190 additions & 0 deletions src/components/Modals/FileBlackListModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import React, { useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import { getFileBlackList, addFileBlackList } from 'services/filesService.js';
import { LoadingOutlined } from '@ant-design/icons';
import { Spin, Input } from 'antd';
import Emitter from 'utils/eventBus';
import { t } from 'utils/text.js';
import CommonModal from './CommonModal';
import isIPFS from 'is-ipfs';

const { TextArea } = Input;

export default function FileBlackListModal({ color, closeModal, showModal }) {
const intl = useIntl();
const [loading, setLoading] = useState(false);
const [isEdit, setIsEdit] = useState(false);
const [listVal, setListVal] = useState('');
const [initListVal, setInitListVal] = useState('');
const [validateMsg, setValidateMsg] = useState('');

const getFileBlackListData = async () => {
setLoading(true);
let listData = (await getFileBlackList()) || [];
setLoading(false);
let listStr = listData.join('\n') || '';
setListVal(listStr);
setInitListVal(listStr);
};

useEffect(() => {
if (showModal) {
setValidateMsg('');
getFileBlackListData();
}
setIsEdit(false);
// Emitter.on('openDecryptFileModal', set);
return () => {
// Emitter.removeListener('openDecryptFileModal');
window.body.style.overflow = '';
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showModal]);

const validateCid = val => {
let res = isIPFS.cid(val);
if (res) {
setValidateMsg('');
return true;
}
return false;
};

// const validateListVal = val => {
// console.log(val,'11')
// let reg = /^[A-Za-z0-9]+$/;
// if (!val || reg.test(val)) {
// setValidateMsg('');
// return true;
// }
// if (!reg.test(val)) {
// setValidateMsg(t('validate_file_blacklist_cid1'));
// return false;
// }
// return true;
// };

const changeListVal = e => {
setListVal(e.target.value);
};

const editFileList = () => {
setIsEdit(!isEdit);
};

const cancelEdit = () => {
setValidateMsg('');
setListVal(initListVal);
setIsEdit(false);
};

const saveFileList = async () => {
// if (listVal && !validateListVal(listVal)) {
// return;
// }
// if(!listVal){
// setValidateMsg(t('validate_file_blacklist_cid1'))
// return
// }
let listArr = listVal.split('\n');
let validateCids = true;
for (var v in listArr) {
if (listArr[v] && !validateCid(listArr[v])) {
validateCids = false;
break;
}
}
if (!validateCids) {
setValidateMsg(t('validate_file_blacklist_cid2'));
return;
}

try {
await addFileBlackList(listArr, true);
setLoading(false);
setInitListVal(listVal);
setIsEdit(false);
Emitter.emit('showMessageAlert', {
message: 'add_file_blacklist_success',
status: 'success',
type: 'frontEnd',
});
closeModal()
} catch (e) {
Emitter.emit('showMessageAlert', { message: e.Message, status: 'error' });
}
};

return (
<CommonModal visible={showModal} onCancel={closeModal}>
<div className="common-modal-wrapper theme-bg">
<main className="flex flex-col justify-center theme-bg theme-text-main">
<img
alt=""
src={require(`../../assets/img/cid-blacklist.png`).default}
className="mb-4"
width={43}
/>
<div className="font-semibold text-xl mb-2"> {t('file_blacklist_title')} </div>
<div className="text-xs font-medium theme-text-sub-info">{t('file_blacklist_desc')}</div>
<div className="text-xs font-medium mb-4 theme-text-sub-info">
{t('file_blacklist_desc2')}
</div>

<Spin spinning={loading} indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />}>
<TextArea
className="w-full h-3 theme-bg theme-border-color rounded-lg h-400-px"
style={{ height: 400 }}
readOnly={!isEdit}
onChange={changeListVal}
value={listVal}
placeholder={intl.formatMessage({ id: 'file_blacklist_cid_placeholder' })}
/>

<div className="flex justify-between w-full mb-4">
<span className="theme-text-error text-xs pt-1">{validateMsg}</span>
</div>
{isEdit ? (
<div className="mt-2 text-right">
<button
className="ml-2 common-btn theme-fill-gray text-gray-900 mr-4"
onClick={cancelEdit}>
{t('file_blacklist_cancel')}
</button>

<div className="ml-2 inline-block">
<button
type="primary"
className="common-btn theme-common-btn"
onClick={saveFileList}>
{t('file_blacklist_save')}
</button>
</div>
</div>
) : (
<div className="mt-2 text-right">
<button
className="ml-2 common-btn theme-fill-gray text-gray-900 mr-4"
onClick={closeModal}>
{t('file_blacklist_close')}
</button>
<div className="ml-2 inline-block">
<Spin
spinning={loading}
indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />}>
<button
type="primary"
className="common-btn theme-common-btn"
onClick={editFileList}>
{t('file_blacklist_edit')}
</button>
</Spin>
</div>
</div>
)}
</Spin>
</main>
</div>
</CommonModal>
);
}
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.1.0
BTFS 3.2.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.1.0</a>
<a className={'sidebar-link theme-sidebar-link'}>{t('version')} 3.2.0</a>
</li>

<li className="items-center">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Stats/NodeStorageStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Contracts = ({ contracts, hostPrice }) => {
{contracts}
</div>
<div className="theme-text-sub-main">
{t('price')}: {hostPrice} WBTT (GB / {t('month')})
{t('price')}: {hostPrice} WBTT (GB / {t('day')})
</div>
</div>
</div>
Expand Down
39 changes: 34 additions & 5 deletions src/components/Tables/LocalFilesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
import FileTableDropdown from 'components/Dropdowns/FileTableDropdown.js';
import ImportFilesDropdown from 'components/Dropdowns/ImportFilesDropdown.js';
import ImportFilesEncryptDropdown from 'components/Dropdowns/ImportFilesEncryptDropdown.js';
import FileBlackListModal from 'components/Modals/FileBlackListModal.js';
import FileControl from 'components/Footers/FileControl.js';
import S3ApiTable from './S3ApiTable';
import { getRootFiles, getHashByPath, getFolerSize, getFiles, searchFiles } from 'services/filesService.js';
Expand All @@ -16,7 +17,6 @@ import moment from 'moment';
import Emitter from 'utils/eventBus';
import { Truncate } from 'utils/text';


let didCancel = false;
let filesAll = [];
let nameArray = [];
Expand All @@ -31,6 +31,11 @@ export default function LocalFilesTable({ color }) {
const [total, setTotal] = useState(0);
const [current, setCurrent] = useState(1);
const [batch, setBatch] = useState([]);
const [activeKey, setActiveKey] = useState('1');
const [showFileBlackListModal, setShowFileBlackListModal] = useState(false);




const selectAll = e => {
let fileControl = document.getElementById('fileControl');
Expand Down Expand Up @@ -202,6 +207,24 @@ export default function LocalFilesTable({ color }) {
addPath(hash, hash, -1);
};

const changeActiveKey = activeKey => {
setActiveKey(activeKey);
};

const showFileBlackListModalFn= ()=>{
setShowFileBlackListModal(true)
}

const operations = () => {
// if (activeKey === '2') {
return <button className="common-btn theme-white-btn" onClick={showFileBlackListModalFn} >{t('file_black_list')}</button>;
// }
// return null
};




useEffect(() => {
const set = async function () {
setTimeout(() => {
Expand All @@ -223,11 +246,15 @@ export default function LocalFilesTable({ color }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

console.log('breadcrumbName', breadcrumbName);

return (
<>
<Tabs defaultActiveKey="1" className="mb-4 common-card theme-bg theme-text-main file-tab-content">
<Tabs
defaultActiveKey="1"
activeKey={activeKey}
onChange={changeActiveKey}
className="mb-4 common-card theme-bg theme-text-main file-tab-content"
tabBarExtraContent={operations()}>
<Tabs.TabPane tab={t('s3_api')} key="1" className="w-full">
<S3ApiTable color={color} />
</Tabs.TabPane>
Expand Down Expand Up @@ -363,9 +390,10 @@ export default function LocalFilesTable({ color }) {
placement="top"
title={item['Name']}>
<span className="ml-3 font-bold">
<Truncate start={5}>{item['Name']}</Truncate>
<Truncate start={5}>
{item['Name']}
</Truncate>
</span>

</Tooltip>
) : (
<span className="ml-3 font-bold">
Expand Down Expand Up @@ -456,6 +484,7 @@ export default function LocalFilesTable({ color }) {
</div>
</Tabs.TabPane>
</Tabs>
<FileBlackListModal color={color} showModal={showFileBlackListModal} closeModal={()=> setShowFileBlackListModal(false)} />
</>
);
}
Expand Down
18 changes: 17 additions & 1 deletion src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,23 @@ const en_US = {
upload_success:'Upload Successfully',
download_success:'Download Successfully',
upload_fail:'Upload Failed',
download_fail:'Download Failed'
download_fail:'Download Failed',

//v1.9
file_black_list: 'File Blacklist',
file_blacklist_cancel: 'Cancel',
file_blacklist_close: 'Close',
file_blacklist_save: 'Save',
file_blacklist_edit: 'Edit',
day: 'Day',
add_file_blacklist_success: 'Added Successfully',
validate_file_blacklist_cid1: 'Chinese characters are not allowed. Please use commas (,) to separate entries.',
validate_file_blacklist_cid2: 'Please enter a valid CID.',
file_blacklist_title: 'Blacklist Content',
file_blacklist_desc: 'Add the CIDs of the content to be blacklisted here, one per line.',
file_blacklist_desc2: 'Content listed in the blacklist will be inaccessible via the BTFSGateway (default port 8080).',
file_blacklist_cid_placeholder:'No file blacklist has been added yet.',
lock_success:'Account Locked Successfully'


};
Expand Down
Loading
Loading