diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/config.json
index 3be10b8ce9b..f9274b76b62 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/config.json
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/config.json
@@ -2,5 +2,10 @@
"theme": {
"type": "default",
"value": "lightBaseTheme"
+ },
+ "config": {
+ "hostname": "localhost",
+ "httpsPort": "9443",
+ "apiPort": "8243"
}
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/configuration.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/configuration.js
new file mode 100644
index 00000000000..84304d86b49
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/configuration.js
@@ -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());
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js
index c0f22aaecaa..27091a166c2 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/common/constants.js
@@ -15,41 +15,47 @@
* specific language governing permissions and limitations
* under the License.
*/
+import Configuration from './configuration';
'use strict';
-//TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc.
-export default class Constants {
-
- static 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 = {
- GET_ALL_APPS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/',
- CREATE_APP: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/',
- UPLOAD_IMAGE_ARTIFACTS: 'https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/upload-image-artifacts/', //+appId
- GET_IMAGE_ARTIFACTS: "https://localhost:8243/api/application-mgt/v1.0/applications/1.0.0/image-artifacts/"
- };
-
- static 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]
+class Constants {
+
+ constructor() {
+ 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';
+ this.appManagerEndpoints = {};
+ this.platformManagerEndpoints = {};
+ this.userConstants = {};
+ this.defaultLocale = "en";
}
- 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);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.jsx b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.jsx
index 0ebad7600b7..491601580c0 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.jsx
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/components/Application/ApplicationListing.jsx
@@ -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 = [
{
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js
index 6a137f3876f..11c58667f69 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js
@@ -24,34 +24,40 @@ import registerServiceWorker from './registerServiceWorker';
import {IntlProvider, addLocaleData, defineMessages} from 'react-intl';
import Axios from 'axios';
import Constants from './common/constants';
+import Configuration from './common/configuration';
-const possibleLocale = navigator.language.split("-")[0];
-let loadLocaleFile = Axios.create({
- baseURL: Constants.hostConstants.baseURL + "/" + Constants.hostConstants.appContext + "/locales/"
- + possibleLocale + ".json"
-}).get();
+function loadStore() {
+ const possibleLocale = navigator.language.split("-")[0];
+ let loadLocaleFile = Axios.create({
+ baseURL: Configuration.hostConstants.baseURL + "/" + Configuration.hostConstants.appContext + "/locales/"
+ + possibleLocale + ".json"
+ }).get();
-/**
- * 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(, 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();
- 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);
+ addLocaleData(require('react-intl/locale-data/' + possibleLocale));
ReactDOM.render(, document.getElementById('root'));
registerServiceWorker();
}).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(, document.getElementById('root'));
+ registerServiceWorker();
+ }).catch(error => {
+ });
});
-});
+}
+
+Configuration.loadConfiguration(loadStore);
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/common/configuration.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/common/configuration.js
index 0d6367a3ad5..0c999fd0611 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/common/configuration.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/store/src/common/configuration.js
@@ -21,7 +21,6 @@ import axios from 'axios';
import Constants from './constants';
-//TODO: Replace the server address with response from auth endpoint and remove hardcoded ids etc.
class Configuration {
constructor() {
@@ -34,7 +33,9 @@ class Configuration {
loadConfiguration(callback) {
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;
Constants.load();
callback();