Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b6c37cb
authored
Jul 28, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feauture-less-activity' into 'master'
Feauture Less Activity
parents
f9f4c6a3
1c6676e1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
50 deletions
+92
-50
circle/dashboard/static/dashboard/dashboard.css
+4
-0
circle/dashboard/static/dashboard/vm-details.js
+35
-21
circle/dashboard/templates/dashboard/instanceactivity_detail.html
+5
-5
circle/dashboard/templates/dashboard/vm-detail/_activity-timeline.html
+18
-2
circle/dashboard/templates/dashboard/vm-detail/activity.html
+1
-1
circle/dashboard/views.py
+29
-21
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
4b6c37cb
...
@@ -751,3 +751,7 @@ textarea[name="list-new-namelist"] {
...
@@ -751,3 +751,7 @@ textarea[name="list-new-namelist"] {
#group-detail-permissions
input
[
type
=
"submit"
]
{
#group-detail-permissions
input
[
type
=
"submit"
]
{
margin-top
:
-6px
;
margin-top
:
-6px
;
}
}
#show-all-activities-container
{
margin
:
20px
0
0
10px
;
}
circle/dashboard/static/dashboard/vm-details.js
View file @
4b6c37cb
var
show_all
=
false
;
var
in_progress
=
false
;
$
(
function
()
{
$
(
function
()
{
/* do we need to check for new activities */
/* do we need to check for new activities */
if
(
decideActivityRefresh
())
{
if
(
decideActivityRefresh
())
{
checkNewActivity
(
false
,
1
);
if
(
!
in_progress
)
{
checkNewActivity
(
1
);
in_progress
=
true
;
}
}
}
$
(
'a[href="#activity"]'
).
click
(
function
(){
$
(
'a[href="#activity"]'
).
click
(
function
(){
$
(
'a[href="#activity"] i'
).
addClass
(
'fa-spin'
);
$
(
'a[href="#activity"] i'
).
addClass
(
'fa-spin'
);
checkNewActivity
(
false
,
1
);
if
(
!
in_progress
)
{
checkNewActivity
(
1
);
in_progress
=
true
;
}
});
$
(
"#activity-refresh"
).
on
(
"click"
,
"#show-all-activities"
,
function
()
{
$
(
this
).
find
(
"i"
).
addClass
(
"fa-spinner fa-spin"
);
show_all
=
!
show_all
;
$
(
'a[href="#activity"]'
).
trigger
(
"click"
);
return
false
;
});
});
/* save resources */
/* save resources */
...
@@ -134,11 +151,6 @@ $(function() {
...
@@ -134,11 +151,6 @@ $(function() {
return
false
;
return
false
;
});
});
/* show help */
$
(
".vm-details-help-button"
).
click
(
function
()
{
$
(
".vm-details-help"
).
stop
().
slideToggle
();
});
/* for interface remove buttons */
/* for interface remove buttons */
$
(
'.interface-remove'
).
click
(
function
()
{
$
(
'.interface-remove'
).
click
(
function
()
{
var
interface_pk
=
$
(
this
).
data
(
'interface-pk'
);
var
interface_pk
=
$
(
this
).
data
(
'interface-pk'
);
...
@@ -320,12 +332,12 @@ function removePort(data) {
...
@@ -320,12 +332,12 @@ function removePort(data) {
function
decideActivityRefresh
()
{
function
decideActivityRefresh
()
{
var
check
=
false
;
var
check
=
false
;
/* if something is still spinning */
/* if something is still spinning */
if
(
$
(
'.timeline .activity
:first i:first
'
).
hasClass
(
'fa-spin'
))
if
(
$
(
'.timeline .activity
i
'
).
hasClass
(
'fa-spin'
))
check
=
true
;
check
=
true
;
/* if there is only one activity */
/* if there is only one activity */
if
(
$
(
'#activity-timeline div[class="activity"]'
).
length
<
2
)
if
(
$
(
'#activity-timeline div[class="activity"]'
).
length
<
2
)
check
=
true
;
check
=
true
;
return
check
;
return
check
;
}
}
...
@@ -340,25 +352,25 @@ function changeHTML(html) {
...
@@ -340,25 +352,25 @@ function changeHTML(html) {
return
html
.
replace
(
/data-original-title/g
,
"title"
).
replace
(
/title=""/g
,
""
).
replace
(
/
\/
/g
,
''
).
replace
(
/ /g
,
''
);
return
html
.
replace
(
/data-original-title/g
,
"title"
).
replace
(
/title=""/g
,
""
).
replace
(
/
\/
/g
,
''
).
replace
(
/ /g
,
''
);
}
}
function
checkNewActivity
(
only_status
,
runs
)
{
function
checkNewActivity
(
runs
)
{
// set default only_status to false
only_status
=
typeof
only_status
!==
'undefined'
?
only_status
:
false
;
var
instance
=
location
.
href
.
split
(
'/'
);
instance
=
instance
[
instance
.
length
-
2
];
var
instance
=
location
.
href
.
split
(
'/'
);
instance
=
instance
[
instance
.
length
-
2
];
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
'/dashboard/vm/'
+
instance
+
'/activity/'
,
url
:
'/dashboard/vm/'
+
instance
+
'/activity/'
,
data
:
{
'
only_status'
:
only_status
},
data
:
{
'
show_all'
:
show_all
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
!
only_status
)
{
if
(
show_all
)
{
/* replace on longer string freezes the spinning stuff */
$
(
"#activity-refresh"
).
html
(
data
[
'activities'
]);
}
else
{
a
=
unescapeHTML
(
data
[
'activities'
]);
a
=
unescapeHTML
(
data
[
'activities'
]);
b
=
changeHTML
(
$
(
"#activity-
timeline
"
).
html
());
b
=
changeHTML
(
$
(
"#activity-
refresh
"
).
html
());
if
(
a
!=
b
)
if
(
a
!=
b
)
$
(
"#activity-timeline"
).
html
(
data
[
'activities'
]);
$
(
"#activity-refresh"
).
html
(
data
[
'activities'
]);
$
(
"#ops"
).
html
(
data
[
'ops'
]);
$
(
"#disk-ops"
).
html
(
data
[
'disk_ops'
]);
$
(
"[title]"
).
tooltip
();
}
}
$
(
"#ops"
).
html
(
data
[
'ops'
]);
$
(
"#disk-ops"
).
html
(
data
[
'disk_ops'
]);
$
(
"[title]"
).
tooltip
();
$
(
"#vm-details-state i"
).
prop
(
"class"
,
"fa "
+
data
[
'icon'
]);
$
(
"#vm-details-state i"
).
prop
(
"class"
,
"fa "
+
data
[
'icon'
]);
$
(
"#vm-details-state span"
).
html
(
data
[
'human_readable_status'
].
toUpperCase
());
$
(
"#vm-details-state span"
).
html
(
data
[
'human_readable_status'
].
toUpperCase
());
...
@@ -378,14 +390,16 @@ function checkNewActivity(only_status, runs) {
...
@@ -378,14 +390,16 @@ function checkNewActivity(only_status, runs) {
if
(
runs
>
0
&&
decideActivityRefresh
())
{
if
(
runs
>
0
&&
decideActivityRefresh
())
{
setTimeout
(
setTimeout
(
function
()
{
checkNewActivity
(
only_status
,
runs
+
1
)},
function
()
{
checkNewActivity
(
runs
+
1
)},
1000
+
Math
.
exp
(
runs
*
0.05
)
1000
+
Math
.
exp
(
runs
*
0.05
)
);
);
}
else
{
in_progress
=
false
;
}
}
$
(
'a[href="#activity"] i'
).
removeClass
(
'fa-spin'
);
$
(
'a[href="#activity"] i'
).
removeClass
(
'fa-spin'
);
},
},
error
:
function
()
{
error
:
function
()
{
in_progress
=
false
;
}
}
});
});
}
}
circle/dashboard/templates/dashboard/instanceactivity_detail.html
View file @
4b6c37cb
...
@@ -14,17 +14,17 @@
...
@@ -14,17 +14,17 @@
</h1>
</h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-
4
"
id=
"vm-info-pane"
>
<div
class=
"col-md-
5
"
id=
"vm-info-pane"
>
<div
class=
"big"
>
<div
class=
"big"
>
<span
id=
"vm-activity-state"
class=
"label label-{% if object.get_status_id == 'wait' %}info{% else %}{% if object.succeeded %}success{% else %}error{% endif %}{% endif %}"
>
<span
id=
"vm-activity-state"
class=
"label label-{% if object.get_status_id == 'wait' %}info{% else %}{% if object.succeeded %}success{% else %}error{% endif %}{% endif %}"
>
<span>
{{ object.get_status_id|upper }}
</span>
<span>
{{ object.get_status_id|upper }}
</span>
</span>
</span>
</div>
</div>
<div
id=
"vm-activity-context"
class=
"timeline"
>
{% include "dashboard/vm-detail/_activity-timeline.html" with active=object %}
{% include "dashboard/vm-detail/_activity-timeline.html" with active=object %}
</div>
</div>
</div>
<div
class=
"col-md-
8
"
>
<div
class=
"col-md-
7
"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel panel-default"
>
<!--<div class="panel-heading"><h2 class="panel-title">{% trans "Activity" %}</h2></div> -->
<!--<div class="panel-heading"><h2 class="panel-title">{% trans "Activity" %}</h2></div> -->
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
...
...
circle/dashboard/templates/dashboard/vm-detail/_activity-timeline.html
View file @
4b6c37cb
{% load i18n %}
{% load i18n %}
<div
id=
"activity-timeline"
class=
"timeline"
>
{% 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 %}"
>
...
@@ -7,7 +10,7 @@
...
@@ -7,7 +10,7 @@
<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 }}"
>
{% if a.times > 1 %}({{ a.times }}x){% endif %}
{% if a.times > 1 %}({{ a.times }}x){% endif %}
{{ a.readable_name.get_user_text }}
</a>
{{ a.readable_name.get_user_text
|capfirst
}}
</a>
{% if a.has_percent %}
{% if a.has_percent %}
- {{ a.percentage }}%
- {{ a.percentage }}%
...
@@ -32,7 +35,7 @@
...
@@ -32,7 +35,7 @@
<div
data-activity-id=
"{{ s.pk }}"
class=
"sub-activity{% if s.has_failed %} sub-activity-failed{% endif %}{% if s.pk == active.pk %} sub-activity-active{% endif %}"
>
<div
data-activity-id=
"{{ s.pk }}"
class=
"sub-activity{% if s.has_failed %} sub-activity-failed{% endif %}{% if s.pk == active.pk %} sub-activity-active{% endif %}"
>
<span
{%
if
s
.
result
%}
title=
"{{ s.result.get_user_text }}"
{%
endif
%}
>
<span
{%
if
s
.
result
%}
title=
"{{ s.result.get_user_text }}"
{%
endif
%}
>
<a
href=
"{{ s.get_absolute_url }}"
>
<a
href=
"{{ s.get_absolute_url }}"
>
{{ s.readable_name.get_user_text }}
</a></span>
–
{{ s.readable_name.get_user_text
|capfirst
}}
</a></span>
–
{% if s.finished %}
{% if s.finished %}
{{ s.finished|time:"H:i:s" }}
{{ s.finished|time:"H:i:s" }}
{% else %}
{% else %}
...
@@ -47,3 +50,16 @@
...
@@ -47,3 +50,16 @@
{% endif %}
{% endif %}
</div>
</div>
{% endfor %}
{% endfor %}
</div>
{% if show_show_all %}
<div
id=
"show-all-activities-container"
>
<a
id=
"show-all-activities"
href=
"#"
>
{% if activities|length > 10 %}
{% trans "Show less activities" %}
<i
class=
"fa fa-angle-double-up"
></i>
{% else %}
{% trans "Show all activities" %}
<i
class=
"fa fa-angle-double-down"
></i>
{% endif %}
</a>
</div>
{% endif %}
circle/dashboard/templates/dashboard/vm-detail/activity.html
View file @
4b6c37cb
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
<h3>
{% trans "Activity" %}
</h3>
<h3>
{% trans "Activity" %}
</h3>
<div
id=
"activity-
timeline"
class=
"timeline
"
>
<div
id=
"activity-
refresh
"
>
{% include "dashboard/vm-detail/_activity-timeline.html" %}
{% include "dashboard/vm-detail/_activity-timeline.html" %}
</div>
</div>
circle/dashboard/views.py
View file @
4b6c37cb
...
@@ -275,8 +275,11 @@ class VmDetailView(CheckedDetailView):
...
@@ -275,8 +275,11 @@ class VmDetailView(CheckedDetailView):
})
})
# activity data
# activity data
context
[
'activities'
]
=
self
.
object
.
get_merged_activities
(
activities
=
instance
.
get_merged_activities
(
self
.
request
.
user
)
self
.
request
.
user
)
show_show_all
=
len
(
activities
)
>
10
activities
=
activities
[:
10
]
context
[
'activities'
]
=
activities
context
[
'show_show_all'
]
=
show_show_all
context
[
'vlans'
]
=
Vlan
.
get_objects_with_level
(
context
[
'vlans'
]
=
Vlan
.
get_objects_with_level
(
'user'
,
self
.
request
.
user
'user'
,
self
.
request
.
user
...
@@ -2429,30 +2432,35 @@ def vm_activity(request, pk):
...
@@ -2429,30 +2432,35 @@ def vm_activity(request, pk):
raise
PermissionDenied
()
raise
PermissionDenied
()
response
=
{}
response
=
{}
only_status
=
request
.
GET
.
get
(
"only_status"
,
"false"
)
show_all
=
request
.
GET
.
get
(
"show_all"
,
"false"
)
==
"true"
activities
=
instance
.
get_merged_activities
(
request
.
user
)
show_show_all
=
len
(
activities
)
>
10
if
not
show_all
:
activities
=
activities
[:
10
]
response
[
'human_readable_status'
]
=
instance
.
get_status_display
()
response
[
'human_readable_status'
]
=
instance
.
get_status_display
()
response
[
'status'
]
=
instance
.
status
response
[
'status'
]
=
instance
.
status
response
[
'icon'
]
=
instance
.
get_status_icon
()
response
[
'icon'
]
=
instance
.
get_status_icon
()
if
only_status
==
"false"
:
# instance activity
context
=
{
'instance'
:
instance
,
'activities'
:
instance
.
get_merged_activities
(
request
.
user
),
'ops'
:
get_operations
(
instance
,
request
.
user
),
}
response
[
'activities'
]
=
render_to_string
(
context
=
{
"dashboard/vm-detail/_activity-timeline.html"
,
'instance'
:
instance
,
RequestContext
(
request
,
context
),
'activities'
:
activities
,
)
'show_show_all'
:
show_show_all
,
response
[
'ops'
]
=
render_to_string
(
'ops'
:
get_operations
(
instance
,
request
.
user
),
"dashboard/vm-detail/_operations.html"
,
}
RequestContext
(
request
,
context
),
)
response
[
'activities'
]
=
render_to_string
(
response
[
'disk_ops'
]
=
render_to_string
(
"dashboard/vm-detail/_activity-timeline.html"
,
"dashboard/vm-detail/_disk-operations.html"
,
RequestContext
(
request
,
context
),
RequestContext
(
request
,
context
),
)
)
response
[
'ops'
]
=
render_to_string
(
"dashboard/vm-detail/_operations.html"
,
RequestContext
(
request
,
context
),
)
response
[
'disk_ops'
]
=
render_to_string
(
"dashboard/vm-detail/_disk-operations.html"
,
RequestContext
(
request
,
context
),
)
return
HttpResponse
(
return
HttpResponse
(
json
.
dumps
(
response
),
json
.
dumps
(
response
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment