Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thecybernanny-webapp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
asranov0003
thecybernanny-webapp
Commits
b1a872bd
Commit
b1a872bd
authored
Sep 18, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: make download recording
parent
1a0770e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
Recording.tsx
src/pages/Recording/Recording.tsx
+28
-3
No files found.
src/pages/Recording/Recording.tsx
View file @
b1a872bd
...
...
@@ -6,7 +6,7 @@ import CButton from "../../components/CButton";
import
{
useTranslation
}
from
"react-i18next"
;
import
{
FaMicrophoneLines
}
from
"react-icons/fa6"
;
import
{
FaImage
}
from
"react-icons/fa"
;
import
{
IoCloudDownloadOutline
,
IoPlay
}
from
"react-icons/io5"
;
import
{
IoCloudDownloadOutline
}
from
"react-icons/io5"
;
import
{
useAppDispatch
,
useAppSelector
,
...
...
@@ -15,10 +15,12 @@ import {
import
{
fetchAudioFiles
}
from
"../../stores/slices/deviceSlice"
;
import
{
AiOutlineAudio
}
from
"react-icons/ai"
;
import
{
APPS
,
type
IApp
}
from
"../../constants/apps"
;
import
type
{
IAudioList
}
from
"../../types/device.types"
;
const
Recording
:
React
.
FC
=
()
=>
{
const
[
selectedApp
,
setSelectedApp
]
=
useState
<
IApp
>
(
APPS
[
0
]);
const
[
selectedTab
,
setSelectedTab
]
=
useState
<
"audio"
|
"image"
>
(
"audio"
);
const
[
downloaded
,
setDownloaded
]
=
useState
<
Set
<
number
>>
(
new
Set
());
const
today
=
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
const
[
fromDate
,
setFromDate
]
=
useState
(
today
);
const
[
toDate
,
setToDate
]
=
useState
(
today
);
...
...
@@ -58,6 +60,17 @@ const Recording: React.FC = () => {
}
};
const
handleDownload
=
(
audio
:
IAudioList
,
index
:
number
)
=>
{
const
link
=
document
.
createElement
(
"a"
);
link
.
href
=
audio
.
url
;
link
.
download
=
`recording_
${
index
}
.
${
audio
.
file_ext
}
`
;
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
setDownloaded
((
prev
)
=>
new
Set
(
prev
).
add
(
index
));
};
useEffect
(()
=>
{
if
(
selectedDevice
?.
id
)
{
filterAudioHistory
();
...
...
@@ -83,6 +96,8 @@ const Recording: React.FC = () => {
<
div
className=
"recording__audio__list"
>
{
audioList
.
map
((
audio
,
index
)
=>
{
const
isDownloaded
=
downloaded
.
has
(
index
);
return
(
<
div
key=
{
index
}
className=
"recording__audio__item"
>
<
div
className=
"recording__audio__item__info"
>
...
...
@@ -95,8 +110,18 @@ const Recording: React.FC = () => {
</
div
>
<
div
className=
"recording__audio__item__info"
>
<
IoCloudDownloadOutline
className=
"recording__audio__item__icon"
/>
<
IoPlay
className=
"recording__audio__item__icon"
/>
<
IoCloudDownloadOutline
className=
{
`recording__audio__item__icon ${
isDownloaded ? "disabled" : ""
}`
}
onClick=
{
()
=>
!
isDownloaded
&&
handleDownload
(
audio
,
index
)
}
style=
{
{
cursor
:
isDownloaded
?
"not-allowed"
:
"pointer"
,
opacity
:
isDownloaded
?
0.4
:
1
,
}
}
/>
</
div
>
</
div
>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment