Adding changes for store.

feature/appm-store/pbac
sinthuja 7 years ago
parent 498b2c02aa
commit 410fc69bfa

@ -1,7 +1,7 @@
{ {
"name": "store", "name": "store",
"version": "1.0.0", "version": "1.0.0",
"description": "WSO2 IoT Server App Publisher", "description": "WSO2 IoT Server App Store",
"main": "App.js", "main": "App.js",
"repository": { "repository": {
"type": "git", "type": "git",

@ -2,5 +2,10 @@
"theme": { "theme": {
"type": "default", "type": "default",
"value": "lightBaseTheme" "value": "lightBaseTheme"
},
"config": {
"hostname": "localhost",
"httpsPort": "9443",
"apiPort": "8243"
} }
} }

@ -21,14 +21,14 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000"> <meta name="theme-color" content="#000000">
<link rel="stylesheet" type="text/css" href="/publisher/css/font-wso2.css"> <link rel="stylesheet" type="text/css" href="/store/css/font-wso2.css">
<link rel="stylesheet" type="text/css" href="/publisher/themes/default/default-theme.css"> <link rel="stylesheet" type="text/css" href="/store/themes/default/default-theme.css">
<!-- <!--
manifest.json provides metadata used when your web app is added to the manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
--> -->
<link rel="manifest" href="/publisher/manifest.json"> <link rel="manifest" href="/store/manifest.json">
<link rel="shortcut icon" href="/publisher/images/favicon.png"> <link rel="shortcut icon" href="/store/images/favicon.png">
<!-- <!--
Notice the use of %PUBLIC_URL% in the tags above. Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build. It will be replaced with the URL of the `public` folder during the build.
@ -38,14 +38,14 @@
work correctly both with client-side routing and a non-root public URL. work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`. Learn how to configure a non-root public URL by running `npm run build`.
--> -->
<title>WSO2 IoT App Publisher</title> <title>WSO2 IoT App Store</title>
</head> </head>
<body> <body>
<noscript> <noscript>
You need to enable JavaScript to run this app. You need to enable JavaScript to run this app.
</noscript> </noscript>
<div id="root"></div> <div id="root"></div>
<script src='/publisher/dist/index.js'></script> <script src='/store/dist/index.js'></script>
<!-- <!--
This HTML file is a template. This HTML file is a template.
If you open it directly in the browser, you will see an empty page. If you open it directly in the browser, you will see an empty page.

@ -1,6 +1,6 @@
{ {
"short_name": "App Publisher", "short_name": "App Store",
"name": "WSO2 IoT App Publisher", "name": "WSO2 IoT App Store",
"icons": [ "icons": [
{ {
"src": "images/favicon.png", "src": "images/favicon.png",

@ -42,7 +42,7 @@ const history = createHistory({basename: '/store'});
* The Router and Route components. * The Router and Route components.
* The Router and Route is used for navigation. * The Router and Route is used for navigation.
* We specify the component which needs to be rendered for an URL. * We specify the component which needs to be rendered for an URL.
* Ex: When navigate to publisher/overview, the overview component will be rendered inside the main layout. * Ex: When navigate to store/overview, the overview component will be rendered inside the main layout.
* *
* HashRouter is used because the other router types need the server to serve those urls. In hashRouter, server does * HashRouter is used because the other router types need the server to serve those urls. In hashRouter, server does
* not want to serve the URL. * not want to serve the URL.
@ -67,6 +67,7 @@ class Base extends Component {
} }
render() { render() {
console.log('in app.jsx');
if (this.state.user !== null) { if (this.state.user !== null) {
return ( return (
<div> <div>
@ -87,9 +88,19 @@ class Base extends Component {
</Switch> </Switch>
</BaseLayout> </BaseLayout>
</div> </div>
) );
} else { } else {
return (<Redirect to={"/assets/apps"}/>) return (
<div>
<BaseLayout>
<Switch>
<Redirect exact path={"/"} to={"/assets/apps"}/>
<Route exact path={"/assets/apps"} component={ApplicationListing}/>
<Route component={NotFound}/>
</Switch>
</BaseLayout>
</div>
);
} }
} }
@ -97,24 +108,19 @@ class Base extends Component {
/** /**
* This component is referred by the index.js to initiate the application. * This component is referred by the index.js to initiate the application.
* TODO: Currently the URL shows like https://localhost:9443/publisher/#/publisher/assets/apps/create. this needs to * TODO: Currently the URL shows like https://localhost:9443/store/#/store/assets/apps/create. this needs to
* be fixed as https://localhost:9443/publisher/#/assets/apps/create * be fixed as https://localhost:9443/store/#/assets/apps/create
* *
* */ * */
class Store extends Component { class Store extends Component {
constructor() { constructor() {
super(); super();
this.state = {
muiTheme: null,
selectedType: null,
selectedTheme: null
};
} }
render() { render() {
return ( return (
<div className="App"> <div className="App">
<Router basename="publisher" history={history}> <Router basename="store" history={history}>
<Switch> <Switch>
<Route path="/login" component={Login}/> <Route path="/login" component={Login}/>
<Route path="/logout" component={Login}/> <Route path="/logout" component={Login}/>

@ -60,6 +60,10 @@ class AuthHandler {
return login_promise; return login_promise;
}; };
static loginAsAnonymous(){
}
/** /**
* Persists the user object in browser's local storage. * Persists the user object in browser's local storage.
* @param user: The user object. * @param user: The user object.

@ -19,7 +19,7 @@
'use strict'; 'use strict';
/** /**
* Helper methods for app publisher. * Helper methods for app store.
* */ * */
export default class Helper { export default class Helper {

@ -16,32 +16,53 @@
* under the License. * under the License.
*/ */
'use strict'; import axios from 'axios';
//TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc. //TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc.
export default class Constants { class Constants {
static scopes = 'perm:application:get perm:application:create perm:application:update perm:application-mgt:login' + constructor() {
' perm:application:delete perm:platform:add perm:platform:remove perm:roles:view perm:devices:view'; this.contentTypeHeaderName = 'Content-Type';
this.contentType = 'application/json';
static appManagerEndpoints = { this.https = 'https://';
GET_ALL_APPS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/', console.log('server config called');
CREATE_APP: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/', this.serverConfig = {};
UPLOAD_IMAGE_ARTIFACTS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/upload-image-artifacts/', //+appId this.getServerConfig();
GET_IMAGE_ARTIFACTS: "https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/image-artifacts/"
}; this.scopes = 'perm:application:get perm:application:create perm:application:update perm:application-mgt:login' +
' perm:application:delete perm:platform:add perm:platform:remove perm:roles:view perm:devices:view';
static platformManagerEndpoints = {
CREATE_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0', this.appManagerEndpoints = {
GET_ENABLED_PLATFORMS: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0?status=ENABLED', GET_ALL_APPS: this.https + this.serverConfig.hostname + ':' + this.serverConfig.httpsPort + '/api/application-mgt/v1.0/applications/1.0.0/',
GET_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0/' CREATE_APP: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/',
}; UPLOAD_IMAGE_ARTIFACTS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/upload-image-artifacts/', //+appId
GET_IMAGE_ARTIFACTS: "https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/image-artifacts/"
static userConstants = { };
LOGIN_URL:"https://localhost:9443/auth/application-mgt/v1.0/auth/login",
LOGOUT_URL: "https://localhost:9443/auth/application-mgt/v1.0/auth/logout", this.platformManagerEndpoints = {
REFRESH_TOKEN_URL: "", CREATE_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0',
WSO2_USER: 'wso2_user', GET_ENABLED_PLATFORMS: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0?status=ENABLED',
PARTIAL_TOKEN: 'WSO2_IOT_TOKEN' GET_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0/'
};
this.userConstants = {
LOGIN_URL: "https://localhost:9443/auth/application-mgt/v1.0/auth/login",
LOGOUT_URL: "https://localhost:9443/auth/application-mgt/v1.0/auth/logout",
REFRESH_TOKEN_URL: "",
WSO2_USER: 'wso2_user',
PARTIAL_TOKEN: 'WSO2_IOT_TOKEN'
};
} }
getServerConfig(callback) {
let baseURL = window.location.origin;
let appContext = window.location.pathname.split("/")[1];
let configFileName = 'config.json';
return axios.get(baseURL + "/" + configFileName);
}
} }
export default (new Constants);

@ -75,7 +75,7 @@ class BaseLayout extends Component {
<div id="header-content"> <div id="header-content">
<div id="header"> <div id="header">
<span id="header-text"> <span id="header-text">
WSO2 IoT App Publisher WSO2 IoT App Store
</span> </span>
<div id="header-btn-container"> <div id="header-btn-container">
<i className="fw fw-notification btn-header"></i> <i className="fw fw-notification btn-header"></i>

@ -21,6 +21,7 @@ import {withRouter} from 'react-router-dom';
import {Button, Col, Row, Table} from 'reactstrap'; import {Button, Col, Row, Table} from 'reactstrap';
import Drawer from '../UIComponents/Drawer/Drawer'; import Drawer from '../UIComponents/Drawer/Drawer';
import ApplicationView from './View/ApplicationView'; import ApplicationView from './View/ApplicationView';
import Constants from '../../common/constants';
/** /**
* The App Create Component. * The App Create Component.
@ -54,6 +55,7 @@ class ApplicationListing extends Component {
src: "http://dl1.cbsistatic.com/i/r/2016/08/08/0e67e43a-5a45-41ab-b81d-acfba8708044/resize/736x552/0c0ee669677b5060a0fa1bfb0c7873b4/android-logo-promo-470.png" src: "http://dl1.cbsistatic.com/i/r/2016/08/08/0e67e43a-5a45-41ab-b81d-acfba8708044/resize/736x552/0c0ee669677b5060a0fa1bfb0c7873b4/android-logo-promo-470.png"
}] }]
}; };
console.log(Constants.appManagerEndpoints.GET_ALL_APPS);
} }
headers = [ headers = [
@ -200,7 +202,7 @@ class ApplicationListing extends Component {
}; };
let appListStyle = { let appListStyle = {
marginRight: '500px', marginRight: '500px'
}; };
this.setState({drawer: style, appListStyle: appListStyle}); this.setState({drawer: style, appListStyle: appListStyle});
@ -237,15 +239,7 @@ class ApplicationListing extends Component {
render() { render() {
return ( return (
<div id="application-list" style={this.state.appListStyle}> <div id="application-list" style={this.state.appListStyle}>
<Row>
<Col xs="3 offset-9">
<div className="platform-link-placeholder">
<Button><i className="fw fw-settings"></i> Platforms</Button>
</div>
</Col>
</Row>
<Row> <Row>
<Col> <Col>
<Table striped hover> <Table striped hover>

@ -72,7 +72,7 @@ class ApplicationEdit extends Component {
} }
handleOnBackClick() { handleOnBackClick() {
window.location.href = "/publisher/assets/apps" window.location.href = "/store/assets/apps"
} }
render() { render() {

@ -132,7 +132,7 @@ class Login extends Component {
{/*TODO: Style the components.*/} {/*TODO: Style the components.*/}
<Card id="login-card"> <Card id="login-card">
<CardBlock> <CardBlock>
<CardTitle>WSO2 IoT APP Publisher</CardTitle> <CardTitle>WSO2 IoT APP Store</CardTitle>
<Form onSubmit={this.handleLogin.bind(this)}> <Form onSubmit={this.handleLogin.bind(this)}>
<FormGroup row> <FormGroup row>
<Label for="userName" sm={2}>User Name:</Label> <Label for="userName" sm={2}>User Name:</Label>

@ -18,7 +18,7 @@
import Login from './User/Login/Login'; import Login from './User/Login/Login';
import NotFound from './Error/NotFound'; import NotFound from './Error/NotFound';
import BaseLayout from './AppPublisherBase/BaseLayout'; import BaseLayout from './AppStoreBase/BaseLayout';
import PlatformCreate from './Platform/PlatformCreate'; import PlatformCreate from './Platform/PlatformCreate';
import PlatformListing from './Platform/PlatformListing'; import PlatformListing from './Platform/PlatformListing';
import ApplicationCreate from './Application/Create/ApplicationCreate'; import ApplicationCreate from './Application/Create/ApplicationCreate';

@ -48,7 +48,7 @@ export default function register() {
} }
window.addEventListener('load', () => { window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/publisher/service-worker.js`; const swUrl = `${process.env.PUBLIC_URL}/store/service-worker.js`;
if (!isLocalhost) { if (!isLocalhost) {
// Is not local host. Just register service worker // Is not local host. Just register service worker

Loading…
Cancel
Save