Last active
August 29, 2015 14:19
-
-
Save zxqx/18b75e0901db95dfa2d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --------------------------------------------- | |
// CreateCapsule Controller | |
import angular from 'angular'; | |
import uiRouter from 'angular-ui-router'; | |
import CreateCapsule from './CreateCapsule.js'; | |
import htmlCreateCapsule from './create-capsule.html'; | |
// Services | |
import envSettingsService from '../env-settings'; | |
// Directives | |
import header from '../header'; | |
import aside from '../aside'; | |
import asideRight from '../aside-right'; | |
import createCapsuleSteps from '../create-capsule-steps'; | |
import choosePageTemplate from '../choose-page-template'; | |
import addWidgets from '../add-widgets'; | |
export default angular.module('w2o.nextworks.createCapsule', [ | |
uiRouter, | |
envSettingsService.name, | |
header.name, | |
aside.name, | |
asideRight.name, | |
createCapsuleSteps.name, | |
choosePageTemplate.name, | |
addWidgets.name | |
]) | |
.config(($stateProvider) => { | |
$stateProvider.state('create-capsule', { | |
url: '/capsule/create', | |
template: htmlCreateCapsule, | |
controller: CreateCapsule, | |
controllerAs: 'vm', | |
resolve: { | |
envSettings: envSettings => envSettings.get() | |
} | |
}); | |
}); | |
// --------------------------------------------- | |
// EnvSettings Service | |
const ENV_SETTINGS_FILEPATH = './settings.json'; | |
/** | |
* Settings for the loc, stg, and prod environments | |
*/ | |
export default class EnvSettings | |
{ | |
constructor($http) | |
{ | |
this.$http = $http; | |
} | |
/** | |
* Make an HTTP GET request for the environment settings file | |
* and expose the values on the instance | |
* @return {Promise} | |
*/ | |
async get() | |
{ | |
return this.$http.get(ENV_SETTINGS_FILEPATH) | |
.then(res => { | |
this.baseURI = res.data.baseURI; | |
this.authDomain = res.data.authDomain; | |
this.isStaging = res.data.isStaging; | |
return res.data; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment