-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from SamTV12345/develop
Added opml local and online export.
- Loading branch information
Showing
10 changed files
with
252 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {useState} from "react"; | ||
import {useTranslation} from "react-i18next"; | ||
import axios from "axios"; | ||
import {apiURL} from "../utils/Utilities"; | ||
|
||
export const OPMLExport = () => { | ||
const [exportType, setExportType] = useState<string>('local') | ||
const {t} = useTranslation() | ||
|
||
const downloadOPML = ()=>{ | ||
axios({ | ||
url: apiURL+"/settings/opml/"+exportType, //your url | ||
method: 'GET', | ||
responseType: "blob" | ||
}).then((response) => { | ||
// create file link in browser's memory | ||
const href = URL.createObjectURL(response.data); | ||
|
||
// create "a" HTML element with href to file & click | ||
const link = document.createElement('a'); | ||
link.href = href; | ||
link.setAttribute('download', 'podcast_'+exportType+".opml"); //or any other extension | ||
document.body.appendChild(link); | ||
link.click(); | ||
|
||
// clean up "a" element & remove ObjectURL | ||
document.body.removeChild(link); | ||
URL.revokeObjectURL(href); | ||
}); | ||
} | ||
|
||
return <div className="bg-slate-900 rounded p-5 text-white"> | ||
<h1 className="text-2xl text-center">{t('opml-export')}</h1> | ||
<div className="mt-2 flex"> | ||
<div className="mt-2 mr-2">{t('i-want-to-export')}</div> | ||
<select id="countries" className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg | ||
focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 | ||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" | ||
onChange={(v)=>{setExportType(v.target.value)}} | ||
value={exportType}> | ||
<option value="local">{t('local')}</option> | ||
<option value="online">{t('online')}</option> | ||
</select> | ||
<div className="mt-2 ml-2">{t('export')}</div> | ||
</div> | ||
<div className="flex"> | ||
<div className="flex-1"></div> | ||
<button className="bg-blue-600 rounded p-2" onClick={()=>downloadOPML()}>{t('download')}</button> | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {setConfirmModalData, setPodcasts} from "../store/CommonSlice"; | ||
import {setModalOpen} from "../store/ModalSlice"; | ||
import {useAppDispatch, useAppSelector} from "../store/hooks"; | ||
import {useTranslation} from "react-i18next"; | ||
import axios from "axios"; | ||
import {apiURL} from "../utils/Utilities"; | ||
import {enqueueSnackbar} from "notistack"; | ||
import {useEffect} from "react"; | ||
|
||
export const PodcastDelete = () => { | ||
const podcasts = useAppSelector(state=>state.common.podcasts) | ||
const dispatch = useAppDispatch() | ||
const {t} = useTranslation() | ||
|
||
useEffect(()=>{ | ||
if(podcasts.length===0){ | ||
axios.get(apiURL+"/podcasts") | ||
.then((v)=>{ | ||
dispatch(setPodcasts(v.data)) | ||
}) | ||
} | ||
},[]) | ||
|
||
const deletePodcast = (withFiles:boolean, podcast_id: number)=>{ | ||
axios.delete(apiURL+"/podcast/"+podcast_id,{data: {delete_files: withFiles}}) | ||
.then(()=>{ | ||
enqueueSnackbar(t('podcast-deleted'),{variant: "success"}) | ||
}) | ||
} | ||
|
||
return <div className="bg-slate-900 rounded p-5 text-white"> | ||
<h1 className="text-2xl text-center">{t('manage-podcasts')}</h1> | ||
<div className="mt-2"> | ||
{ | ||
podcasts.map(p=> | ||
<div className="border-2 border-b-indigo-100 p-4"> | ||
<h2>{p.name}</h2> | ||
<div className="grid grid-cols-2 gap-5"> | ||
<button className="bg-red-500" onClick={()=>{ | ||
dispatch(setConfirmModalData({ | ||
headerText: t('delete-podcast-with-files'), | ||
onAccept:()=>{ | ||
deletePodcast(true, p.id) | ||
}, | ||
onReject: ()=>{ | ||
dispatch(setModalOpen(false)) | ||
}, | ||
acceptText: t('delete-podcast'), | ||
rejectText: t('cancel'), | ||
bodyText: t('delete-podcast-with-files-body', {name: p.name}) | ||
})) | ||
dispatch(setModalOpen(true)) | ||
}}>{t('delete-podcasts-without-files')}</button> | ||
<button className="bg-red-500" onClick={()=>{ | ||
dispatch(setConfirmModalData({ | ||
headerText: t('delete-podcast-without-files'), | ||
onAccept:()=>{ | ||
deletePodcast(false, p.id) | ||
}, | ||
onReject: ()=>{ | ||
dispatch(setModalOpen(false)) | ||
}, | ||
acceptText: t('delete-podcast'), | ||
rejectText: t('cancel'), | ||
bodyText: t('delete-podcast-without-files-body', {name: p.name}) | ||
})) | ||
dispatch(setModalOpen(true)) | ||
}}>{t('delete-podcasts-without-files')}</button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.