CL fixes
This commit is contained in:
parent
cca5daf097
commit
6c1d2afc0f
5 changed files with 19 additions and 21 deletions
|
@ -1057,9 +1057,9 @@ def delete_webhook(namespace_name, repository_name, public_id):
|
|||
webhook.delete_instance()
|
||||
|
||||
def list_logs(user_or_organization_name):
|
||||
account = User.get(User.username == user_or_organization_name)
|
||||
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,
|
||||
access_token=None, ip=None, description=None, metadata={}):
|
||||
|
|
|
@ -16,8 +16,6 @@ from auth.permissions import (ModifyRepositoryPermission, UserPermission,
|
|||
ReadRepositoryPermission,
|
||||
CreateRepositoryPermission)
|
||||
|
||||
from util.log import log_action
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -720,22 +720,20 @@ quayApp.directive('logsView', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($scope.logs) {
|
||||
return;
|
||||
}
|
||||
$scope.loading = true;
|
||||
|
||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'logs') :
|
||||
getRestUrl('user/logs');
|
||||
var loadLogs = Restangular.one(url);
|
||||
loadLogs.customGET().then(function(resp) {
|
||||
if (!$scope.chart) {
|
||||
$scope.chart = new LogUsageChart(resp.logs, logKinds);
|
||||
$scope.chart.draw('bar-chart');
|
||||
$scope.chart = new LogUsageChart(logKinds);
|
||||
$($scope.chart).bind('filteringChanged', function(e) {
|
||||
$scope.$apply(function() { $scope.kindsAllowed = e.allowed; });
|
||||
});
|
||||
}
|
||||
|
||||
$scope.chart.draw('bar-chart', resp.logs);
|
||||
$scope.logs = resp.logs;
|
||||
$scope.loading = false;
|
||||
});
|
||||
|
|
|
@ -1154,10 +1154,10 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
|||
$scope.membersLoading = true;
|
||||
$scope.membersFound = null;
|
||||
$scope.invoiceLoading = true;
|
||||
$scope.logsShown = false;
|
||||
$scope.logsShown = 0;
|
||||
|
||||
$scope.loadLogs = function() {
|
||||
$scope.logsShown = true;
|
||||
$scope.logsShown++;
|
||||
};
|
||||
|
||||
$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.
|
||||
*/
|
||||
function LogUsageChart(logData, titleMap) {
|
||||
this.logs_ = logData;
|
||||
function LogUsageChart(titleMap) {
|
||||
this.titleMap_ = titleMap;
|
||||
this.colorScale_ = d3.scale.category20();
|
||||
}
|
||||
|
@ -1279,15 +1278,15 @@ function LogUsageChart(logData, titleMap) {
|
|||
/**
|
||||
* 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
|
||||
|
||||
// Build entries for each kind of event that occurred, on each day. We have one
|
||||
// entry per {kind, day} pair.
|
||||
var map = {};
|
||||
var entries = [];
|
||||
for (var i = 0; i < this.logs_.length; ++i) {
|
||||
var log = this.logs_[i];
|
||||
for (var i = 0; i < logs.length; ++i) {
|
||||
var log = logs[i];
|
||||
var title = this.titleMap_[log.kind] || log.kind;
|
||||
var datetime = parseDate(log.datetime);
|
||||
var formatted = (datetime.getMonth() + 1) + '/' + datetime.getDate();
|
||||
|
@ -1424,7 +1423,10 @@ LogUsageChart.prototype.handleStateChange_ = function(e) {
|
|||
/**
|
||||
* 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.
|
||||
var offsetDate = function(d, days) {
|
||||
var copy = new Date(d.getTime());
|
||||
|
@ -1433,7 +1435,7 @@ LogUsageChart.prototype.draw = function(container) {
|
|||
};
|
||||
|
||||
var that = this;
|
||||
var data = this.buildData_();
|
||||
var data = this.buildData_(logData);
|
||||
nv.addGraph(function() {
|
||||
// Build the chart itself.
|
||||
var chart = nv.models.multiBarChart()
|
||||
|
|
Reference in a new issue