Remove container usage tab and replace with changlog view

Fixes #179
This commit is contained in:
Joseph Schorr 2015-06-28 08:27:39 +03:00
parent cea4ad2d85
commit b8c74bbb17
6 changed files with 28 additions and 56 deletions

View file

@ -2,7 +2,7 @@
The following are features that have been merged, but not yet deployed: The following are features that have been merged, but not yet deployed:
- Nothing yet! - Add a Changelog view to the superuser panel (#186)
### 1.9.7 ### 1.9.7

View file

@ -118,21 +118,21 @@ def user_view(user):
'super_user': superusers.is_superuser(user.username) 'super_user': superusers.is_superuser(user.username)
} }
@resource('/v1/superuser/usage/') @resource('/v1/superuser/changelog/')
@internal_only @internal_only
@show_if(features.SUPER_USERS) @show_if(features.SUPER_USERS)
class UsageInformation(ApiResource): class ChangeLog(ApiResource):
""" Resource for returning the usage information for enterprise customers. """ """ Resource for returning the change log for enterprise customers. """
@require_fresh_login @require_fresh_login
@verify_not_prod @verify_not_prod
@nickname('getSystemUsage') @nickname('getChangeLog')
def get(self): def get(self):
""" Returns the number of repository handles currently held. """ """ Returns the change log for this installation. """
if SuperUserPermission().can(): if SuperUserPermission().can():
return { with open ('CHANGELOG.md', 'r') as f:
'usage': model.get_repository_usage(), return {
'allowed': app.config.get('MAXIMUM_REPOSITORY_USAGE', 20) 'log': f.read()
} }
abort(403) abort(403)

View file

