Merge branch 'application-mgt-new' into 'application-mgt-new'

Change 401 redirection in APPM UI

See merge request entgra/carbon-device-mgt!128
4.x.x
Dharmakeerthi Lasantha 6 years ago
commit a5ffc12eeb

@ -4,6 +4,7 @@
"value": "lightBaseTheme" "value": "lightBaseTheme"
}, },
"serverConfig": { "serverConfig": {
"protocol": "https",
"hostname": "localhost", "hostname": "localhost",
"httpsPort": "9443", "httpsPort": "9443",
"invokerUri": "/api/application-mgt-handler/v1.0/invoke", "invokerUri": "/api/application-mgt-handler/v1.0/invoke",

@ -30,7 +30,7 @@ class DetailedRating extends React.Component{
getData = (uuid)=>{ getData = (uuid)=>{
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let detailedRating = res.data.data; let detailedRating = res.data.data;
@ -41,7 +41,7 @@ class DetailedRating extends React.Component{
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} }
}); });
}; };

@ -120,7 +120,7 @@ class ConnectedAppsTable extends React.Component {
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
console.log(request); console.log(request);
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let apps = []; let apps = [];
@ -143,7 +143,7 @@ class ConnectedAppsTable extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.status === 401) { if (error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.error('Something went wrong... :('); message.error('Something went wrong... :(');
} }

