mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'application-mgt-new' into 'application-mgt-new'
Get configuration with React Context in APPM store See merge request entgra/carbon-device-mgt!184
This commit is contained in:
commit
147fe09a26
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {Divider, Row, Col, Typography, Button, Drawer} from "antd";
|
import {Divider, Row, Col, Typography, Button, Drawer, Icon} from "antd";
|
||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
import Reviews from "./review/Reviews";
|
import Reviews from "./review/Reviews";
|
||||||
import "../../../App.css";
|
import "../../../App.css";
|
||||||
@ -16,6 +16,18 @@ class ReleaseView extends React.Component {
|
|||||||
if (release == null) {
|
if (release == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const platform = app.deviceType;
|
||||||
|
const defaultPlatformIcons = config.defaultPlatformIcons;
|
||||||
|
let icon = defaultPlatformIcons.default.icon;
|
||||||
|
let color = defaultPlatformIcons.default.color;
|
||||||
|
let theme = defaultPlatformIcons.default.theme;
|
||||||
|
if (defaultPlatformIcons.hasOwnProperty(platform)) {
|
||||||
|
icon = defaultPlatformIcons[platform].icon;
|
||||||
|
color = defaultPlatformIcons[platform].color;
|
||||||
|
theme = defaultPlatformIcons[platform].theme;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="release">
|
<div className="release">
|
||||||
@ -25,7 +37,6 @@ class ReleaseView extends React.Component {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col xl={10} sm={11} className="release-title">
|
<Col xl={10} sm={11} className="release-title">
|
||||||
<Title level={2}>{app.name}</Title>
|
<Title level={2}>{app.name}</Title>
|
||||||
<Text>Version : {release.version}</Text><br/>
|
|
||||||
<StarRatings
|
<StarRatings
|
||||||
rating={release.rating}
|
rating={release.rating}
|
||||||
starRatedColor="#777"
|
starRatedColor="#777"
|
||||||
@ -34,6 +45,17 @@ class ReleaseView extends React.Component {
|
|||||||
numberOfStars={5}
|
numberOfStars={5}
|
||||||
name='rating'
|
name='rating'
|
||||||
/>
|
/>
|
||||||
|
<br/>
|
||||||
|
<Text>Platform : </Text>
|
||||||
|
<span style={{fontSize: 20, color: color, textAlign: "center"}}>
|
||||||
|
<Icon
|
||||||
|
type={icon}
|
||||||
|
theme={theme}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<Divider type="vertical"/>
|
||||||
|
<Text>Version : {release.version}</Text><br/>
|
||||||
|
|
||||||
<EditRelease uuid={release.uuid} type={app.type}/>
|
<EditRelease uuid={release.uuid} type={app.type}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
|
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
|
||||||
|
|||||||
@ -6,9 +6,6 @@
|
|||||||
"primaryColor": "rgb(24, 144, 255)"
|
"primaryColor": "rgb(24, 144, 255)"
|
||||||
},
|
},
|
||||||
"serverConfig": {
|
"serverConfig": {
|
||||||
"protocol": "https",
|
|
||||||
"hostname": "localhost",
|
|
||||||
"httpsPort": "9443",
|
|
||||||
"invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0",
|
"invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0",
|
||||||
"invoker": {
|
"invoker": {
|
||||||
"uri": "/store-ui-request-handler/invoke",
|
"uri": "/store-ui-request-handler/invoke",
|
||||||
|
|||||||
@ -3,30 +3,89 @@ import "antd/dist/antd.less";
|
|||||||
import RouteWithSubRoutes from "./components/RouteWithSubRoutes";
|
import RouteWithSubRoutes from "./components/RouteWithSubRoutes";
|
||||||
import {
|
import {
|
||||||
BrowserRouter as Router,
|
BrowserRouter as Router,
|
||||||
Link, Redirect, Switch,
|
Redirect, Switch,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
import axios from "axios";
|
||||||
|
import {Layout, Spin, Result} from "antd";
|
||||||
|
import ConfigContext from "./context/ConfigContext";
|
||||||
|
|
||||||
|
const {Content} = Layout;
|
||||||
|
const loadingView = (
|
||||||
|
<Layout>
|
||||||
|
<Content style={{
|
||||||
|
padding: '0 0',
|
||||||
|
paddingTop: 300,
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
textAlign: 'center'
|
||||||
|
}}>
|
||||||
|
<Spin tip="Loading..."/>
|
||||||
|
</Content>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
|
||||||
|
const errorView = (
|
||||||
|
<Result
|
||||||
|
style={{
|
||||||
|
paddingTop: 200
|
||||||
|
}}
|
||||||
|
status="500"
|
||||||
|
title="Error occurred while loading the configuration"
|
||||||
|
subTitle="Please refresh your browser window"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
routes;
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.routes = props.routes;
|
this.state = {
|
||||||
|
loading: true,
|
||||||
|
error: false,
|
||||||
|
config: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
axios.get(
|
||||||
|
window.location.origin + "/store/public/conf/config.json",
|
||||||
|
).then(res => {
|
||||||
|
console.log(res);
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
config: res.data
|
||||||
|
})
|
||||||
|
}).catch((error) => {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: true
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
const {loading, error} = this.state;
|
||||||
|
|
||||||
|
const applicationView = (
|
||||||
<Router>
|
<Router>
|
||||||
|
<ConfigContext.Provider value={this.state.config}>
|
||||||
<div>
|
<div>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect exact from="/store" to="/store/android"/>
|
<Redirect exact from="/store" to="/store/android"/>
|
||||||
{this.routes.map((route) => (
|
{this.props.routes.map((route) => (
|
||||||
<RouteWithSubRoutes key={route.path} {...route} />
|
<RouteWithSubRoutes key={route.path} {...route} />
|
||||||
))}
|
))}
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
</ConfigContext.Provider>
|
||||||
</Router>
|
</Router>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{loading && loadingView}
|
||||||
|
{!loading && !error && applicationView}
|
||||||
|
{error && errorView}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import AppCard from "./AppCard";
|
import AppCard from "./AppCard";
|
||||||
import {Col, message, notification, Row, Result, Skeleton} from "antd";
|
import {Col, message, notification, Row, Result, Skeleton} from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../public/conf/config.json";
|
import {withConfigContext} from "../../context/ConfigContext";
|
||||||
|
|
||||||
class AppList extends React.Component {
|
class AppList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -29,7 +29,7 @@ class AppList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchData = (deviceType) => {
|
fetchData = (deviceType) => {
|
||||||
|
const config = this.props.context;
|
||||||
const payload = {};
|
const payload = {};
|
||||||
if (deviceType === "web-clip") {
|
if (deviceType === "web-clip") {
|
||||||
payload.appType = "WEB_CLIP";
|
payload.appType = "WEB_CLIP";
|
||||||
@ -41,7 +41,7 @@ class AppList extends React.Component {
|
|||||||
});
|
});
|
||||||
//send request to the invoker
|
//send request to the invoker
|
||||||
axios.post(
|
axios.post(
|
||||||
config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/",
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/applications/",
|
||||||
payload,
|
payload,
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -58,7 +58,7 @@ class AppList extends React.Component {
|
|||||||
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
||||||
//todo display a popup with error
|
//todo display a popup with error
|
||||||
message.error('You are not logged in');
|
message.error('You are not logged in');
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -99,4 +99,4 @@ class AppList extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AppList;
|
export default withConfigContext(AppList);
|
||||||
@ -2,8 +2,8 @@ import React from "react";
|
|||||||
import {Row, Typography, Icon} from "antd";
|
import {Row, Typography, Icon} from "antd";
|
||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
import "./DetailedRating.css";
|
import "./DetailedRating.css";
|
||||||
import config from "../../../../public/conf/config.json";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import {withConfigContext} from "../../../context/ConfigContext";
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
@ -30,9 +30,10 @@ class DetailedRating extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
getData = (type, uuid)=>{
|
getData = (type, uuid)=>{
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
return axios.get(
|
return axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating",
|
window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating",
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
let detailedRating = res.data.data;
|
let detailedRating = res.data.data;
|
||||||
@ -43,7 +44,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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/publisher/login';
|
window.location.href = window.location.origin+'/publisher/login';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -117,4 +118,4 @@ class DetailedRating extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default DetailedRating;
|
export default withConfigContext(DetailedRating);
|
||||||
@ -5,11 +5,10 @@ import ImgViewer from "../../apps/release/images/ImgViewer";
|
|||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
import DetailedRating from "./DetailedRating";
|
import DetailedRating from "./DetailedRating";
|
||||||
import Reviews from "./review/Reviews";
|
import Reviews from "./review/Reviews";
|
||||||
import AddReview from "./review/AddReview";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../public/conf/config.json";
|
|
||||||
import AppInstallModal from "./install/AppInstallModal";
|
import AppInstallModal from "./install/AppInstallModal";
|
||||||
import CurrentUsersReview from "./review/CurrentUsersReview";
|
import CurrentUsersReview from "./review/CurrentUsersReview";
|
||||||
|
import {withConfigContext} from "../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Title, Text, Paragraph} = Typography;
|
const {Title, Text, Paragraph} = Typography;
|
||||||
|
|
||||||
@ -23,13 +22,14 @@ class ReleaseView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
installApp = (type, payload) => {
|
installApp = (type, payload) => {
|
||||||
|
const config = this.props.context;
|
||||||
const release = this.props.app.applicationReleases[0];
|
const release = this.props.app.applicationReleases[0];
|
||||||
const {uuid} = release;
|
const {uuid} = release;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true,
|
loading: true,
|
||||||
});
|
});
|
||||||
const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/install";
|
const url = window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/install";
|
||||||
axios.post(
|
axios.post(
|
||||||
url,
|
url,
|
||||||
payload,
|
payload,
|
||||||
@ -61,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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -150,4 +150,4 @@ class ReleaseView extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReleaseView;
|
export default withConfigContext(ReleaseView);
|
||||||
@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
|
||||||
import {Button, message, notification, Table, Typography} from "antd";
|
import {Button, message, notification, Table, Typography} from "antd";
|
||||||
import TimeAgo from 'javascript-time-ago'
|
import TimeAgo from 'javascript-time-ago'
|
||||||
|
|
||||||
// Load locale-specific relative date/time formatting rules.
|
// Load locale-specific relative date/time formatting rules.
|
||||||
import en from 'javascript-time-ago/locale/en'
|
import en from 'javascript-time-ago/locale/en'
|
||||||
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
@ -112,6 +112,7 @@ class DeviceInstall extends React.Component {
|
|||||||
|
|
||||||
//fetch data from api
|
//fetch data from api
|
||||||
fetch = (params = {}) => {
|
fetch = (params = {}) => {
|
||||||
|
const config = this.props.context;
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
const {deviceType} = this.props;
|
const {deviceType} = this.props;
|
||||||
// get current page
|
// get current page
|
||||||
@ -130,7 +131,7 @@ class DeviceInstall extends React.Component {
|
|||||||
|
|
||||||
//send request to the invoker
|
//send request to the invoker
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort
|
window.location.origin+
|
||||||
+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams,
|
+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams,
|
||||||
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
@ -148,8 +149,7 @@ class DeviceInstall extends React.Component {
|
|||||||
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
||||||
//todo display a popop with error
|
//todo display a popop with error
|
||||||
message.error('You are not logged in');
|
message.error('You are not logged in');
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':'
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
+ config.serverConfig.httpsPort + '/store/login';
|
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -225,4 +225,4 @@ class DeviceInstall extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeviceInstall;
|
export default withConfigContext(DeviceInstall);
|
||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
@ -25,10 +25,11 @@ class GroupInstall extends React.Component {
|
|||||||
fetchUser = value => {
|
fetchUser = value => {
|
||||||
this.lastFetchId += 1;
|
this.lastFetchId += 1;
|
||||||
const fetchId = this.lastFetchId;
|
const fetchId = this.lastFetchId;
|
||||||
|
const config = this.props.context;
|
||||||
this.setState({data: [], fetching: true});
|
this.setState({data: [], fetching: true});
|
||||||
|
|
||||||
axios.post(
|
axios.post(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value,
|
||||||
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -48,7 +49,7 @@ class GroupInstall extends React.Component {
|
|||||||
}).catch((error) => { console.log(error);
|
}).catch((error) => { console.log(error);
|
||||||
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
||||||
message.error('You are not logged in');
|
message.error('You are not logged in');
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
window.location.href = window.location.origin+'/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -111,4 +112,4 @@ class GroupInstall extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GroupInstall;
|
export default withConfigContext(GroupInstall);
|
||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
@ -23,12 +23,13 @@ class RoleInstall extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchUser = value => {
|
fetchUser = value => {
|
||||||
|
const config = this.props.context;
|
||||||
this.lastFetchId += 1;
|
this.lastFetchId += 1;
|
||||||
const fetchId = this.lastFetchId;
|
const fetchId = this.lastFetchId;
|
||||||
this.setState({data: [], fetching: true});
|
this.setState({data: [], fetching: true});
|
||||||
|
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value,
|
||||||
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -48,7 +49,7 @@ class RoleInstall extends React.Component {
|
|||||||
}).catch((error) => { console.log(error);
|
}).catch((error) => { console.log(error);
|
||||||
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
||||||
message.error('You are not logged in');
|
message.error('You are not logged in');
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
window.location.href = window.location.origin+'/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -111,4 +112,4 @@ class RoleInstall extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RoleInstall;
|
export default withConfigContext(RoleInstall);
|
||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
import {Typography, Select, Spin, message, notification, Button} from "antd";
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
@ -23,6 +23,7 @@ class UserInstall extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchUser = value => {
|
fetchUser = value => {
|
||||||
|
const config = this.props.context;
|
||||||
this.lastFetchId += 1;
|
this.lastFetchId += 1;
|
||||||
const fetchId = this.lastFetchId;
|
const fetchId = this.lastFetchId;
|
||||||
this.setState({data: [], fetching: true});
|
this.setState({data: [], fetching: true});
|
||||||
@ -30,7 +31,7 @@ class UserInstall extends React.Component {
|
|||||||
|
|
||||||
//send request to the invoker
|
//send request to the invoker
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/users/search?username=" + value,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/users/search?username=" + value,
|
||||||
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -50,7 +51,7 @@ class UserInstall 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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -111,4 +112,4 @@ class UserInstall extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserInstall;
|
export default withConfigContext(UserInstall);
|
||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd';
|
import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd';
|
||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Title} = Typography;
|
const {Title} = Typography;
|
||||||
const {TextArea} = Input;
|
const {TextArea} = Input;
|
||||||
@ -41,6 +41,7 @@ class AddReview extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = () => {
|
onSubmit = () => {
|
||||||
|
const config = this.props.context;
|
||||||
const {content, rating} = this.state;
|
const {content, rating} = this.state;
|
||||||
const {uuid} = this.props;
|
const {uuid} = this.props;
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -53,7 +54,7 @@ class AddReview extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios.post(
|
axios.post(
|
||||||
config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid,
|
||||||
payload,
|
payload,
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
@ -85,7 +86,7 @@ class AddReview extends React.Component {
|
|||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -159,4 +160,4 @@ class AddReview extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddReview;
|
export default withConfigContext(AddReview);
|
||||||
@ -2,8 +2,8 @@ import React from "react";
|
|||||||
import {List, message, Typography, Empty, Button, Row, Col, notification} from "antd";
|
import {List, message, Typography, Empty, Button, Row, Col, notification} from "antd";
|
||||||
import SingleReview from "./singleReview/SingleReview";
|
import SingleReview from "./singleReview/SingleReview";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
|
||||||
import AddReview from "./AddReview";
|
import AddReview from "./AddReview";
|
||||||
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Text, Paragraph} = Typography;
|
const {Text, Paragraph} = Typography;
|
||||||
|
|
||||||
@ -23,9 +23,10 @@ class CurrentUsersReview extends React.Component {
|
|||||||
|
|
||||||
fetchData = () => {
|
fetchData = () => {
|
||||||
const {uuid} = this.props;
|
const {uuid} = this.props;
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid,
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = res.data.data.data;
|
const data = res.data.data.data;
|
||||||
@ -35,7 +36,7 @@ class CurrentUsersReview 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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -106,4 +107,4 @@ class CurrentUsersReview extends React.Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CurrentUsersReview;
|
export default withConfigContext(CurrentUsersReview);
|
||||||
@ -5,7 +5,7 @@ import "./Reviews.css";
|
|||||||
import InfiniteScroll from 'react-infinite-scroller';
|
import InfiniteScroll from 'react-infinite-scroller';
|
||||||
import SingleReview from "./singleReview/SingleReview";
|
import SingleReview from "./singleReview/SingleReview";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const limit = 5;
|
const limit = 5;
|
||||||
|
|
||||||
@ -29,9 +29,10 @@ class Reviews extends React.Component {
|
|||||||
fetchData = (offset, limit, callback) => {
|
fetchData = (offset, limit, callback) => {
|
||||||
|
|
||||||
const {uuid, type} = this.props;
|
const {uuid, type} = this.props;
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid,
|
window.location.origin+ config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid,
|
||||||
{
|
{
|
||||||
headers: {'X-Platform': config.serverConfig.platform}
|
headers: {'X-Platform': config.serverConfig.platform}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -42,7 +43,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 = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -133,4 +134,4 @@ class Reviews extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Reviews;
|
export default withConfigContext(Reviews);
|
||||||
@ -6,7 +6,7 @@ import Twemoji from "react-twemoji";
|
|||||||
import "./SingleReview.css";
|
import "./SingleReview.css";
|
||||||
import EditReview from "./editReview/EditReview";
|
import EditReview from "./editReview/EditReview";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Text, Paragraph} = Typography;
|
const {Text, Paragraph} = Typography;
|
||||||
const colorList = ['#f0932b', '#badc58', '#6ab04c', '#eb4d4b', '#0abde3', '#9b59b6', '#3498db', '#22a6b3', '#e84393', '#f9ca24'];
|
const colorList = ['#f0932b', '#badc58', '#6ab04c', '#eb4d4b', '#0abde3', '#9b59b6', '#3498db', '#22a6b3', '#e84393', '#f9ca24'];
|
||||||
@ -38,9 +38,9 @@ class SingleReview extends React.Component {
|
|||||||
deleteReview = () => {
|
deleteReview = () => {
|
||||||
const {uuid} = this.props;
|
const {uuid} = this.props;
|
||||||
const {id} = this.state.review;
|
const {id} = this.state.review;
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
let url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' +
|
let url =window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store;
|
||||||
config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store;
|
|
||||||
|
|
||||||
// call as an admin api if the review is not a personal review
|
// call as an admin api if the review is not a personal review
|
||||||
if (!this.props.isPersonalReview) {
|
if (!this.props.isPersonalReview) {
|
||||||
@ -62,7 +62,7 @@ class SingleReview extends React.Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -131,4 +131,4 @@ class SingleReview extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SingleReview;
|
export default withConfigContext(SingleReview);
|
||||||
@ -2,8 +2,8 @@ import React from "react";
|
|||||||
import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd';
|
import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd';
|
||||||
import StarRatings from "react-star-ratings";
|
import StarRatings from "react-star-ratings";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../../../public/conf/config.json";
|
|
||||||
import "./EditReview.css";
|
import "./EditReview.css";
|
||||||
|
import {withConfigContext} from "../../../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Title} = Typography;
|
const {Title} = Typography;
|
||||||
const {TextArea} = Input;
|
const {TextArea} = Input;
|
||||||
@ -54,6 +54,7 @@ class EditReview extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = () => {
|
onSubmit = () => {
|
||||||
|
const config = this.props.context;
|
||||||
const {content, rating} = this.state;
|
const {content, rating} = this.state;
|
||||||
const {id} = this.props.review;
|
const {id} = this.props.review;
|
||||||
const {uuid} = this.props;
|
const {uuid} = this.props;
|
||||||
@ -67,7 +68,7 @@ class EditReview extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios.put(
|
axios.put(
|
||||||
config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id,
|
||||||
payload,
|
payload,
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -98,7 +99,7 @@ class EditReview extends React.Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -169,4 +170,4 @@ class EditReview extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditReview;
|
export default withConfigContext(EditReview);
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const ConfigContext = React.createContext();
|
||||||
|
|
||||||
|
export const withConfigContext = Component => {
|
||||||
|
return props => (
|
||||||
|
<ConfigContext.Consumer>
|
||||||
|
{context => {
|
||||||
|
return <Component {...props} context={context}/>;
|
||||||
|
}}
|
||||||
|
</ConfigContext.Consumer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConfigContext;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ ReactDOM.render(
|
|||||||
<App routes={routes}/>,
|
<App routes={routes}/>,
|
||||||
document.getElementById('root'));
|
document.getElementById('root'));
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
// If you want your app e and load faster, you can change
|
||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
// Learn more about service workers: https://bit.ly/CRA-PWA
|
// Learn more about service workers: https://bit.ly/CRA-PWA
|
||||||
serviceWorker.unregister();
|
serviceWorker.unregister();
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
import * as dagre from "dagre";
|
|
||||||
import * as _ from "lodash";
|
|
||||||
|
|
||||||
const size = {
|
|
||||||
width: 60,
|
|
||||||
height: 60
|
|
||||||
};
|
|
||||||
|
|
||||||
export function distributeElements(model) {
|
|
||||||
let clonedModel = _.cloneDeep(model);
|
|
||||||
let nodes = distributeGraph(clonedModel);
|
|
||||||
nodes.forEach(node => {
|
|
||||||
let modelNode = clonedModel.nodes.find(item => item.id === node.id);
|
|
||||||
modelNode.x = node.x - node.width / 2;
|
|
||||||
modelNode.y = node.y - node.height / 2;
|
|
||||||
});
|
|
||||||
return clonedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
function distributeGraph(model) {
|
|
||||||
let nodes = mapElements(model);
|
|
||||||
let edges = mapEdges(model);
|
|
||||||
let graph = new dagre.graphlib.Graph();
|
|
||||||
graph.setGraph({});
|
|
||||||
graph.setDefaultEdgeLabel(() => ({}));
|
|
||||||
//add elements to dagre graph
|
|
||||||
nodes.forEach(node => {
|
|
||||||
graph.setNode(node.id, node.metadata);
|
|
||||||
});
|
|
||||||
edges.forEach(edge => {
|
|
||||||
if (edge.from && edge.to) {
|
|
||||||
graph.setEdge(edge.from, edge.to);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//auto-distribute
|
|
||||||
dagre.layout(graph);
|
|
||||||
return graph.nodes().map(node => graph.node(node));
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapElements(model) {
|
|
||||||
// dagre compatible format
|
|
||||||
return model.nodes.map(node => ({ id: node.id, metadata: { ...size, id: node.id } }));
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapEdges(model) {
|
|
||||||
// returns links which connects nodes
|
|
||||||
// we check are there both from and to nodes in the model. Sometimes links can be detached
|
|
||||||
return model.links
|
|
||||||
.map(link => ({
|
|
||||||
from: link.source,
|
|
||||||
to: link.target
|
|
||||||
}))
|
|
||||||
.filter(
|
|
||||||
item => model.nodes.find(node => node.id === item.from) && model.nodes.find(node => node.id === item.to)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -2,13 +2,14 @@ import React from "react";
|
|||||||
import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd';
|
import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox} from 'antd';
|
||||||
import './Login.css';
|
import './Login.css';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import config from "../../public/conf/config.json";
|
import {withConfigContext} from "../context/ConfigContext";
|
||||||
|
|
||||||
const {Title} = Typography;
|
const {Title} = Typography;
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
|
|
||||||
class Login extends React.Component {
|
class Login extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
const config = this.props.context;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="background">
|
<div className="background">
|
||||||
@ -59,6 +60,9 @@ class NormalLoginForm extends React.Component {
|
|||||||
|
|
||||||
handleSubmit = (e) => {
|
handleSubmit = (e) => {
|
||||||
const thisForm = this;
|
const thisForm = this;
|
||||||
|
const config = this.props.context;
|
||||||
|
console.log(config);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.form.validateFields((err, values) => {
|
this.props.form.validateFields((err, values) => {
|
||||||
thisForm.setState({
|
thisForm.setState({
|
||||||
@ -76,10 +80,10 @@ class NormalLoginForm 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('&');
|
||||||
|
|
||||||
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.loginUri, request
|
axios.post(window.location.origin+ config.serverConfig.loginUri, request
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
window.location = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + "/store";
|
window.location = window.location.origin+ "/store";
|
||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
if (error.response.status === 400) {
|
if (error.response.status === 400) {
|
||||||
@ -144,6 +148,6 @@ class NormalLoginForm extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const WrappedNormalLoginForm = Form.create({name: 'normal_login'})(NormalLoginForm);
|
const WrappedNormalLoginForm = withConfigContext(Form.create({name: 'normal_login'})(NormalLoginForm));
|
||||||
|
|
||||||
export default Login;
|
export default withConfigContext(Login);
|
||||||
|
|||||||
@ -5,16 +5,16 @@ import {Link} from "react-router-dom";
|
|||||||
import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"
|
import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"
|
||||||
import {Switch} from 'react-router'
|
import {Switch} from 'react-router'
|
||||||
import "../../App.css";
|
import "../../App.css";
|
||||||
import config from "../../../public/conf/config.json";
|
import {withConfigContext} from "../../context/ConfigContext";
|
||||||
|
|
||||||
class Dashboard extends React.Component {
|
class Dashboard extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
routes: props.routes,
|
routes: props.routes,
|
||||||
selectedKeys : []
|
selectedKeys: []
|
||||||
};
|
};
|
||||||
this.Logo = config.theme.logo;
|
this.logo = this.props.context.theme.logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeSelectedMenuItem = (key) =>{
|
changeSelectedMenuItem = (key) =>{
|
||||||
@ -30,7 +30,7 @@ class Dashboard extends React.Component {
|
|||||||
<Layout className="layout">
|
<Layout className="layout">
|
||||||
<Header style={{paddingLeft: 0, paddingRight: 0}}>
|
<Header style={{paddingLeft: 0, paddingRight: 0}}>
|
||||||
<div className="logo-image">
|
<div className="logo-image">
|
||||||
<img alt="logo" src={this.Logo}/>
|
<img alt="logo" src={this.logo}/>
|
||||||
</div>
|
</div>
|
||||||
<Menu
|
<Menu
|
||||||
theme="light"
|
theme="light"
|
||||||
@ -63,4 +63,4 @@ class Dashboard extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Dashboard;
|
export default withConfigContext(Dashboard);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import '../../../../App.css';
|
|||||||
import {Skeleton, Typography, Row, Col, Card, message, notification} from "antd";
|
import {Skeleton, Typography, Row, Col, Card, message, notification} from "antd";
|
||||||
import ReleaseView from "../../../../components/apps/release/ReleaseView";
|
import ReleaseView from "../../../../components/apps/release/ReleaseView";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../../../../../public/conf/config.json";
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
const {Title} = Typography;
|
const {Title} = Typography;
|
||||||
|
|
||||||
@ -36,9 +36,11 @@ class Release extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchData = (uuid)=>{
|
fetchData = (uuid)=>{
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
//send request to the invoker
|
//send request to the invoker
|
||||||
axios.get(
|
axios.get(
|
||||||
config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/"+uuid,
|
window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/"+uuid,
|
||||||
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@ -55,7 +57,7 @@ class Release extends React.Component {
|
|||||||
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
if (error.hasOwnProperty("response") && error.response.status === 401) {
|
||||||
//todo display a popop with error
|
//todo display a popop with error
|
||||||
message.error('You are not logged in');
|
message.error('You are not logged in');
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
window.location.href = window.location.origin+ '/store/login';
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: "There was a problem",
|
message: "There was a problem",
|
||||||
@ -101,4 +103,4 @@ class Release extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default Release;
|
export default withConfigContext(Release);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user