From 33d0b896aaaca7d31c2aa7d96c6f38c02d89aa0b Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 25 Aug 2017 12:22:54 +0900 Subject: [PATCH] bug fix --- src/ts/@overflow/app/views/history/List.tsx | 2 +- .../history/react/components/HistoryList.tsx | 98 ++++--------------- 2 files changed, 18 insertions(+), 82 deletions(-) diff --git a/src/ts/@overflow/app/views/history/List.tsx b/src/ts/@overflow/app/views/history/List.tsx index 8ba433d..99c1084 100644 --- a/src/ts/@overflow/app/views/history/List.tsx +++ b/src/ts/@overflow/app/views/history/List.tsx @@ -11,7 +11,7 @@ class HistoryList extends React.Component, object> { public render(): JSX.Element { return (
- +
); } diff --git a/src/ts/@overflow/history/react/components/HistoryList.tsx b/src/ts/@overflow/history/react/components/HistoryList.tsx index e0ebb4d..9934597 100644 --- a/src/ts/@overflow/history/react/components/HistoryList.tsx +++ b/src/ts/@overflow/history/react/components/HistoryList.tsx @@ -50,7 +50,7 @@ export class HistoryList extends React.Component { id: 1, }; this.props.onReadAllProbeByDomain(domain); - this.props.onReadAllMetaHistoryType(); + // this.props.onReadAllMetaHistoryType(); if (this.props.path === '/histories') { this.setState({ @@ -80,11 +80,11 @@ export class HistoryList extends React.Component { } public getTypedHistory(pageNo: number): void { + let url = this.props.path.split('/'); let probe: Probe = { - id: this.selectedProbeId, + id: url[2], }; - let type = this.props.path.split('/')[1]; - this.props.onReadAllByProbeAndType(probe, this.getMetaType(type), String(pageNo), String(this.countPerPage)); + this.props.onReadAllByProbeAndType(probe, this.getMetaType(url[1]), String(pageNo), String(this.countPerPage)); } public getMetaType(typeStr: string): MetaHistoryType { @@ -136,20 +136,20 @@ export class HistoryList extends React.Component { {this.props.histories && this.props.histories.content ? this.props.histories.content.map((history: History, index: number) => ( - {history.id} - + {history.id} + {history.probe.displayName} - + {history.type.name} {history.message} - + {history.createDate} - + {history.member.name} @@ -166,11 +166,12 @@ export class HistoryList extends React.Component { ); - let filter = ; + let filter = null; + if (!this.state.isTypedHistory) { + filter = ; + } return ( { ); } - // todo. refactoring private handleProbeChange = (probeId: number) => { this.selectedProbeId = probeId; - this.getHistoryByFilter(); - } - // 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)); - } - } + this.getAllHistory(0); } + } @@ -227,14 +193,11 @@ export class HistoryList extends React.Component { export interface FilterProps { probes: Probe[]; - historyTypes: MetaHistoryType[]; onProbeChange(probeId: number): void; - onTypeChange(typeId: number): void; } export interface FilterState { selectedProbeId: number; - selectedTypeId: number; } import { Dropdown, Form, Radio } from 'semantic-ui-react'; @@ -245,7 +208,6 @@ export class HistoryFilter extends React.Component { super(props, context); this.state = { selectedProbeId: 0, - selectedTypeId: 0, }; } @@ -265,36 +227,10 @@ export class HistoryFilter extends React.Component { this.props.onProbeChange(data.value); }} /> - Type - {this.renderTypesRadio()} - ); } - private renderTypesRadio = (): JSX.Element[] => { - if (this.props.historyTypes === undefined) { - return null; - } - return this.props.historyTypes.map((type: MetaHistoryType, index: number) => ( - - - - )); - } - - private handleTypeChange = (e: React.SyntheticEvent, data: any) => { - this.setState({ selectedTypeId: data.value }); - this.props.onTypeChange(data.value); - } - private getOptions(): Array { let res = new Array; let all = {