probe setup

This commit is contained in:
insanity 2017-07-26 13:39:09 +09:00
parent 5aa58d3456
commit c471b8b3fb

View File

@ -4,8 +4,8 @@ import {
Menu, Menu,
Segment, Segment,
MenuItemProps, MenuItemProps,
Header,
Container, Container,
Icon,
} from 'semantic-ui-react'; } from 'semantic-ui-react';
export interface StateProps { export interface StateProps {
@ -19,45 +19,81 @@ export interface DispatchProps {
export type Props = StateProps & DispatchProps; export type Props = StateProps & DispatchProps;
export interface State { export interface State {
activeItem: string[]; activeItem: string;
} }
const osNames = ['Windows', 'Debian', 'Ubuntu', 'Fedora', 'CentOS']; const osNames = [
{
'name': 'Windows',
'icon': 'windows',
},
{
'name': 'Ubuntu',
'icon': 'linux',
},
{
'name': 'Fedora',
'icon': 'linux',
},
{
'name': 'CentOS',
'icon': 'linux',
},
];
export class ProbeDown extends React.Component<any, any> { export class ProbeDown extends React.Component<any, any> {
constructor(props: Props, context: State) { constructor(props: Props, context: State) {
super(props, context); super(props, context);
this.state = { activeItem: osNames[0] }; this.state = { activeItem: osNames[0].name };
} }
public handleItemClick = (event: React.SyntheticEvent<HTMLAnchorElement>, data: MenuItemProps): void => { public handleItemClick = (event: React.SyntheticEvent<HTMLAnchorElement>, data: MenuItemProps): void => {
this.setState({ activeItem: data.name }); this.setState({ activeItem: data.name });
}
console.log(data.name); public ShowContent = (): JSX.Element => {
let os = this.state.activeItem;
switch (os) {
case 'Windows': {
return <Windows />;
}
case 'Ubuntu': {
return <Ubuntu />;
}
case 'Fedora': {
return <Fedora />;
}
case 'CentOS': {
return <CentOS />;
}
default:
break;
}
return null;
} }
public render(): JSX.Element { public render(): JSX.Element {
const { activeItem } = this.state.activeItem; const { activeItem } = this.state.activeItem;
return ( return (
<Container fluid> <Container fluid>
<Header as='h3' dividing>Probe Download</Header>
<Grid> <Grid>
<Grid.Column width={4}> <Grid.Column width={4}>
<Menu fluid vertical tabular> <Menu fluid vertical icon='labeled'>
{osNames.map((os: string) => { {osNames.map((item: any, index: number) => {
return ( return (
<Menu.Item name={os} active={activeItem === os} onClick={this.handleItemClick} /> <Menu.Item key={index} name={item.name} active={activeItem === item.name} onClick={this.handleItemClick} >
<Icon name={item.icon} />
{item.name}
</Menu.Item>
); );
})} })}
</Menu> </Menu>
</Grid.Column> </Grid.Column>
<Grid.Column stretched width={12}> <Grid.Column stretched width={12}>
<Segment vertical> <Segment>
{this.state.activeItem} Download Page {this.ShowContent()}
</Segment> </Segment>
</Grid.Column> </Grid.Column>
</Grid> </Grid>
@ -66,3 +102,58 @@ export class ProbeDown extends React.Component<any, any> {
} }
} }
export class Windows extends React.Component<any, any> {
constructor(props: Props, context: State) {
super(props, context);
}
public render(): JSX.Element {
return (
<div>
Windows Download Page
</div>
);
}
}
export class Ubuntu extends React.Component<any, any> {
constructor(props: Props, context: State) {
super(props, context);
}
public render(): JSX.Element {
return (
<Container fluid>
Ubuntu Download Page
</Container>
);
}
}
export class Fedora extends React.Component<any, any> {
constructor(props: Props, context: State) {
super(props, context);
}
public render(): JSX.Element {
return (
<Container fluid>
Fedora Download Page
</Container>
);
}
}
export class CentOS extends React.Component<any, any> {
constructor(props: Props, context: State) {
super(props, context);
}
public render(): JSX.Element {
return (
<Container fluid>
CentOS Download Page
</Container>
);
}
}