From a442341cd003b75d06c2df69acf194e27c417823 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 11 Oct 2018 15:20:17 -0700 Subject: [PATCH] Changing space indents on UI. Changing td aligns to bootstrap text-right --- server/ui/.editorconfig | 2 +- server/ui/src/index.tsx | 342 ++++++++++++++++++------------------ server/ui/src/interfaces.ts | 30 ++-- 3 files changed, 187 insertions(+), 187 deletions(-) diff --git a/server/ui/.editorconfig b/server/ui/.editorconfig index c43ef8b..ac63e19 100644 --- a/server/ui/.editorconfig +++ b/server/ui/.editorconfig @@ -1,5 +1,5 @@ [*.{js,jsx,ts,tsx,json}] -indent_style = tab +indent_style = space indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true diff --git a/server/ui/src/index.tsx b/server/ui/src/index.tsx index e3ff7bd..9f2e1c5 100644 --- a/server/ui/src/index.tsx +++ b/server/ui/src/index.tsx @@ -11,196 +11,196 @@ const container = document.getElementById('app'); class TorrentSearchComponent extends Component { - state: State = { - results: { - torrents: [] - }, - searchParams: { - q: "", - page: 1 - }, - searching: false - }; + state: State = { + results: { + torrents: [] + }, + searchParams: { + q: "", + page: 1 + }, + searching: false + }; - constructor(props, context) { - super(props, context); + constructor(props, context) { + super(props, context); - } + } - search(i: TorrentSearchComponent, event) { - event.preventDefault(); + search(i: TorrentSearchComponent, event) { + event.preventDefault(); - if (!!i.state.searchParams.q) { - i.setState({ searching: true, results: { torrents: [] } }); - i.fetchData(i.state.searchParams) - .then(results => { - if (!!results) { - i.setState({ - results: results - }); - } - }).catch(error => { - console.error('request failed', error); - }).then(() => i.setState({ searching: false })); - } else { - i.setState({ results: { torrents: [] } }); - } - } + if (!!i.state.searchParams.q) { + i.setState({ searching: true, results: { torrents: [] } }); + i.fetchData(i.state.searchParams) + .then(results => { + if (!!results) { + i.setState({ + results: results + }); + } + }).catch(error => { + console.error('request failed', error); + }).then(() => i.setState({ searching: false })); + } else { + i.setState({ results: { torrents: [] } }); + } + } - fetchData(searchParams: SearchParams): Promise { - let q = encodeURI(searchParams.q); - return fetch(`${endpoint}/service/search?q=${q}&page=${searchParams.page}`) - .then(data => data.text()) - .then(csv => convertCsvToJson(csv)); - } + fetchData(searchParams: SearchParams): Promise { + let q = encodeURI(searchParams.q); + return fetch(`${endpoint}/service/search?q=${q}&page=${searchParams.page}`) + .then(data => data.text()) + .then(csv => convertCsvToJson(csv)); + } - render() { - return ( -
- {this.navbar()} -
-
-
- { - this.state.searching ? - this.spinner() - : - this.state.results.torrents[0] ? this.table() : this.onboard() - } -
-
-
-
- ); - } + render() { + return ( +
+ {this.navbar()} +
+
+
+ { + this.state.searching ? + this.spinner() + : + this.state.results.torrents[0] ? this.table() : this.onboard() + } +
+
+
+
+ ); + } - table() { - return ( -
- - - - - - - - - - - - - - {this.state.results.torrents.map(torrent => ( - - - - - - - - - - ))} - -
NameSizeSeedsLeechesCreatedScraped
{torrent.name}{humanFileSize(torrent.size_bytes, true)}{torrent.seeders}{torrent.leechers}{moment(torrent.created_unix * 1000).fromNow()}{moment(torrent.scraped_date * 1000).fromNow()} - - - -
- {this.paginator()} -
- ); - } + table() { + return ( +
+ + + + + + + + + + + + + + {this.state.results.torrents.map(torrent => ( + + + + + + + + + + ))} + +
NameSizeSeedsLeechesCreatedScraped
{torrent.name}{humanFileSize(torrent.size_bytes, true)}{torrent.seeders}{torrent.leechers}{moment(torrent.created_unix * 1000).fromNow()}{moment(torrent.scraped_date * 1000).fromNow()} + + + +
+ {this.paginator()} +
+ ); + } - navbar() { - return ( - + ); + } - // TODO - // https://www.codeply.com/go/xBVaM3q5X4/bootstrap-4-navbar-search-full-width - searchForm() { - return ( -
-
- - - -
-
- ); - } + // TODO + // https://www.codeply.com/go/xBVaM3q5X4/bootstrap-4-navbar-search-full-width + searchForm() { + return ( +
+
+ + + +
+
+ ); + } - spinner() { - return ( -
- + spinner() { + return ( +
+ +
+ ); + } + + onboard() { + let site: string = "https://gitlab.com/dessalines/torrents.csv"; + return ( +
+ Torrents.csv is a collaborative, vetted git repository of torrents, consisting of a single, searchable torrents.csv file. Its initially populated with a January 2017 backup of the pirate bay, and new torrents are periodically added from various torrents sites via a rust script.



+ Torrents.csv will only store torrents with at least one seeder to keep the file small, and will be periodically purged of non-seeded torrents, and sorted by seeders descending.



+ To request more torrents, or add your own to the file, go here.



+ Made with Rust, ripgrep, Actix, Inferno, and Typescript.
- ); - } + ); + } - onboard() { - let site: string = "https://gitlab.com/dessalines/torrents.csv"; - return ( -
- Torrents.csv is a collaborative, vetted git repository of torrents, consisting of a single, searchable torrents.csv file. Its initially populated with a January 2017 backup of the pirate bay, and new torrents are periodically added from various torrents sites via a rust script.



- Torrents.csv will only store torrents with at least one seeder to keep the file small, and will be periodically purged of non-seeded torrents, and sorted by seeders descending.



- To request more torrents, or add your own to the file, go here.



- Made with Rust, ripgrep, Actix, Inferno, and Typescript. -
- ); - } - - paginator() { - return ( - - ); - } + + + + ); + } - searchChange(i, event) { - let searchParams: SearchParams = { - q: event.target.value, - page: 1 - } - i.setState({ searchParams: searchParams }); - } + searchChange(i, event) { + let searchParams: SearchParams = { + q: event.target.value, + page: 1 + } + i.setState({ searchParams: searchParams }); + } - switchPage(a: { i: TorrentSearchComponent, nextPage: boolean }, event) { + switchPage(a: { i: TorrentSearchComponent, nextPage: boolean }, event) { - let newSearch = a.i.state.searchParams; - newSearch.page += (a.nextPage) ? 1 : -1; - a.i.setState({ - searchParams: newSearch - }); + let newSearch = a.i.state.searchParams; + newSearch.page += (a.nextPage) ? 1 : -1; + a.i.setState({ + searchParams: newSearch + }); - a.i.search(a.i, event); - } + a.i.search(a.i, event); + } } diff --git a/server/ui/src/interfaces.ts b/server/ui/src/interfaces.ts index 388a020..32fb3e7 100644 --- a/server/ui/src/interfaces.ts +++ b/server/ui/src/interfaces.ts @@ -1,26 +1,26 @@ export interface SearchParams { - q: string; - page: number; - size?: number; + q: string; + page: number; + size?: number; } export interface Results { - torrents: Array; + torrents: Array; } export interface Torrent { - infohash: string; - name: string; - size_bytes: number; - created_unix: number; - seeders: number; - leechers: number; - completed: number; - scraped_date: number; + infohash: string; + name: string; + size_bytes: number; + created_unix: number; + seeders: number; + leechers: number; + completed: number; + scraped_date: number; } export interface State { - results: Results; - searchParams: SearchParams; - searching: Boolean; + results: Results; + searchParams: SearchParams; + searching: Boolean; } \ No newline at end of file