From 3d73000e92ff88325e188a691563a0c900411ffb Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 21 Oct 2017 15:16:58 +0200 Subject: [PATCH] Displays a button that can be used to fetch search results and then each element has a magnet button to send it back. --- client/app/components/admin/PirateSearch.jsx | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 client/app/components/admin/PirateSearch.jsx diff --git a/client/app/components/admin/PirateSearch.jsx b/client/app/components/admin/PirateSearch.jsx new file mode 100644 index 0000000..b1d5191 --- /dev/null +++ b/client/app/components/admin/PirateSearch.jsx @@ -0,0 +1,57 @@ +import React, { Component } from 'react'; +import { fetchJSON } from '../http.jsx'; + +class PirateSearch extends Component { + constructor() { + super(); + this.state = { + response: [], + name: '', + } + } + + sendToDownload(torrent) { + console.log(torrent.magnet) + + let data = {magnet: torrent.magnet} + fetchJSON('https://apollo.kevinmidboe.com/api/v1/pirate/add', 'POST', data) + .then((response) => { + console.log(response) + }) + } + + searchTheBay() { + const query = this.props.name; + const type = this.props.type; + + fetchJSON('https://apollo.kevinmidboe.com/api/v1/pirate/search?query='+query+'&type='+type, 'GET') + .then((response) => { + console.log(response.torrents) + this.setState({ + response: response.torrents.map((torrent, index) => { + return ( +
+ {torrent.name}
+ {torrent.size}
+ {torrent.seed}
+ +

+
+ ) + }) + }) + }) + } + + render() { + return ( +
+ {this.props.name} + + {this.state.response} +
+ ) + } +} + +export default PirateSearch \ No newline at end of file