Managing environment using babel
diff --git a/mCordPortal/README.md b/mCordPortal/README.md
index f414994..2444a23 100644
--- a/mCordPortal/README.md
+++ b/mCordPortal/README.md
@@ -5,28 +5,10 @@
This demo is developed with AngularJs, but your subscriber portal could be developed using whichever framework
in whichever language as it should only integrate XOS api with your services (eg: Authentication, CRM, Bug Tracker...)
-
-## Concept Demonstrated
-
-This is intended to be a portal for a Subscriber user to manage a Parent Control Application provided by XOS.
-To Subscriber will be able to choose between two bundles:
- - Basic Bundle
- - Family Bundle
-
-The subscriber should enable the _Family Bundle_ trough the _Bundles_ page.
-Once enable he will be able to define different levels of Parental Control for each device in his house.
-
-### Data Sources
-
-_Bundles_ are intended as a group of services offered by a company, so they should be managed by the company services and business logic.
-They are not intended to be part of XOS, so for demonstrative purposes have been hardcoded into the application.
-Consider that this kind of information can be provided by a remote service.
-
-_Subscribers_, _Users_ and _Parental Control_ are information managed by XOS and currently provided by its API.
## Getting started
-_All commands in this section refers to `applications/subscriberPortal`_
+_All commands in this section refers to `xos-external-app-examples/mCordPortal`_
_Note that NodeJs and Bower are required to run this demo_
@@ -37,6 +19,10 @@
This should open the demo in the browser.
+>A different environment can be specified in the env folder. To do that create a new file `myEnv.js` with the same content of `default.js` and start the project using `NODE_ENV=myEnv npm start`
+
+>If you prefer to contact the Apiary Mock Backend start the application with `MOCK=true npm start`
+
### Bugs
Please report any bug or question trough github issues.
diff --git a/mCordPortal/package.json b/mCordPortal/package.json
index ac47728..a7af37a 100644
--- a/mCordPortal/package.json
+++ b/mCordPortal/package.json
@@ -4,7 +4,7 @@
"description": "Demo implementation for a subscriber portal in XOS",
"main": "index.js",
"scripts": {
- "scripts": "babel --presets es2015 ./src/app --watch --out-dir ./src/dist -s",
+ "scripts": "babel --presets es2015 --plugins transform-inline-environment-variables ./src/app --watch --out-dir ./src/dist -s",
"preserver": "bower install && wiredep --dependencies --src src/index.html",
"styles": "node-sass -w -r --include-path --source-map-embed -o ./src/style ./src/sass/main.scss",
"server": "browser-sync start --config bs-config.js",
@@ -15,13 +15,14 @@
"author": "Matteo Scandolo",
"license": "ISC",
"devDependencies": {
+ "babel-cli": "^6.4.5",
+ "babel-plugin-transform-inline-environment-variables": "^6.8.0",
+ "babel-preset-es2015": "^6.5.0",
"browser-sync": "^2.11.1",
"http-proxy": "^1.12.1",
"node-sass": "^3.4.2",
"parallelshell": "^2.0.0",
- "wiredep": "^3.0.0",
- "babel-cli": "^6.4.5",
- "babel-preset-es2015": "^6.5.0"
+ "wiredep": "^3.0.0"
},
"dependencies": {}
}
diff --git a/mCordPortal/src/app/services/config.js b/mCordPortal/src/app/services/config.js
new file mode 100644
index 0000000..9bba19f
--- /dev/null
+++ b/mCordPortal/src/app/services/config.js
@@ -0,0 +1,10 @@
+(function () {
+ angular.module('mCord')
+ .value('baseUrl', (function(){
+ if (process.env.MOCK === 'true') {
+ return 'http://private-c85424-progranrestapi.apiary-mock.com/';
+ } else {
+ return '';
+ }
+ })())
+})();
\ No newline at end of file
diff --git a/mCordPortal/src/app/services/rest/enodeb.js b/mCordPortal/src/app/services/rest/enodeb.js
index bf6415c..42cd062 100644
--- a/mCordPortal/src/app/services/rest/enodeb.js
+++ b/mCordPortal/src/app/services/rest/enodeb.js
@@ -1,6 +1,6 @@
(function () {
angular.module('mCord')
- .service('Enodeb', function($resource){
- return $resource('http://private-c85424-progranrestapi.apiary-mock.com/api/enodeb/:id', {id: '@id'});
+ .service('Enodeb', function($resource, baseUrl){
+ return $resource(`${baseUrl}api/enodeb/:id`, {id: '@id'});
})
})();
\ No newline at end of file
diff --git a/mCordPortal/src/index.html b/mCordPortal/src/index.html
index e6af32c..621bfc9 100644
--- a/mCordPortal/src/index.html
+++ b/mCordPortal/src/index.html
@@ -41,6 +41,7 @@
<link rel="stylesheet" href="style/main.css">
<script src="cord.js"></script>
+ <script src="dist/services/config.js"></script>
<script src="dist/services/users.js"></script>
<script src="dist/services/helpers.js"></script>
<script src="dist/services/rest/enodeb.js"></script>