noauth probe accept/deny

This commit is contained in:
insanity 2017-08-22 15:36:40 +09:00
parent dd2683eada
commit dcb5e78c3d
20 changed files with 203 additions and 196 deletions

View File

@ -9,6 +9,8 @@ import readProbeReducer from '@overflow/probe/redux/reducer/read';
import hostReadByProbeReducer from '@overflow/probe/redux/reducer/host_read_by_probe';
import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain';
import noauthAcceptReducer from '@overflow/noauthprobe/redux/reducer/accept';
import noauthDenyReducer from '@overflow/noauthprobe/redux/reducer/deny';
import readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe';
import readAllTargetByDomainReducer from '@overflow/target/redux/reducer/read_all_by_domain';
@ -85,6 +87,8 @@ const reduxConfig: ReduxConfig = {
readOSReducer,
readServiceReducer,
hostReadByProbeReducer,
noauthAcceptReducer,
noauthDenyReducer,
],
sagaWatchers: [
AsyncRequest,

View File

@ -1,32 +1,38 @@
import { connect, Dispatch } from 'react-redux';
import {
NoauthProbeList,
StateProps as NoAuthProbeListStateProps,
DispatchProps as NoAuthProbeListDispatchProps,
NoauthProbeList,
StateProps as NoAuthProbeListStateProps,
DispatchProps as NoAuthProbeListDispatchProps,
} from './components/NoauthProbeList';
import Domain from '@overflow/domain/api/model/Domain';
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
import * as noauthListActions from '../redux/action/read_all_by_domain';
import * as denyActions from '../redux/action/deny';
import * as acceptActions from '../redux/action/accept';
import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe';
export function mapStateToProps(state: any): NoAuthProbeListStateProps {
return {
noauthList: state.noauthList,
};
return {
noauthList: state.noauthList,
};
}
export function mapDispatchToProps(dispatch: Dispatch<any>): NoAuthProbeListDispatchProps {
return {
onReadAllByDomain: (domain: Domain) => {
dispatch(asyncRequestActions.request('NoAuthProbeService', 'readAllByDomain', noauthListActions.REQUEST, JSON.stringify(domain)));
},
registNoAuthProbe: (noauthProbe: NoAuthProbe[]) => {
// dispatch(
// asyncRequestActions.request(
// 'NoAuthProbeService', 'registForNoAuthProbes', noauthListActions.REQUEST, JSON.stringify(noauthProbe))
// );
},
};
return {
onReadAllByDomain: (domain: Domain) => {
dispatch(asyncRequestActions.request('NoAuthProbeService', 'readAllByDomain', noauthListActions.REQUEST, JSON.stringify(domain)));
},
acceptNoAuthProbe: (noauthProbes: NoAuthProbe[]) => {
dispatch(
asyncRequestActions.request(
'NoAuthProbeService', 'acceptNoAuthProbes', acceptActions.REQUEST, JSON.stringify(noauthProbes)));
},
denyNoAuthProbe: (noauthProbes: NoAuthProbe[]) => {
dispatch(
asyncRequestActions.request(
'NoAuthProbeService', 'denyNoauthProbes', denyActions.REQUEST, JSON.stringify(noauthProbes)));
},
};
}
export default connect(mapStateToProps, mapDispatchToProps)(NoauthProbeList);

View File

@ -5,6 +5,9 @@ import {
Button,
Header,
Container,
Modal,
Icon,
List,
} from 'semantic-ui-react';
import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe';
import Domain from '@overflow/domain/api/model/Domain';
@ -15,15 +18,18 @@ export interface StateProps {
}
export interface DispatchProps {
onReadAllByDomain?(domain: Domain):void;
registNoAuthProbe?(noauthProbe: NoAuthProbe[]):void;
onReadAllByDomain?(domain: Domain): void;
acceptNoAuthProbe?(noauthProbe: NoAuthProbe[]): void;
denyNoAuthProbe?(noauthProbe: NoAuthProbe[]): void;
}
export type Props = StateProps & DispatchProps;
export interface State {
selected: NoAuthProbe[];
list: NoAuthProbe[];
modalVisible: boolean;
actionDisabled: boolean;
isDeny: boolean;
}
export class NoauthProbeList extends React.Component<Props, State> {
@ -35,14 +41,16 @@ export class NoauthProbeList extends React.Component<Props, State> {
super(props, context);
this.state = {
selected: [],
list: null,
modalVisible: false,
actionDisabled: true,
isDeny: false,
};
this.selectedIds = new Array();
}
public componentWillMount(): void {
let domain: Domain = {
id:1,
id: 1,
};
this.props.onReadAllByDomain(domain);
}
@ -59,10 +67,8 @@ export class NoauthProbeList extends React.Component<Props, State> {
});
}
// tslint:disable-next-line:no-empty
public handleSearch = (result: any[]): void => {
this.setState({
list: result,
});
}
public checkExist(probe: NoAuthProbe): boolean {
@ -72,12 +78,34 @@ export class NoauthProbeList extends React.Component<Props, State> {
return true;
}
public handleAccept(): void {
this.props.registNoAuthProbe(this.state.selected);
public handleActionDisable(): boolean {
if (this.state.selected === null || this.state.selected === undefined) {
return true;
}
if (this.state.selected.length === 0) {
return true;
}
return false;
}
public handleConfirm(): void {
if (this.state.isDeny) {
console.log('Denied.');
this.props.denyNoAuthProbe(this.state.selected);
} else {
console.log('Accepted.');
this.props.acceptNoAuthProbe(this.state.selected);
}
this.setState({
modalVisible: false,
});
}
public handleDeny(): void {
alert(this.state.selected);
this.setState({
isDeny: true,
modalVisible: true,
});
}
public handleRowActive(probe: NoAuthProbe): boolean {
@ -86,6 +114,13 @@ export class NoauthProbeList extends React.Component<Props, State> {
}
return true;
}
public showList(): JSX.Element[] {
return this.state.selected.map((probe: NoAuthProbe, index: number) => (
<div key={index}>
{probe.ipAddress}
</div>
));
}
public render(): JSX.Element {
let noauth =
@ -107,8 +142,33 @@ export class NoauthProbeList extends React.Component<Props, State> {
{this.renderRows()}
</Table.Body>
</Table>
<Button primary floated={'right'} onClick={this.handleAccept.bind(this)}>Accept</Button>
<Button floated={'right'} onClick={this.handleDeny.bind(this)}>Deny</Button>
{/* <Button primary disabled={this.state.actionDisabled} */}
<Button primary disabled={this.handleActionDisable()}
floated={'right'} onClick={() => this.setState({ modalVisible: true, isDeny: false })}>
Accept
</Button>
<Button disabled={this.handleActionDisable()} floated={'right'}
onClick={() => this.setState({ modalVisible: true, isDeny: true })}>
Deny
</Button>
<Modal size='tiny'
open={this.state.modalVisible}
>
<Header icon='certificate' content='Confirm' />
<Modal.Content>
Are you sure?
{this.showList()}
</Modal.Content>
<Modal.Actions>
<Button color='red' onClick={() => this.setState({ modalVisible: false })}>
<Icon name='remove' /> No
</Button>
<Button color='green' onClick={this.handleConfirm.bind(this)} >
<Icon name='checkmark' /> Yes
</Button>
</Modal.Actions>
</Modal>
</Container>;
return (
<ListContainer
@ -147,57 +207,3 @@ export class NoauthProbeList extends React.Component<Props, State> {
}
}
// this.data = [
// {
// 'id': '11',
// 'MetaNoAuthProbeStatus': {
// 'name': 'PROCESS',
// },
// 'hostName': 'insanity windows',
// 'macAddress': '14:fe:b5:9d:54:7e',
// 'ipAddress': '192.168.1.105',
// 'tempProbeKey': '45374d4egsdfw332',
// 'apiKey': '45374d4egsdfw332',
// 'domain': {
//
// },
// 'probe': {
//
// },
// },
// {
// 'id': '22',
// 'MetaNoAuthProbeStatus': {
// 'name': 'PROCESS',
// },
// 'hostName': 'insanity ubuntu',
// 'macAddress': '14:fe:b5:9d:54:7e',
// 'ipAddress': '192.168.1.105',
// 'tempProbeKey': '45374d4egsdfw332',
// 'apiKey': '45374d4egsdfw332',
// 'domain': {
//
// },
// 'probe': {
//
// },
// },
// {
// 'id': '33',
// 'MetaNoAuthProbeStatus': {
// 'name': 'PROCESS',
// },
// 'hostName': 'insanity ubuntu',
// 'macAddress': '14:fe:b5:9d:54:7e',
// 'ipAddress': '192.168.1.105',
// 'tempProbeKey': '45374d4egsdfw332',
// 'apiKey': '45374d4egsdfw332',
// 'domain': {
//
// },
// 'probe': {
//
// },
// },
// ];

View File

@ -0,0 +1,7 @@
export type REQUEST = '@overflow/noAuthProbe/accept/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noAuthProbe/accept/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/noAuthProbe/accept/REQUEST/FAILURE';
export const REQUEST: REQUEST = '@overflow/noAuthProbe/accept/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/accept/REQUEST/SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/accept/REQUEST/FAILURE';

View File

@ -0,0 +1,8 @@
export type REQUEST = '@overflow/noAuthProbe/deny/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noAuthProbe/deny/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/noAuthProbe/deny/REQUEST/FAILURE';
export const REQUEST: REQUEST = '@overflow/noAuthProbe/deny/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/deny/REQUEST/SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/deny/REQUEST/FAILURE';

View File

@ -1,43 +0,0 @@
import Action from '@overflow/commons/redux/Action';
import NoAuthProbe from '../..//api/model/NoAuthProbe';
import ReadPayload from '../payload/ReadPayload';
// Action Type
export type REQUEST = '@overflow/noAuthProbe/read/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noAuthProbe/read/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/noAuthProbe/read/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/noAuthProbe/read/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/read/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/read/REQUEST_FAILURE';
// Action Creater
export type request = (id: number) => Action<ReadPayload>;
export type requestSuccess = (noAuthProbe: NoAuthProbe) => Action<NoAuthProbe>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<ReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (noAuthProbe: NoAuthProbe): Action<NoAuthProbe> => {
return {
type: REQUEST_SUCCESS,
payload: noAuthProbe,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,43 +0,0 @@
import Action from '@overflow/commons/redux/Action';
import NoAuthProbe from '../..//api/model/NoAuthProbe';
import RegistPayload from '../payload/RegistPayload';
// Action Type
export type REQUEST = '@overflow/noAuthProbe/regist/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noAuthProbe/regist/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/noAuthProbe/regist/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/noAuthProbe/regist/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/regist/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/regist/REQUEST_FAILURE';
// Action Creater
export type request = (noAuthProbe: NoAuthProbe) => Action<RegistPayload>;
export type requestSuccess = (noAuthProbe: NoAuthProbe) => Action<NoAuthProbe>;
export type requestFailure = (error: Error) => Action;
export const request: request = (noAuthProbe: NoAuthProbe): Action<RegistPayload> => {
return {
type: REQUEST,
payload: {
noAuthProbe:noAuthProbe,
},
};
};
export const requestSuccess: requestSuccess = (noAuthProbe: NoAuthProbe): Action<NoAuthProbe> => {
return {
type: REQUEST_SUCCESS,
payload: noAuthProbe,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,7 @@
import NoAuthProbe from '../../api/model/NoAuthProbe';
interface AcceptPayload {
noAuthProbes: NoAuthProbe[];
}
export default AcceptPayload;

View File

@ -0,0 +1,7 @@
import NoAuthProbe from '../../api/model/NoAuthProbe';
interface DenyPayload {
noAuthProbes: NoAuthProbe[];
}
export default DenyPayload;

View File

@ -1,7 +0,0 @@
interface ReadPayload {
id: number;
}
export default ReadPayload;

View File

@ -1,7 +0,0 @@
import NoAuthProbe from '../../api/model/NoAuthProbe';
interface RegistPayload {
noAuthProbe: NoAuthProbe;
}
export default RegistPayload;

View File

@ -0,0 +1,24 @@
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe';
import * as AcceptActionTypes from '../action/accept';
import AcceptState, { defaultState as acceptDefaultState } from '../state/Accept';
const reducer: ReducersMapObject = {
[AcceptActionTypes.REQUEST_SUCCESS]:
(state: AcceptState = acceptDefaultState, action: Action<NoAuthProbe>):
AcceptState => {
return {
...state,
noauthList: <NoAuthProbe[]>action.payload,
};
},
[AcceptActionTypes.REQUEST_FAILURE]:
(state: AcceptState = acceptDefaultState, action: Action<Error>):
AcceptState => {
return state;
},
};
export default reducer;

View File

@ -0,0 +1,24 @@
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe';
import * as DenyActionTypes from '../action/deny';
import DenyState, { defaultState as denyDefaultState } from '../state/Deny';
const reducer: ReducersMapObject = {
[DenyActionTypes.REQUEST_SUCCESS]:
(state: DenyState = denyDefaultState, action: Action<NoAuthProbe>):
DenyState => {
return {
...state,
noauthList: <NoAuthProbe[]>action.payload,
};
},
[DenyActionTypes.REQUEST_FAILURE]:
(state: DenyState = denyDefaultState, action: Action<Error>):
DenyState => {
return state;
},
};
export default reducer;

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -1,6 +1,3 @@
/**
* Created by geek on 17. 7. 3.
*/
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import NoAuthProbe from '@overflow/noauthprobe/api/model/NoAuthProbe';

View File

@ -0,0 +1,13 @@
import NoAuthProbe from '../../api/model/NoAuthProbe';
export interface State {
readonly noauthList?: NoAuthProbe[];
readonly error?: Error;
}
export const defaultState: State = {
noauthList: undefined,
error: undefined,
};
export default State;

View File

@ -0,0 +1,13 @@
import NoAuthProbe from '../../api/model/NoAuthProbe';
export interface State {
readonly noauthList?: NoAuthProbe[];
readonly error?: Error;
}
export const defaultState: State = {
noauthList: undefined,
error: undefined,
};
export default State;

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/

View File

@ -1,3 +0,0 @@
/**
* Created by geek on 17. 7. 3.
*/