@ -26,7 +26,7 @@
$scope.logsCounter = 0; $scope.logsCounter = 0;
$scope.newUser = {}; $scope.newUser = {};
$scope.createdUser = null; $scope.createdUser = null;
$scope.systemUsage = null; $scope.changeLog = null;
$scope.debugServices = null; $scope.debugServices = null;
$scope.debugLogs = null; $scope.debugLogs = null;
$scope.pollChannel = null; $scope.pollChannel = null;
@ -89,12 +89,12 @@
}, ApiService.errorDisplay('Cannot load system logs. Please contact support.')) }, ApiService.errorDisplay('Cannot load system logs. Please contact support.'))
}; };
$scope.getUsage = function() { $scope.getChangeLog = function() {
if ($scope.systemUsage) { return; } if ($scope.changeLog) { return; }
ApiService.getSystemUsage().then(function(resp) { ApiService.getChangeLog().then(function(resp) {
$scope.systemUsage = resp; $scope.changeLog = resp;
}, ApiService.errorDisplay('Cannot load system usage. Please contact support.')) }, ApiService.errorDisplay('Cannot load change log. Please contact support.'))
} }
$scope.loadUsageLogs = function() { $scope.loadUsageLogs = function() {

View file

@ -28,8 +28,8 @@
tab-shown="setDashboardActive(true)" tab-hidden="setDashboardActive(false)"> tab-shown="setDashboardActive(true)" tab-hidden="setDashboardActive(false)">
<i class="fa fa-tachometer"></i> <i class="fa fa-tachometer"></i>
</span> </span>
<span class="cor-tab" tab-title="Container Usage" tab-target="#usage-counter" tab-init="getUsage()"> <span class="cor-tab" tab-title="Change Log" tab-target="#change-log" tab-init="getChangeLog()">
<i class="fa fa-pie-chart"></i> <i class="fa fa-rss"></i>
</span> </span>
<span class="cor-tab" tab-title="Usage Logs" tab-target="#logs" tab-init="loadUsageLogs()"> <span class="cor-tab" tab-title="Usage Logs" tab-target="#logs" tab-init="loadUsageLogs()">
<i class="fa fa-bar-chart"></i> <i class="fa fa-bar-chart"></i>
@ -86,30 +86,12 @@
<div class="logsView" makevisible="logsCounter" all-logs="true"></div> <div class="logsView" makevisible="logsCounter" all-logs="true"></div>
</div> <!-- /logs tab--> </div> <!-- /logs tab-->
<!-- Usage tab --> <!-- Change Log tab -->
<div id="usage-counter" class="tab-pane"> <div id="change-log" class="tab-pane">
<div class="cor-loader" ng-show="systemUsage == null"></div> <h3 style="margin-top: 0px;">Change Log</h3>
<div class="usage-chart" total="systemUsage.allowed" limit="systemUsageLimit" <div class="cor-loader" ng-if="!changeLog"></div>
current="systemUsage.usage" usage-title="Deployed Containers"></div> <div class="markdown-view" content="changeLog.log" ng-if="changeLog"></div>
</div> <!-- /change-log tab-->
<!-- Alerts -->
<div class="alert alert-danger" ng-show="systemUsageLimit == 'over' && systemUsage">
You have deployed more repositories than your plan allows. Please
upgrade your subscription by contacting <a href="mailto:sales@coreos.com">CoreOS Sales</a>.
</div>
<div class="alert alert-warning" ng-show="systemUsageLimit == 'at' && systemUsage">
You are at your current plan's number of allowed repositories. It might be time to think about
upgrading your subscription by contacting <a href="mailto:sales@coreos.com">CoreOS Sales</a>.
</div>
<div class="alert alert-success" ng-show="systemUsageLimit == 'near' && systemUsage">
You are nearing the number of allowed deployed repositories. It might be time to think about
upgrading your subscription by contacting <a href="mailto:sales@coreos.com">CoreOS Sales</a>.
</div>
For more information: <a href="https://coreos.com/products/enterprise-registry/plans/">See Here</a>.
</div> <!-- /usage-counter tab-->
<!-- Organizations tab --> <!-- Organizations tab -->
<div id="organizations" class="tab-pane"> <div id="organizations" class="tab-pane">

View file

@ -45,7 +45,7 @@ from endpoints.api.repository import RepositoryList, RepositoryVisibility, Repos
from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission, from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission,
RepositoryTeamPermissionList, RepositoryUserPermissionList) RepositoryTeamPermissionList, RepositoryUserPermissionList)
from endpoints.api.superuser import (SuperUserLogs, SuperUserList, SuperUserManagement, from endpoints.api.superuser import (SuperUserLogs, SuperUserList, SuperUserManagement,
SuperUserSendRecoveryEmail, UsageInformation, SuperUserSendRecoveryEmail, ChangeLog,
SuperUserOrganizationManagement, SuperUserOrganizationList) SuperUserOrganizationManagement, SuperUserOrganizationList)
@ -3928,10 +3928,10 @@ class TestTeamMemberInvite(ApiTestCase):
self._run_test('DELETE', 400, 'devtable', None) self._run_test('DELETE', 400, 'devtable', None)
class TestUsageInformation(ApiTestCase): class TestChangeLog(ApiTestCase):
def setUp(self): def setUp(self):
ApiTestCase.setUp(self) ApiTestCase.setUp(self)
self._set_url(UsageInformation) self._set_url(ChangeLog)
def test_get_anonymous(self): def test_get_anonymous(self):
self._run_test('GET', 401, None, None) self._run_test('GET', 401, None, None)

View file

@ -47,8 +47,7 @@ from endpoints.api.organization import (OrganizationList, OrganizationMember,
from endpoints.api.repository import RepositoryList, RepositoryVisibility, Repository from endpoints.api.repository import RepositoryList, RepositoryVisibility, Repository
from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission, from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission,
RepositoryTeamPermissionList, RepositoryUserPermissionList) RepositoryTeamPermissionList, RepositoryUserPermissionList)
from endpoints.api.superuser import (SuperUserLogs, SuperUserList, SuperUserManagement, from endpoints.api.superuser import (SuperUserLogs, SuperUserList, SuperUserManagement)
UsageInformation)
try: try:
app.register_blueprint(api_bp, url_prefix='/api') app.register_blueprint(api_bp, url_prefix='/api')
@ -2877,15 +2876,6 @@ class TestSuperUserList(ApiTestCase):
assert len(json['users']) > 0 assert len(json['users']) > 0
class TestUsageInformation(ApiTestCase):
def test_get_usage(self):
self.login(ADMIN_ACCESS_USER)
json = self.getJsonResponse(UsageInformation)
assert 'usage' in json
assert 'allowed' in json
class TestSuperUserManagement(ApiTestCase): class TestSuperUserManagement(ApiTestCase):
def test_get_user(self): def test_get_user(self):
self.login(ADMIN_ACCESS_USER) self.login(ADMIN_ACCESS_USER)