Add resource constrait view on app installation attempt

This commit is contained in:
Johannes Zellner
2015-10-22 10:40:33 +02:00
parent 6103640b53
commit d11e030150
3 changed files with 22 additions and 6 deletions

View File

@@ -638,6 +638,10 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.enoughResourcesAvailable = function (app) {
return true;
};
client = new Client();
return client;
}]);

View File

@@ -52,11 +52,15 @@
<div ng-bind-html="appInstall.app.manifest.description | markdown2html"></div>
</div>
</div>
<div class="collapse" id="collapseResourceConstraint" data-toggle="false">
<h4 class="text-danger">Not enough resources left to install this application.</h4>
<p>The Cloudron's resources can be extended with a model upgrade or available resources may be freed up by uninstalling unused applications.</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" ng-show="!appInstall.installFormVisible && user.admin" ng-click="showInstallForm()">Install</button>
<button type="button" class="btn btn-success" ng-show="appInstall.installFormVisible && user.admin" ng-click="doInstall()" ng-disabled="appInstallForm.$invalid || appInstall.busy"><i class="fa fa-spinner fa-pulse" ng-show="appInstall.busy"></i> Install</button>
<button type="button" class="btn btn-success" ng-show="!appInstall.installFormVisible && user.admin && !appInstall.resourceConstraintVisible" ng-click="showInstallForm()">Install</button>
<button type="button" class="btn btn-success" ng-show="appInstall.installFormVisible && user.admin && !appInstall.resourceConstraintVisible" ng-click="doInstall()" ng-disabled="appInstallForm.$invalid || appInstall.busy"><i class="fa fa-spinner fa-pulse" ng-show="appInstall.busy"></i> Install</button>
</div>
</div>
</div>

View File

@@ -140,8 +140,10 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
$scope.appInstall.accessRestriction = null;
$scope.appInstall.oauthProxy = false;
$scope.appInstall.installFormVisible = false;
$scope.appInstall.resourceConstraintVisible = false;
$scope.appInstall.mediaLinks = [];
$('#collapseInstallForm').collapse('hide');
$('#collapseResourceConstraint').collapse('hide');
$('#collapseMediaLinksCarousel').collapse('show');
$scope.appInstallForm.$setPristine();
@@ -149,10 +151,16 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
};
$scope.showInstallForm = function () {
$scope.appInstall.installFormVisible = true;
$('#collapseMediaLinksCarousel').collapse('hide');
$('#collapseInstallForm').collapse('show');
$('#appInstallLocationInput').focus();
if (Client.enoughResourcesAvailable($scope.appInstall.app)) {
$scope.appInstall.installFormVisible = true;
$('#collapseMediaLinksCarousel').collapse('hide');
$('#collapseInstallForm').collapse('show');
$('#appInstallLocationInput').focus();
} else {
$scope.appInstall.resourceConstraintVisible = true;
$('#collapseMediaLinksCarousel').collapse('hide');
$('#collapseResourceConstraint').collapse('show');
}
};
$scope.showInstall = function (app) {