Skip to content

Commit

Permalink
Merge pull request #72 from bittorrent/v2.3.5
Browse files Browse the repository at this point in the history
V2.3.5
  • Loading branch information
lulu-tro authored Mar 27, 2024
2 parents 6ec23dc + d0c4cf0 commit 0fdc7a1
Show file tree
Hide file tree
Showing 23 changed files with 758 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BTFS-Dashboard",
"version": "2.3.3",
"version": "2.3.5",
"description": "",
"repository": "",
"license": "MIT",
Expand Down
41 changes: 37 additions & 4 deletions src/APIClient/APIClient10.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ class APIClient10 {
constructor() {
this.apiUrl = localStorage.getItem('NODE_URL') ? localStorage.getItem('NODE_URL') : "http://localhost:5001";
this.request = async (url, body, config) => {
const isFormData = body instanceof FormData
return new Promise(async (resolve, reject) => {
try {

let {data} = await xhr.post(
this.apiUrl + url,
isFormData?body:
{
...body
},
{...config}
);

resolve(data);

}
catch (e) {
let message;
Expand All @@ -25,10 +29,25 @@ class APIClient10 {
if (e.response && e.response.status === 400) {
message = e.response['data'];
}
resolve({
Type: 'error',
Message: message ? message : 'network error or host version not up to date'
});

if(e.response && e.response?.data && !e.response?.data?.success && e.response?.data?.type === 'application/json'){
const fileReader = new FileReader()
fileReader.readAsText(e.response.data,'utf-8')
fileReader.onload = function(){
const result = JSON.parse(fileReader.result)
message = result['Message']
resolve({
Type: 'error',
Message: message ? message : 'network error or host version not up to date'
});
return;
}
}else{
resolve({
Type: 'error',
Message: message ? message : 'network error or host version not up to date'
});
}
}
}).catch(err => {
console.log(err)
Expand Down Expand Up @@ -347,6 +366,20 @@ class APIClient10 {
}
}

encrypt(formData,to,onUploadProgress) {
return this.request(`/api/v1/encrypt?${to?'to='+to:''}`,formData,{
'headers':{
'Content-Type':'application/x-www-form-urlencoded',
},
'timeout': 0,
onUploadProgress:onUploadProgress
});
}

decrypt(hash, body, config) {
return this.request('/api/v1/decrypt?arg=' + hash, body, config);
}

// s3 api

// generate key
Expand Down
9 changes: 9 additions & 0 deletions src/assets/img/decrypt-icon_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/img/decrypt-icon_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/img/encrypt-icon_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/img/encrypt-icon_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
font-family: Helvetica-Bold, Helvetica;
}

.align-top{
vertical-align: top;
}

.fill-white{
fill: #fff;
}
.monospaced-font {
font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}
Expand All @@ -207,4 +214,4 @@
background-color: #a1a7c4;
}

}
}
1 change: 1 addition & 0 deletions src/assets/styles/overwrite.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@
}
}
}

7 changes: 7 additions & 0 deletions src/assets/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,13 @@ video {
padding-bottom: 0.75rem;
}

.border-dotted{
border-style: dotted;
}
.border-dashed{
border-style: dashed;
}

.common-modal-wrapper {
border-radius: 1rem;
height: 100%;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/styles/themeAntd.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
color: $text-color-main;
}


.border-color-active{
border-style: $active-color;
}
// antd theme dark
.dark {
.ant-btn {
Expand Down
4 changes: 4 additions & 0 deletions src/assets/styles/themeDark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,8 @@
._box-shadow {
box-shadow: 0px 6px 16px 0px #21242c, 0px 3px 6px -4px #21242c;
}

.ant-switch{
background-color: rgba(255,255,255,0.25);
}
}
3 changes: 3 additions & 0 deletions src/components/Dropdowns/ImportFilesDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ImportFilesDropdown = ({ color, path }) => {
createPopper(btnDropdownRef.current, popoverDropdownRef.current, {
placement: 'bottom-start',
});
Emitter.emit('closeDropdownPopover');
setDropdownPopoverShow(true);
};
const closeDropdownPopover = () => {
Expand Down Expand Up @@ -63,9 +64,11 @@ const ImportFilesDropdown = ({ color, path }) => {
const t = function () {
closeDropdownPopover();
};
Emitter.on('closeDropdownPopover',closeDropdownPopover);
document.addEventListener('click', t);
return () => {
document.removeEventListener('click', t);
Emitter.removeListener('closeDropdownPopover');
};
}, []);

Expand Down
100 changes: 100 additions & 0 deletions src/components/Dropdowns/ImportFilesEncryptDropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React, { useEffect } from 'react';
import { createPopper } from '@popperjs/core';
import Emitter from 'utils/eventBus';
import { t } from 'utils/text.js';

// let folderInput = null;





const ImportFilesEncryptDropdown = ({ color, path }) => {
const [dropdownPopoverShow, setDropdownPopoverShow] = React.useState(false);
const btnDropdownRef = React.createRef();
const popoverDropdownRef = React.createRef();
const openDropdownPopover = () => {
createPopper(btnDropdownRef.current, popoverDropdownRef.current, {
placement: 'bottom-start',
});
Emitter.emit('closeDropdownPopover');
setDropdownPopoverShow(true);
};
const closeDropdownPopover = () => {
setDropdownPopoverShow(false);
};


const onDecryptFile = e => {
e.preventDefault();
Emitter.emit('openDecryptFileModal',{ path: path });
};

const onAddEncryptFile = e => {
e.preventDefault();
Emitter.emit('openEncryptFileModal',{ path: path });
};


useEffect(() => {
const t = function () {
closeDropdownPopover();
};

Emitter.on('closeDropdownPopover',closeDropdownPopover);
document.addEventListener('click', t);
return () => {
document.removeEventListener('click', t);
Emitter.removeListener('closeDropdownPopover');
};
}, []);

return (
<>
<button
className="common-btn theme-common-btn mr-4"
type="button"
ref={btnDropdownRef}
onClick={e => {
e.preventDefault();
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
dropdownPopoverShow ? closeDropdownPopover() : openDropdownPopover();
}}>
{t('encrypt_decrypt')}
</button>

<div
ref={popoverDropdownRef}
className={
(dropdownPopoverShow ? 'block ' : 'hidden ') +
'_box-shadow text-base z-50 float-left py-2 list-none text-left rounded shadow-lg min-w-48 mt-important theme-bg'
}>
<a
href="#addFile"
className={'text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent'}
onClick={onAddEncryptFile}>
<img
alt=""
src={require(`../../assets/img/encrypt-icon_${color}.svg`).default}
className="far mr-2 align-top "
/>
{t('encrypt_file')}
</a>
<a
href="#addFolder"
className={' text-sm py-2 px-4 font-normal block w-full whitespace-nowrap bg-transparent'}
onClick={onDecryptFile}>
<img
alt=""
src={require(`../../assets/img/decrypt-icon_${color}.svg`).default}
className="far mr-2 align-top"
/>
{t('decrypt_file')}
</a>
</div>
</>
);
};

export default ImportFilesEncryptDropdown;
Loading

0 comments on commit 0fdc7a1

Please sign in to comment.