noauthProbe

This commit is contained in:
geek 2017-08-11 15:09:00 +09:00
parent 84d501921d
commit 3fc7439a60
6 changed files with 155 additions and 130 deletions

View File

@ -6,6 +6,9 @@ import signUpReducer from '@overflow/member/redux/reducer/signUp';
import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain';
import readProbeReducer from '@overflow/probe/redux/reducer/read';
import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain';
import readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe';
import readTargetReducer from '@overflow/target/redux/reducer/read';
@ -57,6 +60,7 @@ const reduxConfig: ReduxConfig = {
SensorItemReadAllBySensorReducer,
readAllTargetByProbeReducer,
readTargetReducer,
readNoAuthProbeReducer,
],
sagaWatchers: [
AsyncRequest,

View File

@ -1,20 +1,24 @@
import { connect, Dispatch } from 'react-redux';
import {
NoauthProbeList,
StateProps as ProbeListStateProps,
DispatchProps as ProbeListDispatchProps,
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';
export function mapStateToProps(state: any): ProbeListStateProps {
export function mapStateToProps(state: any): NoAuthProbeListStateProps {
return {
noauthList: state.noauthList,
};
}
export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeListDispatchProps {
export function mapDispatchToProps(dispatch: Dispatch<any>): NoAuthProbeListDispatchProps {
return {
onReadAllByDomain: (domain: Domain) => {
dispatch(asyncRequestActions.request('NoAuthProbeService', 'readAllByDomain', noauthListActions.REQUEST, JSON.stringify(domain)));
},
};
}

View File

@ -11,9 +11,11 @@ import Domain from '@overflow/domain/api/model/Domain';
import { ListContainer } from '@overflow/commons/react/component/ListContainer';
export interface StateProps {
noauthList?: NoAuthProbe[];
}
export interface DispatchProps {
onReadAllByDomain?(domain: Domain):void;
}
export type Props = StateProps & DispatchProps;
@ -23,10 +25,10 @@ export interface State {
list: NoAuthProbe[];
}
export class NoauthProbeList extends React.Component<any, any> {
export class NoauthProbeList extends React.Component<Props, State> {
private data: any;
private selectedIds: Array<string>;
private selectedIds: NoAuthProbe[];
constructor(props: Props, context: State) {
super(props, context);
@ -38,68 +40,16 @@ export class NoauthProbeList extends React.Component<any, any> {
}
public componentWillMount(): void {
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': {
},
},
];
this.setState({
list: this.data,
});
let domain: Domain = {
id:1,
};
this.props.onReadAllByDomain(domain);
}
public handleSelect(id: string): void {
let idx = this.selectedIds.indexOf(id);
public handleSelect(probe: NoAuthProbe): void {
let idx = this.selectedIds.indexOf(probe);
if (idx === -1) {
this.selectedIds.push(id);
this.selectedIds.push(probe);
} else {
this.selectedIds.splice(idx, 1);
}
@ -114,10 +64,10 @@ export class NoauthProbeList extends React.Component<any, any> {
});
}
public checkExist(id: string): boolean {
if (this.state.selected.indexOf(id) === -1) {
return false;
}
public checkExist(probe: NoAuthProbe): boolean {
// if (this.state.selected.indexOf(id) === -1) {
// return false;
// }
return true;
}
@ -129,8 +79,8 @@ export class NoauthProbeList extends React.Component<any, any> {
alert(this.state.selected);
}
public handleRowActive(id: string): boolean {
if (this.state.selected.indexOf(id) === -1) {
public handleRowActive(probe: NoAuthProbe): boolean {
if (this.state.selected.indexOf(probe) === -1) {
return false;
}
return true;
@ -153,19 +103,7 @@ export class NoauthProbeList extends React.Component<any, any> {
</Table.Header>
<Table.Body>
{this.state.list.map((probe: any, index: number) => (
<Table.Row key={index} onClick={this.handleSelect.bind(this, probe.id)} active={this.handleRowActive(probe.id)}>
<Table.Cell collapsing>
<Checkbox checked={this.checkExist(probe.id)} />
</Table.Cell>
<Table.Cell textAlign={'center'}>{index + 1}</Table.Cell>
<Table.Cell textAlign={'center'}>{probe.ipAddress}</Table.Cell>
<Table.Cell textAlign={'center'}>{probe.macAddress}</Table.Cell>
<Table.Cell>{probe.hostName}</Table.Cell>
<Table.Cell textAlign={'center'}></Table.Cell>
<Table.Cell textAlign={'center'}>{probe.apiKey}</Table.Cell>
</Table.Row>
))}
{this.renderRows()}
</Table.Body>
</Table>
<Button primary floated={'right'} onClick={this.handleAccept.bind(this)}>Accept</Button>
@ -174,13 +112,91 @@ export class NoauthProbeList extends React.Component<any, any> {
return (
<ListContainer
contents={noauth}
data={this.data}
data={this.props.noauthList}
onSearch={this.handleSearch}
filter={null}
/>
);
}
private renderRows(): (JSX.Element | JSX.Element[]) {
if (this.props.noauthList === undefined) {
return null;
}
if (this.props.noauthList.length === 0) {
return <Table.Row error >
<Table.Cell textAlign='center' colSpan='6'>No results found.</Table.Cell>
</Table.Row>;
}
return this.props.noauthList.map((probe: NoAuthProbe, index: number) => (
<Table.Row key={index} onClick={this.handleSelect.bind(this, probe)} active={this.handleRowActive(probe)}>
<Table.Cell collapsing>
<Checkbox checked={this.checkExist(probe)} />
</Table.Cell>
<Table.Cell textAlign={'center'}>{index + 1}</Table.Cell>
<Table.Cell textAlign={'center'}>{probe.ipAddress}</Table.Cell>
<Table.Cell textAlign={'center'}>{probe.macAddress}</Table.Cell>
<Table.Cell>{probe.hostName}</Table.Cell>
<Table.Cell textAlign={'center'}></Table.Cell>
<Table.Cell textAlign={'center'}>{probe.apiKey}</Table.Cell>
</Table.Row>
));
}
}
// 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

@ -1,44 +1,8 @@
import Action from '@overflow/commons/redux/Action';
import NoAuthProbe from '../../api/model/NoAuthProbe';
import Domain from '@overflow/domain/api/model/Domain';
export type REQUEST = '@overflow/noauth/read_all_by_domain/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noauth/read_all_by_domain/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/noauth/read_all_by_domain/REQUEST/FAILURE';
import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload';
export const REQUEST: REQUEST = '@overflow/noauth/read_all_by_domain/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noauth/read_all_by_domain/REQUEST/SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noauth/read_all_by_domain/REQUEST/FAILURE';
// Action Type
export type REQUEST = '@overflow/noAuthProbe/read_all_by_domain/REQUEST';
export type REQUEST_SUCCESS = '@overflow/noAuthProbe/read_all_by_domain/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/noAuthProbe/read_all_by_domain/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/noAuthProbe/read_all_by_domain/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/noAuthProbe/read_all_by_domain/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/noAuthProbe/read_all_by_domain/REQUEST_FAILURE';
// Action Creater
export type request = (domain: Domain) => Action<ReadAllByDomainPayload>;
export type requestSuccess = (noAuthProbeList: NoAuthProbe[]) => Action<NoAuthProbe[]>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domain: Domain): Action<ReadAllByDomainPayload> => {
return {
type: REQUEST,
payload: {
domain:domain,
},
};
};
export const requestSuccess: requestSuccess = (noAuthProbeList: NoAuthProbe[]): Action<NoAuthProbe[]> => {
return {
type: REQUEST_SUCCESS,
payload: noAuthProbeList,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -1,3 +1,27 @@
/**
* 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';
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain';
import ReadAllNoAuthProbeByDomainState, { defaultState as readAllNoAuthProbeByDomainDefaultState } from '../state/ReadAllByDomain';
const reducer: ReducersMapObject = {
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
(state: ReadAllNoAuthProbeByDomainState = readAllNoAuthProbeByDomainDefaultState, action: Action<NoAuthProbe>):
ReadAllNoAuthProbeByDomainState => {
return {
...state,
noauthList: <NoAuthProbe[]>action.payload,
};
},
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
(state: ReadAllNoAuthProbeByDomainState = readAllNoAuthProbeByDomainDefaultState, action: Action<Error>):
ReadAllNoAuthProbeByDomainState => {
return state;
},
};
export default reducer;

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;