New config service with more clear format.
parent
d6583381a9
commit
f8c1740744
|
@ -8,4 +8,6 @@ app/coffee/modules/locales/locale*.coffee
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
tags
|
tags
|
||||||
|
tmp/
|
||||||
|
conf/
|
||||||
app/config/main.coffee
|
app/config/main.coffee
|
||||||
|
|
|
@ -193,14 +193,10 @@ init = ($log, $i18n, $config, $rootscope, $auth, $events) ->
|
||||||
if $auth.isAuthenticated()
|
if $auth.isAuthenticated()
|
||||||
$events.setupConnection()
|
$events.setupConnection()
|
||||||
|
|
||||||
# Default Value for taiga local config module.
|
|
||||||
angular.module("taigaLocalConfig", []).value("localconfig", {})
|
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main Global Modules
|
# Main Global Modules
|
||||||
"taigaBase",
|
"taigaBase",
|
||||||
"taigaCommon",
|
"taigaCommon",
|
||||||
"taigaConfig",
|
|
||||||
"taigaResources",
|
"taigaResources",
|
||||||
"taigaLocales",
|
"taigaLocales",
|
||||||
"taigaAuth",
|
"taigaAuth",
|
||||||
|
|
|
@ -16,35 +16,20 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# File: config.coffee
|
# File: modules/base/conf.coffee
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
defaults = {
|
||||||
|
api: "http://localhost:8000/api/v1/"
|
||||||
|
debug: true
|
||||||
|
lang: "en"
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigService extends taiga.Service
|
class ConfigurationService
|
||||||
defaults: {
|
@.$inject = ["localconf"]
|
||||||
host: "localhost:8000"
|
|
||||||
scheme: "http"
|
|
||||||
|
|
||||||
debug: false
|
constructor: (localconf) ->
|
||||||
|
@.config = _.merge(_.clone(defaults, true), localconf)
|
||||||
defaultLanguage: "en"
|
|
||||||
languageOptions: {
|
|
||||||
"es": "Spanish"
|
|
||||||
"en": "English"
|
|
||||||
}
|
|
||||||
|
|
||||||
publicRegisterEnabled: false
|
|
||||||
|
|
||||||
termsOfServiceUrl: null
|
|
||||||
privacyPolicyUrl: null
|
|
||||||
|
|
||||||
feedbackEnabled: true
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize: (localconfig) ->
|
|
||||||
defaults = _.clone(@.defaults, true)
|
|
||||||
@.config = _.merge(defaults, localconfig)
|
|
||||||
|
|
||||||
get: (key, defaultValue=null) ->
|
get: (key, defaultValue=null) ->
|
||||||
if _.has(@.config, key)
|
if _.has(@.config, key)
|
||||||
|
@ -52,12 +37,7 @@ class ConfigService extends taiga.Service
|
||||||
return defaultValue
|
return defaultValue
|
||||||
|
|
||||||
|
|
||||||
# Initialize config loading local configuration.
|
module = angular.module("taigaBase")
|
||||||
init = ($log, localconfig, config) ->
|
module.service("$tgConfig", ConfigurationService)
|
||||||
$log.debug("Initializing configuration", localconfig)
|
module.value("localconf", null)
|
||||||
config.initialize(localconfig)
|
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaConfig", ["taigaLocalConfig"])
|
|
||||||
module.service("$tgConfig", ConfigService)
|
|
||||||
module.run(["$log", "localconfig", "$tgConfig", init])
|
|
|
@ -1,19 +0,0 @@
|
||||||
config = {
|
|
||||||
host: "localhost:8000"
|
|
||||||
scheme: "http"
|
|
||||||
|
|
||||||
debug: true
|
|
||||||
|
|
||||||
defaultLanguage: "en"
|
|
||||||
languageOptions: {
|
|
||||||
"en": "English"
|
|
||||||
}
|
|
||||||
|
|
||||||
publicRegisterEnabled: true
|
|
||||||
privacyPolicyUrl: null
|
|
||||||
termsOfServiceUrl: null
|
|
||||||
|
|
||||||
feedbackEnabled: true
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("taigaLocalConfig", []).value("localconfig", config)
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"api": "http://localhost:8000/api/v1/",
|
||||||
|
"eventsUrl": "ws://localhost:8888/events",
|
||||||
|
"debug": "true",
|
||||||
|
"publicRegisterEnabled": true,
|
||||||
|
"privacyPolicyUrl": null,
|
||||||
|
"termsOfServiceUrl": null
|
||||||
|
}
|
Loading…
Reference in New Issue