Fix device load issue in APPM store

feature/appm-store/pbac
Jayasanka 6 years ago
parent 4d59b8d900
commit 6849222774

@ -91,12 +91,16 @@ class ReleaseView extends React.Component {
}; };
render() { render() {
const app = this.props.app; const {app,deviceType} = this.props;
const release = app.applicationReleases[0]; const release = app.applicationReleases[0];
return ( return (
<div> <div>
<AppInstallModal uuid={release.uuid} visible={this.state.appInstallModalVisible} <AppInstallModal
onClose={this.closeAppInstallModal} onInstall={this.installApp}/> uuid={release.uuid}
visible={this.state.appInstallModalVisible}
deviceType = {deviceType}
onClose={this.closeAppInstallModal}
onInstall={this.installApp}/>
<div className="release"> <div className="release">
<Row> <Row>
<Col xl={4} sm={6} xs={8} className="release-icon"> <Col xl={4} sm={6} xs={8} className="release-icon">

@ -12,6 +12,7 @@ class AppInstallModal extends React.Component{
data:[] data:[]
}; };
render() { render() {
const {deviceType} = this.props;
return ( return (
<div> <div>
<Modal <Modal
@ -22,7 +23,7 @@ class AppInstallModal extends React.Component{
> >
<Tabs defaultActiveKey="device"> <Tabs defaultActiveKey="device">
<TabPane tab="Device" key="device"> <TabPane tab="Device" key="device">
<DeviceInstall onInstall={this.props.onInstall}/> <DeviceInstall deviceType={deviceType} onInstall={this.props.onInstall}/>
</TabPane> </TabPane>
<TabPane tab="User" key="user"> <TabPane tab="User" key="user">
<UserInstall onInstall={this.props.onInstall}/> <UserInstall onInstall={this.props.onInstall}/>

@ -113,7 +113,7 @@ class DeviceInstall extends React.Component {
//fetch data from api //fetch data from api
fetch = (params = {}) => { fetch = (params = {}) => {
this.setState({loading: true}); this.setState({loading: true});
const {deviceType} = this.props;
// get current page // get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1; const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
@ -121,25 +121,16 @@ class DeviceInstall extends React.Component {
offset: 10 * (currentPage - 1), //calculate the offset offset: 10 * (currentPage - 1), //calculate the offset
limit: 10, limit: 10,
status: "ACTIVE", status: "ACTIVE",
requireDeviceInfo: true requireDeviceInfo: true,
type: deviceType
}; };
// note: encode with '%26' not '&' // note: encode with '%26' not '&'
const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('%26'); const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&');
const parameters = {
method: "get",
'content-type': "application/json",
payload: "{}",
'api-endpoint': "/device-mgt/v1.0/devices?" + encodedExtraParams
};
//url-encode parameters
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
//send request to the invoker //send request to the invoker
axios.get( axios.get(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"devices?" + encodedExtraParams, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams,
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {

@ -71,10 +71,12 @@ class Release extends React.Component {
render() { render() {
const {app, loading} = this.state; const {app, loading} = this.state;
const {deviceType} = this.props.match.params;
let content = <Title level={3}>No Releases Found</Title>; let content = <Title level={3}>No Releases Found</Title>;
if (app != null && app.applicationReleases.length!==0) { if (app != null && app.applicationReleases.length!==0) {
content = <ReleaseView app={app}/>; content = <ReleaseView app={app} deviceType={deviceType}/>;
} }

Loading…
Cancel
Save