Add creation date information to robots API and UI
Fixes https://jira.coreos.com/browse/QUAY-846
This commit is contained in:
parent
c4a6273e00
commit
a693771345
5 changed files with 28 additions and 10 deletions
|
@ -375,7 +375,7 @@ def _list_entity_robots(entity_name):
|
|||
def list_entity_robot_permission_teams(entity_name, include_permissions=False):
|
||||
query = (_list_entity_robots(entity_name))
|
||||
|
||||
fields = [User.username, FederatedLogin.service_ident]
|
||||
fields = [User.username, User.creation_date, FederatedLogin.service_ident]
|
||||
if include_permissions:
|
||||
query = (query
|
||||
.join(RepositoryPermission, JOIN_LEFT_OUTER,
|
||||
|
|
|
@ -3,6 +3,8 @@ from collections import namedtuple
|
|||
|
||||
from six import add_metaclass
|
||||
|
||||
from endpoints.api import format_date
|
||||
|
||||
|
||||
class Permission(namedtuple('Permission', ['repository_name', 'repository_visibility_name', 'role_name'])):
|
||||
"""
|
||||
|
@ -36,6 +38,7 @@ class RobotWithPermissions(
|
|||
namedtuple('RobotWithPermissions', [
|
||||
'name',
|
||||
'password',
|
||||
'created',
|
||||
'teams',
|
||||
'repository_names',
|
||||
])):
|
||||
|
@ -43,6 +46,7 @@ class RobotWithPermissions(
|
|||
RobotWithPermissions is a list of robot entries.
|
||||
:type name: string
|
||||
:type password: string
|
||||
:type created: datetime|None
|
||||
:type teams: [Team]
|
||||
:type repository_names: [string]
|
||||
|
||||
|
@ -52,6 +56,7 @@ class RobotWithPermissions(
|
|||
return {
|
||||
'name': self.name,
|
||||
'token': self.password,
|
||||
'created': format_date(self.created) if self.created is not None else None,
|
||||
'teams': [team.to_dict() for team in self.teams],
|
||||
'repositories': self.repository_names
|
||||
}
|
||||
|
@ -61,18 +66,21 @@ class Robot(
|
|||
namedtuple('Robot', [
|
||||
'name',
|
||||
'password',
|
||||
'created',
|
||||
])):
|
||||
"""
|
||||
Robot represents a robot entity.
|
||||
:type name: string
|
||||
:type password: string
|
||||
:type created: datetime|None
|
||||
|
||||
"""
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'name': self.name,
|
||||
'token': self.password
|
||||
'token': self.password,
|
||||
'created': format_date(self.created) if self.created is not None else None,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class RobotPreOCIModel(RobotInterface):
|
|||
robot_dict = {
|
||||
'name': robot_name,
|
||||
'token': robot_tuple.get(FederatedLogin.service_ident),
|
||||
'created': robot_tuple.get(User.creation_date),
|
||||
}
|
||||
|
||||
if include_permissions:
|
||||
|
@ -30,7 +31,7 @@ class RobotPreOCIModel(RobotInterface):
|
|||
'teams': [],
|
||||
'repositories': []
|
||||
})
|
||||
robots[robot_name] = Robot(robot_dict['name'], robot_dict['token'])
|
||||
robots[robot_name] = Robot(robot_dict['name'], robot_dict['token'], robot_dict['created'])
|
||||
if include_permissions:
|
||||
team_name = robot_tuple.get(TeamTable.name)
|
||||
repository_name = robot_tuple.get(Repository.name)
|
||||
|
@ -48,40 +49,41 @@ class RobotPreOCIModel(RobotInterface):
|
|||
if repository_name is not None:
|
||||
if repository_name not in robot_dict['repositories']:
|
||||
robot_dict['repositories'].append(repository_name)
|
||||
robots[robot_name] = RobotWithPermissions(robot_dict['name'], robot_dict['token'], robot_dict['teams'],
|
||||
robots[robot_name] = RobotWithPermissions(robot_dict['name'], robot_dict['token'],
|
||||
robot_dict['created'], robot_dict['teams'],
|
||||
robot_dict['repositories'])
|
||||
|
||||
return robots.values()
|
||||
|
||||
def regenerate_user_robot_token(self, robot_shortname, owning_user):
|
||||
robot, password = model.user.regenerate_robot_token(robot_shortname, owning_user)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
def regenerate_org_robot_token(self, robot_shortname, orgname):
|
||||
parent = model.organization.get_organization(orgname)
|
||||
robot, password = model.user.regenerate_robot_token(robot_shortname, parent)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
def delete_robot(self, robot_username):
|
||||
model.user.delete_robot(robot_username)
|
||||
|
||||
def create_user_robot(self, robot_shortname, owning_user):
|
||||
robot, password = model.user.create_robot(robot_shortname, owning_user)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
def create_org_robot(self, robot_shortname, orgname):
|
||||
parent = model.organization.get_organization(orgname)
|
||||
robot, password = model.user.create_robot(robot_shortname, parent)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
def get_org_robot(self, robot_shortname, orgname):
|
||||
parent = model.organization.get_organization(orgname)
|
||||
robot, password = model.user.get_robot(robot_shortname, parent)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
def get_user_robot(self, robot_shortname, owning_user):
|
||||
robot, password = model.user.get_robot(robot_shortname, owning_user)
|
||||
return Robot(robot.username, password)
|
||||
return Robot(robot.username, password, robot.creation_date)
|
||||
|
||||
|
||||
pre_oci_model = RobotPreOCIModel()
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
<a ng-click="TableService.orderBy('teams_string', options)">Teams</a>
|
||||
</td>
|
||||
<td>Repositories</td>
|
||||
<td ng-class="TableService.tablePredicateClass('created_datetime', options.predicate, options.reverse)">
|
||||
<a ng-click="TableService.orderBy('created_datetime', options)">Created</a>
|
||||
</td>
|
||||
<td class="options-col"></td>
|
||||
</thead>
|
||||
|
||||
|
@ -78,6 +81,9 @@
|
|||
</a>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<time-ago datetime="robotInfo.created"></time-ago>
|
||||
</td>
|
||||
<td class="options-col">
|
||||
<span class="cor-options-menu">
|
||||
<span class="cor-option" option-click="showRobot(robotInfo)">
|
||||
|
|
|
@ -39,6 +39,8 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
robot['teams_string'] = robot.teams.map(function(team) {
|
||||
return team['name'] || '';
|
||||
}).join(',');
|
||||
|
||||
robot['created_datetime'] = robot.created ? TableService.getReversedTimestamp(robot.created) : null;
|
||||
});
|
||||
|
||||
$scope.orderedRobots = TableService.buildOrderedItems(robots, $scope.options,
|
||||
|
|
Reference in a new issue