Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix device type loading issue for custom apps

See merge request entgra/carbon-device-mgt!248
merge-requests/249/head
Dharmakeerthi Lasantha 5 years ago
commit 8ce3318645

@ -67,28 +67,7 @@
"text": "The final state of an application, where no transition of states will be allowed after this."
}
},
"installationTypes": {
"ENTERPRISE": {
"deviceTypes": [
"android",
"ios"
]
},
"PUBLIC": {
"deviceTypes": [
"android",
"ios"
]
},
"WEB_CLIP": {
"deviceTypes": [
"android",
"ios"
]
},
"CUSTOM": {
"deviceTypes": [
]
}
"deviceTypes": {
"mobileTypes": ["android", "ios"]
}
}

@ -414,6 +414,7 @@ class AppDetailsDrawer extends React.Component {
}
};
render() {
const config = this.props.context;
const {app, visible, onClose} = this.props;
@ -459,12 +460,11 @@ class AppDetailsDrawer extends React.Component {
<div>
<Drawer
placement="right"
width={this.state.drawerWidth}
width={640}
closable={false}
onClose={onClose}
visible={visible}
>
<Spin spinning={loading} delay={500}>
<div style={{textAlign: "center"}}>
{avatar}
@ -555,7 +555,6 @@ class AppDetailsDrawer extends React.Component {
)}
<Divider dashed={true}/>
<Text strong={true}>Categories </Text>
{!isCategoriesEditEnabled && (<Text
style={{color: config.theme.primaryColor, cursor: "pointer"}}
@ -600,8 +599,8 @@ class AppDetailsDrawer extends React.Component {
}</span>
)}
<Divider dashed={true}/>
<Divider dashed={true}/>
<Text strong={true}>Tags </Text>
{!isTagsEditEnabled && (<Text
style={{color: config.theme.primaryColor, cursor: "pointer"}}

@ -148,21 +148,31 @@ class NewAppDetailsForm extends React.Component {
getDeviceTypes = () => {
const config = this.props.context;
const {formConfig} = this.props;
console.log("test");
const {installationType} = formConfig;
axios.get(
window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types"
).then(res => {
if (res.status === 200) {
const allDeviceTypes = JSON.parse(res.data.data);
const whitelistedDeviceTypes = config.installationTypes[formConfig.installationType].deviceTypes;
const mobileDeviceTypes = config.deviceTypes.mobileTypes;
const allowedDeviceTypes = [];
allDeviceTypes.forEach(deviceType=>{
if(whitelistedDeviceTypes.includes(deviceType.name)){
allowedDeviceTypes.push(deviceType);
}
});
// exclude mobile device types if installation type is custom
if(installationType==="CUSTOM"){
allDeviceTypes.forEach(deviceType=>{
if(!mobileDeviceTypes.includes(deviceType.name)){
allowedDeviceTypes.push(deviceType);
}
});
}else{
allDeviceTypes.forEach(deviceType=>{
if(mobileDeviceTypes.includes(deviceType.name)){
allowedDeviceTypes.push(deviceType);
}
});
}
this.setState({
deviceTypes: allowedDeviceTypes,
loading: false,

Loading…
Cancel
Save