@@ -30,23 +30,14 @@
|
||||
// create main application module
|
||||
var app = angular.module('Application', []);
|
||||
|
||||
// FIXME this does not work with custom domains!
|
||||
function detectApiOrigin() {
|
||||
var host = window.location.host;
|
||||
var tmp = host.split('.')[0];
|
||||
if (tmp.indexOf('-') === -1) return 'https://my-' + host;
|
||||
else return 'https://my' + tmp.slice(tmp.indexOf('-')) + host.slice(tmp.length);
|
||||
}
|
||||
|
||||
app.controller('Controller', ['$scope', '$http', function ($scope, $http) {
|
||||
var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {});
|
||||
|
||||
$scope.apiOrigin = detectApiOrigin();
|
||||
$scope.cloudronName = 'Cloudron';
|
||||
$scope.referrer = search.referrer || null;
|
||||
|
||||
// try to fetch cloudron status
|
||||
$http.get($scope.apiOrigin + '/api/v1/cloudron/status').success(function(data, status) {
|
||||
$http.get('/api/v1/cloudron/status').success(function(data, status) {
|
||||
if (status !== 200 || typeof data !== 'object') return console.error(status, data);
|
||||
$scope.cloudronName = data.cloudronName;
|
||||
document.title = $scope.cloudronName + ' App Error';
|
||||
|
||||
Reference in New Issue
Block a user