Commit 447cd126 authored by Randall Leeds's avatar Randall Leeds

Front-end feature flags

parent 08a1ba1e
...@@ -78,6 +78,11 @@ setupStreamer = [ ...@@ -78,6 +78,11 @@ setupStreamer = [
$http.defaults.headers.common['X-Client-Id'] = clientId $http.defaults.headers.common['X-Client-Id'] = clientId
] ]
angular.module('h.config', [])
.provider('identity', require('./identity'))
.provider('session', require('./session'))
module.exports = angular.module('h', [ module.exports = angular.module('h', [
'angulartics' 'angulartics'
'angulartics.google.analytics' 'angulartics.google.analytics'
...@@ -88,6 +93,7 @@ module.exports = angular.module('h', [ ...@@ -88,6 +93,7 @@ module.exports = angular.module('h', [
'ngSanitize' 'ngSanitize'
'ngTagsInput' 'ngTagsInput'
'toastr' 'toastr'
'h.config'
]) ])
.controller('AppController', require('./app-controller')) .controller('AppController', require('./app-controller'))
...@@ -118,9 +124,6 @@ module.exports = angular.module('h', [ ...@@ -118,9 +124,6 @@ module.exports = angular.module('h', [
.filter('persona', require('./filter/persona')) .filter('persona', require('./filter/persona'))
.filter('urlencode', require('./filter/urlencode')) .filter('urlencode', require('./filter/urlencode'))
.provider('identity', require('./identity'))
.provider('session', require('./session'))
.service('annotator', -> new Annotator(angular.element('<div>'))) .service('annotator', -> new Annotator(angular.element('<div>')))
.service('annotationMapper', require('./annotation-mapper')) .service('annotationMapper', require('./annotation-mapper'))
.service('annotationUI', require('./annotation-ui')) .service('annotationUI', require('./annotation-ui'))
......
...@@ -11,15 +11,18 @@ SESSION_ACTIONS = [ ...@@ -11,15 +11,18 @@ SESSION_ACTIONS = [
] ]
configure = [ module.exports = [
'$httpProvider', 'identityProvider', 'sessionProvider' '$httpProvider', '$provide', 'identityProvider', 'sessionProvider'
($httpProvider, identityProvider, sessionProvider) -> ($httpProvider, $provide, identityProvider, sessionProvider) ->
# Pending authentication check # Pending authentication check
authCheck = null authCheck = null
# Use the Pyramid XSRF header name # Use the Pyramid XSRF header name
$httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token' $httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token'
# Provide an XSRF token for the session provider
$provide.constant('xsrf', token: null)
identityProvider.checkAuthentication = [ identityProvider.checkAuthentication = [
'$q', 'session', '$q', 'session',
($q, session) -> ($q, session) ->
...@@ -70,8 +73,3 @@ configure = [ ...@@ -70,8 +73,3 @@ configure = [
__formid__: action __formid__: action
withCredentials: true withCredentials: true
] ]
angular.module('h')
.value('xsrf', token: null)
.config(configure)
FEATURES = {
accounts: """{{ feature('accounts') | json }}""",
notification: """{{ feature('notification') | json }}""",
streamer: """{{ feature('streamer') | json }}"""
}
feature = (name) ->
value = FEATURES[name]
if value?
return !!value
else
throw new Error("unknown feature: #{name}")
config = (fn) ->
module.exports.config(fn)
angular = require('angular')
module.exports = angular.module('h.config').value('feature', feature)
if feature('accounts')
config(require('./accounts'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment