New config service with more clear format.
parent
d6583381a9
commit
f8c1740744
|
@ -8,4 +8,6 @@ app/coffee/modules/locales/locale*.coffee
|
|||
*.swp
|
||||
*.swo
|
||||
tags
|
||||
tmp/
|
||||
conf/
|
||||
app/config/main.coffee
|
||||
|
|
|
@ -193,14 +193,10 @@ init = ($log, $i18n, $config, $rootscope, $auth, $events) ->
|
|||
if $auth.isAuthenticated()
|
||||
$events.setupConnection()
|
||||
|
||||
# Default Value for taiga local config module.
|
||||
angular.module("taigaLocalConfig", []).value("localconfig", {})
|
||||
|
||||
modules = [
|
||||
# Main Global Modules
|
||||
"taigaBase",
|
||||
"taigaCommon",
|
||||
"taigaConfig",
|
||||
"taigaResources",
|
||||
"taigaLocales",
|
||||
"taigaAuth",
|
||||
|
|
|
@ -16,35 +16,20 @@
|
|||
# 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/>.
|
||||
#
|
||||
# File: config.coffee
|
||||
# File: modules/base/conf.coffee
|
||||
###
|
||||
|
||||
taiga = @.taiga
|
||||
|
||||
class ConfigService extends taiga.Service
|
||||
defaults: {
|
||||
host: "localhost:8000"
|
||||
scheme: "http"
|
||||
|
||||
debug: false
|
||||
|
||||
defaultLanguage: "en"
|
||||
languageOptions: {
|
||||
"es": "Spanish"
|
||||
"en": "English"
|
||||
defaults = {
|
||||
api: "http://localhost:8000/api/v1/"
|
||||
debug: true
|
||||
lang: "en"
|
||||
}
|
||||
|
||||
publicRegisterEnabled: false
|
||||
class ConfigurationService
|
||||
@.$inject = ["localconf"]
|
||||
|
||||
termsOfServiceUrl: null
|
||||
privacyPolicyUrl: null
|
||||
|
||||
feedbackEnabled: true
|
||||
}
|
||||
|
||||
initialize: (localconfig) ->
|
||||
defaults = _.clone(@.defaults, true)
|
||||
@.config = _.merge(defaults, localconfig)
|
||||
constructor: (localconf) ->
|
||||
@.config = _.merge(_.clone(defaults, true), localconf)
|
||||
|
||||
get: (key, defaultValue=null) ->
|
||||
if _.has(@.config, key)
|
||||
|
@ -52,12 +37,7 @@ class ConfigService extends taiga.Service
|
|||
return defaultValue
|
||||
|
||||
|
||||
# Initialize config loading local configuration.
|
||||
init = ($log, localconfig, config) ->
|
||||
$log.debug("Initializing configuration", localconfig)
|
||||
config.initialize(localconfig)
|
||||
module = angular.module("taigaBase")
|
||||
module.service("$tgConfig", ConfigurationService)
|
||||
module.value("localconf", null)
|
||||
|
||||
|
||||
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