Add ui improvements to APPM Publisher UI

The following changes are with this commit
- View subscription status of devices in release view
- Display server error response in add new app form
feature/appm-store/pbac
Jayasanka 5 years ago
parent 6a5e21dd9b
commit 951325ee75

@ -54,7 +54,8 @@ class AddNewAppFormComponent extends React.Component {
release: null, release: null,
isError: false, isError: false,
deviceType: null, deviceType: null,
supportedOsVersions: [] supportedOsVersions: [],
errorText: ""
}; };
} }
@ -112,11 +113,12 @@ class AddNewAppFormComponent extends React.Component {
} }
}).catch((error) => { }).catch((error) => {
handleApiError(error, "Sorry, we were unable to complete your request.") handleApiError(error, error.response.data.data);
this.setState({ this.setState({
loading: false, loading: false,
isError: true, isError: true,
current: 2 current: 2,
errorText: error.response.data.data
}); });
}); });
@ -149,7 +151,7 @@ class AddNewAppFormComponent extends React.Component {
}; };
render() { render() {
const {loading, current, isError, supportedOsVersions} = this.state; const {loading, current, isError, supportedOsVersions, errorText} = this.state;
const {formConfig} = this.props; const {formConfig} = this.props;
return ( return (
<div> <div>
@ -190,7 +192,7 @@ class AddNewAppFormComponent extends React.Component {
{isError && (<Result {isError && (<Result
status="500" status="500"
title="Error occurred while creating the application." title={errorText}
subTitle="Go back to edit the details and submit again." subTitle="Go back to edit the details and submit again."
extra={<Button onClick={this.onClickBackButton}>Back</Button>} extra={<Button onClick={this.onClickBackButton}>Back</Button>}
/>)} />)}

@ -32,29 +32,72 @@ let config = null;
const columns = [ const columns = [
{ {
title: 'Device', title: 'Device',
dataIndex: 'name', dataIndex: 'device',
width: 100, width: 100,
render: device => device.name
}, },
{ {
title: 'Owner', title: 'Owner',
dataIndex: 'enrolmentInfo', dataIndex: 'device',
key: 'owner', key: 'owner',
render: enrolmentInfo => enrolmentInfo.owner render: device => device.enrolmentInfo.owner
// todo add filtering options
}, },
{ {
title: 'Ownership', title: 'Action Type',
dataIndex: 'enrolmentInfo', dataIndex: 'actionType',
key: 'ownership', key: 'actionType',
render: enrolmentInfo => enrolmentInfo.ownership render: actionType => actionType.toLowerCase()
// todo add filtering options
}, },
{ {
title: 'Status', title: 'Action',
dataIndex: 'enrolmentInfo', dataIndex: 'action',
key: 'status', key: 'action',
render: (enrolmentInfo) => { render: action => action.toLowerCase()
const status = enrolmentInfo.status.toLowerCase(); },
{
title: 'Triggered By',
dataIndex: 'actionTriggeredBy',
key: 'actionTriggeredBy'
},
{
title: 'Action Triggered At',
dataIndex: 'actionTriggeredTimestamp',
key: 'actionTriggeredTimestamp'
},
{
title: 'Action Status',
dataIndex: 'status',
key: 'actionStatus',
render: (status) => {
let color = "#f9ca24";
switch (status) {
case "COMPLETED":
color = "#badc58";
break;
case "REPEATED":
color = "#6ab04c";
break;
case "ERROR":
case "INVALID":
case "UNAUTHORIZED":
color = "#ff7979";
break;
case "IN_PROGRESS":
color = "#f9ca24";
break;
case "PENDING":
color = "#636e72";
break;
}
return <Tag color={color}>{status.toLowerCase()}</Tag>;
}
},
{
title: 'Device Status',
dataIndex: 'device',
key: 'deviceStatus',
render: (device) => {
const status = device.enrolmentInfo.status.toLowerCase();
let color = "#f9ca24"; let color = "#f9ca24";
switch (status) { switch (status) {
case "active": case "active":
@ -75,18 +118,6 @@ const columns = [
} }
return <Tag color={color}>{status}</Tag>; return <Tag color={color}>{status}</Tag>;
} }
// todo add filtering options
},
{
title: 'Last Updated',
dataIndex: 'enrolmentInfo',
key: 'dateOfLastUpdate',
render: (data) => {
const {dateOfLastUpdate} = data;
const timeAgoString = getTimeAgo(dateOfLastUpdate);
return <Tooltip title={new Date(dateOfLastUpdate).toString()}>{timeAgoString}</Tooltip>;
}
// todo add filtering options
} }
]; ];
@ -135,14 +166,15 @@ class InstalledDevicesTable extends React.Component {
//send request to the invoker //send request to the invoker
axios.get( axios.get(
window.location.origin + config.serverConfig.invoker.uri + window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt + config.serverConfig.invoker.store +
"/devices?" + encodedExtraParams, `/admin/subscription/${this.props.uuid}?` + encodedExtraParams,
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
const pagination = {...this.state.pagination}; const pagination = {...this.state.pagination};
console.log(res.data.data.data);
this.setState({ this.setState({
loading: false, loading: false,
data: res.data.data.devices, data: res.data.data.data,
pagination, pagination,
}); });
} }
@ -179,7 +211,7 @@ class InstalledDevicesTable extends React.Component {
</div> </div>
<Table <Table
columns={columns} columns={columns}
rowKey={record => (record.deviceIdentifier + record.enrolmentInfo.owner + record.enrolmentInfo.ownership)} rowKey={record => (record.device.deviceIdentifier + record.device.enrolmentInfo.owner + record.device.enrolmentInfo.ownership)}
dataSource={data} dataSource={data}
pagination={{ pagination={{
...pagination, ...pagination,

@ -208,7 +208,7 @@ class ReleaseView extends React.Component {
<ReviewContainer uuid={release.uuid}/> <ReviewContainer uuid={release.uuid}/>
</TabPane> </TabPane>
<TabPane tab="Installed devices" key="2"> <TabPane tab="Installed devices" key="2">
<InstalledDevicesTable/> <InstalledDevicesTable uuid={release.uuid}/>
</TabPane> </TabPane>
</Tabs> </Tabs>
</div> </div>

Loading…
Cancel
Save