Commit 0c8fc223 by Őry Máté

Merge branch 'feature-timeline-icons' into 'master'

Feature Timeline Icons
parents 50bdf11a df43baaa
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
{% block content %} {% block content %}
<div class="body-content"> <div class="body-content">
<div class="page-header"> <div class="page-header">
<h1> <h1><i class="fa fa-{{icon}}"></i>
{{ object.instance.name }}: {{ object.instance.name }}:
{% if user.is_superuser %} {% if user.is_superuser %}
{{object.readable_name.get_admin_text}} {{object.readable_name.get_admin_text}}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% for a in activities %} {% for a in activities %}
<div class="activity{% if a.pk == active.pk %} activity-active{%endif%}" data-activity-id="{{ a.pk }}"> <div class="activity{% if a.pk == active.pk %} activity-active{%endif%}" data-activity-id="{{ a.pk }}">
<span class="timeline-icon{% if a.has_failed %} timeline-icon-failed{% endif %}"> <span class="timeline-icon{% if a.has_failed %} timeline-icon-failed{% endif %}">
<i class="fa {% if not a.finished %}fa-refresh fa-spin {% else %}fa-plus{% endif %}"></i> <i class="fa {% if not a.finished %}fa-refresh fa-spin {% else %}fa-{{a.icon}}{% endif %}"></i>
</span> </span>
<strong{% if a.result %} title="{{ a.result.get_user_text }}"{% endif %}> <strong{% if a.result %} title="{{ a.result.get_user_text }}"{% endif %}>
<a href="{{ a.get_absolute_url }}"> <a href="{{ a.get_absolute_url }}">
......
...@@ -309,7 +309,7 @@ class VmDetailView(CheckedDetailView): ...@@ -309,7 +309,7 @@ class VmDetailView(CheckedDetailView):
activities = instance.get_merged_activities(user) activities = instance.get_merged_activities(user)
show_show_all = len(activities) > 10 show_show_all = len(activities) > 10
activities = activities[:10] activities = activities[:10]
context['activities'] = activities context['activities'] = _format_activities(activities)
context['show_show_all'] = show_show_all context['show_show_all'] = show_show_all
latest = instance.get_latest_activity_in_progress() latest = instance.get_latest_activity_in_progress()
context['is_new_state'] = (latest and context['is_new_state'] = (latest and
...@@ -2501,7 +2501,8 @@ def vm_activity(request, pk): ...@@ -2501,7 +2501,8 @@ def vm_activity(request, pk):
response = {} response = {}
show_all = request.GET.get("show_all", "false") == "true" show_all = request.GET.get("show_all", "false") == "true"
activities = instance.get_merged_activities(request.user) activities = _format_activities(
instance.get_merged_activities(request.user))
show_show_all = len(activities) > 10 show_show_all = len(activities) > 10
if not show_all: if not show_all:
activities = activities[:10] activities = activities[:10]
...@@ -2958,6 +2959,20 @@ def get_disk_download_status(request, pk): ...@@ -2958,6 +2959,20 @@ def get_disk_download_status(request, pk):
) )
def _get_activity_icon(act):
op = act.get_operation()
if op and op.id in vm_ops:
return vm_ops[op.id].icon
else:
return "cog"
def _format_activities(acts):
for i in acts:
i.icon = _get_activity_icon(i)
return acts
class InstanceActivityDetail(CheckedDetailView): class InstanceActivityDetail(CheckedDetailView):
model = InstanceActivity model = InstanceActivity
context_object_name = 'instanceactivity' # much simpler to mock object context_object_name = 'instanceactivity' # much simpler to mock object
...@@ -2968,8 +2983,9 @@ class InstanceActivityDetail(CheckedDetailView): ...@@ -2968,8 +2983,9 @@ class InstanceActivityDetail(CheckedDetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
ctx = super(InstanceActivityDetail, self).get_context_data(**kwargs) ctx = super(InstanceActivityDetail, self).get_context_data(**kwargs)
ctx['activities'] = self.object.instance.get_activities( ctx['activities'] = _format_activities(
self.request.user) self.object.instance.get_activities(self.request.user))
ctx['icon'] = _get_activity_icon(self.object)
return ctx return ctx
......
...@@ -190,6 +190,10 @@ class InstanceActivity(ActivityModel): ...@@ -190,6 +190,10 @@ class InstanceActivity(ActivityModel):
readable_name=readable_name) readable_name=readable_name)
return activitycontextimpl(act, on_abort=on_abort, on_commit=on_commit) return activitycontextimpl(act, on_abort=on_abort, on_commit=on_commit)
def get_operation(self):
return self.instance.get_operation_from_activity_code(
self.activity_code)
@contextmanager @contextmanager
def instance_activity(code_suffix, instance, on_abort=None, on_commit=None, def instance_activity(code_suffix, instance, on_abort=None, on_commit=None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment