sort and paging
This commit is contained in:
parent
d2d35b91ea
commit
a03599f16e
|
@ -30,20 +30,20 @@ export interface DispatchProps {
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
isTypedHistory: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HistoryList extends React.Component<Props, State> {
|
export class HistoryList extends React.Component<Props, State> {
|
||||||
|
|
||||||
private countPerPage: number = 10;
|
|
||||||
private selectedProbeId: number = 0;
|
private selectedProbeId: number = 0;
|
||||||
private selectedTypeId: number = 0;
|
private isTypedHistory: boolean = false;
|
||||||
|
|
||||||
|
private countPerPage: number = 10;
|
||||||
|
private sortCol: string = 'id';
|
||||||
|
private sortDirection: string = 'descending';
|
||||||
|
private pageNo: number = 0;
|
||||||
|
|
||||||
constructor(props: Props, context: State) {
|
constructor(props: Props, context: State) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
|
||||||
isTypedHistory: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillMount(): void {
|
public componentWillMount(): void {
|
||||||
|
@ -54,24 +54,20 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
// this.props.onReadAllMetaHistoryType();
|
// this.props.onReadAllMetaHistoryType();
|
||||||
|
|
||||||
if (this.props.path === '/histories') {
|
if (this.props.path === '/histories') {
|
||||||
this.setState({
|
this.isTypedHistory = false;
|
||||||
isTypedHistory: false,
|
this.getAllHistory();
|
||||||
});
|
|
||||||
this.getAllHistory(0);
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.isTypedHistory = true;
|
||||||
isTypedHistory: true,
|
this.getTypedHistory();
|
||||||
});
|
|
||||||
this.getTypedHistory(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAllHistory(pageNo: number): void {
|
public getAllHistory(): void {
|
||||||
const pageParams: PageParams = {
|
const pageParams: PageParams = {
|
||||||
pageNo: String(pageNo),
|
pageNo: String(this.pageNo),
|
||||||
countPerPage: String(10),
|
countPerPage: String(this.countPerPage),
|
||||||
sortCol: 'id',
|
sortCol: this.sortCol,
|
||||||
sortDirection: 'descending',
|
sortDirection: this.sortDirection,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.selectedProbeId === 0) {
|
if (this.selectedProbeId === 0) {
|
||||||
|
@ -87,16 +83,16 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTypedHistory(pageNo: number): void {
|
public getTypedHistory(): void {
|
||||||
let url = this.props.path.split('/');
|
let url = this.props.path.split('/');
|
||||||
let probe: Probe = {
|
let probe: Probe = {
|
||||||
id: url[2],
|
id: url[2],
|
||||||
};
|
};
|
||||||
const pageParams: PageParams = {
|
const pageParams: PageParams = {
|
||||||
pageNo: String(pageNo),
|
pageNo: String(this.pageNo),
|
||||||
countPerPage: String(10),
|
countPerPage: String(this.countPerPage),
|
||||||
sortCol: 'id',
|
sortCol: this.sortCol,
|
||||||
sortDirection: 'descending',
|
sortDirection: this.sortDirection,
|
||||||
};
|
};
|
||||||
this.props.onReadAllByProbeAndType(probe, this.getMetaType(url[1]), pageParams);
|
this.props.onReadAllByProbeAndType(probe, this.getMetaType(url[1]), pageParams);
|
||||||
}
|
}
|
||||||
|
@ -124,25 +120,23 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
let probe: Probe = {
|
let probe: Probe = {
|
||||||
id: Number(1),
|
id: Number(1),
|
||||||
};
|
};
|
||||||
if (this.state.isTypedHistory) {
|
this.pageNo = pageNo;
|
||||||
this.getTypedHistory(pageNo);
|
if (this.isTypedHistory) {
|
||||||
|
this.getTypedHistory();
|
||||||
} else {
|
} else {
|
||||||
this.getAllHistory(pageNo);
|
this.getAllHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleSort = (col: string, direction: string): void => {
|
private handleSort = (col: string, direction: string): void => {
|
||||||
console.log(col + ' || direction:' + direction);
|
console.log(col + ' || direction:' + direction);
|
||||||
const pageParams: PageParams = {
|
this.sortCol = col;
|
||||||
pageNo: String(0),
|
this.sortDirection = direction;
|
||||||
countPerPage: String(10),
|
if (this.isTypedHistory) {
|
||||||
sortCol: col,
|
this.getTypedHistory();
|
||||||
sortDirection: direction,
|
} else {
|
||||||
};
|
this.getAllHistory();
|
||||||
let domain: Domain = {
|
}
|
||||||
id: 1,
|
|
||||||
};
|
|
||||||
this.props.onReadAllByDomain(domain, pageParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
|
@ -205,7 +199,7 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let filter = null;
|
let filter = null;
|
||||||
if (!this.state.isTypedHistory) {
|
if (!this.isTypedHistory) {
|
||||||
filter = <HistoryFilter probes={this.props.probes}
|
filter = <HistoryFilter probes={this.props.probes}
|
||||||
onProbeChange={this.handleProbeChange}
|
onProbeChange={this.handleProbeChange}
|
||||||
/>;
|
/>;
|
||||||
|
@ -221,7 +215,7 @@ export class HistoryList extends React.Component<Props, State> {
|
||||||
|
|
||||||
private handleProbeChange = (probeId: number) => {
|
private handleProbeChange = (probeId: number) => {
|
||||||
this.selectedProbeId = probeId;
|
this.selectedProbeId = probeId;
|
||||||
this.getAllHistory(0);
|
this.getAllHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user