bug fix
This commit is contained in:
parent
639b803b47
commit
33d0b896aa
|
@ -11,7 +11,7 @@ class HistoryList extends React.Component<RouteComponentProps<object>, object> {
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<HistoryListContainer params={this.props.match.path}/>
|
<HistoryListContainer params={this.props.match.url}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
id: 1,
|
id: 1,
|
||||||
};
|
};
|
||||||
this.props.onReadAllProbeByDomain(domain);
|
this.props.onReadAllProbeByDomain(domain);
|
||||||
this.props.onReadAllMetaHistoryType();
|
// this.props.onReadAllMetaHistoryType();
|
||||||
|
|
||||||
if (this.props.path === '/histories') {
|
if (this.props.path === '/histories') {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -80,11 +80,11 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTypedHistory(pageNo: number): void {
|
public getTypedHistory(pageNo: number): void {
|
||||||
|
let url = this.props.path.split('/');
|
||||||
let probe: Probe = {
|
let probe: Probe = {
|
||||||
id: this.selectedProbeId,
|
id: url[2],
|
||||||
};
|
};
|
||||||
let type = this.props.path.split('/')[1];
|
this.props.onReadAllByProbeAndType(probe, this.getMetaType(url[1]), String(pageNo), String(this.countPerPage));
|
||||||
this.props.onReadAllByProbeAndType(probe, this.getMetaType(type), String(pageNo), String(this.countPerPage));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMetaType(typeStr: string): MetaHistoryType {
|
public getMetaType(typeStr: string): MetaHistoryType {
|
||||||
|
@ -136,20 +136,20 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
{this.props.histories && this.props.histories.content ?
|
{this.props.histories && this.props.histories.content ?
|
||||||
this.props.histories.content.map((history: History, index: number) => (
|
this.props.histories.content.map((history: History, index: number) => (
|
||||||
<Table.Row key={index} >
|
<Table.Row key={index} >
|
||||||
<Table.Cell textAlign={'center'} collapsing>{history.id}</Table.Cell>
|
<Table.Cell textAlign={'center'}>{history.id}</Table.Cell>
|
||||||
<Table.Cell textAlign={'center'} collapsing>
|
<Table.Cell >
|
||||||
{history.probe.displayName}
|
{history.probe.displayName}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell textAlign={'center'} collapsing>
|
<Table.Cell textAlign={'center'}>
|
||||||
{history.type.name}
|
{history.type.name}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
{history.message}
|
{history.message}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell>
|
||||||
{history.createDate}
|
{history.createDate}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell>
|
||||||
{history.member.name}
|
{history.member.name}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
@ -166,11 +166,12 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
||||||
let filter = <HistoryFilter probes={this.props.probes}
|
let filter = null;
|
||||||
onProbeChange={this.handleProbeChange}
|
if (!this.state.isTypedHistory) {
|
||||||
historyTypes={this.props.historyTypes}
|
filter = <HistoryFilter probes={this.props.probes}
|
||||||
onTypeChange={this.handleTypeChange}
|
onProbeChange={this.handleProbeChange}
|
||||||
/>;
|
/>;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<ListContainer
|
<ListContainer
|
||||||
filter={filter}
|
filter={filter}
|
||||||
|
@ -180,46 +181,11 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo. refactoring
|
|
||||||
private handleProbeChange = (probeId: number) => {
|
private handleProbeChange = (probeId: number) => {
|
||||||
this.selectedProbeId = probeId;
|
this.selectedProbeId = probeId;
|
||||||
this.getHistoryByFilter();
|
this.getAllHistory(0);
|
||||||
}
|
|
||||||
// todo. refactoring
|
|
||||||
private handleTypeChange = (typeId: number) => {
|
|
||||||
this.selectedTypeId = typeId;
|
|
||||||
this.getHistoryByFilter();
|
|
||||||
}
|
|
||||||
// todo. refactoring
|
|
||||||
private getHistoryByFilter = () => {
|
|
||||||
if (this.selectedProbeId === 0) {
|
|
||||||
// readAllByDomain or readAllByDomainAndType
|
|
||||||
const domain: Domain = {
|
|
||||||
id: 1,
|
|
||||||
};
|
|
||||||
if (this.selectedTypeId === 0) {
|
|
||||||
this.props.onReadAllByDomain(domain, String(0), String(this.countPerPage));
|
|
||||||
} else {
|
|
||||||
const type: MetaHistoryType = {
|
|
||||||
id: this.selectedTypeId,
|
|
||||||
};
|
|
||||||
this.props.onReadAllByDomainAndType(domain, type, String(0), String(this.countPerPage));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// readAllByProbe or readAllByProbeAndType
|
|
||||||
const probe: Probe = {
|
|
||||||
id: this.selectedProbeId,
|
|
||||||
};
|
|
||||||
if (this.selectedTypeId === 0) {
|
|
||||||
this.props.onReadAllByProbe(probe, String(0), String(this.countPerPage));
|
|
||||||
} else {
|
|
||||||
const type: MetaHistoryType = {
|
|
||||||
id: this.selectedTypeId,
|
|
||||||
};
|
|
||||||
this.props.onReadAllByProbeAndType(probe, type, String(0), String(this.countPerPage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,14 +193,11 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
|
|
||||||
export interface FilterProps {
|
export interface FilterProps {
|
||||||
probes: Probe[];
|
probes: Probe[];
|
||||||
historyTypes: MetaHistoryType[];
|
|
||||||
onProbeChange(probeId: number): void;
|
onProbeChange(probeId: number): void;
|
||||||
onTypeChange(typeId: number): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FilterState {
|
export interface FilterState {
|
||||||
selectedProbeId: number;
|
selectedProbeId: number;
|
||||||
selectedTypeId: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import { Dropdown, Form, Radio } from 'semantic-ui-react';
|
import { Dropdown, Form, Radio } from 'semantic-ui-react';
|
||||||
|
@ -245,7 +208,6 @@ export class HistoryFilter extends React.Component<FilterProps, FilterState> {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedProbeId: 0,
|
selectedProbeId: 0,
|
||||||
selectedTypeId: 0,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,36 +227,10 @@ export class HistoryFilter extends React.Component<FilterProps, FilterState> {
|
||||||
this.props.onProbeChange(data.value);
|
this.props.onProbeChange(data.value);
|
||||||
}} />
|
}} />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
<Form.Field>Type</Form.Field>
|
|
||||||
{this.renderTypesRadio()}
|
|
||||||
|
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderTypesRadio = (): JSX.Element[] => {
|
|
||||||
if (this.props.historyTypes === undefined) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return this.props.historyTypes.map((type: MetaHistoryType, index: number) => (
|
|
||||||
<Form.Field key={index}>
|
|
||||||
<Radio
|
|
||||||
slider
|
|
||||||
label={type.name}
|
|
||||||
name='historyType'
|
|
||||||
value={type.id}
|
|
||||||
checked={this.state.selectedTypeId === type.id}
|
|
||||||
onChange={this.handleTypeChange}
|
|
||||||
/>
|
|
||||||
</Form.Field>
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleTypeChange = (e: React.SyntheticEvent<HTMLInputElement>, data: any) => {
|
|
||||||
this.setState({ selectedTypeId: data.value });
|
|
||||||
this.props.onTypeChange(data.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getOptions(): Array<object> {
|
private getOptions(): Array<object> {
|
||||||
let res = new Array;
|
let res = new Array;
|
||||||
let all = {
|
let all = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user