@ -21,7 +21,7 @@ class ManageCategories extends React.Component {
componentDidMount() { componentDidMount() {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/categories"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/categories";
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let categories = JSON.parse(res.data.data); let categories = JSON.parse(res.data.data);
@ -33,7 +33,7 @@ class ManageCategories extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
@ -56,7 +56,7 @@ class ManageCategories extends React.Component {
loading: true loading: true
}); });
const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -65,23 +65,22 @@ class ManageCategories extends React.Component {
"Category Removed Successfully!", "Category Removed Successfully!",
}); });
const {categories} = this.state;
const remainingElements = categories.filter(function (value) {
return value.categoryName !== id;
});
this.setState({ this.setState({
loading: false loading: false,
categories: remainingElements
}); });
// this.setState({
// categories: [...categories, ...tempElements],
// tempElements: [],
// inputVisible: false,
// inputValue: '',
// loading: false,
// isAddNewVisible: false
// });
} }
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }
@ -135,12 +134,12 @@ class ManageCategories extends React.Component {
}; };
renderTempElement = (category) => { renderTempElement = (category) => {
const {tempElements} = this.state;
const tagElem = ( const tagElem = (
<Tag <Tag
closable closable
onClose={e=>{ onClose={e=>{
e.preventDefault(); e.preventDefault();
const {tempElements} = this.state;
const remainingElements = tempElements.filter(function (value) { const remainingElements = tempElements.filter(function (value) {
return value.categoryName !== category.categoryName; return value.categoryName !== category.categoryName;
@ -196,7 +195,7 @@ class ManageCategories extends React.Component {
const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const dataArray = JSON.stringify(tempElements.map(category => category.categoryName));
const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories";
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -218,7 +217,7 @@ class ManageCategories extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }
@ -257,7 +256,7 @@ class ManageCategories extends React.Component {
isEditModalVisible: false, isEditModalVisible: false,
}); });
const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/rename?from="+currentlyEditingId+"%26to="+editingValue; const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/rename?from="+currentlyEditingId+"%26to="+editingValue;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -278,7 +277,7 @@ class ManageCategories extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }

@ -21,7 +21,7 @@ class ManageTags extends React.Component {
componentDidMount() { componentDidMount() {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/tags"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/tags";
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let categories = JSON.parse(res.data.data); let categories = JSON.parse(res.data.data);
@ -33,7 +33,7 @@ class ManageTags extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
@ -56,7 +56,7 @@ class ManageTags extends React.Component {
loading: true loading: true
}); });
const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id; const request = "method=delete&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories/" + id;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -81,7 +81,7 @@ class ManageTags extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }
@ -196,7 +196,7 @@ class ManageTags extends React.Component {
const dataArray = JSON.stringify(tempElements.map(category => category.categoryName)); const dataArray = JSON.stringify(tempElements.map(category => category.categoryName));
const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories"; const request = "method=post&content-type=application/json&payload=" + dataArray + "&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories";
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -218,7 +218,7 @@ class ManageTags extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }
@ -257,7 +257,7 @@ class ManageTags extends React.Component {
isEditModalVisible: false, isEditModalVisible: false,
}); });
const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories?from="+currentlyEditingId+"%26to="+editingValue; const request = "method=put&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/admin/applications/categories?from="+currentlyEditingId+"%26to="+editingValue;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
notification["success"]({ notification["success"]({
@ -278,7 +278,7 @@ class ManageTags extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.hasOwnProperty("status") && error.response.status === 401) { if (error.response.hasOwnProperty("status") && error.response.status === 401) {
message.error('You are not logged in'); message.error('You are not logged in');
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');
} }

@ -6,7 +6,7 @@ export const getApps = () => dispatch => {
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications"; const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let apps = []; let apps = [];
@ -19,7 +19,7 @@ export const getApps = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} }
}); });
@ -29,7 +29,7 @@ export const getRelease = (uuid) => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/" + uuid; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/release/" + uuid;
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let release = res.data.data; let release = res.data.data;
@ -38,7 +38,7 @@ export const getRelease = (uuid) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} }
}); });
@ -73,7 +73,7 @@ export const closeLifecycleModal = () => dispatch => {
export const getLifecycle = () => dispatch => { export const getLifecycle = () => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let lifecycle = res.data.data; let lifecycle = res.data.data;
@ -82,7 +82,7 @@ export const getLifecycle = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} }
}); });
}; };
@ -97,7 +97,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-publisher/v1.0/applications/life-cycle/" + uuid; const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-publisher/v1.0/applications/life-cycle/" + uuid;
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
let release = res.data.data; let release = res.data.data;
@ -111,7 +111,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
} else if (error.response.status === 500) { } else if (error.response.status === 500) {
alert("error"); alert("error");
dispatch({ dispatch({

@ -59,7 +59,7 @@ class NormalLoginForm extends React.Component {
}); });
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher"; let data = "username=" + values.username + "&password=" + values.password + "&platform=publisher";
axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
window.location = res.data.url; window.location = res.data.url;

@ -4,9 +4,9 @@ import {Layout, Menu, Icon} from 'antd';
const {Header, Content, Footer} = Layout; const {Header, Content, Footer} = Layout;
import Logo from "../../../public/images/logo.svg"; import Logo from "../../../public/images/logo.svg";
import {Link, NavLink} from "react-router-dom"; import {BrowserRouter,Switch,Link, NavLink} from "react-router-dom";
import RouteWithSubRoutes from "../../components/RouteWithSubRoutes" import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"
import {Switch, Redirect} from 'react-router' import {Redirect} from 'react-router'
import "../../App.css"; import "../../App.css";
class Dashboard extends React.Component { class Dashboard extends React.Component {
@ -41,6 +41,7 @@ class Dashboard extends React.Component {
</Layout> </Layout>
<Layout> <Layout>
<Content style={{padding: '0 0'}}> <Content style={{padding: '0 0'}}>
<BrowserRouter>
<Switch> <Switch>
<Redirect exact from="/publisher" to="/publisher/apps"/> <Redirect exact from="/publisher" to="/publisher/apps"/>
{this.state.routes.map((route) => ( {this.state.routes.map((route) => (
@ -48,6 +49,7 @@ class Dashboard extends React.Component {
))} ))}
</Switch> </Switch>
</BrowserRouter>
</Content> </Content>
<Footer style={{textAlign: 'center'}}> <Footer style={{textAlign: 'center'}}>

@ -35,7 +35,7 @@ class Manage extends React.Component {
return ( return (
<div> <div>
<PageHeader <PageHeader
breadcrumb={{routes}} // breadcrumb={{routes}}
title = "Manage" title = "Manage"
> >
<div className="wrap"> <div className="wrap">

@ -16,6 +16,7 @@
"d3": "^5.9.2", "d3": "^5.9.2",
"dagre": "^0.8.4", "dagre": "^0.8.4",
"keymirror": "^0.1.1", "keymirror": "^0.1.1",
"lodash.debounce": "^4.0.8",
"rc-viewer": "0.0.9", "rc-viewer": "0.0.9",
"react": "^16.8.4", "react": "^16.8.4",
"react-d3-graph": "^2.0.2", "react-d3-graph": "^2.0.2",

@ -4,6 +4,7 @@
"value": "lightBaseTheme" "value": "lightBaseTheme"
}, },
"serverConfig": { "serverConfig": {
"protocol": "https",
"hostname": "localhost", "hostname": "localhost",
"httpsPort": "9443", "httpsPort": "9443",
"invokerUri": "/api/application-mgt-handler/v1.0/invoke", "invokerUri": "/api/application-mgt-handler/v1.0/invoke",

@ -8,6 +8,7 @@ import Reviews from "./review/Reviews";
import AddReview from "./review/AddReview"; import AddReview from "./review/AddReview";
import axios from "axios"; import axios from "axios";
import config from "../../../../public/conf/config.json"; import config from "../../../../public/conf/config.json";
import AppInstallModal from "./install/AppInstallModal";
const {Title, Text, Paragraph} = Typography; const {Title, Text, Paragraph} = Typography;
@ -15,24 +16,32 @@ class ReleaseView extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
loading: false loading: false,
appInstallModalVisible: false
} }
} }
installApp = () =>{ installApp = (type,payload) => {
const {uuid} = this.props.release; const {uuid} = this.props.release;
const payload = ["admin"];
const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/subscription/install/"+uuid+"/user/install";
const parameters = {
method: "post",
'content-type': "application/json",
payload: JSON.stringify(payload),
'api-endpoint': "/application-mgt-store/v1.0/subscription/install/" + uuid + "/"+type+"/install"
};
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
this.setState({ this.setState({
loading: true, loading: true,
}); });
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
loading: false loading: false,
appInstallModalVisible: false
}); });
notification["success"]({ notification["success"]({
message: 'Done!', message: 'Done!',
@ -52,7 +61,7 @@ class ReleaseView extends React.Component {
}).catch((error) => { }).catch((error) => {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} else { } else {
this.setState({ this.setState({
loading: false, loading: false,
@ -67,10 +76,24 @@ class ReleaseView extends React.Component {
}); });
}; };
showAppInstallModal = () => {
this.setState({
appInstallModalVisible: true
});
};
closeAppInstallModal = () => {
this.setState({
appInstallModalVisible: false
});
};
render() { render() {
const release = this.props.release; const release = this.props.release;
return ( return (
<div> <div>
<AppInstallModal uuid={release.uuid} visible={this.state.appInstallModalVisible}
onClose={this.closeAppInstallModal} onInstall={this.installApp}/>
<div className="release"> <div className="release">
<Row> <Row>
<Col xl={4} sm={6} xs={8} className="release-icon"> <Col xl={4} sm={6} xs={8} className="release-icon">
@ -91,7 +114,8 @@ class ReleaseView extends React.Component {
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}> <Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
<div> <div>
<Button.Group style={{float: "right"}}> <Button.Group style={{float: "right"}}>
<Button onClick={this.installApp} loading={this.state.loading} htmlType="button" type="primary" icon="download">Install</Button> <Button onClick={this.showAppInstallModal} loading={this.state.loading}
htmlType="button" type="primary" icon="download">Install</Button>
</Button.Group> </Button.Group>
</div> </div>
</Col> </Col>

@ -0,0 +1,38 @@
import React from "react";
import {Button, Modal, Tabs} from "antd";
import UserInstall from "./UserInstall";
const { TabPane } = Tabs;
class AppInstallModal extends React.Component{
render() {
return (
<div>
<Modal
title="Install App"
visible={this.props.visible}
// onOk={this.handleOk}
onCancel={this.props.onClose}
footer={null}
>
<Tabs defaultActiveKey="1">
<TabPane tab="User" key="1">
<UserInstall onInstall={this.props.onInstall}/>
</TabPane>
<TabPane tab="Device" key="2">
Tab 2
</TabPane>
<TabPane tab="Role" key="3">
Tab 3
</TabPane>
<TabPane tab="Group" key="4">
Tab 3
</TabPane>
</Tabs>
</Modal>
</div>
);
}
}
export default AppInstallModal;

@ -0,0 +1,115 @@
import React from "react";
import {Typography, Select, Spin, message, notification, Button} from "antd";
import debounce from 'lodash.debounce';
import axios from "axios";
import config from "../../../../../public/conf/config.json";
const {Text} = Typography;
const {Option} = Select;
class UserInstall extends React.Component {
constructor(props) {
super(props);
this.lastFetchId = 0;
this.fetchUser = debounce(this.fetchUser, 800);
}
state = {
data: [],
value: [],
fetching: false,
};
fetchUser = value => {
console.log('fetching user', value);
this.lastFetchId += 1;
const fetchId = this.lastFetchId;
this.setState({data: [], fetching: true});
const parameters = {
method: "get",
'content-type': "application/json",
payload: "{}",
'api-endpoint': "/device-mgt/v1.0/users/search?username=" + value
};
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
console.log(request);
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => {
if (res.status === 200) {
if (fetchId !== this.lastFetchId) {
// for fetch callback order
return;
}
console.log(res.data.data);
const data = res.data.data.users.map(user => ({
text: user.username,
value: user.username,
}));
this.setState({data, fetching: false});
}
}).catch((error) => {
if (error.response.hasOwnProperty(status) && error.response.status === 401) {
message.error('You are not logged in');
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} else {
message.error('Something went wrong... :(');
}
this.setState({fetching: false});
});
};
handleChange = value => {
this.setState({
value,
data: [],
fetching: false,
});
};
install = () =>{
this.props.onInstall("user",this.state.data);
};
render() {
const {fetching, data, value} = this.state;
return (
<div>
<Text>Lorem ipsum dolor sit amet, ne tation labores quo, errem facilisis expetendis vel in. Ut choro
decore ubique sed,</Text>
<p>Select users</p>
<Select
mode="multiple"
labelInValue
value={value}
placeholder="Enter the username"
notFoundContent={fetching ? <Spin size="small"/> : null}
filterOption={false}
onSearch={this.fetchUser}
onChange={this.handleChange}
style={{width: '100%'}}
>
{data.map(d => (
<Option key={d.value}>{d.text}</Option>
))}
</Select>
<div style={{paddingTop:10}}>
<Button htmlType="button" type="primary" onClick={this.install}>Install</Button>
</div>
</div>
);
}
}
export default UserInstall;

@ -54,7 +54,7 @@ class AddReview extends React.Component {
const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid; const request = "method=post&content-type=application/json&payload="+JSON.stringify(payload)+"&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
this.setState({ this.setState({
@ -84,7 +84,7 @@ class AddReview extends React.Component {
}).catch((error) =>{ }).catch((error) =>{
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} else{ } else{
this.setState({ this.setState({
loading: false, loading: false,

@ -28,7 +28,7 @@ class Reviews extends React.Component {
fetchData = (offset, limit, callback) => { fetchData = (offset, limit, callback) => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/" + this.props.uuid + "?offset=" + offset + "%26limit=" + limit; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/" + this.props.uuid + "?offset=" + offset + "%26limit=" + limit;
axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let reviews = res.data.data.data; let reviews = res.data.data.data;
@ -37,7 +37,7 @@ class Reviews extends React.Component {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
} else { } else {
message.warning('Something went wrong'); message.warning('Something went wrong');

@ -6,7 +6,7 @@ export const getApps = () => dispatch => {
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications"; const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let apps = []; let apps = [];
@ -19,7 +19,7 @@ export const getApps = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} }
}); });
@ -29,7 +29,7 @@ export const getRelease = (uuid) => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + uuid; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + uuid;
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let release = res.data.data.applicationReleases[0]; let release = res.data.data.applicationReleases[0];
@ -43,7 +43,7 @@ export const getRelease = (uuid) => dispatch => {
} }
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
}else if(error.response.status===404){ }else if(error.response.status===404){
dispatch({ dispatch({
type: ActionTypes.GET_RELEASE, type: ActionTypes.GET_RELEASE,
@ -94,7 +94,7 @@ export const setLoading = (stateToLoad) => dispatch => {
export const getLifecycle = () => dispatch => { export const getLifecycle = () => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/lifecycle-config"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/lifecycle-config";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let lifecycle = res.data.data; let lifecycle = res.data.data;
@ -103,7 +103,7 @@ export const getLifecycle = () => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} }
}); });
}; };
@ -118,7 +118,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/v1.0/applications/life-cycle/" + uuid; const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/v1.0/applications/life-cycle/" + uuid;
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 201) {
let release = res.data.data; let release = res.data.data;
@ -132,7 +132,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} else if (error.response.status === 500) { } else if (error.response.status === 500) {
alert("error"); alert("error");
dispatch({ dispatch({
@ -147,7 +147,7 @@ export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
export const getDetailedRating = (uuid) => dispatch => { export const getDetailedRating = (uuid) => dispatch => {
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating";
return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
let detailedRating = res.data.data; let detailedRating = res.data.data;
@ -156,7 +156,7 @@ export const getDetailedRating = (uuid) => dispatch => {
}).catch(function (error) { }).catch(function (error) {
if (error.response.status === 401) { if (error.response.status === 401) {
window.location.href = 'https://localhost:9443/store/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
} else{ } else{
dispatch({ dispatch({
type: ActionTypes.GET_DETAILED_RATING, payload: null type: ActionTypes.GET_DETAILED_RATING, payload: null

@ -58,7 +58,7 @@ class NormalLoginForm extends React.Component {
loading: true loading: true
}); });
let data = "username=" + values.username + "&password=" + values.password + "&platform=store"; let data = "username=" + values.username + "&password=" + values.password + "&platform=store";
axios.post('https://'+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname+':'+config.serverConfig.httpsPort+config.serverConfig.loginUri, data
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
window.location = res.data.url; window.location = res.data.url;

Loading…
Cancel
Save