CL fixes
This commit is contained in:
parent
cca5daf097
commit
6c1d2afc0f
5 changed files with 19 additions and 21 deletions
|
@ -1057,14 +1057,14 @@ def delete_webhook(namespace_name, repository_name, public_id):
|
||||||
webhook.delete_instance()
|
webhook.delete_instance()
|
||||||
|
|
||||||
def list_logs(user_or_organization_name):
|
def list_logs(user_or_organization_name):
|
||||||
account = User.get(User.username == user_or_organization_name)
|
|
||||||
week_ago = datetime.today() - timedelta(7) # One week
|
week_ago = datetime.today() - timedelta(7) # One week
|
||||||
return LogEntry.select().where(LogEntry.account == account, LogEntry.datetime >= week_ago).order_by(LogEntry.datetime.desc())
|
joined = LogEntry.select().join(User)
|
||||||
|
return joined.where(User.username == user_or_organization_name, LogEntry.datetime >= week_ago).order_by(LogEntry.datetime.desc())
|
||||||
|
|
||||||
def log_action(kind_name, user_or_organization_name, performer=None, repository=None,
|
def log_action(kind_name, user_or_organization_name, performer=None, repository=None,
|
||||||
access_token=None, ip=None, description=None, metadata={}):
|
access_token=None, ip=None, description=None, metadata={}):
|
||||||
kind = LogEntryKind.get(LogEntryKind.name == kind_name)
|
kind = LogEntryKind.get(LogEntryKind.name == kind_name)
|
||||||
account = User.get(User.username == user_or_organization_name)
|
account = User.get(User.username == user_or_organization_name)
|
||||||
entry = LogEntry.create(kind = kind, account = account, performer = performer,
|
entry = LogEntry.create(kind=kind, account=account, performer=performer,
|
||||||
repository = repository, access_token = access_token, ip = ip,
|
repository=repository, access_token=access_token, ip=ip,
|
||||||
description = description, metadata_json = json.dumps(metadata))
|
description=description, metadata_json=json.dumps(metadata))
|
||||||
|
|
|
@ -16,8 +16,6 @@ from auth.permissions import (ModifyRepositoryPermission, UserPermission,
|
||||||
ReadRepositoryPermission,
|
ReadRepositoryPermission,
|
||||||
CreateRepositoryPermission)
|
CreateRepositoryPermission)
|
||||||
|
|
||||||
from util.log import log_action
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -720,22 +720,20 @@ quayApp.directive('logsView', function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.logs) {
|
$scope.loading = true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'logs') :
|
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'logs') :
|
||||||
getRestUrl('user/logs');
|
getRestUrl('user/logs');
|
||||||
var loadLogs = Restangular.one(url);
|
var loadLogs = Restangular.one(url);
|
||||||
loadLogs.customGET().then(function(resp) {
|
loadLogs.customGET().then(function(resp) {
|
||||||
if (!$scope.chart) {
|
if (!$scope.chart) {
|
||||||
$scope.chart = new LogUsageChart(resp.logs, logKinds);
|
$scope.chart = new LogUsageChart(logKinds);
|
||||||
$scope.chart.draw('bar-chart');
|
|
||||||
$($scope.chart).bind('filteringChanged', function(e) {
|
$($scope.chart).bind('filteringChanged', function(e) {
|
||||||
$scope.$apply(function() { $scope.kindsAllowed = e.allowed; });
|
$scope.$apply(function() { $scope.kindsAllowed = e.allowed; });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.chart.draw('bar-chart', resp.logs);
|
||||||
$scope.logs = resp.logs;
|
$scope.logs = resp.logs;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1154,10 +1154,10 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
||||||
$scope.membersLoading = true;
|
$scope.membersLoading = true;
|
||||||
$scope.membersFound = null;
|
$scope.membersFound = null;
|
||||||
$scope.invoiceLoading = true;
|
$scope.invoiceLoading = true;
|
||||||
$scope.logsShown = false;
|
$scope.logsShown = 0;
|
||||||
|
|
||||||
$scope.loadLogs = function() {
|
$scope.loadLogs = function() {
|
||||||
$scope.logsShown = true;
|
$scope.logsShown++;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.planChanged = function(plan) {
|
$scope.planChanged = function(plan) {
|
||||||
|
|
|
@ -1269,8 +1269,7 @@ RepositoryUsageChart.prototype.draw = function(container) {
|
||||||
/**
|
/**
|
||||||
* A chart which displays the last seven days of actions in the account.
|
* A chart which displays the last seven days of actions in the account.
|
||||||
*/
|
*/
|
||||||
function LogUsageChart(logData, titleMap) {
|
function LogUsageChart(titleMap) {
|
||||||
this.logs_ = logData;
|
|
||||||
this.titleMap_ = titleMap;
|
this.titleMap_ = titleMap;
|
||||||
this.colorScale_ = d3.scale.category20();
|
this.colorScale_ = d3.scale.category20();
|
||||||
}
|
}
|
||||||
|
@ -1279,15 +1278,15 @@ function LogUsageChart(logData, titleMap) {
|
||||||
/**
|
/**
|
||||||
* Builds the D3-representation of the data.
|
* Builds the D3-representation of the data.
|
||||||
*/
|
*/
|
||||||
LogUsageChart.prototype.buildData_ = function() {
|
LogUsageChart.prototype.buildData_ = function(logs) {
|
||||||
var parseDate = d3.time.format("%a, %d %b %Y %H:%M:%S GMT").parse
|
var parseDate = d3.time.format("%a, %d %b %Y %H:%M:%S GMT").parse
|
||||||
|
|
||||||
// Build entries for each kind of event that occurred, on each day. We have one
|
// Build entries for each kind of event that occurred, on each day. We have one
|
||||||
// entry per {kind, day} pair.
|
// entry per {kind, day} pair.
|
||||||
var map = {};
|
var map = {};
|
||||||
var entries = [];
|
var entries = [];
|
||||||
for (var i = 0; i < this.logs_.length; ++i) {
|
for (var i = 0; i < logs.length; ++i) {
|
||||||
var log = this.logs_[i];
|
var log = logs[i];
|
||||||
var title = this.titleMap_[log.kind] || log.kind;
|
var title = this.titleMap_[log.kind] || log.kind;
|
||||||
var datetime = parseDate(log.datetime);
|
var datetime = parseDate(log.datetime);
|
||||||
var formatted = (datetime.getMonth() + 1) + '/' + datetime.getDate();
|
var formatted = (datetime.getMonth() + 1) + '/' + datetime.getDate();
|
||||||
|
@ -1424,7 +1423,10 @@ LogUsageChart.prototype.handleStateChange_ = function(e) {
|
||||||
/**
|
/**
|
||||||
* Draws the chart in the given container element.
|
* Draws the chart in the given container element.
|
||||||
*/
|
*/
|
||||||
LogUsageChart.prototype.draw = function(container) {
|
LogUsageChart.prototype.draw = function(container, logData) {
|
||||||
|
// Reset the container's contents.
|
||||||
|
document.getElementById(container).innerHTML = '<svg></svg>';
|
||||||
|
|
||||||
// Returns a date offset from the given date by "days" Days.
|
// Returns a date offset from the given date by "days" Days.
|
||||||
var offsetDate = function(d, days) {
|
var offsetDate = function(d, days) {
|
||||||
var copy = new Date(d.getTime());
|
var copy = new Date(d.getTime());
|
||||||
|
@ -1433,7 +1435,7 @@ LogUsageChart.prototype.draw = function(container) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
var data = this.buildData_();
|
var data = this.buildData_(logData);
|
||||||
nv.addGraph(function() {
|
nv.addGraph(function() {
|
||||||
// Build the chart itself.
|
// Build the chart itself.
|
||||||
var chart = nv.models.multiBarChart()
|
var chart = nv.models.multiBarChart()
|
||||||
|
|
Reference in a new issue