2015-02-19 21:21:54 +00:00
|
|
|
/**
|
|
|
|
* Feature flags.
|
|
|
|
*/
|
|
|
|
angular.module('quay').factory('Features', [function() {
|
|
|
|
if (!window.__features) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var features = window.__features;
|
|
|
|
features.getFeature = function(name, opt_defaultValue) {
|
|
|
|
var value = features[name];
|
|
|
|
if (value == null) {
|
|
|
|
return opt_defaultValue;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
|
|
|
|
features.hasFeature = function(name) {
|
|
|
|
return !!features.getFeature(name);
|
|
|
|
};
|
|
|
|
|
|
|
|
features.matchesFeatures = function(list) {
|
|
|
|
for (var i = 0; i < list.length; ++i) {
|
|
|
|
var value = features.getFeature(list[i]);
|
|
|
|
if (!value) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
return features;
|
|
|
|
}]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Application configuration.
|
|
|
|
*/
|
2016-04-06 19:57:40 +00:00
|
|
|
angular.module('quay').factory('Config', ['Features', function(Features) {
|
2015-02-19 21:21:54 +00:00
|
|
|
if (!window.__config) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var config = window.__config;
|
|
|
|
config.getDomain = function() {
|
|
|
|
return config['SERVER_HOSTNAME'];
|
|
|
|
};
|
|
|
|
|
|
|
|
config.getHost = function(opt_auth) {
|
|
|
|
var auth = opt_auth;
|
|
|
|
if (auth) {
|
|
|
|
auth = auth + '@';
|
|
|
|
}
|
|
|
|
|
|
|
|
return config['PREFERRED_URL_SCHEME'] + '://' + auth + config['SERVER_HOSTNAME'];
|
|
|
|
};
|
|
|
|
|
2015-03-19 19:08:18 +00:00
|
|
|
config.getHttp = function() {
|
|
|
|
return config['PREFERRED_URL_SCHEME'];
|
|
|
|
};
|
|
|
|
|
2015-02-19 21:21:54 +00:00
|
|
|
config.getUrl = function(opt_path) {
|
|
|
|
var path = opt_path || '';
|
|
|
|
return config['PREFERRED_URL_SCHEME'] + '://' + config['SERVER_HOSTNAME'] + path;
|
|
|
|
};
|
|
|
|
|
|
|
|
config.getValue = function(name, opt_defaultValue) {
|
|
|
|
var value = config[name];
|
|
|
|
if (value == null) {
|
|
|
|
return opt_defaultValue;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
|
2018-05-07 16:47:29 +00:00
|
|
|
config.getEnterpriseLogo = function(opt_defaultValue) {
|
2016-04-06 19:57:40 +00:00
|
|
|
if (!config.ENTERPRISE_LOGO_URL) {
|
2018-05-07 16:47:29 +00:00
|
|
|
if (opt_defaultValue) {
|
|
|
|
return opt_defaultValue;
|
2018-05-07 15:11:33 +00:00
|
|
|
}
|
|
|
|
|
2016-04-06 19:57:40 +00:00
|
|
|
if (Features.BILLING) {
|
2016-11-21 20:50:11 +00:00
|
|
|
return '/static/img/quay-horizontal-color.svg';
|
2016-04-06 19:57:40 +00:00
|
|
|
} else {
|
|
|
|
return '/static/img/QuayEnterprise_horizontal_color.svg';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return config.ENTERPRISE_LOGO_URL;
|
|
|
|
};
|
|
|
|
|
2015-02-19 21:21:54 +00:00
|
|
|
return config;
|
|
|
|
}]);
|