forked from imWildCat/scylla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Web UI filter for https/anonymous
- Loading branch information
Showing
8 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
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
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,86 @@ | ||
import * as React from 'react'; | ||
import {Link} from "react-router-dom"; | ||
import * as queryString from "query-string"; | ||
|
||
export interface ProxyListFilterProps { | ||
location: any; | ||
} | ||
|
||
export interface ProxyListFilterState { | ||
https: boolean | null; | ||
anonymous: boolean | null; | ||
} | ||
|
||
export default class ProxyListFilter extends React.Component<ProxyListFilterProps, ProxyListFilterState> { | ||
constructor(props: ProxyListFilterProps) { | ||
super(props); | ||
|
||
this.state = { | ||
https: null, | ||
anonymous: null, | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="filter"> | ||
<Link to={this.genLink('HTTPS')} className={this.genClassName('HTTPS')}>HTTPS</Link> | ||
<Link to={this.genLink('ANONYMOUS')} className={this.genClassName('ANONYMOUS')}>ANONYMOUS</Link> | ||
</div> | ||
); | ||
} | ||
|
||
componentDidMount() { | ||
this.handleProps(this.props); | ||
} | ||
|
||
componentWillReceiveProps(nextProps: ProxyListFilterProps) { | ||
this.handleProps(nextProps); | ||
} | ||
|
||
handleProps(props: ProxyListFilterProps) { | ||
const parsed = queryString.parse(props.location.search); | ||
|
||
const https = parsed['https'] == 'true' ? true : null; | ||
const anonymous = parsed['anonymous'] == 'true' ? true : null; | ||
|
||
this.setState({https: https, anonymous: anonymous}) | ||
} | ||
|
||
genLink(key: string): string { | ||
|
||
const {anonymous, https} = this.state; | ||
let params: any = { | ||
anonymous, | ||
https, | ||
}; | ||
|
||
if (key === 'HTTPS') { | ||
params['https'] = https == true ? null : true; | ||
} else if (key === 'ANONYMOUS') { | ||
params['anonymous'] = anonymous == true ? null : true; | ||
} | ||
|
||
|
||
return `/?${queryString.stringify(params)}`; | ||
} | ||
|
||
|
||
genClassName(key: string): string { | ||
const {anonymous, https} = this.state; | ||
|
||
let baseClassName = 'button'; | ||
|
||
if (key === 'HTTPS') { | ||
if (!https) { | ||
baseClassName += ' button-outline' | ||
} | ||
} else if (key === 'ANONYMOUS') { | ||
if (!anonymous) { | ||
baseClassName += ' button-outline' | ||
} | ||
} | ||
return baseClassName; | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -37,6 +37,10 @@ ul.pagination { | |
} | ||
} | ||
|
||
.button + .button { | ||
margin-left: 5px; | ||
} | ||
|
||
footer { | ||
div { | ||
text-align: center; | ||
|
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