Skip to content

Commit

Permalink
INTECH-596 add searching and sorting flags on frontend side
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostya Intsyn committed Aug 21, 2023
1 parent 138096c commit 5c55453
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
9 changes: 8 additions & 1 deletion its_on/admin/views/switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ class SwitchListAdminView(web.View):
async def get(self) -> Dict[str, Union[Optional[List[RowProxy]], bool]]:
request_params = self.validator.load(data=self.request.query)
flags = await self.get_response_data(request_params)
# Move to dict because it's Raw
flag_dicts = []
for flag in flags:
flag_dicts.append({
**dict(flag),
"estimate_at": flag.created_at + datetime.timedelta(days=flag.ttl),
})
groups = await self.get_distinct_groups(request_params)
return {
'active_group': request_params.get('group'),
'flags': flags,
'flags': flag_dicts,
'groups': groups,
'show_copy_button': bool(settings.SYNC_FROM_ITS_ON_URL),
}
Expand Down
2 changes: 2 additions & 0 deletions its_on/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/js/select2.min.js"></script>
<link href="https://unpkg.com/[email protected]/dist/bootstrap-table.min.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/bootstrap-table.min.js"></script>
{% endblock %}
</head>
<body>
Expand Down
34 changes: 23 additions & 11 deletions its_on/templates/switches/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ <h2>Switches list</h2>
</div>

<div class="col-sm-9">
<table class="table table-striped">
<table class="table table-striped"
id="table"
data-toggle="table"
data-search="true"
>
<thead>
<tr>
<th>Switch name</th>
<th>Active</th>
<th>Groups</th>
<th>TTL</th>
<th>Created at</th>
<th>Updated at</th>
<th>Deleted at</th>
<th data-field="id">Switch name</th>
<th data-field="is_active" data-sortable="true">Active</th>
<th data-field="groups">Groups</th>
<th data-field="ttl" data-sortable="true">TTL</th>
<th data-field="create_at" data-sortable="true">Created at</th>
<th data-field="updated_at" data-sortable="true">Updated at</th>
<th data-field="estimated_at" data-sortable="true">Estimated at</th>
<th data-field="deleted_at" data-sortable="true">Deleted at</th>
</tr>
</thead>
<tbody>
Expand All @@ -65,21 +70,28 @@ <h2>Switches list</h2>
</td>
<td>
{% if flag.created_at %}
{{ flag.created_at.strftime('%d-%m-%Y %H:%M:%S') }}
{{ flag.created_at.strftime('%d-%m-%Y') }}
{% else %}
-
{% endif %}
</td>
<td>
{% if flag.updated_at %}
{{ flag.updated_at.strftime('%d-%m-%Y %H:%M:%S') }}
{{ flag.updated_at.strftime('%d-%m-%Y') }}
{% else %}
-
{% endif %}
</td>
<td>
{% if flag.estimate_at %}
{{ flag.estimate_at.strftime('%d-%m-%Y') }}
{% else %}
-
{% endif %}
</td>
<td>
{% if flag.deleted_at %}
{{ flag.deleted_at.strftime('%d-%m-%Y %H:%M:%S') }}
{{ flag.deleted_at.strftime('%d-%m-%Y') }}
{% else %}
-
{% endif %}
Expand Down

0 comments on commit 5c55453

Please sign in to comment.