spaces: use edition instead of setting

This commit is contained in:
Girish Ramakrishnan
2018-08-28 18:55:13 -07:00
parent dd53d0d575
commit d316d216db
7 changed files with 10 additions and 74 deletions

View File

@@ -511,7 +511,7 @@
</div>
</div>
</div>
<div class="grid-item-bottom-mobile" ng-show="user.admin || (config.spaces.enabled && app.ownerId === user.id)">
<div class="grid-item-bottom-mobile" ng-show="user.admin || (config.spaces && app.ownerId === user.id)">
<div class="row">
<div class="col-xs-4 text-left">
<a href="" ng-click="appRestore.show(app)" ng-show="backupConfig.provider !== 'noop'">
@@ -531,7 +531,7 @@
</div>
</div>
</div>
<div class="grid-item-bottom" ng-show="user.admin || (config.spaces.enabled && app.ownerId === user.id)">
<div class="grid-item-bottom" ng-show="user.admin || (config.spaces && app.ownerId === user.id)">
<div>
<a href="" ng-click="showUninstall(app)" uib-tooltip="Uninstall" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-remove scale"></i></a>
</div>

View File

@@ -52,7 +52,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appConfigure.app = app;
if ($scope.user.admin) {
$scope.appConfigure.location = app.location;
} else { // strip the trailing username
} else { // strip the trailing username in spaces mode
$scope.appConfigure.location = app.location === $scope.spacesSuffix ? '' : app.location.replace(new RegExp('-' + $scope.spacesSuffix + '$'),'');
}
$scope.appConfigure.domain = $scope.domains.filter(function (d) { return d.domain === app.domain; })[0];
@@ -604,7 +604,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.spacesSuffix = $scope.user.username.replace(/\./g, '-');
if ($scope.user.admin || $scope.config.spaces.enabled) {
if ($scope.user.admin || $scope.config.spaces) {
fetchUsers();
fetchGroups();
getDomains();

View File

@@ -1,7 +1,7 @@
'use strict';
angular.module('Application').controller('AppStoreController', ['$scope', '$location', '$timeout', '$routeParams', 'Client', 'AppStore', function ($scope, $location, $timeout, $routeParams, Client, AppStore) {
Client.onReady(function () { if (!Client.getUserInfo().admin && !Client.getConfig().spaces.enabled) $location.path('/'); });
Client.onReady(function () { if (!Client.getUserInfo().admin && !Client.getConfig().spaces) $location.path('/'); });
$scope.HOST_PORT_MIN = 1024;
$scope.HOST_PORT_MAX = 65535;
@@ -484,7 +484,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
}
// non admins cannot read appstore settings in spaces mode
if (!$scope.user.admin && $scope.config.spaces.enabled) {
if (!$scope.user.admin && $scope.config.spaces) {
$scope.validAppstoreAccount = true;
return callback();
}

View File

@@ -325,27 +325,4 @@
</div>
</div>
<div class="text-left" ng-show="subscription && subscription.plan.id.indexOf('spaces') !== -1">
<h3>Cloudron Spaces</h3>
</div>
<div class="card" style="margin-bottom: 15px;" ng-show="subscription && subscription.plan.id.indexOf('spaces') !== -1">
<div class="row">
<div class="col-md-12">
<p>Cloudron Spaces allows users to install and run apps of their own</p>
<p class="text-danger" ng-show="spaces.error"><br/>{{ spaces.error }}</p>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<button ng-class="spaces.enabled ? 'btn btn-danger' : 'btn btn-primary'" class="pull-right" ng-click="spaces.submit()" ng-disabled="spaces.busy">
<i class="fa fa-circle-o-notch fa-spin" ng-show="spaces.busy"></i>
{{ spaces.enabled ? "Disable" : "Enable" }}
</button>
</div>
</div>
</div>
</div>

View File

@@ -64,23 +64,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
};
$scope.spaces = {
error: '',
busy: false,
enabled: false,
submit: function () {
$scope.spaces.error = null;
$scope.spaces.busy = true;
Client.setSpacesConfig({ enabled: !$scope.spaces.enabled }, function (error) {
if (error) $scope.spaces.error = error.message;
getSpacesConfig();
});
}
};
$scope.planChange = {
busy: false,
error: {},
@@ -313,17 +296,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
});
}
function getSpacesConfig() {
$scope.spaces.busy = true;
Client.getSpacesConfig(function (error, result) {
if (error) return console.error(error);
$scope.spaces.busy = false;
$scope.spaces.enabled = result.enabled;
});
}
function getSubscription() {
AppStore.getSubscription($scope.appstoreConfig, function (error, result) {
if (error) return console.error(error);
@@ -433,7 +405,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
Client.onReady(function () {
getAutoupdatePattern();
getSpacesConfig();
if ($scope.config.provider === 'caas') {
Client.getCaasConfig(function (error, caasConfig) {