From ee80e42e9a2fff0472083686267aaaf333ec8dbd Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 23 Apr 2019 22:29:19 +0530 Subject: [PATCH 01/13] Publisher: added basic redirection to login page if not logged in --- .../src/pages/dashboard/apps/Apps.js | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 3a2994b184..8e4ce3b10d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -2,6 +2,7 @@ import React from "react"; import "antd/dist/antd.css"; import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd"; import Highlighter from 'react-highlight-words'; +import axios from "axios"; const Paragraph = Typography; const Search = Input.Search; @@ -65,6 +66,34 @@ class Apps extends React.Component { constructor(props) { super(props); this.routes = props.routes; + this.state = { + data: [] + }; + + this.loadData = this.loadData.bind(this); + } + + loadData(){ + const thisComponent = this; + const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; + axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request + ).then(res => { + if(res.status === 200){ + thisComponent.setState({ + data : [] + }) + } + + }).catch(function (error) { + if(error.status === 401){ + window.location = 'https://localhost:9443/publisher/login' + } + }); + } + + componentDidMount() { + this.loadData(); + } getColumnSearchProps = (dataIndex) => ({ @@ -113,17 +142,17 @@ class Apps extends React.Component { textToHighlight={text.toString()} /> ), - }) + }); handleSearch = (selectedKeys, confirm) => { confirm(); this.setState({ searchText: selectedKeys[0] }); - } + }; handleReset = (clearFilters) => { clearFilters(); this.setState({ searchText: '' }); - } + }; render() { @@ -157,10 +186,10 @@ class Apps extends React.Component { color = 'green'; break; case 'removed': - color = 'red' + color = 'red'; break; case 'default': - color = 'blue' + color = 'blue'; } return {tag.toUpperCase()}; }, @@ -202,7 +231,7 @@ class Apps extends React.Component { - +
From c1cf3faba93fbe9a21d54a51c835956d53abe35e Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Sun, 28 Apr 2019 14:57:00 +0530 Subject: [PATCH 02/13] fixed error redirection --- .../react-app/src/pages/dashboard/apps/Apps.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 8e4ce3b10d..5a38f1460e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -85,8 +85,9 @@ class Apps extends React.Component { } }).catch(function (error) { - if(error.status === 401){ - window.location = 'https://localhost:9443/publisher/login' + if(error.response.status === 401){ + console.log("bis"); + window.location.href = 'https://localhost:9443/publisher/login'; } }); } From b3d87186ebefb074a179de0434e1512d98a47f0f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Sun, 28 Apr 2019 16:32:25 +0530 Subject: [PATCH 03/13] listed apps --- .../react-app/src/js/actions/index.js | 16 ++++++ .../src/js/constants/action-types.js | 4 +- .../react-app/src/js/reducers/index.js | 9 +++- .../src/pages/dashboard/apps/Apps.js | 49 ++++++------------- 4 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js new file mode 100644 index 0000000000..a1192b70eb --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -0,0 +1,16 @@ +import axios from "axios"; +import {GET_APPS} from "../constants/action-types"; + +export function getApps() { + axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request + ).then(res => { + if(res.status === 200){ + return {type: GET_APPS, payload : res.data} + } + + }).catch(function (error) { + if(error.response.status === 401){ + window.location.href = 'https://localhost:9443/publisher/login'; + } + }); +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js index 2cd535bbc2..e270ea0c6a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js @@ -1 +1,3 @@ -export const LOGIN = "LOGIN"; \ No newline at end of file +export const LOGIN = "LOGIN"; +export const GET_APPS = "GET_APPS"; + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js index 08eb66ed6d..8ba2625ee7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js @@ -1,8 +1,15 @@ +import {GET_APPS} from "../constants/action-types"; + const initialState = { - + apps : [] }; function rootReducer(state = initialState, action) { + if (action.type === GET_APPS) { + return Object.assign({}, state, { + apps: state.apps.concat(action.payload) + }); + } return state; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 5a38f1460e..6802245486 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -23,41 +23,9 @@ const routes = [ ]; - - -const data = [{ - key: '1', - icon: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', - name: 'John Brown', - platform: 'android', - type: 'Enterprise', - status: 'published', - version: '13.0.0.1', - updated_at: '27-03-2019 08:27' -},{ - key: '2', - icon: 'http://aztechbeat.com/wp-content/uploads/2014/04/confide-app-icon.png', - name: 'Lorem Ipsum', - platform: 'ios', - type: 'Enterprise', - status: 'published', - version: '2.3.1.2', - updated_at: '27-03-2019 09:45' -},{ - key: '3', - icon: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRx2Xx1-hnH16EGZHUlT06nOcfGODPoboA2TXKaBVtODto4lJtK', - name: 'Lorem Ipsum', - platform: 'ios', - type: 'Enterprise', - status: 'removed', - version: '4.1.1.0', - updated_at: '27-03-2019 09:46' -}]; - class Apps extends React.Component { routes; - state = { searchText: '', }; @@ -79,14 +47,27 @@ class Apps extends React.Component { axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request ).then(res => { if(res.status === 200){ + console.log(res.status); + let apps = []; + res.data['data']['applications'].forEach(function (app) { + apps.push({ + key: app.id, + icon: app["applicationReleases"][0]["iconPath"], + name: app.name, + platform: 'undefined', + type: app.type, + status: 'undefined', + version: 'undefined', + updated_at: 'undefined' + }); + }); thisComponent.setState({ - data : [] + data : apps }) } }).catch(function (error) { if(error.response.status === 401){ - console.log("bis"); window.location.href = 'https://localhost:9443/publisher/login'; } }); From 9a580e513f67a92c4b5c39762ab4373893a26fce Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Sun, 28 Apr 2019 17:22:16 +0530 Subject: [PATCH 04/13] fixed routing --- .../react-app/src/App.js | 30 +++++++++++-------- .../src/components/RouteWithSubRoutes.js | 2 +- .../react-app/src/index.js | 17 +++++++---- .../src/pages/dashboard/Dashboard.js | 2 +- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js index be1c130124..7ba8524e2e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js @@ -3,27 +3,33 @@ import "antd/dist/antd.css"; import RouteWithSubRoutes from "./components/RouteWithSubRoutes"; import { BrowserRouter as Router, - Link, + Link, Redirect, Switch, } from 'react-router-dom'; class App extends React.Component { routes; + constructor(props) { super(props); this.routes = props.routes; } - render() { - return ( - -
- {this.routes.map((route) => ( - - ))} -
-
- ); - } + render() { + console.log(this.routes); + return ( + +
+ + + {this.routes.map((route) => ( + + ))} + +
+
+ + ); + } } export default App; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js index c172b28edd..41cb84caf8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/RouteWithSubRoutes.js @@ -8,7 +8,7 @@ class RouteWithSubRoutes extends React.Component{ } render() { return( - ( + ( )}/> ); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js index df386140c4..046b3dae08 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js @@ -9,24 +9,29 @@ import AddNewApp from "./pages/dashboard/add-new-app/AddNewApp"; import './index.css'; import store from "./js/store/index"; import {Provider} from "react-redux"; +import {Switch} from "react-router"; const routes = [ { path: '/publisher/login', + exact: true, component: Login }, { - path: '/publisher', + path: '/publisher/dashboard', + exact: false, component: Dashboard, routes: [ { - path: '/publisher/apps', - component: Apps + path: '/publisher/dashboard/apps', + component: Apps, + exact: false }, { - path: '/publisher/new-app', - component: AddNewApp + path: '/publisher/dashboard/new-app', + component: AddNewApp, + exact: false } ] } @@ -35,7 +40,7 @@ const routes = [ ReactDOM.render( - + , document.getElementById('root')); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js index 9d8569b12a..0fca91e5a9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js @@ -38,7 +38,7 @@ class Dashboard extends React.Component { - + {this.state.routes.map((route) => ( ))} From 1c86d57da311a0ee4490d2cc48d89086d77968a1 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Sun, 28 Apr 2019 18:32:57 +0530 Subject: [PATCH 05/13] changed routes --- .../react-app/src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js index 046b3dae08..882fe0c8b6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js @@ -19,19 +19,19 @@ const routes = [ component: Login }, { - path: '/publisher/dashboard', + path: '/publisher/apps', exact: false, component: Dashboard, routes: [ { - path: '/publisher/dashboard/apps', + path: '/publisher/apps', component: Apps, - exact: false + exact: true }, { - path: '/publisher/dashboard/new-app', + path: '/publisher/apps/new-app', component: AddNewApp, - exact: false + exact: true } ] } From 9c80756c12f3c5ef905b63eaccd56ffdc0bddde2 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 13:35:32 +0530 Subject: [PATCH 06/13] refactored Apps Component --- .../react-app/src/index.js | 4 ++-- .../src/pages/dashboard/apps/{Apps.js => OldApps.js} | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/{Apps.js => OldApps.js} (98%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js index 882fe0c8b6..fc646cba4d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js @@ -4,7 +4,7 @@ import * as serviceWorker from './serviceWorker'; import App from "./App"; import Login from "./pages/Login"; import Dashboard from "./pages/dashboard/Dashboard"; -import Apps from "./pages/dashboard/apps/Apps"; +import OldApps from "./pages/dashboard/apps/OldApps"; import AddNewApp from "./pages/dashboard/add-new-app/AddNewApp"; import './index.css'; import store from "./js/store/index"; @@ -25,7 +25,7 @@ const routes = [ routes: [ { path: '/publisher/apps', - component: Apps, + component: OldApps, exact: true }, { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/OldApps.js similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/OldApps.js index 6802245486..75750bfc36 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/OldApps.js @@ -18,12 +18,12 @@ const routes = [ }, { path: 'second', - breadcrumbName: 'Apps', + breadcrumbName: 'OldApps', }, ]; -class Apps extends React.Component { +class OldApps extends React.Component { routes; state = { @@ -223,4 +223,4 @@ class Apps extends React.Component { } } -export default Apps; +export default OldApps; From ca1f147c77f85af35b2b3a6aee2bc1414186a590 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 13:51:03 +0530 Subject: [PATCH 07/13] fixed wrong redirection --- .../react-app/src/App.js | 2 +- .../react-app/src/index.js | 4 +- .../src/pages/dashboard/apps/Apps.js | 64 +++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js index 7ba8524e2e..9c532989fa 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/App.js @@ -20,7 +20,7 @@ class App extends React.Component {
- + {this.routes.map((route) => ( ))} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js index fc646cba4d..882fe0c8b6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js @@ -4,7 +4,7 @@ import * as serviceWorker from './serviceWorker'; import App from "./App"; import Login from "./pages/Login"; import Dashboard from "./pages/dashboard/Dashboard"; -import OldApps from "./pages/dashboard/apps/OldApps"; +import Apps from "./pages/dashboard/apps/Apps"; import AddNewApp from "./pages/dashboard/add-new-app/AddNewApp"; import './index.css'; import store from "./js/store/index"; @@ -25,7 +25,7 @@ const routes = [ routes: [ { path: '/publisher/apps', - component: OldApps, + component: Apps, exact: true }, { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js new file mode 100644 index 0000000000..e90fcf84b9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -0,0 +1,64 @@ +import React from "react"; +import "antd/dist/antd.css"; +import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd"; +import Highlighter from 'react-highlight-words'; +import axios from "axios"; + +const Paragraph = Typography; +const Search = Input.Search; + +const routes = [ + { + path: 'index', + breadcrumbName: 'Publisher', + }, + { + path: 'first', + breadcrumbName: 'Dashboard', + }, + { + path: 'second', + breadcrumbName: 'Apps', + }, +]; + + +class Apps extends React.Component { + routes; + constructor(props) { + super(props); + this.routes = props.routes; + + } + + + + render() { + return ( +
+ +
+ + + +
+ console.log(value)} + style={{ width: 200}} + /> + + + + + + + + + ); + } +} + +export default Apps; From 1cd23097d5e6db6df4009b6aa5ff3901263ab747 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 15:38:50 +0530 Subject: [PATCH 08/13] created component to load apps --- .../react-app/package.json | 1 + .../react-app/public/conf/config.json | 7 ++- .../react-app/src/components/AppCard.js | 43 +++++++++++++++++++ .../src/pages/dashboard/Dashboard.js | 6 +-- .../src/pages/dashboard/apps/Apps.js | 42 ++++++++++-------- 5 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json index 3029a00c3f..7a7e27ed67 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json @@ -37,6 +37,7 @@ "html-loader": "^0.5.5", "html-webpack-plugin": "^3.2.0", "img-loader": "^3.0.1", + "json-loader": "^0.5.7", "less": "^3.9.0", "less-loader": "^4.1.0", "mini-css-extract-plugin": "^0.5.0", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index 63678cb541..edd76448fe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -8,5 +8,10 @@ "httpsPort": "9443", "apiPort": "8243" }, - "serverUrl" : "https://localhost:9443" + "serverUrl" : "https://localhost:9443", + "defaultPlatformIcons": { + "default": "http://www.newdesignfile.com/postpic/2015/08/square-app-icon-blue_77131.png", + "android": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAZlBMVEX///+m2GSt23Gk11+i1lug1le+4pLb7sTu9+Tl89X5/PSk12Ge1VOo2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qkjBIKaWsHH5t11P3hdSHsNJ1KNIyu3l1GFJpqFcR0555hLGi/dQSUxGZtTQUfciSmonIrRaip1I7NTmIS6jFBU4vCc2u+JLpmKf0bFl+TRsdxjC95rVH1R4NR0ZBz9DzqUsk77TJGaUVfAjFK9Kzinz6EEqfioG+4OGU6Jsi6nsKQXjp5bw23I8jeBJeZjFC7qcDfAnF7jYltxiWL6FUtnfOrpXsTXiJJRAjfrEvf0Lf/D17lxdguGpmRETm5WbBysu2LW5qyzzigrKrfuwlXBAZdLYc0nqssviurBrrbioMHdI6gma+RXhJJmrniuu2zyHpmpwGadm76F37CBdDg3C7ydvedQtJ0iYnXCAaj6qQq/YSXsbGuIbA5u2MH9HjVOTOgbQlIQ9vW7sJL/EE5rhZUw7A7HxXlQ4t+FfZvPEoqP/QfsLF1JjLjb7ZpV8TnKzzoaTut5ekjZrUdwAvYQiXzk3lz75ZG7VTx62tVn1ArlvwzG7nh4IQLoxVuvbtqbzp68yjyv8y58fbdH220y54Xu38UyDCVVl9nVb13bhjUi1KsuWoTNOuruKddKv+ANf/kjfiNBjwAAAAAElFTkSuQmCC" + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js new file mode 100644 index 0000000000..1a03260c71 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js @@ -0,0 +1,43 @@ +import { + Skeleton, Switch, Card, Icon, Avatar, Typography +} from 'antd'; +import React from "react"; +import config from "../../public/conf/config.json"; + +const { Meta } = Card; +const { Text } = Typography; + +class AppCard extends React.Component { + + constructor(props){ + super(props); + } + + + render() { + const defaultPlatformIcons = config.defaultPlatformIcons; + let icon = defaultPlatformIcons.default; + if(defaultPlatformIcons.hasOwnProperty(this.props.platform)){ + icon = defaultPlatformIcons[this.props.platform]; + } + const description = ( +
+

{this.props.description}

+ {this.props.type} + {this.props.subType} +
+ ); + + return ( + , , ]}> + } + title={this.props.title} + description={description} + /> + + ); + } +} + +export default AppCard; \ 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/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js index 0fca91e5a9..396e335f2e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js @@ -31,9 +31,9 @@ class Dashboard extends React.Component { defaultSelectedKeys={['2']} style={{lineHeight: '64px'}} > - Apps - Apps - Add New App + Apps + Apps + Add New App diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index e90fcf84b9..80a7f20486 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -1,10 +1,9 @@ import React from "react"; import "antd/dist/antd.css"; -import {Table, Divider, Tag, Card, PageHeader, Typography, Avatar,Input, Button, Icon, Row, Col} from "antd"; -import Highlighter from 'react-highlight-words'; -import axios from "axios"; +import {PageHeader, Typography,Input, Button, Row, Col} from "antd"; + +import AppCard from "../../../components/AppCard"; -const Paragraph = Typography; const Search = Input.Search; const routes = [ @@ -31,8 +30,6 @@ class Apps extends React.Component { } - - render() { return (
@@ -40,19 +37,28 @@ class Apps extends React.Component { breadcrumb={{routes}} />
+ +
+ console.log(value)} + style={{ width: 200}} + /> + + + - - - - console.log(value)} - style={{ width: 200}} - /> - - - - + + + + + + + + + + + From 321a2e902c3ea196ca33ca9423ec181c45217a74 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 16:10:06 +0530 Subject: [PATCH 09/13] Created component to list apps --- .../react-app/src/components/AppList.js | 39 +++++++++++++++++++ .../src/pages/dashboard/apps/Apps.js | 14 +------ 2 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js new file mode 100644 index 0000000000..0c2b611cd2 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js @@ -0,0 +1,39 @@ +import React from "react"; +import AppCard from "./AppCard"; +import {Col, Row} from "antd"; + +class AppList extends React.Component { + constructor(props) { + super(props); + this.state = { + apps: [ + { + id: 1, + title: 'Hi', + platform: 'android', + description: 'lorem', + subType: 'FREE', + type: 'ENTERPRISE' + } + ] + } + } + + render() { + return ( + + {this.state.apps.map(app => ( + + + + ))} + + ); + } +} + +export default AppList; \ 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/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 80a7f20486..16fc0687f5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -3,6 +3,7 @@ import "antd/dist/antd.css"; import {PageHeader, Typography,Input, Button, Row, Col} from "antd"; import AppCard from "../../../components/AppCard"; +import AppList from "../../../components/AppList"; const Search = Input.Search; @@ -47,18 +48,7 @@ class Apps extends React.Component { - - - - - - - - - - - - + From 1b3390f1b9ab216f7b9c69ae4c8c06a9e762ec5f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 16:21:03 +0530 Subject: [PATCH 10/13] Load data from Redux state --- .../react-app/src/components/AppList.js | 29 +++++++++---------- .../react-app/src/js/reducers/index.js | 17 ++++++++++- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js index 0c2b611cd2..728fff0382 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js @@ -1,30 +1,25 @@ import React from "react"; import AppCard from "./AppCard"; import {Col, Row} from "antd"; +import {connect} from "react-redux"; -class AppList extends React.Component { +// connecting state.articles with the component +const mapStateToProps= state => { + return {apps : state.apps} +}; + + +class ConnectedAppList extends React.Component { constructor(props) { super(props); - this.state = { - apps: [ - { - id: 1, - title: 'Hi', - platform: 'android', - description: 'lorem', - subType: 'FREE', - type: 'ENTERPRISE' - } - ] - } } render() { return ( - {this.state.apps.map(app => ( - - ( + + Date: Mon, 29 Apr 2019 17:06:26 +0530 Subject: [PATCH 11/13] get Data --- .../react-app/package.json | 3 +- .../react-app/src/components/AppCard.js | 2 +- .../react-app/src/components/AppList.js | 9 +++-- .../react-app/src/index.js | 1 - .../react-app/src/js/actions/index.js | 36 +++++++++++++------ .../react-app/src/js/reducers/index.js | 20 ++--------- .../react-app/src/js/store/index.js | 5 +-- .../src/pages/dashboard/apps/Apps.js | 2 -- 8 files changed, 41 insertions(+), 37 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json index 7a7e27ed67..ba015d08d1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json @@ -16,10 +16,11 @@ "react": "^16.8.4", "react-dom": "^16.8.4", "react-highlight-words": "^0.16.0", + "react-router": "latest", "react-router-config": "^5.0.0", "react-router-dom": "latest", "react-scripts": "2.1.8", - "react-router": "latest" + "redux-thunk": "^2.3.0" }, "devDependencies": { "@babel/core": "^7.0.0", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js index 1a03260c71..7ae50e0c90 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js @@ -32,7 +32,7 @@ class AppCard extends React.Component { , , ]}> } - title={this.props.title} + title={this.props.name} description={description} /> diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js index 728fff0382..20d874e099 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js @@ -2,6 +2,7 @@ import React from "react"; import AppCard from "./AppCard"; import {Col, Row} from "antd"; import {connect} from "react-redux"; +import {getApps} from "../js/actions"; // connecting state.articles with the component const mapStateToProps= state => { @@ -13,13 +14,17 @@ class ConnectedAppList extends React.Component { constructor(props) { super(props); } + componentDidMount() { + this.props.getApps(); + } render() { return ( {this.props.apps.map(app => ( - { - if(res.status === 200){ - return {type: GET_APPS, payload : res.data} - } - - }).catch(function (error) { - if(error.response.status === 401){ - window.location.href = 'https://localhost:9443/publisher/login'; - } - }); + + return (dispatch) => { + const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; + + return axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request + ).then(res => { + if (res.status === 200) { + let apps = []; + + if(res.data.data.hasOwnProperty("applications")){ + apps = res.data.data.applications; + } + console.log(res.data); + dispatch({type: GET_APPS, payload: apps}); + } + + }).catch(function (error) { + if (error.response.status === 401) { + window.location.href = 'https://localhost:9443/publisher/login'; + } + }); + + }; + + } \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js index 79a4fd1f90..3093402642 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js @@ -1,28 +1,14 @@ import {GET_APPS} from "../constants/action-types"; const initialState = { - apps: [{ - id: 1, - title: 'Hi', - platform: 'android', - description: 'lorem', - subType: 'FREE', - type: 'ENTERPRISE' - }, - { - id: 2, - title: 'Hi', - platform: 'android', - description: 'lorem', - subType: 'FREE', - type: 'ENTERPRISE' - }] + apps: [] }; function rootReducer(state = initialState, action) { if (action.type === GET_APPS) { + console.log(11); return Object.assign({}, state, { - apps: state.apps.concat(action.payload) + apps: action.payload }); } return state; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/store/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/store/index.js index 7209a4b021..04957eb39a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/store/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/store/index.js @@ -1,4 +1,5 @@ -import { createStore } from "redux"; +import { createStore, applyMiddleware } from "redux"; import rootReducer from "../reducers/index"; -const store = createStore(rootReducer); +import thunk from "redux-thunk"; +const store = createStore(rootReducer, applyMiddleware(thunk)); export default store; \ 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/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js index 16fc0687f5..92d366a3ae 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js @@ -1,8 +1,6 @@ import React from "react"; import "antd/dist/antd.css"; import {PageHeader, Typography,Input, Button, Row, Col} from "antd"; - -import AppCard from "../../../components/AppCard"; import AppList from "../../../components/AppList"; const Search = Input.Search; From 42727786ceb5e6033d1fd5d1e22d1deb6e1b218f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 17:07:41 +0530 Subject: [PATCH 12/13] changed platform to devicetype --- .../react-app/src/components/AppList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js index 20d874e099..d6c54f4039 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppList.js @@ -25,7 +25,7 @@ class ConnectedAppList extends React.Component { From feb68e9a70b93f04f301055b62dfd10f5f2ce0e6 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Mon, 29 Apr 2019 17:54:02 +0530 Subject: [PATCH 13/13] Changed hard coded urls to config --- .../react-app/public/conf/config.json | 5 +++-- .../react-app/src/components/AppCard.js | 6 +++++- .../react-app/src/js/actions/index.js | 3 ++- .../react-app/src/pages/Login.js | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index edd76448fe..c2e66dda14 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -3,10 +3,11 @@ "type": "default", "value": "lightBaseTheme" }, - "config": { + "serverConfig": { "hostname": "localhost", "httpsPort": "9443", - "apiPort": "8243" + "invokerUri": "/api/application-mgt-handler/v1.0/invoke", + "loginUri": "/api/application-mgt-handler/v1.0/login" }, "serverUrl" : "https://localhost:9443", "defaultPlatformIcons": { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js index 7ae50e0c90..d965e05d7f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/AppCard.js @@ -20,9 +20,13 @@ class AppCard extends React.Component { if(defaultPlatformIcons.hasOwnProperty(this.props.platform)){ icon = defaultPlatformIcons[this.props.platform]; } + let descriptionText = this.props.description; + if(descriptionText.length>50){ + descriptionText = descriptionText.substring(0,50)+"..."; + } const description = (
-

{this.props.description}

+

{descriptionText}

{this.props.type} {this.props.subType}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index 1649e3e31e..05da75eb70 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -1,12 +1,13 @@ import axios from "axios"; import {GET_APPS} from "../constants/action-types"; +import config from "../../../public/conf/config.json"; export function getApps() { return (dispatch) => { const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; - return axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/invoke', request + return axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.invokerUri, request ).then(res => { if (res.status === 200) { let apps = []; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js index e49b031118..8953e32352 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js @@ -2,6 +2,7 @@ import React from "react"; import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd'; import styles from './Login.less'; import axios from 'axios'; +import config from "../../public/conf/config.json"; const {Title} = Typography; const {Text} = Typography; @@ -58,7 +59,7 @@ class NormalLoginForm extends React.Component { }); console.log('Received values of form: ', values); let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher"; - axios.post('https://localhost:9443/api/application-mgt-handler/v1.0/login', data + axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data ).then(res => { if (res.status === 200) { window.location = res.data.url;