diff --git a/data/model.py b/data/model.py index f95fe5a2a..5c1d3a214 100644 --- a/data/model.py +++ b/data/model.py @@ -1058,13 +1058,12 @@ def delete_webhook(namespace_name, repository_name, public_id): webhook.delete_instance() return webhook -def list_logs(user_or_organization_name, repository = None): - week_ago = datetime.today() - timedelta(7) # One week +def list_logs(user_or_organization_name, start_time, repository = None): joined = LogEntry.select().join(User) if repository: joined = joined.where(LogEntry.repository == repository) - return joined.where(User.username == user_or_organization_name, LogEntry.datetime >= week_ago).order_by(LogEntry.datetime.desc()) + return joined.where(User.username == user_or_organization_name, LogEntry.datetime >= start_time).order_by(LogEntry.datetime.desc()) def log_action(kind_name, user_or_organization_name, performer=None, repository=None, access_token=None, ip=None, metadata={}, timestamp=None): diff --git a/endpoints/api.py b/endpoints/api.py index 00e405d15..e6bb02746 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -28,7 +28,7 @@ from auth.permissions import (ReadRepositoryPermission, from endpoints import registry from endpoints.web import common_login from util.cache import cache_control - +from datetime import datetime, timedelta store = app.config['STORAGE'] user_files = app.config['USERFILES'] @@ -1727,8 +1727,10 @@ def log_view(log): def org_logs_api(orgname): permission = AdministerOrganizationPermission(orgname) if permission.can(): - logs = model.list_logs(orgname) + week_ago = datetime.today() - timedelta(7) # One week + logs = model.list_logs(orgname, week_ago) return jsonify({ + 'start_time': week_ago, 'logs': [log_view(log) for log in logs] }) diff --git a/static/css/quay.css b/static/css/quay.css index 21b3d3f1c..30b70e972 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -25,6 +25,7 @@ html, body { font-size: 22px; padding: 6px; cursor: pointer; + color: black; } i.toggle-icon:hover { diff --git a/static/directives/logs-view.html b/static/directives/logs-view.html index 4f0f88dea..2ed8f60bd 100644 --- a/static/directives/logs-view.html +++ b/static/directives/logs-view.html @@ -8,6 +8,9 @@ + + + diff --git a/static/js/app.js b/static/js/app.js index 8b80de5fb..dd1b228d1 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -686,6 +686,7 @@ quayApp.directive('logsView', function () { $scope.logs = null; $scope.kindsAllowed = null; $scope.chartVisible = true; + $scope.logsPath = ''; var logDescriptions = { 'account_change_plan': 'Change plan', @@ -781,9 +782,11 @@ quayApp.directive('logsView', function () { if ($scope.repository) { url = getRestUrl('repository', $scope.repository.namespace, $scope.repository.name, 'logs'); } - + var loadLogs = Restangular.one(url); loadLogs.customGET().then(function(resp) { + $scope.logsPath = '/api/' + url; + if (!$scope.chart) { $scope.chart = new LogUsageChart(logKinds); $($scope.chart).bind('filteringChanged', function(e) {