router bug fix
This commit is contained in:
parent
4fec91aaef
commit
90be19289a
@ -32,19 +32,19 @@ export class ProbeDetailLayout extends React.Component<Props, State> {
|
||||
const sub = [
|
||||
{
|
||||
'name': 'Info',
|
||||
'path': this.state.currUrl,
|
||||
'path': '/',
|
||||
},
|
||||
{
|
||||
'name': 'Host',
|
||||
'path': this.state.currUrl + '/host',
|
||||
'path': '/host',
|
||||
},
|
||||
{
|
||||
'name': 'History',
|
||||
'path': this.state.currUrl + '/history',
|
||||
'path': '/history',
|
||||
},
|
||||
{
|
||||
'name': 'Targets',
|
||||
'path': this.state.currUrl + '/targets',
|
||||
'path': '/targets',
|
||||
},
|
||||
];
|
||||
return (
|
||||
@ -68,5 +68,6 @@ export class ProbeDetailLayout extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default ProbeDetailLayout;
|
||||
|
||||
|
@ -30,19 +30,19 @@ class SensorDetailLayout extends React.Component<Props, State> {
|
||||
const sub = [
|
||||
{
|
||||
'name': 'Info',
|
||||
'path': this.state.currUrl,
|
||||
'path': '/',
|
||||
},
|
||||
{
|
||||
'name': 'Items',
|
||||
'path': this.state.currUrl + '/items',
|
||||
'path': '/items',
|
||||
},
|
||||
{
|
||||
'name': 'Setup',
|
||||
'path': this.state.currUrl + '/setup',
|
||||
'path': '/setup',
|
||||
},
|
||||
{
|
||||
'name': 'History',
|
||||
'path': this.state.currUrl + '/history',
|
||||
'path': '/history',
|
||||
},
|
||||
];
|
||||
return (
|
||||
|
@ -30,15 +30,15 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
||||
const sub = [
|
||||
{
|
||||
'name': 'Info',
|
||||
'path': this.state.currUrl + '',
|
||||
'path': '',
|
||||
},
|
||||
{
|
||||
'name': 'Sensor',
|
||||
'path': this.state.currUrl + '/sensor',
|
||||
'path': '/sensor',
|
||||
},
|
||||
{
|
||||
'name': 'History',
|
||||
'path': this.state.currUrl + '/history',
|
||||
'path': '/history',
|
||||
},
|
||||
];
|
||||
return (
|
||||
|
@ -26,12 +26,35 @@ export class TitleBar extends React.Component<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
public componentWillMount(): void {
|
||||
if (this.props.sub === undefined || this.props.sub === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
let last = this.props.location.split('/').pop().toLowerCase();
|
||||
for(let i = 0; i < this.props.sub.length; i++) {
|
||||
if(this.props.sub[i].name.toLowerCase() === last) {
|
||||
this.setState({selected: i});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public handleMenu(menu: any, index: number): any {
|
||||
this.setState({
|
||||
selected: index,
|
||||
});
|
||||
if (this.state.selected !== index) {
|
||||
this.props.onRedirect(menu.path);
|
||||
let id = null;
|
||||
let urlArr = this.props.location.split('/');
|
||||
for (let u of urlArr) {
|
||||
let reg = /^(?:[1-9]\d*|\d)$/;
|
||||
if (reg.test(u)) {
|
||||
id = u;
|
||||
}
|
||||
}
|
||||
let url = '/' + urlArr[1] + '/' + id + menu.path;
|
||||
|
||||
this.props.onRedirect(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user