|
|
|
@ -28,7 +28,7 @@ class Contexmenu extends Component {
@@ -28,7 +28,7 @@ class Contexmenu extends Component {
|
|
|
|
|
if(this.props.mode == 'horizontal'){ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if(this.props.selectedUserIds.indexOf(this.props.item) == -1) |
|
|
|
|
if(this.props.selectedIpIds.indexOf(this.props.item) == -1) |
|
|
|
|
this.props.setIpSelectedIds([this.props.item]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -85,24 +85,23 @@ class Contexmenu extends Component {
@@ -85,24 +85,23 @@ class Contexmenu extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete = async () => { |
|
|
|
|
let {item, users, profile, selectedUserIds, mode, data, ban_ip} = this.props; |
|
|
|
|
await this.props.deleteIp({id: selectedUserIds}); |
|
|
|
|
let {item, users, profile, selectedIpIds, mode, data, ban_ip} = this.props; |
|
|
|
|
await this.props.deleteIp({id: selectedIpIds}); |
|
|
|
|
this.setState({warningDelete: false}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleMenuClick = async (e) => { |
|
|
|
|
let {item, users, profile, selectedUserIds, mode, data, ban_ip} = this.props; |
|
|
|
|
let {item, users, profile, selectedIpIds, mode, data, ban_ip} = this.props; |
|
|
|
|
|
|
|
|
|
switch (e.key) { |
|
|
|
|
case 'delete': |
|
|
|
|
await this.props.deleteIp({id: selectedUserIds}); |
|
|
|
|
await this.props.deleteIp({id: selectedIpIds}); |
|
|
|
|
break; |
|
|
|
|
case 'delete2': |
|
|
|
|
this.props.handleMenuClick(); |
|
|
|
|
this.setState({warningDelete: true}) |
|
|
|
|
break; |
|
|
|
|
case 'is_ban': |
|
|
|
|
for(let item_id of selectedUserIds){ |
|
|
|
|
for(let item_id of selectedIpIds){ |
|
|
|
|
let index = _.findIndex(data, ['id', item_id]); |
|
|
|
|
let log_item = index > -1 ? data[index] : null; |
|
|
|
|
if(log_item){ |
|
|
|
@ -112,7 +111,7 @@ class Contexmenu extends Component {
@@ -112,7 +111,7 @@ class Contexmenu extends Component {
|
|
|
|
|
await this.props.getIps() |
|
|
|
|
break; |
|
|
|
|
case 'is_white': |
|
|
|
|
for(let item_id of selectedUserIds){ |
|
|
|
|
for(let item_id of selectedIpIds){ |
|
|
|
|
let index = _.findIndex(data, ['id', item_id]); |
|
|
|
|
let log_item = index > -1 ? data[index] : null; |
|
|
|
|
if(log_item){ |
|
|
|
@ -129,7 +128,7 @@ class Contexmenu extends Component {
@@ -129,7 +128,7 @@ class Contexmenu extends Component {
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
let {warningDelete} = this.state; |
|
|
|
|
let {item, users, profile, selectedUserIds, mode, data, ban_ip} = this.props; |
|
|
|
|
let {item, users, profile, selectedIpIds, mode, data, ban_ip} = this.props; |
|
|
|
|
|
|
|
|
|
if(!mode){ |
|
|
|
|
mode = "vertical"; |
|
|
|
@ -143,6 +142,13 @@ class Contexmenu extends Component {
@@ -143,6 +142,13 @@ class Contexmenu extends Component {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let ips = []; |
|
|
|
|
|
|
|
|
|
data.forEach(element => { |
|
|
|
|
if(~selectedIpIds.indexOf(element.id)){ |
|
|
|
|
ips.push(element.ip.replace(/:/g, '').replace('ffff', '')) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -161,8 +167,8 @@ class Contexmenu extends Component {
@@ -161,8 +167,8 @@ class Contexmenu extends Component {
|
|
|
|
|
> |
|
|
|
|
<div className="modal__body"> |
|
|
|
|
|
|
|
|
|
{selectedUserIds.length > 1 ? |
|
|
|
|
<h4 style={{color: 'white', fontWeight: 300}} key="msg1">Ви справді бажаєте видалити Ip?</h4> : <h4 style={{color: 'white', fontWeight: 300}}>Ви справді бажаєте видалити Ip</h4>} |
|
|
|
|
{selectedIpIds.length > 1 ? |
|
|
|
|
<h4 style={{color: 'white', fontWeight: 300}} key="msg1">Ви справді бажаєте видалити Ip: {ips.join(', ')} ?</h4> : <h4 style={{color: 'white', fontWeight: 300}}>Ви справді бажаєте видалити Ip {log.ip.replace(/:/g, '').replace('ffff', '')} ?</h4>} |
|
|
|
|
</div> |
|
|
|
|
<ButtonToolbar className="modal__footer"> |
|
|
|
|
<Button onClick={() => {this.setState({warningDelete: false})}}>Ні</Button>{' '} |
|
|
|
@ -171,7 +177,7 @@ class Contexmenu extends Component {
@@ -171,7 +177,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Modal> |
|
|
|
|
<Menu onClick={this.handleMenuClick} selectable={false} mode={mode || "vertical"}> |
|
|
|
|
|
|
|
|
|
{ selectedUserIds.length >= 1 && !is_white ? |
|
|
|
|
{ selectedIpIds.length >= 1 && !is_white ? |
|
|
|
|
<Item key='delete'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Розблокувати ip' : null}> |
|
|
|
|
<i className="fal fa-lock-open-alt"></i>{mode == "vertical" ? ' Розблокувати ip' : null} |
|
|
|
@ -179,7 +185,7 @@ class Contexmenu extends Component {
@@ -179,7 +185,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{ selectedUserIds.length >= 1 && !is_white ? |
|
|
|
|
{ selectedIpIds.length >= 1 && !is_white ? |
|
|
|
|
<Item key='is_white'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Додати в білий список' : null}> |
|
|
|
|
<i className="fal fa-notes-medical"></i>{mode == "vertical" ? ' Додати в білий список' : null} |
|
|
|
@ -187,7 +193,7 @@ class Contexmenu extends Component {
@@ -187,7 +193,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{ selectedUserIds.length >= 1 && is_white ? |
|
|
|
|
{ selectedIpIds.length >= 1 && is_white ? |
|
|
|
|
<Item key='is_ban'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Заблокувати ip' : null}> |
|
|
|
|
<i className="fal fa-lock-alt"></i>{mode == "vertical" ? ' Заблокувати ip' : null} |
|
|
|
@ -195,7 +201,7 @@ class Contexmenu extends Component {
@@ -195,7 +201,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{ selectedUserIds.length >= 1 ? |
|
|
|
|
{ selectedIpIds.length >= 1 ? |
|
|
|
|
<Item key='delete2'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Видалити' : null}> |
|
|
|
|
<i className="fal fa-trash-alt"></i>{mode == "vertical" ? ' Видалити' : null} |
|
|
|
@ -203,7 +209,7 @@ class Contexmenu extends Component {
@@ -203,7 +209,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{/* {getPermissionCheck('user', 'update', profile) && selectedUserIds.length == 1 && log.user_id && log.user_id.is_ban ? |
|
|
|
|
{/* {getPermissionCheck('user', 'update', profile) && selectedIpIds.length == 1 && log.user_id && log.user_id.is_ban ? |
|
|
|
|
<Item key='notban'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Розблокувати користувача' : null}> |
|
|
|
|
<i className="fal fa-lock-open-alt"></i>{mode == "vertical" ? ' Розблокувати користувача' : null} |
|
|
|
@ -211,7 +217,7 @@ class Contexmenu extends Component {
@@ -211,7 +217,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{getPermissionCheck('user', 'update', profile) && selectedUserIds.length == 1 && find_index < 0 ? |
|
|
|
|
{getPermissionCheck('user', 'update', profile) && selectedIpIds.length == 1 && find_index < 0 ? |
|
|
|
|
<Item key='isban_ip'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Заблокувати ip' : null}> |
|
|
|
|
<i className="fal fa-lock-alt"></i>{mode == "vertical" ? ' Заблокувати ip' : null} |
|
|
|
@ -219,7 +225,7 @@ class Contexmenu extends Component {
@@ -219,7 +225,7 @@ class Contexmenu extends Component {
|
|
|
|
|
</Item> |
|
|
|
|
: null} |
|
|
|
|
|
|
|
|
|
{getPermissionCheck('user', 'update', profile) && selectedUserIds.length == 1 && find_index > -1 ? |
|
|
|
|
{getPermissionCheck('user', 'update', profile) && selectedIpIds.length == 1 && find_index > -1 ? |
|
|
|
|
<Item key='notban_ip'> |
|
|
|
|
<Tooltip placement="bottom" title={mode != "vertical" ? ' Розблокувати ip' : null}> |
|
|
|
|
<i className="fal fa-lock-open-alt"></i>{mode == "vertical" ? ' Розблокувати ip' : null} |
|
|
|
@ -239,7 +245,7 @@ Contexmenu.propTypes = {
@@ -239,7 +245,7 @@ Contexmenu.propTypes = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => ({ |
|
|
|
|
selectedUserIds: state.ips.ip_selected_ids, |
|
|
|
|
selectedIpIds: state.ips.ip_selected_ids, |
|
|
|
|
data: state.ips.data, |
|
|
|
|
ban_ip: state.ips.ban_ip, |
|
|
|
|
profile: state.auth.profile, |
|
|
|
|