Fix installation error in APPM ui

feature/appm-store/pbac
Jayasanka 5 years ago
parent 2558bdc172
commit c8086f8b5c

@ -19,16 +19,24 @@
}, },
"defaultPlatformIcons": { "defaultPlatformIcons": {
"default": { "default": {
"icon": "mobile", "icon": "global",
"color": "#535c68" "color": "#535c68",
"theme": "outlined"
}, },
"android": { "android": {
"icon": "android", "icon": "android",
"color": "#7db343" "color": "#7db343",
"theme": "filled"
}, },
"ios": { "ios": {
"icon": "apple", "icon": "apple",
"color": "#535c68" "color": "#535c68",
"theme": "filled"
},
"windows": {
"icon": "windows",
"color": "#008cc4",
"theme": "filled"
} }
} }
} }

@ -37,7 +37,7 @@ class ReleaseView extends React.Component {
headers: {'X-Platform': config.serverConfig.platform} headers: {'X-Platform': config.serverConfig.platform}
} }
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 200) {
this.setState({ this.setState({
loading: false, loading: false,
appInstallModalVisible: false appInstallModalVisible: false
@ -45,7 +45,7 @@ class ReleaseView extends React.Component {
notification["success"]({ notification["success"]({
message: 'Done!', message: 'Done!',
description: description:
'App installed successfully.', 'App installed triggered.',
}); });
} else { } else {
this.setState({ this.setState({

@ -1,9 +1,11 @@
import React from "react"; import React from "react";
import {Layout, Menu, Icon} from 'antd'; import {Layout, Menu, Icon} from 'antd';
const {Header, Content, Footer} = Layout; const {Header, Content, Footer} = Layout;
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import RouteWithSubRoutes from "../../components/RouteWithSubRoutes" import RouteWithSubRoutes from "../../components/RouteWithSubRoutes";
import {Switch} from 'react-router' import {Switch} from 'react-router';
import axios from "axios";
import "../../App.css"; import "../../App.css";
import {withConfigContext} from "../../context/ConfigContext"; import {withConfigContext} from "../../context/ConfigContext";
@ -12,11 +14,46 @@ class Dashboard extends React.Component {
super(props); super(props);
this.state = { this.state = {
routes: props.routes, routes: props.routes,
selectedKeys: [] selectedKeys: [],
deviceTypes: []
}; };
this.logo = this.props.context.theme.logo; this.logo = this.props.context.theme.logo;
} }
componentDidMount() {
this.getDeviceTypes();
}
getDeviceTypes = () => {
const config = this.props.context;
axios.get(
window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types"
).then(res => {
if (res.status === 200) {
const deviceTypes = JSON.parse(res.data.data);
this.setState({
deviceTypes,
loading: false,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
window.location.href = window.location.origin + '/publisher/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:
"Error occurred while trying to load device types.",
});
}
this.setState({
loading: false
});
});
};
changeSelectedMenuItem = (key) => { changeSelectedMenuItem = (key) => {
this.setState({ this.setState({
selectedKeys: [key] selectedKeys: [key]
@ -24,7 +61,9 @@ class Dashboard extends React.Component {
}; };
render() { render() {
const {selectedKeys} = this.state; const config = this.props.context;
const {selectedKeys, deviceTypes} = this.state;
return ( return (
<div> <div>
<Layout className="layout"> <Layout className="layout">
@ -38,9 +77,28 @@ class Dashboard extends React.Component {
defaultSelectedKeys={selectedKeys} defaultSelectedKeys={selectedKeys}
style={{lineHeight: '64px'}} style={{lineHeight: '64px'}}
> >
<Menu.Item key="android"><Link to="/store/android"><Icon type="android" theme="filled"/>Android</Link></Menu.Item> {
<Menu.Item key="ios"><Link to="/store/ios"><Icon type="apple" theme="filled"/>iOS</Link></Menu.Item> deviceTypes.map((deviceType)=>{
<Menu.Item key="web-clip"><Link to="/store/web-clip"><Icon type="upload"/>Web Clips</Link></Menu.Item> const platform = deviceType.name;
const defaultPlatformIcons = config.defaultPlatformIcons;
let icon = defaultPlatformIcons.default.icon;
let theme = defaultPlatformIcons.default.theme;
if (defaultPlatformIcons.hasOwnProperty(platform)) {
icon = defaultPlatformIcons[platform].icon;
theme = defaultPlatformIcons[platform].theme;
}
return (
<Menu.Item key={platform}>
<Link to={"/store/"+platform}>
<Icon type={icon} theme={theme}/>
{platform}
</Link>
</Menu.Item>
);
})
}
<Menu.Item key="web-clip"><Link to="/store/web-clip"><Icon type="upload"/>Web
Clips</Link></Menu.Item>
</Menu> </Menu>
</Header> </Header>
</Layout> </Layout>
@ -48,7 +106,8 @@ class Dashboard extends React.Component {
<Content style={{padding: '0 0'}}> <Content style={{padding: '0 0'}}>
<Switch> <Switch>
{this.state.routes.map((route) => ( {this.state.routes.map((route) => (
<RouteWithSubRoutes changeSelectedMenuItem={this.changeSelectedMenuItem} key={route.path} {...route} /> <RouteWithSubRoutes changeSelectedMenuItem={this.changeSelectedMenuItem}
key={route.path} {...route} />
))} ))}
</Switch> </Switch>

Loading…
Cancel
Save