From f4ec3e211cb2197866078338f630047bfafd7e7c Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 4 Apr 2019 23:38:35 +0530 Subject: [PATCH] added all form items to single page --- .../react-app/src/App.css | 4 ++ .../pages/dashboard/add-new-app/AddNewApp.js | 49 +++++++++++++- .../pages/dashboard/add-new-app/IconImg.js | 66 +++++++++++++++++++ .../add-new-app/UploadScreenshots.js | 54 +++++++++++++++ 4 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/IconImg.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/UploadScreenshots.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.css index b41d297cab1..4fea44459f7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.css +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.css @@ -31,3 +31,7 @@ transform: rotate(360deg); } } + +.ant-upload.ant-upload-drag { + height: 170px; +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js index dd5c5343f43..c94b693d35a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewApp.js @@ -22,6 +22,8 @@ import Step1 from "./Step1" import Step2 from "./Step2" import Step3 from "./Step3" import styles from "./Style.less" +import IconImage from "./IconImg" +import UploadScreenshots from "./UploadScreenshots" const Paragraph = Typography; const Dragger = Upload.Dragger; @@ -40,6 +42,23 @@ const routes = [ }, ]; +const props = { + name: 'file', + multiple: true, + action: '//jsonplaceholder.typicode.com/posts/', + onChange(info) { + const status = info.file.status; + if (status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (status === 'done') { + message.success(`${info.file.name} file uploaded successfully.`); + } else if (status === 'error') { + message.error(`${info.file.name} file upload failed.`); + } + }, +}; + const Step = Steps.Step; const steps = [{ @@ -238,7 +257,35 @@ class AddNewApp extends React.Component { - + +

Application

+
+ +

+ +

+

Click or drag file to this area to upload

+

Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files

+
+
+ + +

Icon

+ + + +

Banner

+ + +
+ + + + +

Screenshots

+ + +
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/IconImg.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/IconImg.js new file mode 100644 index 00000000000..b56dedb034d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/IconImg.js @@ -0,0 +1,66 @@ +import React from "react"; +import { Upload, Icon, message } from 'antd'; + +function getBase64(img, callback) { + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result)); + reader.readAsDataURL(img); +} + +function beforeUpload(file) { + const isJPG = file.type === 'image/jpeg'; + if (!isJPG) { + message.error('You can only upload JPG file!'); + } + const isLt2M = file.size / 1024 / 1024 < 2; + if (!isLt2M) { + message.error('Image must smaller than 2MB!'); + } + return isJPG && isLt2M; +} + + +class IconImage extends React.Component { + state = { + loading: false, + }; + + handleChange = (info) => { + if (info.file.status === 'uploading') { + this.setState({ loading: true }); + return; + } + if (info.file.status === 'done') { + // Get this url from response in real world. + getBase64(info.file.originFileObj, imageUrl => this.setState({ + imageUrl, + loading: false, + })); + } + } + + render() { + const uploadButton = ( +
+ +
Upload
+
+ ); + const imageUrl = this.state.imageUrl; + return ( + + {imageUrl ? avatar : uploadButton} + + ); + } +} + +export default IconImage; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/UploadScreenshots.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/UploadScreenshots.js new file mode 100644 index 00000000000..8f83fc3d238 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/UploadScreenshots.js @@ -0,0 +1,54 @@ +import React from "react"; +import { Upload, Icon, Modal} from 'antd'; + + +class UploadScreenshots extends React.Component { + state = { + previewVisible: false, + previewImage: '', + fileList: [{ + uid: '-1', + name: 'xxx.png', + status: 'done', + url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', + }], + }; + + handleCancel = () => this.setState({ previewVisible: false }) + + handlePreview = (file) => { + this.setState({ + previewImage: file.url || file.thumbUrl, + previewVisible: true, + }); + } + + handleChange = ({ fileList }) => this.setState({ fileList }) + + render() { + const { previewVisible, previewImage, fileList } = this.state; + const uploadButton = ( +
+ +
Upload
+
+ ); + return ( +
+ + {fileList.length >= 3 ? null : uploadButton} + + + example + +
+ ); + } +} +export default UploadScreenshots; \ No newline at end of file