Complete add app functionality in APPM UI

feature/appm-store/pbac
Jayasanka 5 years ago
parent f1c99a5b74
commit e5c37ca208

@ -41,7 +41,7 @@ class AppDetailsDrawer extends React.Component {
<br/> <br/>
<br/> <br/>
<span> <span>
{app.appCategories.map(category => { {app.categories.map(category => {
return ( return (
<Tag color="blue" key={category} style={{paddingBottom: 5}}> <Tag color="blue" key={category} style={{paddingBottom: 5}}>
{category} {category}

@ -28,10 +28,10 @@ const columns = [
}, },
{ {
title: 'Categories', title: 'Categories',
dataIndex: 'appCategories', dataIndex: 'categories',
render: appCategories => ( render: categories => (
<span> <span>
{appCategories.map(category => { {categories.map(category => {
return ( return (
<Tag color="blue" key={category}> <Tag color="blue" key={category}>
{category} {category}
@ -104,17 +104,13 @@ class AppsTable extends React.Component {
params.page = 1; params.page = 1;
} }
const extraParams = { const data = {
offset: 10 * (params.page - 1), offset: 10 * (params.page - 1),
limit: 10 limit: 10
}; };
// note: encode with '%26' not '&'
const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&');
const data = {
};
axios.post( axios.post(
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications?"+encodedExtraParams, config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications",
data, data,
{ {
headers: { 'X-Platform': config.serverConfig.platform } headers: { 'X-Platform': config.serverConfig.platform }

@ -121,30 +121,23 @@ class AddNewAppFormComponent extends React.Component {
this.setState({ this.setState({
loading: true loading: true
}); });
const {name, description, appCategories, tags, price, isSharedWithAllTenants, binaryFile, icon, screenshots, releaseDescription} = values; const {name, description, categories, tags, price, isSharedWithAllTenants, binaryFile, icon, screenshots, releaseDescription,releaseType} = values;
const application = { const application = {
name, name,
description, description,
appCategories, categories,
subType: (price === undefined || parseInt(price) === 0) ? "FREE" : "PAID", subMethod: (price === undefined || parseInt(price) === 0) ? "FREE" : "PAID",
tags, tags,
unrestrictedRoles: [], unrestrictedRoles: [],
// deviceType,
// entAppReleaseWrappers: [{
// description,
// price: (price === undefined) ? 0 : parseInt(price),
// isSharedWithAllTenants,
// metaData: "string",
// supportedOsVersions: "4.0-10.0"
// }]
}; };
const data = new FormData(); const data = new FormData();
if (formConfig.deviceType === "WEB_CLIP") { if (formConfig.installationType !== "WEB_CLIP") {
application.deviceType = "ALL";
} else {
application.deviceType = values.deviceType; application.deviceType = values.deviceType;
}else{
application.type = "WEB_CLIP";
application.deviceType ="ALL";
} }
if (specificElements.hasOwnProperty("binaryFile")) { if (specificElements.hasOwnProperty("binaryFile")) {
@ -157,9 +150,13 @@ class AddNewAppFormComponent extends React.Component {
price: (price === undefined) ? 0 : parseInt(price), price: (price === undefined) ? 0 : parseInt(price),
isSharedWithAllTenants, isSharedWithAllTenants,
metaData: "string", metaData: "string",
supportedOsVersions: "4.0-10.0" releaseType: releaseType
}; };
if (formConfig.installationType !== "WEB_CLIP") {
release.supportedOsVersions = "4.0-10.0";
}
if (specificElements.hasOwnProperty("version")) { if (specificElements.hasOwnProperty("version")) {
release.version = values.version; release.version = values.version;
} }
@ -182,12 +179,11 @@ class AddNewAppFormComponent extends React.Component {
const blob = new Blob([json], { const blob = new Blob([json], {
type: 'application/json' type: 'application/json'
}); });
data.append('application', blob); data.append(formConfig.jsonPayloadName, blob);
console.log(application); console.log(application);
const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications"+formConfig.endpoint; const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications" + formConfig.endpoint;
axios.post( axios.post(
url, url,
@ -319,7 +315,7 @@ class AddNewAppFormComponent extends React.Component {
)} )}
</Form.Item> </Form.Item>
<Form.Item {...formItemLayout} label="Categories"> <Form.Item {...formItemLayout} label="Categories">
{getFieldDecorator('appCategories', { {getFieldDecorator('categories', {
rules: [{ rules: [{
required: true, required: true,
message: 'Please select categories' message: 'Please select categories'
@ -385,11 +381,6 @@ class AddNewAppFormComponent extends React.Component {
</Row> </Row>
</InputGroup> </InputGroup>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{span: 12, offset: 5}}>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</div> </div>
</Col> </Col>
<Col span={12} style={{paddingLeft: 20}}> <Col span={12} style={{paddingLeft: 20}}>
@ -405,7 +396,7 @@ class AddNewAppFormComponent extends React.Component {
})( })(
<Upload <Upload
name="binaryFile" name="binaryFile"
onChange={this.handleIconChange} onChange={this.handleBinaryFileChange}
beforeUpload={() => false} beforeUpload={() => false}
> >
{binaryFiles.length !== 1 && ( {binaryFiles.length !== 1 && (
@ -509,6 +500,17 @@ class AddNewAppFormComponent extends React.Component {
</Form.Item> </Form.Item>
)} )}
<Form.Item {...formItemLayout} label="Release Type">
{getFieldDecorator('releaseType', {
rules: [{
required: true,
message: 'Please input the Release Type'
}],
})(
<Input placeholder="Release Type"/>
)}
</Form.Item>
<Form.Item {...formItemLayout} label="Description"> <Form.Item {...formItemLayout} label="Description">
{getFieldDecorator('releaseDescription', { {getFieldDecorator('releaseDescription', {
rules: [{ rules: [{
@ -547,7 +549,11 @@ class AddNewAppFormComponent extends React.Component {
</Col> </Col>
</Row> </Row>
<Form.Item style={{float: "right"}}>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form> </Form>
</Card> </Card>
</Col> </Col>

@ -11,6 +11,7 @@ const Paragraph = Typography;
const formConfig = { const formConfig = {
installationType: "ENTERPRISE", installationType: "ENTERPRISE",
endpoint: "/ent-app", endpoint: "/ent-app",
jsonPayloadName:"application",
releaseWrapperName: "entAppReleaseWrappers", releaseWrapperName: "entAppReleaseWrappers",
specificElements: { specificElements: {
binaryFile: { binaryFile: {

@ -11,10 +11,14 @@ const Paragraph = Typography;
const formConfig = { const formConfig = {
installationType: "PUBLIC", installationType: "PUBLIC",
endpoint: "/public-app", endpoint: "/public-app",
jsonPayloadName:"public-app",
releaseWrapperName: "publicAppReleaseWrappers", releaseWrapperName: "publicAppReleaseWrappers",
specificElements: { specificElements: {
packageName : { packageName : {
required: true required: true
},
version : {
required: true
} }
} }
}; };

@ -11,10 +11,14 @@ const Paragraph = Typography;
const formConfig = { const formConfig = {
installationType: "WEB_CLIP", installationType: "WEB_CLIP",
endpoint: "/web-app", endpoint: "/web-app",
releaseWrapperName: "webClipReleaseWrappers", jsonPayloadName:"webapp",
releaseWrapperName: "webAppReleaseWrappers",
specificElements: { specificElements: {
url : { url : {
required: true required: true
},
version : {
required: true
} }
} }
}; };

Loading…
Cancel
Save