From e5c37ca208df0f011dbf28511cc2cdb912b425b1 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 25 Jun 2019 19:28:42 +0530 Subject: [PATCH] Complete add app functionality in APPM UI --- .../apps/list-apps/AppDetailsDrawer.js | 2 +- .../components/apps/list-apps/AppsTable.js | 14 ++--- .../src/components/new-app/AddNewAppForm.js | 58 ++++++++++--------- .../add-new-app/AddNewEnterpriseApp.js | 1 + .../dashboard/add-new-app/AddNewPublicApp.js | 4 ++ .../dashboard/add-new-app/AddNewWebClip.js | 6 +- 6 files changed, 48 insertions(+), 37 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer.js index 094db7aae9..8663806eb0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppDetailsDrawer.js @@ -41,7 +41,7 @@ class AppDetailsDrawer extends React.Component {

- {app.appCategories.map(category => { + {app.categories.map(category => { return ( {category} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js index d99cccd8f7..21c8786382 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js @@ -28,10 +28,10 @@ const columns = [ }, { title: 'Categories', - dataIndex: 'appCategories', - render: appCategories => ( + dataIndex: 'categories', + render: categories => ( - {appCategories.map(category => { + {categories.map(category => { return ( {category} @@ -104,17 +104,13 @@ class AppsTable extends React.Component { params.page = 1; } - const extraParams = { + const data = { offset: 10 * (params.page - 1), limit: 10 }; - // note: encode with '%26' not '&' - const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('&'); - const data = { - }; 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, { headers: { 'X-Platform': config.serverConfig.platform } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js index 7f99ddc4fd..72e48d3c4d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js @@ -121,30 +121,23 @@ class AddNewAppFormComponent extends React.Component { this.setState({ 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 = { name, description, - appCategories, - subType: (price === undefined || parseInt(price) === 0) ? "FREE" : "PAID", + categories, + subMethod: (price === undefined || parseInt(price) === 0) ? "FREE" : "PAID", tags, unrestrictedRoles: [], - // deviceType, - // entAppReleaseWrappers: [{ - // description, - // price: (price === undefined) ? 0 : parseInt(price), - // isSharedWithAllTenants, - // metaData: "string", - // supportedOsVersions: "4.0-10.0" - // }] }; const data = new FormData(); - if (formConfig.deviceType === "WEB_CLIP") { - application.deviceType = "ALL"; - } else { + if (formConfig.installationType !== "WEB_CLIP") { application.deviceType = values.deviceType; + }else{ + application.type = "WEB_CLIP"; + application.deviceType ="ALL"; } if (specificElements.hasOwnProperty("binaryFile")) { @@ -157,9 +150,13 @@ class AddNewAppFormComponent extends React.Component { price: (price === undefined) ? 0 : parseInt(price), isSharedWithAllTenants, metaData: "string", - supportedOsVersions: "4.0-10.0" + releaseType: releaseType }; + if (formConfig.installationType !== "WEB_CLIP") { + release.supportedOsVersions = "4.0-10.0"; + } + if (specificElements.hasOwnProperty("version")) { release.version = values.version; } @@ -182,12 +179,11 @@ class AddNewAppFormComponent extends React.Component { const blob = new Blob([json], { type: 'application/json' }); - data.append('application', blob); + data.append(formConfig.jsonPayloadName, blob); 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( url, @@ -319,7 +315,7 @@ class AddNewAppFormComponent extends React.Component { )} - {getFieldDecorator('appCategories', { + {getFieldDecorator('categories', { rules: [{ required: true, message: 'Please select categories' @@ -385,11 +381,6 @@ class AddNewAppFormComponent extends React.Component { - - - @@ -405,7 +396,7 @@ class AddNewAppFormComponent extends React.Component { })( false} > {binaryFiles.length !== 1 && ( @@ -509,6 +500,17 @@ class AddNewAppFormComponent extends React.Component { )} + + {getFieldDecorator('releaseType', { + rules: [{ + required: true, + message: 'Please input the Release Type' + }], + })( + + )} + + {getFieldDecorator('releaseDescription', { rules: [{ @@ -547,7 +549,11 @@ class AddNewAppFormComponent extends React.Component { - + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js index cff3bea7c1..d6245bd10f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js @@ -11,6 +11,7 @@ const Paragraph = Typography; const formConfig = { installationType: "ENTERPRISE", endpoint: "/ent-app", + jsonPayloadName:"application", releaseWrapperName: "entAppReleaseWrappers", specificElements: { binaryFile: { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js index ef4907edc4..f175007499 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js @@ -11,10 +11,14 @@ const Paragraph = Typography; const formConfig = { installationType: "PUBLIC", endpoint: "/public-app", + jsonPayloadName:"public-app", releaseWrapperName: "publicAppReleaseWrappers", specificElements: { packageName : { required: true + }, + version : { + required: true } } }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js index c68e89e620..9f1a459f0e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js @@ -11,10 +11,14 @@ const Paragraph = Typography; const formConfig = { installationType: "WEB_CLIP", endpoint: "/web-app", - releaseWrapperName: "webClipReleaseWrappers", + jsonPayloadName:"webapp", + releaseWrapperName: "webAppReleaseWrappers", specificElements: { url : { required: true + }, + version : { + required: true } } };