mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding the server config to be read and used.
This commit is contained in:
parent
b15e532983
commit
f1aa4b69ba
@ -2,5 +2,10 @@
|
|||||||
"theme": {
|
"theme": {
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"value": "lightBaseTheme"
|
"value": "lightBaseTheme"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"hostname": "localhost",
|
||||||
|
"httpsPort": "9443",
|
||||||
|
"apiPort": "8243"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
import Constants from './constants';
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.serverConfig = {};
|
||||||
|
this.hostConstants = {
|
||||||
|
baseURL: window.location.origin,
|
||||||
|
appContext: window.location.pathname.split("/")[1]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
loadConfiguration(callback) {
|
||||||
|
let thisObject = this;
|
||||||
|
axios.get(thisObject.hostConstants.baseURL + '/' + thisObject.hostConstants.appContext + "/config.json").
|
||||||
|
then(function (response) {
|
||||||
|
console.log('server config was read successfully! ');
|
||||||
|
thisObject.serverConfig = response.data.config;
|
||||||
|
Constants.load();
|
||||||
|
callback();
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log('unable to load the config file!' + error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (new Configuration());
|
||||||
@ -15,41 +15,47 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
import Configuration from './configuration';
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
//TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc.
|
class Constants {
|
||||||
export default 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.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 appManagerEndpoints = {
|
this.appManagerEndpoints = {};
|
||||||
GET_ALL_APPS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/',
|
this.platformManagerEndpoints = {};
|
||||||
CREATE_APP: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/',
|
this.userConstants = {};
|
||||||
UPLOAD_IMAGE_ARTIFACTS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/upload-image-artifacts/', //+appId
|
this.defaultLocale = "en";
|
||||||
GET_IMAGE_ARTIFACTS: "https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/image-artifacts/"
|
|
||||||
};
|
|
||||||
|
|
||||||
static platformManagerEndpoints = {
|
|
||||||
CREATE_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0',
|
|
||||||
GET_ENABLED_PLATFORMS: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0?status=ENABLED',
|
|
||||||
GET_PLATFORM: 'https://localhost:8243/api/application-mgt/v1.0/platforms/1.0.0/'
|
|
||||||
};
|
|
||||||
|
|
||||||
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",
|
|
||||||
REFRESH_TOKEN_URL: "",
|
|
||||||
WSO2_USER: 'wso2_user',
|
|
||||||
PARTIAL_TOKEN: 'WSO2_IOT_TOKEN'
|
|
||||||
};
|
|
||||||
|
|
||||||
static hostConstants = {
|
|
||||||
baseURL : window.location.origin,
|
|
||||||
appContext : window.location.pathname.split("/")[1]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultLocale = "en";
|
load() {
|
||||||
|
let apiBaseUrl = 'https://' + Configuration.serverConfig.hostname + ':' + Configuration.serverConfig.apiPort;
|
||||||
|
let httpBaseUrl = 'https://' + Configuration.serverConfig.hostname + ':' + Configuration.serverConfig.httpsPort;
|
||||||
|
|
||||||
|
this.appManagerEndpoints = {
|
||||||
|
GET_ALL_APPS: apiBaseUrl + '/api/application-mgt/v1.0/applications/1.0.0/',
|
||||||
|
CREATE_APP: apiBaseUrl + '/api/application-mgt/v1.0/applications/1.0.0/',
|
||||||
|
UPLOAD_IMAGE_ARTIFACTS: apiBaseUrl + '/api/application-mgt/v1.0/applications/1.0.0/upload-image-artifacts/', //+appId
|
||||||
|
GET_IMAGE_ARTIFACTS: apiBaseUrl + '/api/application-mgt/v1.0/applications/1.0.0/image-artifacts/'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.platformManagerEndpoints = {
|
||||||
|
CREATE_PLATFORM: apiBaseUrl + '/api/application-mgt/v1.0/platforms/1.0.0',
|
||||||
|
GET_ENABLED_PLATFORMS: apiBaseUrl + '/api/application-mgt/v1.0/platforms/1.0.0?status=ENABLED',
|
||||||
|
GET_PLATFORM: apiBaseUrl + '/api/application-mgt/v1.0/platforms/1.0.0/'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.userConstants = {
|
||||||
|
LOGIN_URL: httpBaseUrl + '/auth/application-mgt/v1.0/auth/login',
|
||||||
|
LOGOUT_URL: httpBaseUrl + '/auth/application-mgt/v1.0/auth/logout',
|
||||||
|
REFRESH_TOKEN_URL: "",
|
||||||
|
WSO2_USER: 'wso2_user',
|
||||||
|
PARTIAL_TOKEN: 'WSO2_IOT_TOKEN'
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default(new Constants);
|
||||||
|
|||||||
@ -57,46 +57,6 @@ class ApplicationListing extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = [
|
|
||||||
{
|
|
||||||
data_id: "image",
|
|
||||||
data_type: "image",
|
|
||||||
sortable: false,
|
|
||||||
label: ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data_id: "applicationName",
|
|
||||||
data_type: "string",
|
|
||||||
sortable: true,
|
|
||||||
label: "Application Name",
|
|
||||||
sort: this.sortData
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data_id: "platform",
|
|
||||||
data_type: "image_array",
|
|
||||||
sortable: false,
|
|
||||||
label: "Platform"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data_id: "category",
|
|
||||||
data_type: "string",
|
|
||||||
sortable: false,
|
|
||||||
label: "Category"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data_id: "status",
|
|
||||||
data_type: "string",
|
|
||||||
sortable: false,
|
|
||||||
label: "Status"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data_id: "edit",
|
|
||||||
data_type: "button",
|
|
||||||
sortable: false,
|
|
||||||
label: ""
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
applications = [
|
applications = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,34 +24,40 @@ import registerServiceWorker from './registerServiceWorker';
|
|||||||
import {IntlProvider, addLocaleData, defineMessages} from 'react-intl';
|
import {IntlProvider, addLocaleData, defineMessages} from 'react-intl';
|
||||||
import Axios from 'axios';
|
import Axios from 'axios';
|
||||||
import Constants from './common/constants';
|
import Constants from './common/constants';
|
||||||
|
import Configuration from './common/configuration';
|
||||||
|
|
||||||
const possibleLocale = navigator.language.split("-")[0];
|
function loadStore() {
|
||||||
let loadLocaleFile = Axios.create({
|
const possibleLocale = navigator.language.split("-")[0];
|
||||||
baseURL: Constants.hostConstants.baseURL + "/" + Constants.hostConstants.appContext + "/locales/"
|
let loadLocaleFile = Axios.create({
|
||||||
+ possibleLocale + ".json"
|
baseURL: Configuration.hostConstants.baseURL + "/" + Configuration.hostConstants.appContext + "/locales/"
|
||||||
}).get();
|
+ possibleLocale + ".json"
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the base js file of the app. All the content will be rendered in the root element.
|
|
||||||
* */
|
|
||||||
loadLocaleFile.then(response => {
|
|
||||||
const messages = defineMessages(response.data);
|
|
||||||
addLocaleData(require('react-intl/locale-data/' + possibleLocale));
|
|
||||||
ReactDOM.render(<IntlProvider locale={possibleLocale}
|
|
||||||
messages={messages}><Publisher/></IntlProvider>, document.getElementById('root'));
|
|
||||||
registerServiceWorker();
|
|
||||||
}).catch(error => {
|
|
||||||
addLocaleData(require('react-intl/locale-data/' + Constants.defaultLocale));
|
|
||||||
let defaultLocale = axios.create({
|
|
||||||
baseURL: Constants.hostConstants.baseURL + "/" + Constants.hostConstants.appContext + "/locales"
|
|
||||||
+ Constants.defaultLocale + ".json"
|
|
||||||
}).get();
|
}).get();
|
||||||
defaultLocale.then(response => {
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base js file of the app. All the content will be rendered in the root element.
|
||||||
|
* */
|
||||||
|
loadLocaleFile.then(response => {
|
||||||
const messages = defineMessages(response.data);
|
const messages = defineMessages(response.data);
|
||||||
|
addLocaleData(require('react-intl/locale-data/' + possibleLocale));
|
||||||
ReactDOM.render(<IntlProvider locale={possibleLocale}
|
ReactDOM.render(<IntlProvider locale={possibleLocale}
|
||||||
messages={messages}><Publisher/></IntlProvider>, document.getElementById('root'));
|
messages={messages}><Publisher/></IntlProvider>, document.getElementById('root'));
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
addLocaleData(require('react-intl/locale-data/en'));
|
||||||
|
let defaultLocale = axios.create({
|
||||||
|
baseURL: Configuration.hostConstants.baseURL + "/" + Configuration.hostConstants.appContext + "/locales"
|
||||||
|
+ Constants.defaultLocale + ".json"
|
||||||
|
}).get();
|
||||||
|
defaultLocale.then(response => {
|
||||||
|
const messages = defineMessages(response.data);
|
||||||
|
ReactDOM.render(<IntlProvider locale={possibleLocale}
|
||||||
|
messages={messages}><Publisher/></IntlProvider>, document.getElementById('root'));
|
||||||
|
registerServiceWorker();
|
||||||
|
}).catch(error => {
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
Configuration.loadConfiguration(loadStore);
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import axios from 'axios';
|
|||||||
import Constants from './constants';
|
import Constants from './constants';
|
||||||
|
|
||||||
|
|
||||||
//TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc.
|
|
||||||
class Configuration {
|
class Configuration {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -34,7 +33,9 @@ class Configuration {
|
|||||||
|
|
||||||
loadConfiguration(callback) {
|
loadConfiguration(callback) {
|
||||||
let thisObject = this;
|
let thisObject = this;
|
||||||
axios.get(thisObject.hostConstants.baseURL + '/' + thisObject.hostConstants.appContext + "/config.json").then(function (response) {
|
axios.get(thisObject.hostConstants.baseURL + '/' + thisObject.hostConstants.appContext + "/config.json").
|
||||||
|
then(function (response) {
|
||||||
|
console.log('successfully loaded the configuration!');
|
||||||
thisObject.serverConfig = response.data.config;
|
thisObject.serverConfig = response.data.config;
|
||||||
Constants.load();
|
Constants.load();
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user