Skip to content

Commit

Permalink
fix: 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu-tro committed Dec 11, 2024
1 parent ee077ba commit a79b320
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 72 deletions.
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.
131 changes: 63 additions & 68 deletions src/components/Modals/FileBlackListModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import isIPFS from 'is-ipfs';
const { TextArea } = Input;

export default function EncryptFileModal({ color, closeModal, showModal = false }) {

const intl = useIntl();
const [loading, setLoading] = useState(false);
const [isEdit, setIsEdit] = useState(false);
Expand All @@ -20,8 +19,10 @@ export default function EncryptFileModal({ color, closeModal, showModal = false
const [validateMsg, setValidateMsg] = useState('');

const getFileBlackListData = async () => {
let listData = await getFileBlackList() || [];
let listStr = listData.join('\n') || ''
setLoading(true);
let listData = (await getFileBlackList()) || [];
setLoading(false);
let listStr = listData.join('\n') || '';
setListVal(listStr);
setInitListVal(listStr);
};
Expand All @@ -44,7 +45,6 @@ export default function EncryptFileModal({ color, closeModal, showModal = false
}, [showModal]);

const validateCid = val => {

let res = isIPFS.cid(val);
if (res) {
setValidateMsg('');
Expand Down Expand Up @@ -85,25 +85,28 @@ export default function EncryptFileModal({ color, closeModal, showModal = false
// 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
for (var v in listArr) {
if (listArr[v] && !validateCid(listArr[v])) {
validateCids = false;
break;
}

}
if(!validateCids){
if (!validateCids) {
setValidateMsg(t('validate_file_blacklist_cid2'));
return
return;
}

try {
await addFileBlackList(listArr,true);
await addFileBlackList(listArr, true);
setLoading(false);
setInitListVal(listVal);
setIsEdit(false)
setIsEdit(false);
Emitter.emit('showMessageAlert', {
message: 'add_file_blacklist_success',
status: 'success',
Expand All @@ -112,84 +115,76 @@ export default function EncryptFileModal({ color, closeModal, showModal = false
} 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/decrypt-cid.png`).default}
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 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>



<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: 'decrypt_input_cid_placeholder' })}
/>

<div className="flex justify-between w-full mb-4">
<span className="theme-text-error text-xs pt-1">{validateMsg}</span>
{t('file_blacklist_desc2')}
</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">
<Spin
spinning={loading}
indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />}>

<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>
</Spin>
</div>
</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 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>
</div>
)}
)}
</Spin>
</main>
</div>
</CommonModal>
Expand Down
5 changes: 3 additions & 2 deletions src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,12 @@ const en_US = {
file_blacklist_edit:'编辑',
day: 'Day',
add_file_blacklist_success:'添加成功',
validate_file_blacklist_cid1:'不可输入中文,请使用英文逗号,区分',
validate_file_blacklist_cid1:'请输入cid',
validate_file_blacklist_cid2:'请输入正确的cid',
file_blacklist_title:'黑名单内容',
file_blacklist_desc:'请在此处添加需纳入黑名单的内容 CID,每行一个。',
file_blacklist_desc2:'被列入黑名单的内容将无法通过 BTFSGateway(8080端口)访问。'
file_blacklist_desc2:'被列入黑名单的内容将无法通过 BTFSGateway(8080端口)访问。',
file_blacklist_cid_placeholder:'输入黑名单CID'

};

Expand Down
4 changes: 3 additions & 1 deletion src/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ const zh_CN = {
validate_file_blacklist_cid2:'请输入正确的cid',
file_blacklist_title:'黑名单内容',
file_blacklist_desc:'请在此处添加需纳入黑名单的内容 CID,每行一个。',
file_blacklist_desc2:'被列入黑名单的内容将无法通过 BTFSGateway(8080端口)访问。'
file_blacklist_desc2:'被列入黑名单的内容将无法通过 BTFSGateway(8080端口)访问。',
file_blacklist_cid_placeholder:'输入黑名单CID'



};
Expand Down
2 changes: 1 addition & 1 deletion src/services/dashboardService.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export const getNodeStorageStats = async () => {
capacity: switchStorageUnit2(result[1]['StorageMax']),
storageUsed: switchStorageUnit2(result[1]['RepoSize']),
percentage: new BigNumber(result[1]['RepoSize']).dividedBy(result[1]['StorageMax']).multipliedBy(100).toFixed(2),
hostPrice: formatNumber((result[0]['price'] * 30 / PRECISION),2),
hostPrice: formatNumber((result[0]['price'] / PRECISION_RATE),2),
contracts: result[2]['active_contract_num'],
uncashed: switchBalanceUnit(result[3]['total_received_uncashed']),
uncashedChange: switchBalanceUnit(result[3]['total_received_daily_uncashed']),
Expand Down

0 comments on commit a79b320

Please sign in to comment.