Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6cb335d7
authored
Sep 01, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix js code style
parent
411a478b
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
227 additions
and
228 deletions
+227
-228
circle/dashboard/static/dashboard/dashboard.js
+96
-95
circle/dashboard/static/dashboard/disk-list.js
+4
-4
circle/dashboard/static/dashboard/group-details.js
+4
-4
circle/dashboard/static/dashboard/group-list.js
+4
-4
circle/dashboard/static/dashboard/node-details.js
+10
-10
circle/dashboard/static/dashboard/node-list.js
+10
-12
circle/dashboard/static/dashboard/profile.js
+2
-2
circle/dashboard/static/dashboard/store.js
+3
-3
circle/dashboard/static/dashboard/template-list.js
+14
-14
circle/dashboard/static/dashboard/vm-common.js
+1
-1
circle/dashboard/static/dashboard/vm-console.js
+3
-3
circle/dashboard/static/dashboard/vm-create.js
+20
-20
circle/dashboard/static/dashboard/vm-details.js
+41
-41
circle/dashboard/static/dashboard/vm-list.js
+8
-8
circle/dashboard/static/dashboard/vm-tour.js
+7
-7
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
6cb335d7
...
@@ -3,8 +3,8 @@ $(function () {
...
@@ -3,8 +3,8 @@ $(function () {
var
template
=
$
(
this
).
data
(
"template"
);
var
template
=
$
(
this
).
data
(
"template"
);
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
'/dashboard/vm/create/'
+
(
typeof
template
===
"undefined"
?
''
:
'?template='
+
template
),
url
:
'/dashboard/vm/create/'
+
(
typeof
template
===
"undefined"
?
''
:
'?template='
+
template
),
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
vmCreateLoaded
();
vmCreateLoaded
();
addSliderMiscs
();
addSliderMiscs
();
...
@@ -16,12 +16,12 @@ $(function () {
...
@@ -16,12 +16,12 @@ $(function () {
});
});
return
false
;
return
false
;
});
});
$
(
'.node-create'
).
click
(
function
(
e
)
{
$
(
'.node-create'
).
click
(
function
(
e
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
'/dashboard/node/create/'
,
url
:
'/dashboard/node/create/'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
nodeCreateLoaded
();
nodeCreateLoaded
();
addSliderMiscs
();
addSliderMiscs
();
...
@@ -53,8 +53,8 @@ $(function () {
...
@@ -53,8 +53,8 @@ $(function () {
$
(
'.template-choose'
).
click
(
function
(
e
)
{
$
(
'.template-choose'
).
click
(
function
(
e
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
'/dashboard/template/choose/'
,
url
:
'/dashboard/template/choose/'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
...
@@ -154,7 +154,7 @@ $(function () {
...
@@ -154,7 +154,7 @@ $(function () {
$
(
'.vm-delete'
).
click
(
function
()
{
$
(
'.vm-delete'
).
click
(
function
()
{
var
vm_pk
=
$
(
this
).
data
(
'vm-pk'
);
var
vm_pk
=
$
(
this
).
data
(
'vm-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/vm/delete/'
+
vm_pk
+
'/'
,
{
'url'
:
'/dashboard/vm/delete/'
+
vm_pk
+
'/'
,
'data'
:
[],
'data'
:
[],
'pk'
:
vm_pk
,
'pk'
:
vm_pk
,
...
@@ -162,11 +162,11 @@ $(function () {
...
@@ -162,11 +162,11 @@ $(function () {
'redirect'
:
dir
});
'redirect'
:
dir
});
return
false
;
return
false
;
});
});
/* for disk remove buttons */
/* for disk remove buttons */
$
(
'.disk-remove'
).
click
(
function
()
{
$
(
'.disk-remove'
).
click
(
function
()
{
var
disk_pk
=
$
(
this
).
data
(
'disk-pk'
);
var
disk_pk
=
$
(
this
).
data
(
'disk-pk'
);
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/disk/'
+
disk_pk
+
'/remove/'
,
{
'url'
:
'/dashboard/disk/'
+
disk_pk
+
'/remove/'
,
'data'
:
[],
'data'
:
[],
'pk'
:
disk_pk
,
'pk'
:
disk_pk
,
...
@@ -179,13 +179,13 @@ $(function () {
...
@@ -179,13 +179,13 @@ $(function () {
$
(
'.node-delete'
).
click
(
function
()
{
$
(
'.node-delete'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/node/delete/'
+
node_pk
+
'/'
,
{
'url'
:
'/dashboard/node/delete/'
+
node_pk
+
'/'
,
'data'
:
[],
'data'
:
[],
'pk'
:
node_pk
,
'pk'
:
node_pk
,
'type'
:
"node"
,
'type'
:
"node"
,
'redirect'
:
dir
});
'redirect'
:
dir
});
return
false
;
return
false
;
});
});
...
@@ -194,8 +194,8 @@ $(function () {
...
@@ -194,8 +194,8 @@ $(function () {
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
postto
=
$
(
this
).
attr
(
'href'
);
var
postto
=
$
(
this
).
attr
(
'href'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
function
(){},
addModalConfirmation
(
function
(){},
{
'url'
:
postto
,
{
'url'
:
postto
,
'data'
:
[],
'data'
:
[],
'pk'
:
node_pk
,
'pk'
:
node_pk
,
'type'
:
"node"
,
'type'
:
"node"
,
...
@@ -208,18 +208,18 @@ $(function () {
...
@@ -208,18 +208,18 @@ $(function () {
$
(
'.group-delete'
).
click
(
function
()
{
$
(
'.group-delete'
).
click
(
function
()
{
var
group_pk
=
$
(
this
).
data
(
'group-pk'
);
var
group_pk
=
$
(
this
).
data
(
'group-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/group/delete/'
+
group_pk
+
'/'
,
{
'url'
:
'/dashboard/group/delete/'
+
group_pk
+
'/'
,
'data'
:
[],
'data'
:
[],
'type'
:
"group"
,
'type'
:
"group"
,
'pk'
:
group_pk
,
'pk'
:
group_pk
,
'redirect'
:
dir
});
'redirect'
:
dir
});
return
false
;
return
false
;
});
});
/* search for vms */
/* search for vms */
var
my_vms
=
[]
var
my_vms
=
[]
;
$
(
"#dashboard-vm-search-input"
).
keyup
(
function
(
e
)
{
$
(
"#dashboard-vm-search-input"
).
keyup
(
function
(
e
)
{
// if my_vms is empty get a list of our vms
// if my_vms is empty get a list of our vms
if
(
my_vms
.
length
<
1
)
{
if
(
my_vms
.
length
<
1
)
{
...
@@ -241,7 +241,7 @@ $(function () {
...
@@ -241,7 +241,7 @@ $(function () {
}
}
input
=
$
(
"#dashboard-vm-search-input"
).
val
().
toLowerCase
();
input
=
$
(
"#dashboard-vm-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
var
html
=
''
;
for
(
var
i
in
my_vms
)
{
for
(
var
i
in
my_vms
)
{
if
(
my_vms
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
if
(
my_vms
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
...
@@ -249,12 +249,12 @@ $(function () {
...
@@ -249,12 +249,12 @@ $(function () {
}
}
}
}
search_result
.
sort
(
compareVmByFav
);
search_result
.
sort
(
compareVmByFav
);
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
for
(
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
search_result
[
i
].
host
,
search_result
[
i
].
icon
,
search_result
[
i
].
host
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
fav
,
search_result
[
i
].
status
,
search_result
[
i
].
fav
,
(
search_result
.
length
<
5
));
(
search_result
.
length
<
5
));
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
=
0
)
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
$
(
"#dashboard-vm-list"
).
html
(
html
);
$
(
"#dashboard-vm-list"
).
html
(
html
);
$
(
'.title-favourite'
).
tooltip
({
'placement'
:
'right'
});
$
(
'.title-favourite'
).
tooltip
({
'placement'
:
'right'
});
...
@@ -270,7 +270,7 @@ $(function () {
...
@@ -270,7 +270,7 @@ $(function () {
});
});
/* search for nodes */
/* search for nodes */
var
my_nodes
=
[]
var
my_nodes
=
[]
;
$
(
"#dashboard-node-search-input"
).
keyup
(
function
(
e
)
{
$
(
"#dashboard-node-search-input"
).
keyup
(
function
(
e
)
{
// if my_nodes is empty get a list of our nodes
// if my_nodes is empty get a list of our nodes
if
(
my_nodes
.
length
<
1
)
{
if
(
my_nodes
.
length
<
1
)
{
...
@@ -290,29 +290,29 @@ $(function () {
...
@@ -290,29 +290,29 @@ $(function () {
}
}
input
=
$
(
"#dashboard-node-search-input"
).
val
().
toLowerCase
();
input
=
$
(
"#dashboard-node-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
var
html
=
''
;
for
(
var
i
in
my_nodes
)
{
for
(
var
i
in
my_nodes
)
{
if
(
my_nodes
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
if
(
my_nodes
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
search_result
.
push
(
my_nodes
[
i
]);
search_result
.
push
(
my_nodes
[
i
]);
}
}
}
}
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
for
(
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateNodeHTML
(
search_result
[
i
].
name
,
html
+=
generateNodeHTML
(
search_result
[
i
].
name
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
url
,
search_result
[
i
].
url
,
(
search_result
.
length
<
5
));
(
search_result
.
length
<
5
));
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
=
0
)
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
$
(
"#dashboard-node-list"
).
html
(
html
);
$
(
"#dashboard-node-list"
).
html
(
html
);
html
=
''
;
html
=
''
;
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
for
(
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateNodeTagHTML
(
search_result
[
i
].
name
,
html
+=
generateNodeTagHTML
(
search_result
[
i
].
name
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
label
,
search_result
[
i
].
url
);
search_result
[
i
].
label
,
search_result
[
i
].
url
);
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
=
0
)
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
html
+=
'<div class="list-group-item list-group-item-last">'
+
gettext
(
"No result"
)
+
'</div>'
;
$
(
"#dashboard-node-taglist"
).
html
(
html
);
$
(
"#dashboard-node-taglist"
).
html
(
html
);
...
@@ -326,7 +326,7 @@ $(function () {
...
@@ -326,7 +326,7 @@ $(function () {
});
});
/* search for groups */
/* search for groups */
var
my_groups
=
[]
var
my_groups
=
[]
;
$
(
"#dashboard-group-search-input"
).
keyup
(
function
(
e
)
{
$
(
"#dashboard-group-search-input"
).
keyup
(
function
(
e
)
{
// if my_groups is empty get a list of our groups
// if my_groups is empty get a list of our groups
if
(
my_groups
.
length
<
1
)
{
if
(
my_groups
.
length
<
1
)
{
...
@@ -343,16 +343,16 @@ $(function () {
...
@@ -343,16 +343,16 @@ $(function () {
}
}
input
=
$
(
"#dashboard-group-search-input"
).
val
().
toLowerCase
();
input
=
$
(
"#dashboard-group-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
var
html
=
''
;
for
(
var
i
in
my_groups
)
{
for
(
var
i
in
my_groups
)
{
if
(
my_groups
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
if
(
my_groups
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
search_result
.
push
(
my_groups
[
i
]);
search_result
.
push
(
my_groups
[
i
]);
}
}
}
}
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
for
(
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateGroupHTML
(
search_result
[
i
].
url
,
search_result
[
i
].
name
,
search_result
.
length
<
5
);
html
+=
generateGroupHTML
(
search_result
[
i
].
url
,
search_result
[
i
].
name
,
search_result
.
length
<
5
);
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
=
0
)
html
+=
'<div class="list-group-item list-group-item-last">No result</div>'
;
html
+=
'<div class="list-group-item list-group-item-last">No result</div>'
;
$
(
"#dashboard-group-list"
).
html
(
html
);
$
(
"#dashboard-group-list"
).
html
(
html
);
...
@@ -374,30 +374,30 @@ $(function () {
...
@@ -374,30 +374,30 @@ $(function () {
/* don't close notifications window on missclick */
/* don't close notifications window on missclick */
$
(
document
).
on
(
"click"
,
".notification-messages"
,
function
(
e
)
{
$
(
document
).
on
(
"click"
,
".notification-messages"
,
function
(
e
)
{
if
(
$
(
e
.
target
).
closest
(
"a"
).
length
)
if
(
$
(
e
.
target
).
closest
(
"a"
).
length
)
return
true
return
true
;
else
else
return
false
;
return
false
;
});
});
$
(
"#notification-button a"
).
click
(
function
()
{
$
(
"#notification-button a"
).
click
(
function
()
{
$
(
'.notification-messages'
).
load
(
"/dashboard/notifications/"
);
$
(
'.notification-messages'
).
load
(
"/dashboard/notifications/"
);
$
(
'#notification-button a span[class*="badge-pulse"]'
).
remove
();
$
(
'#notification-button a span[class*="badge-pulse"]'
).
remove
();
});
});
});
});
function
generateVmHTML
(
pk
,
name
,
host
,
icon
,
_status
,
fav
,
is_last
)
{
function
generateVmHTML
(
pk
,
name
,
host
,
icon
,
_status
,
fav
,
is_last
)
{
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item'
+
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item'
+
(
is_last
?
' list-group-item-last'
:
''
)
+
'">'
+
(
is_last
?
' list-group-item-last'
:
''
)
+
'">'
+
'<span class="index-vm-list-name">'
+
'<span class="index-vm-list-name">'
+
'<i class="fa '
+
icon
+
'" title="'
+
_status
+
'"></i> '
+
name
+
'<i class="fa '
+
icon
+
'" title="'
+
_status
+
'"></i> '
+
name
+
'</span>'
+
'</span>'
+
'<small class="text-muted"> '
+
host
+
'</small>'
+
'<small class="text-muted"> '
+
host
+
'</small>'
+
'<div class="pull-right dashboard-vm-favourite" data-vm="'
+
pk
+
'">'
+
'<div class="pull-right dashboard-vm-favourite" data-vm="'
+
pk
+
'">'
+
(
fav
?
'<i class="fa fa-star text-primary title-favourite" title="Unfavourite"></i>'
:
(
fav
?
'<i class="fa fa-star text-primary title-favourite" title="Unfavourite"></i>'
:
'<i class="fa fa-star-o text-primary title-favourite" title="Mark as favorite"></i>'
)
+
'<i class="fa fa-star-o text-primary title-favourite" title="Mark as favorite"></i>'
)
+
'</div>'
+
'</div>'
+
'<div style="clear: both;"></div>'
+
'<div style="clear: both;"></div>'
+
'</a>'
;
'</a>'
;
}
}
function
generateGroupHTML
(
url
,
name
,
is_last
)
{
function
generateGroupHTML
(
url
,
name
,
is_last
)
{
...
@@ -424,7 +424,7 @@ function generateNodeTagHTML(name, icon, _status, label , url) {
...
@@ -424,7 +424,7 @@ function generateNodeTagHTML(name, icon, _status, label , url) {
/* copare vm-s by fav, pk order */
/* copare vm-s by fav, pk order */
function
compareVmByFav
(
a
,
b
)
{
function
compareVmByFav
(
a
,
b
)
{
if
(
a
.
fav
&&
b
.
fav
)
{
if
(
a
.
fav
&&
b
.
fav
)
{
return
a
.
pk
<
b
.
pk
?
-
1
:
1
;
return
a
.
pk
<
b
.
pk
?
-
1
:
1
;
}
}
else
if
(
a
.
fav
&&
!
b
.
fav
)
{
else
if
(
a
.
fav
&&
!
b
.
fav
)
{
return
-
1
;
return
-
1
;
...
@@ -433,13 +433,13 @@ function compareVmByFav(a, b) {
...
@@ -433,13 +433,13 @@ function compareVmByFav(a, b) {
return
1
;
return
1
;
}
}
else
else
return
a
.
pk
<
b
.
pk
?
-
1
:
1
;
return
a
.
pk
<
b
.
pk
?
-
1
:
1
;
}
}
$
(
document
).
on
(
'shown.bs.tab'
,
'a[href="#resources"]'
,
function
(
e
)
{
$
(
document
).
on
(
'shown.bs.tab'
,
'a[href="#resources"]'
,
function
(
e
)
{
$
(
".cpu-priority-input"
).
trigger
(
"change"
);
$
(
".cpu-priority-input"
).
trigger
(
"change"
);
$
(
".cpu-count-input, .ram-input"
).
trigger
(
"input"
);
$
(
".cpu-count-input, .ram-input"
).
trigger
(
"input"
);
})
})
;
function
addSliderMiscs
()
{
function
addSliderMiscs
()
{
// set max values based on inputs
// set max values based on inputs
...
@@ -470,7 +470,7 @@ function addSliderMiscs() {
...
@@ -470,7 +470,7 @@ function addSliderMiscs() {
if
(
!
val
)
return
;
if
(
!
val
)
return
;
$
(
".cpu-count-slider"
).
simpleSlider
(
"setValue"
,
val
);
$
(
".cpu-count-slider"
).
simpleSlider
(
"setValue"
,
val
);
});
});
var
ram_fire
=
false
;
var
ram_fire
=
false
;
$
(
".ram-slider"
).
bind
(
"slider:changed"
,
function
(
event
,
data
)
{
$
(
".ram-slider"
).
bind
(
"slider:changed"
,
function
(
event
,
data
)
{
...
@@ -508,21 +508,21 @@ function setDefaultSliderValues() {
...
@@ -508,21 +508,21 @@ function setDefaultSliderValues() {
function
deleteObject
(
data
)
{
function
deleteObject
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
data
:
{
'redirect'
:
data
[
'redirect'
]
},
data
:
{
'redirect'
:
data
.
redirect
},
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
[
'redirect'
]
)
{
if
(
!
data
.
redirect
)
{
selected
=
[];
selected
=
[];
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
if
(
data
.
type
===
"disk"
)
{
if
(
data
.
type
===
"disk"
)
{
// no need to remove them from DOM
// no need to remove them from DOM
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"li"
).
fadeOut
();
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"li"
).
fadeOut
();
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"h4"
).
fadeOut
();
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"h4"
).
fadeOut
();
}
}
else
{
else
{
$
(
'a[data-'
+
data
[
'type'
]
+
'-pk="'
+
data
[
'pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
'a[data-'
+
data
.
type
+
'-pk="'
+
data
.
pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
}
}
}
else
{
}
else
{
...
@@ -530,32 +530,33 @@ function deleteObject(data) {
...
@@ -530,32 +530,33 @@ function deleteObject(data) {
}
}
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
function
massDeleteVm
(
data
)
{
function
massDeleteVm
(
data
)
{
$
.
ajax
({
f
=
function
()
{
traditional
:
true
,
selected
=
[];
url
:
data
[
'url'
],
// reset group buttons
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
type
:
'POST'
,
$
(
this
).
remove
();
data
:
{
'vms'
:
data
[
'data'
][
'v'
]},
};
success
:
function
(
re
,
textStatus
,
xhr
)
{
$
.
ajax
({
for
(
var
i
=
0
;
i
<
data
[
'data'
][
'v'
].
length
;
i
++
)
traditional
:
true
,
$
(
'.vm-list-table tbody tr[data-vm-pk="'
+
data
[
'data'
][
'v'
][
i
]
+
'"]'
).
fadeOut
(
500
,
function
()
{
url
:
data
.
url
,
selected
=
[];
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
// reset group buttons
type
:
'POST'
,
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
data
:
{
'vms'
:
data
.
data
.
v
},
$
(
this
).
remove
();
success
:
function
(
re
,
textStatus
,
xhr
)
{
});
for
(
var
i
=
0
;
i
<
data
.
data
.
v
.
length
;
i
++
)
addMessage
(
re
[
'message'
],
'success'
);
$
(
'.vm-list-table tbody tr[data-vm-pk="'
+
data
.
data
.
v
[
i
]
+
'"]'
).
fadeOut
(
500
,
f
);
},
addMessage
(
re
.
message
,
'success'
);
error
:
function
(
xhr
,
textStatus
,
error
)
{
},
// TODO this
error
:
function
(
xhr
,
textStatus
,
error
)
{
}
// TODO this
});
}
});
}
}
...
@@ -573,8 +574,8 @@ function addMessage(text, type) {
...
@@ -573,8 +574,8 @@ function addMessage(text, type) {
function
addModalConfirmation
(
func
,
data
)
{
function
addModalConfirmation
(
func
,
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
data
:
jQuery
.
param
(
data
[
'data'
]
),
data
:
jQuery
.
param
(
data
.
data
),
success
:
function
(
result
)
{
success
:
function
(
result
)
{
$
(
'body'
).
append
(
result
);
$
(
'body'
).
append
(
result
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
...
@@ -590,25 +591,25 @@ function addModalConfirmation(func, data) {
...
@@ -590,25 +591,25 @@ function addModalConfirmation(func, data) {
}
}
// for AJAX calls
// for AJAX calls
/**
/**
* Getter for user cookies
* Getter for user cookies
* @param {String} name Cookie name
* @param {String} name Cookie name
* @return {String} Cookie value
* @return {String} Cookie value
*/
*/
function
getCookie
(
name
)
{
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
if
(
document
.
cookie
&&
document
.
cookie
!=
=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
break
;
}
}
}
}
}
}
return
cookieValue
;
return
cookieValue
;
}
}
...
...
circle/dashboard/static/dashboard/disk-list.js
View file @
6cb335d7
...
@@ -8,16 +8,16 @@ $(function() {
...
@@ -8,16 +8,16 @@ $(function() {
function
refreshDisk
(
disk
,
element
)
{
function
refreshDisk
(
disk
,
element
)
{
$
.
get
(
"/dashboard/disk/"
+
disk
+
"/status/"
,
function
(
result
)
{
$
.
get
(
"/dashboard/disk/"
+
disk
+
"/status/"
,
function
(
result
)
{
if
(
result
.
percentage
==
null
||
result
.
failed
==
"True"
)
{
if
(
result
.
percentage
==
=
null
||
result
.
failed
==
"True"
)
{
location
.
reload
();
location
.
reload
();
}
else
{
}
else
{
var
diff
=
result
.
percentage
-
parseInt
(
element
.
html
());
var
diff
=
result
.
percentage
-
parseInt
(
element
.
html
());
var
refresh
=
5
-
diff
;
var
refresh
=
5
-
diff
;
refresh
=
refresh
<
1
?
1
:
(
result
.
percentage
==
0
?
1
:
refresh
);
refresh
=
refresh
<
1
?
1
:
(
result
.
percentage
==
=
0
?
1
:
refresh
);
if
(
isNaN
(
refresh
))
refresh
=
2
;
// this should not happen
if
(
isNaN
(
refresh
))
refresh
=
2
;
// this should not happen
element
.
html
(
result
.
percentage
);
element
.
html
(
result
.
percentage
);
setTimeout
(
function
()
{
refreshDisk
(
disk
,
element
)},
refresh
*
1000
);
setTimeout
(
function
()
{
refreshDisk
(
disk
,
element
)
;
},
refresh
*
1000
);
}
}
});
});
}
}
circle/dashboard/static/dashboard/group-details.js
View file @
6cb335d7
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
data
:
{
'new_name'
:
name
},
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#group-details-h1-name"
).
html
(
data
[
'new_name'
]
).
show
();
$
(
"#group-details-h1-name"
).
html
(
data
.
new_name
).
show
();
$
(
'#group-details-rename'
).
hide
();
$
(
'#group-details-rename'
).
hide
();
// addMessage(data['message'], "success");
// addMessage(data['message'], "success");
},
},
...
@@ -51,14 +51,14 @@
...
@@ -51,14 +51,14 @@
function
removeMember
(
data
)
{
function
removeMember
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
data
[
'tr'
]
.
fadeOut
(
function
()
{
data
.
tr
.
fadeOut
(
function
()
{
$
(
this
).
remove
();});
$
(
this
).
remove
();});
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
...
...
circle/dashboard/static/dashboard/group-list.js
View file @
6cb335d7
...
@@ -7,7 +7,7 @@ $(function() {
...
@@ -7,7 +7,7 @@ $(function() {
/* rename ajax */
/* rename ajax */
$
(
'.group-list-rename-submit'
).
click
(
function
()
{
$
(
'.group-list-rename-submit'
).
click
(
function
()
{
var
row
=
$
(
this
).
closest
(
"tr"
)
var
row
=
$
(
this
).
closest
(
"tr"
)
;
var
name
=
$
(
'#group-list-rename-name'
,
row
).
val
();
var
name
=
$
(
'#group-list-rename-name'
,
row
).
val
();
var
url
=
'/dashboard/group/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
var
url
=
'/dashboard/group/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
$
.
ajax
({
$
.
ajax
({
...
@@ -16,12 +16,12 @@ $(function() {
...
@@ -16,12 +16,12 @@ $(function() {
data
:
{
'new_name'
:
name
},
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#group-list-column-name"
,
row
).
html
(
$
(
"#group-list-column-name"
,
row
).
html
(
$
(
"<a/>"
,
{
$
(
"<a/>"
,
{
'class'
:
"real-link"
,
'class'
:
"real-link"
,
href
:
"/dashboard/group/"
+
data
[
'group_pk'
]
+
"/"
,
href
:
"/dashboard/group/"
+
data
.
group_pk
+
"/"
,
text
:
data
[
'new_name'
]
text
:
data
.
new_name
})
})
).
show
();
).
show
();
$
(
'#group-list-rename'
,
row
).
hide
();
$
(
'#group-list-rename'
,
row
).
hide
();
...
...
circle/dashboard/static/dashboard/node-details.js
View file @
6cb335d7
...
@@ -15,9 +15,9 @@ $(function() {
...
@@ -15,9 +15,9 @@ $(function() {
data
:
{
'new_name'
:
name
},
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#node-details-h1-name"
).
html
(
data
[
'new_name'
]
).
show
();
$
(
"#node-details-h1-name"
).
html
(
data
.
new_name
).
show
();
$
(
'#node-details-rename'
).
hide
();
$
(
'#node-details-rename'
).
hide
();
// addMessage(data
['message']
, "success");
// addMessage(data
.message
, "success");
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
addMessage
(
"Error during renaming!"
,
"danger"
);
...
@@ -34,7 +34,7 @@ $(function() {
...
@@ -34,7 +34,7 @@ $(function() {
$
(
'.node-enable'
).
click
(
function
()
{
$
(
'.node-enable'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
changeNodeStatus
,
addModalConfirmation
(
changeNodeStatus
,
{
'url'
:
'/dashboard/node/status/'
+
node_pk
+
'/'
,
{
'url'
:
'/dashboard/node/status/'
+
node_pk
+
'/'
,
'data'
:
[],
'data'
:
[],
'pk'
:
node_pk
,
'pk'
:
node_pk
,
...
@@ -51,17 +51,17 @@ $(function() {
...
@@ -51,17 +51,17 @@ $(function() {
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
location
.
href
,
url
:
location
.
href
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
data
:
{
'to_remove'
:
to_remove
},
data
:
{
'to_remove'
:
to_remove
},
success
:
function
(
re
)
{
success
:
function
(
re
)
{
if
(
re
[
'message'
]
.
toLowerCase
()
==
"success"
)
{
if
(
re
.
message
.
toLowerCase
()
==
"success"
)
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
}
}
},
},
error
:
function
()
{
error
:
function
()
{
addMessage
(
re
[
'message'
]
,
'danger'
);
addMessage
(
re
.
message
,
'danger'
);
}
}
});
});
...
@@ -73,18 +73,18 @@ $(function() {
...
@@ -73,18 +73,18 @@ $(function() {
function
changeNodeStatus
(
data
)
{
function
changeNodeStatus
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
[
'redirect'
]
)
{
if
(
!
data
.
redirect
)
{
selected
=
[];
selected
=
[];
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
}
else
{
}
else
{
window
.
location
.
replace
(
'/dashboard'
);
window
.
location
.
replace
(
'/dashboard'
);
}
}
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
circle/dashboard/static/dashboard/node-list.js
View file @
6cb335d7
...
@@ -4,12 +4,10 @@ $(function() {
...
@@ -4,12 +4,10 @@ $(function() {
});
});
// find disabled nodes, set danger (red) on the rows
// find disabled nodes, set danger (red) on the rows
function
colortable
()
function
colortable
()
{
{
var
tr
=
$
(
'.false'
).
closest
(
"tr"
);
$
(
'.false'
).
closest
(
"tr"
).
addClass
(
'danger'
);
tr
.
addClass
(
'danger'
);
$
(
'.true'
).
closest
(
"tr"
).
removeClass
(
'danger'
);
var
tr
=
$
(
'.true'
).
closest
(
"tr"
);
tr
.
removeClass
(
'danger'
);
}
}
/* rename */
/* rename */
...
@@ -20,7 +18,7 @@ $(function() {
...
@@ -20,7 +18,7 @@ $(function() {
/* rename ajax */
/* rename ajax */
$
(
'.node-list-rename-submit'
).
click
(
function
()
{
$
(
'.node-list-rename-submit'
).
click
(
function
()
{
var
row
=
$
(
this
).
closest
(
"tr"
)
var
row
=
$
(
this
).
closest
(
"tr"
)
;
var
name
=
$
(
'#node-list-rename-name'
,
row
).
val
();
var
name
=
$
(
'#node-list-rename-name'
,
row
).
val
();
var
url
=
'/dashboard/node/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
var
url
=
'/dashboard/node/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
$
.
ajax
({
$
.
ajax
({
...
@@ -29,12 +27,12 @@ $(function() {
...
@@ -29,12 +27,12 @@ $(function() {
data
:
{
'new_name'
:
name
},
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#node-list-column-name"
,
row
).
html
(
$
(
"#node-list-column-name"
,
row
).
html
(
$
(
"<a/>"
,
{
$
(
"<a/>"
,
{
'class'
:
"real-link"
,
'class'
:
"real-link"
,
href
:
"/dashboard/node/"
+
data
[
'node_pk'
]
+
"/"
,
href
:
"/dashboard/node/"
+
data
.
node_pk
+
"/"
,
text
:
data
[
'new_name'
]
text
:
data
.
new_name
})
})
).
show
();
).
show
();
$
(
'#node-list-rename'
,
row
).
hide
();
$
(
'#node-list-rename'
,
row
).
hide
();
...
@@ -50,7 +48,7 @@ $(function() {
...
@@ -50,7 +48,7 @@ $(function() {
function
statuschangeSuccess
(
tr
){
function
statuschangeSuccess
(
tr
){
var
tspan
=
tr
.
children
(
'.enabled'
).
children
();
var
tspan
=
tr
.
children
(
'.enabled'
).
children
();
var
buttons
=
tr
.
children
(
'.actions'
).
children
(
'.btn-group'
).
children
(
'.dropdown-menu'
).
children
(
'li'
).
children
(
'.node-enable'
);
var
buttons
=
tr
.
children
(
'.actions'
).
children
(
'.btn-group'
).
children
(
'.dropdown-menu'
).
children
(
'li'
).
children
(
'.node-enable'
);
buttons
.
each
(
function
(
index
){
buttons
.
each
(
function
(
index
){
if
(
$
(
this
).
css
(
"display"
)
==
"block"
){
if
(
$
(
this
).
css
(
"display"
)
==
"block"
){
$
(
this
).
css
(
"display"
,
"none"
);
$
(
this
).
css
(
"display"
,
"none"
);
...
@@ -58,12 +56,12 @@ $(function() {
...
@@ -58,12 +56,12 @@ $(function() {
else
{
else
{
$
(
this
).
css
(
"display"
,
"block"
);
$
(
this
).
css
(
"display"
,
"block"
);
}
}
});
});
if
(
tspan
.
hasClass
(
"false"
)){
if
(
tspan
.
hasClass
(
"false"
)){
tspan
.
removeClass
(
"false"
);
tspan
.
removeClass
(
"false"
);
tspan
.
addClass
(
"true"
);
tspan
.
addClass
(
"true"
);
tspan
.
text
(
"✔"
);
tspan
.
text
(
"✔"
);
}
}
else
{
else
{
tspan
.
removeClass
(
"true"
);
tspan
.
removeClass
(
"true"
);
tspan
.
addClass
(
"false"
);
tspan
.
addClass
(
"false"
);
...
...
circle/dashboard/static/dashboard/profile.js
View file @
6cb335d7
...
@@ -7,10 +7,10 @@ $(function() {
...
@@ -7,10 +7,10 @@ $(function() {
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
"/dashboard/profile/"
+
user
+
"/use_gravatar/"
,
url
:
"/dashboard/profile/"
+
user
+
"/use_gravatar/"
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
)
{
success
:
function
(
re
)
{
if
(
re
.
new_avatar_url
)
{
if
(
re
.
new_avatar_url
)
{
$
(
"#dashboard-profile-avatar"
).
prop
(
"src"
,
re
.
new_avatar_url
);
$
(
"#dashboard-profile-avatar"
).
prop
(
"src"
,
re
.
new_avatar_url
);
}
}
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
...
...
circle/dashboard/static/dashboard/store.js
View file @
6cb335d7
...
@@ -25,18 +25,18 @@ $(function() {
...
@@ -25,18 +25,18 @@ $(function() {
$
(
'#store-upload-form button[type="submit"] i'
).
addClass
(
"fa-spinner fa-spin"
);
$
(
'#store-upload-form button[type="submit"] i'
).
addClass
(
"fa-spinner fa-spin"
);
var
current_dir
=
$
(
"#store-upload-form"
).
find
(
'[name="current_dir"]'
).
val
();
var
current_dir
=
$
(
"#store-upload-form"
).
find
(
'[name="current_dir"]'
).
val
();
$
.
get
(
$
(
"#store-upload-form"
).
data
(
"action"
)
+
"?current_dir="
+
current_dir
,
function
(
result
)
{
$
.
get
(
$
(
"#store-upload-form"
).
data
(
"action"
)
+
"?current_dir="
+
current_dir
,
function
(
result
)
{
$
(
"#store-upload-form"
).
get
(
0
).
setAttribute
(
"action"
,
result
[
'url'
]
);
$
(
"#store-upload-form"
).
get
(
0
).
setAttribute
(
"action"
,
result
.
url
);
$
(
"#store-upload-form"
).
submit
();
$
(
"#store-upload-form"
).
submit
();
});
});
return
false
;
return
false
;
});
});
/* "fake" browse button */
/* "fake" browse button */
$
(
"#store-list-container"
).
on
(
"click"
,
"#store-upload-browse"
,
function
()
{
$
(
"#store-list-container"
).
on
(
"click"
,
"#store-upload-browse"
,
function
()
{
$
(
'#store-upload-form input[type="file"]'
).
click
();
$
(
'#store-upload-form input[type="file"]'
).
click
();
});
});
$
(
"#store-list-container"
).
on
(
"change"
,
"#store-upload-file"
,
function
()
{
$
(
"#store-list-container"
).
on
(
"change"
,
"#store-upload-file"
,
function
()
{
var
input
=
$
(
this
);
var
input
=
$
(
this
);
var
numFiles
=
input
.
get
(
0
).
files
?
input
.
get
(
0
).
files
.
length
:
1
;
var
numFiles
=
input
.
get
(
0
).
files
?
input
.
get
(
0
).
files
.
length
:
1
;
...
...
circle/dashboard/static/dashboard/template-list.js
View file @
6cb335d7
...
@@ -20,7 +20,7 @@ $(function() {
...
@@ -20,7 +20,7 @@ $(function() {
});
});
return
false
;
return
false
;
});
});
/* template table sort */
/* template table sort */
var
ttable
=
$
(
".template-list-table"
).
stupidtable
();
var
ttable
=
$
(
".template-list-table"
).
stupidtable
();
...
@@ -37,7 +37,7 @@ $(function() {
...
@@ -37,7 +37,7 @@ $(function() {
// only if js is enabled
// only if js is enabled
$
(
".template-list-table thead th"
).
css
(
"cursor"
,
"pointer"
);
$
(
".template-list-table thead th"
).
css
(
"cursor"
,
"pointer"
);
$
(
".template-list-table th a"
).
on
(
"click"
,
function
(
event
)
{
$
(
".template-list-table th a"
).
on
(
"click"
,
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
});
});
...
@@ -48,16 +48,16 @@ $(function() {
...
@@ -48,16 +48,16 @@ $(function() {
function
deleteTemplate
(
data
)
{
function
deleteTemplate
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
$
(
'a[data-template-pk="'
+
data
[
'template_pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
'a[data-template-pk="'
+
data
.
template_pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
...
@@ -67,16 +67,16 @@ function deleteTemplate(data) {
...
@@ -67,16 +67,16 @@ function deleteTemplate(data) {
function
deleteLease
(
data
)
{
function
deleteLease
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
$
(
'a[data-lease-pk="'
+
data
[
'lease_pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
'a[data-lease-pk="'
+
data
.
lease_pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
circle/dashboard/static/dashboard/vm-common.js
View file @
6cb335d7
...
@@ -74,7 +74,7 @@ $(function() {
...
@@ -74,7 +74,7 @@ $(function() {
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
if
(
xhr
.
status
==
500
)
{
if
(
xhr
.
status
==
500
)
{
addMessage
(
"500 Internal Server Error"
,
"danger"
);
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
}
else
{
...
...
circle/dashboard/static/dashboard/vm-console.js
View file @
6cb335d7
...
@@ -6,7 +6,7 @@ $(function() {
...
@@ -6,7 +6,7 @@ $(function() {
var
rfb
;
var
rfb
;
function
updateState
(
rfb
,
state
,
oldstate
,
msg
)
{
function
updateState
(
rfb
,
state
,
oldstate
,
msg
)
{
$
(
'#_console .btn-toolbar button'
).
attr
(
'disabled'
,
!
(
state
=
==
"normal"
));
$
(
'#_console .btn-toolbar button'
).
attr
(
'disabled'
,
(
state
!
==
"normal"
));
rfb
.
sendKey
(
0xffe3
);
// press and release ctrl to kill screensaver
rfb
.
sendKey
(
0xffe3
);
// press and release ctrl to kill screensaver
if
(
typeof
(
msg
)
!==
'undefined'
)
{
if
(
typeof
(
msg
)
!==
'undefined'
)
{
...
@@ -42,13 +42,13 @@ $(function() {
...
@@ -42,13 +42,13 @@ $(function() {
if
(
window
.
location
.
port
==
8080
)
{
if
(
window
.
location
.
port
==
8080
)
{
port
=
9999
;
port
=
9999
;
}
else
{
}
else
{
port
=
window
.
location
.
port
==
""
?
"443"
:
window
.
location
.
port
;
port
=
window
.
location
.
port
==
=
""
?
"443"
:
window
.
location
.
port
;
}
}
password
=
''
;
password
=
''
;
$
(
'#_console .btn-toolbar button'
).
attr
(
'disabled'
,
true
);
$
(
'#_console .btn-toolbar button'
).
attr
(
'disabled'
,
true
);
$
(
'#noVNC_status'
).
html
(
'Retreiving authorization token.'
);
$
(
'#noVNC_status'
).
html
(
'Retreiving authorization token.'
);
$
.
get
(
VNC_URL
,
function
(
data
)
{
$
.
get
(
VNC_URL
,
function
(
data
)
{
if
(
data
.
indexOf
(
'vnc'
)
!=
0
)
{
if
(
data
.
indexOf
(
'vnc'
)
!=
=
0
)
{
$
(
'#noVNC_status'
).
html
(
'No authorization token received.'
);
$
(
'#noVNC_status'
).
html
(
'No authorization token received.'
);
}
}
else
{
else
{
...
...
circle/dashboard/static/dashboard/vm-create.js
View file @
6cb335d7
...
@@ -18,7 +18,7 @@ function vmCreateLoaded() {
...
@@ -18,7 +18,7 @@ function vmCreateLoaded() {
$
(
".customize-vm"
).
click
(
function
()
{
$
(
".customize-vm"
).
click
(
function
()
{
var
template
=
$
(
this
).
data
(
"template-pk"
);
var
template
=
$
(
this
).
data
(
"template-pk"
);
$
.
get
(
"/dashboard/vm/create/?template="
+
template
,
function
(
data
)
{
$
.
get
(
"/dashboard/vm/create/?template="
+
template
,
function
(
data
)
{
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
...
@@ -34,7 +34,7 @@ function vmCreateLoaded() {
...
@@ -34,7 +34,7 @@ function vmCreateLoaded() {
});
});
return
false
;
return
false
;
});
});
/* start vm button clicks */
/* start vm button clicks */
$
(
'.vm-create-start'
).
click
(
function
()
{
$
(
'.vm-create-start'
).
click
(
function
()
{
template
=
$
(
this
).
data
(
"template-pk"
);
template
=
$
(
this
).
data
(
"template-pk"
);
...
@@ -60,7 +60,7 @@ function vmCreateLoaded() {
...
@@ -60,7 +60,7 @@ function vmCreateLoaded() {
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
if
(
xhr
.
status
==
500
)
{
if
(
xhr
.
status
==
500
)
{
addMessage
(
"500 Internal Server Error"
,
"danger"
);
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
}
else
{
...
@@ -77,7 +77,7 @@ function vmCreateLoaded() {
...
@@ -77,7 +77,7 @@ function vmCreateLoaded() {
var
now
=
$
(
this
).
attr
(
'aria-valuenow'
);
var
now
=
$
(
this
).
attr
(
'aria-valuenow'
);
var
siz
=
(
now
-
min
)
*
100
/
(
max
-
min
);
var
siz
=
(
now
-
min
)
*
100
/
(
max
-
min
);
$
(
this
).
css
(
'width'
,
siz
+
'%'
);
$
(
this
).
css
(
'width'
,
siz
+
'%'
);
});
});
}
}
...
@@ -93,18 +93,18 @@ function vmCustomizeLoaded() {
...
@@ -93,18 +93,18 @@ function vmCustomizeLoaded() {
// remove the hex chars
// remove the hex chars
name
=
name
.
substring
(
name
.
indexOf
(
" "
),
name
.
length
);
name
=
name
.
substring
(
name
.
indexOf
(
" "
),
name
.
length
);
if
(
$
(
'#vm-create-network-list'
).
children
(
'span'
).
length
<
1
)
{
if
(
$
(
'#vm-create-network-list'
).
children
(
'span'
).
length
<
1
)
{
$
(
'#vm-create-network-list'
).
html
(
''
);
$
(
'#vm-create-network-list'
).
html
(
''
);
}
}
$
(
'#vm-create-network-list'
).
append
(
$
(
'#vm-create-network-list'
).
append
(
vmCreateNetworkLabel
(
vlan_pk
,
name
,
managed
)
vmCreateNetworkLabel
(
vlan_pk
,
name
,
managed
)
);
);
/* select the network in the hidden network select */
/* select the network in the hidden network select */
$
(
'#vm-create-network-add-vlan option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
$
(
'#vm-create-network-add-vlan option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
$
(
'option:selected'
,
$
(
'#vm-create-network-add-select'
)).
remove
();
$
(
'option:selected'
,
$
(
'#vm-create-network-add-select'
)).
remove
();
/* add dummy text if no more networks are available */
/* add dummy text if no more networks are available */
if
(
$
(
'#vm-create-network-add-select option'
).
length
<
1
)
{
if
(
$
(
'#vm-create-network-add-select option'
).
length
<
1
)
{
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
true
);
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
true
);
...
@@ -117,23 +117,23 @@ function vmCustomizeLoaded() {
...
@@ -117,23 +117,23 @@ function vmCustomizeLoaded() {
/* remove network */
/* remove network */
// event for network remove button (icon, X)
// event for network remove button (icon, X)
$
(
'body'
).
on
(
'click'
,
'.vm-create-remove-network'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'.vm-create-remove-network'
,
function
()
{
var
vlan_pk
=
(
$
(
this
).
parent
(
'span'
).
prop
(
'id'
)).
replace
(
'vlan-'
,
''
)
var
vlan_pk
=
(
$
(
this
).
parent
(
'span'
).
prop
(
'id'
)).
replace
(
'vlan-'
,
''
)
;
// if it's "blue" then it's managed, kinda not cool
// if it's "blue" then it's managed, kinda not cool
var
managed
=
$
(
this
).
parent
(
'span'
).
hasClass
(
'label-primary'
);
var
managed
=
$
(
this
).
parent
(
'span'
).
hasClass
(
'label-primary'
);
$
(
this
).
parent
(
'span'
).
fadeOut
(
500
,
function
()
{
$
(
this
).
parent
(
'span'
).
fadeOut
(
500
,
function
()
{
/* if ther are no more vlans disabled the add button */
/* if ther are no more vlans disabled the add button */
if
(
$
(
'#vm-create-network-add-select option'
)[
0
].
value
==
-
1
)
{
if
(
$
(
'#vm-create-network-add-select option'
)[
0
].
value
==
-
1
)
{
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
false
);
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
false
);
$
(
'#vm-create-network-add-select'
).
html
(
''
);
$
(
'#vm-create-network-add-select'
).
html
(
''
);
}
}
/* remove the network label */
/* remove the network label */
$
(
this
).
remove
();
$
(
this
).
remove
();
var
vlan_name
=
$
(
this
).
text
();
var
vlan_name
=
$
(
this
).
text
();
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
vlan_pk
+
'">'
+
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
vlan_pk
+
'">'
+
(
managed
?
""
:
""
)
+
vlan_name
+
'</option>'
;
(
managed
?
""
:
""
)
+
vlan_name
+
'</option>'
;
$
(
'#vm-create-network-add-select'
).
append
(
html
);
$
(
'#vm-create-network-add-select'
).
append
(
html
);
...
@@ -148,7 +148,7 @@ function vmCustomizeLoaded() {
...
@@ -148,7 +148,7 @@ function vmCustomizeLoaded() {
/* copy networks from hidden select */
/* copy networks from hidden select */
$
(
'#vm-create-network-add-vlan option'
).
each
(
function
()
{
$
(
'#vm-create-network-add-vlan option'
).
each
(
function
()
{
var
managed
=
$
(
this
).
text
().
indexOf
(
"mana"
)
==
0
;
var
managed
=
$
(
this
).
text
().
indexOf
(
"mana"
)
==
=
0
;
var
raw_text
=
$
(
this
).
text
();
var
raw_text
=
$
(
this
).
text
();
var
pk
=
$
(
this
).
val
();
var
pk
=
$
(
this
).
val
();
if
(
managed
)
{
if
(
managed
)
{
...
@@ -157,7 +157,7 @@ function vmCustomizeLoaded() {
...
@@ -157,7 +157,7 @@ function vmCustomizeLoaded() {
text
=
raw_text
.
replace
(
"unmanaged -"
,
""
);
text
=
raw_text
.
replace
(
"unmanaged -"
,
""
);
}
}
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
pk
+
'">'
+
text
+
'</option>'
;
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
pk
+
'">'
+
text
+
'</option>'
;
if
(
$
(
'#vm-create-network-list span'
).
length
<
1
)
{
if
(
$
(
'#vm-create-network-list span'
).
length
<
1
)
{
$
(
"#vm-create-network-list"
).
html
(
""
);
$
(
"#vm-create-network-list"
).
html
(
""
);
}
}
...
@@ -180,7 +180,7 @@ function vmCustomizeLoaded() {
...
@@ -180,7 +180,7 @@ function vmCustomizeLoaded() {
vlans
.
push
({
vlans
.
push
({
'name'
:
$
(
this
).
text
().
replace
(
"unmanaged -"
,
""
).
replace
(
"managed -"
,
""
),
'name'
:
$
(
this
).
text
().
replace
(
"unmanaged -"
,
""
).
replace
(
"managed -"
,
""
),
'pk'
:
parseInt
(
$
(
this
).
val
()),
'pk'
:
parseInt
(
$
(
this
).
val
()),
'managed'
:
$
(
this
).
text
().
indexOf
(
"mana"
)
==
0
,
'managed'
:
$
(
this
).
text
().
indexOf
(
"mana"
)
==
=
0
,
});
});
});
});
...
@@ -248,7 +248,7 @@ function vmCustomizeLoaded() {
...
@@ -248,7 +248,7 @@ function vmCustomizeLoaded() {
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
var
r
=
$
(
'#create-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
if
(
xhr
.
status
==
500
)
{
if
(
xhr
.
status
==
500
)
{
addMessage
(
"500 Internal Server Error"
,
"danger"
);
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
}
else
{
...
@@ -260,8 +260,8 @@ function vmCustomizeLoaded() {
...
@@ -260,8 +260,8 @@ function vmCustomizeLoaded() {
});
});
/* for no js stuff */
/* for no js stuff */
$
(
'.no-js-hidden'
).
show
();
$
(
'.no-js-hidden'
).
show
();
$
(
'.js-hidden'
).
hide
();
$
(
'.js-hidden'
).
hide
();
}
}
...
...
circle/dashboard/static/dashboard/vm-details.js
View file @
6cb335d7
...
@@ -41,7 +41,7 @@ $(function() {
...
@@ -41,7 +41,7 @@ $(function() {
var
vm
=
$
(
this
).
data
(
"vm"
);
var
vm
=
$
(
this
).
data
(
"vm"
);
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
"/dashboard/vm/"
+
vm
+
"/op/resources_change/"
,
url
:
"/dashboard/vm/"
+
vm
+
"/op/resources_change/"
,
data
:
$
(
'#vm-details-resources-form'
).
serialize
(),
data
:
$
(
'#vm-details-resources-form'
).
serialize
(),
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
if
(
data
.
success
)
{
if
(
data
.
success
)
{
...
@@ -57,7 +57,7 @@ $(function() {
...
@@ -57,7 +57,7 @@ $(function() {
addMessage
(
"500 Internal Server Error"
,
"danger"
);
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
}
else
{
addMessage
(
xhr
.
status
+
" Unknown Error"
,
"danger"
);
addMessage
(
xhr
.
status
+
" Unknown Error"
,
"danger"
);
}
}
}
}
});
});
return
false
;
return
false
;
...
@@ -70,17 +70,17 @@ $(function() {
...
@@ -70,17 +70,17 @@ $(function() {
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
location
.
href
,
url
:
location
.
href
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
data
:
{
'to_remove'
:
to_remove
},
data
:
{
'to_remove'
:
to_remove
},
success
:
function
(
re
)
{
success
:
function
(
re
)
{
if
(
re
[
'message'
]
.
toLowerCase
()
==
"success"
)
{
if
(
re
.
message
.
toLowerCase
()
==
"success"
)
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
}
}
},
},
error
:
function
()
{
error
:
function
()
{
addMessage
(
re
[
'message'
]
,
'danger'
);
addMessage
(
re
.
message
,
'danger'
);
}
}
});
});
...
@@ -89,7 +89,7 @@ $(function() {
...
@@ -89,7 +89,7 @@ $(function() {
/* remove port */
/* remove port */
$
(
'.vm-details-remove-port'
).
click
(
function
()
{
$
(
'.vm-details-remove-port'
).
click
(
function
()
{
addModalConfirmation
(
removePort
,
addModalConfirmation
(
removePort
,
{
{
'url'
:
$
(
this
).
prop
(
"href"
),
'url'
:
$
(
this
).
prop
(
"href"
),
'data'
:
[],
'data'
:
[],
...
@@ -100,13 +100,13 @@ $(function() {
...
@@ -100,13 +100,13 @@ $(function() {
/* for js fallback */
/* for js fallback */
$
(
"#vm-details-pw-show"
).
parent
(
"div"
).
children
(
"input"
).
prop
(
"type"
,
"password"
);
$
(
"#vm-details-pw-show"
).
parent
(
"div"
).
children
(
"input"
).
prop
(
"type"
,
"password"
);
/* show password */
/* show password */
$
(
"#vm-details-pw-show"
).
click
(
function
()
{
$
(
"#vm-details-pw-show"
).
click
(
function
()
{
var
input
=
$
(
this
).
parent
(
"div"
).
children
(
"input"
);
var
input
=
$
(
this
).
parent
(
"div"
).
children
(
"input"
);
var
eye
=
$
(
this
).
children
(
"#vm-details-pw-eye"
);
var
eye
=
$
(
this
).
children
(
"#vm-details-pw-eye"
);
eye
.
tooltip
(
"destroy"
)
eye
.
tooltip
(
"destroy"
)
;
if
(
eye
.
hasClass
(
"fa-eye"
))
{
if
(
eye
.
hasClass
(
"fa-eye"
))
{
eye
.
removeClass
(
"fa-eye"
).
addClass
(
"fa-eye-slash"
);
eye
.
removeClass
(
"fa-eye"
).
addClass
(
"fa-eye-slash"
);
input
.
prop
(
"type"
,
"text"
);
input
.
prop
(
"type"
,
"text"
);
...
@@ -148,7 +148,7 @@ $(function() {
...
@@ -148,7 +148,7 @@ $(function() {
}
}
});
});
}
else
{
}
else
{
$
(
"#vm-details-pw-confirm"
).
fadeOut
();
$
(
"#vm-details-pw-confirm"
).
fadeOut
();
}
}
return
false
;
return
false
;
});
});
...
@@ -168,7 +168,7 @@ $(function() {
...
@@ -168,7 +168,7 @@ $(function() {
/* 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'
);
addModalConfirmation
(
removeInterface
,
addModalConfirmation
(
removeInterface
,
{
'url'
:
'/dashboard/interface/'
+
interface_pk
+
'/delete/'
,
{
'url'
:
'/dashboard/interface/'
+
interface_pk
+
'/delete/'
,
'data'
:
[],
'data'
:
[],
'pk'
:
interface_pk
,
'pk'
:
interface_pk
,
...
@@ -181,15 +181,15 @@ $(function() {
...
@@ -181,15 +181,15 @@ $(function() {
function
removeInterface
(
data
)
{
function
removeInterface
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
/* remove the html element */
/* remove the html element */
$
(
'a[data-interface-pk="'
+
data
.
pk
+
'"]'
).
closest
(
"div"
).
fadeOut
();
$
(
'a[data-interface-pk="'
+
data
.
pk
+
'"]'
).
closest
(
"div"
).
fadeOut
();
location
.
reload
();
location
.
reload
();
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
}
});
});
}
}
...
@@ -219,12 +219,12 @@ $(function() {
...
@@ -219,12 +219,12 @@ $(function() {
data
:
{
'new_name'
:
name
},
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
".vm-details-home-edit-name"
).
text
(
data
[
'new_name'
]
).
show
();
$
(
".vm-details-home-edit-name"
).
text
(
data
.
new_name
).
show
();
$
(
".vm-details-home-edit-name"
).
parent
(
"div"
).
show
();
$
(
".vm-details-home-edit-name"
).
parent
(
"div"
).
show
();
$
(
".vm-details-home-edit-name-click"
).
show
();
$
(
".vm-details-home-edit-name-click"
).
show
();
$
(
".vm-details-home-rename-form-div"
).
hide
();
$
(
".vm-details-home-rename-form-div"
).
hide
();
// update the inputs too
// update the inputs too
$
(
".vm-details-rename-submit"
).
parent
(
"span"
).
prev
(
"input"
).
val
(
data
[
'new_name'
]);
$
(
".vm-details-rename-submit"
).
parent
(
"span"
).
prev
(
"input"
).
val
(
data
.
new_name
);
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
addMessage
(
"Error during renaming!"
,
"danger"
);
...
@@ -232,7 +232,7 @@ $(function() {
...
@@ -232,7 +232,7 @@ $(function() {
});
});
return
false
;
return
false
;
});
});
/* update description click */
/* update description click */
$
(
".vm-details-home-edit-description-click"
).
click
(
function
()
{
$
(
".vm-details-home-edit-description-click"
).
click
(
function
()
{
$
(
".vm-details-home-edit-description-click"
).
hide
();
$
(
".vm-details-home-edit-description-click"
).
hide
();
...
@@ -241,10 +241,10 @@ $(function() {
...
@@ -241,10 +241,10 @@ $(function() {
var
tmp
=
ta
.
val
();
var
tmp
=
ta
.
val
();
ta
.
val
(
""
);
ta
.
val
(
""
);
ta
.
focus
();
ta
.
focus
();
ta
.
val
(
tmp
)
ta
.
val
(
tmp
)
;
return
false
;
return
false
;
});
});
/* description update ajax */
/* description update ajax */
$
(
'.vm-details-description-submit'
).
click
(
function
()
{
$
(
'.vm-details-description-submit'
).
click
(
function
()
{
var
description
=
$
(
this
).
prev
(
"textarea"
).
val
();
var
description
=
$
(
this
).
prev
(
"textarea"
).
val
();
...
@@ -254,14 +254,14 @@ $(function() {
...
@@ -254,14 +254,14 @@ $(function() {
data
:
{
'new_description'
:
description
},
data
:
{
'new_description'
:
description
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
var
new_desc
=
data
[
'new_description'
]
;
var
new_desc
=
data
.
new_description
;
/* we can't simply use $.text, because we need new lines */
/* we can't simply use $.text, because we need new lines */
var
tagsToReplace
=
{
var
tagsToReplace
=
{
'&'
:
"&"
,
'&'
:
"&"
,
'<'
:
"<"
,
'<'
:
"<"
,
'>'
:
">"
,
'>'
:
">"
,
};
};
new_desc
=
new_desc
.
replace
(
/
[
&<>
]
/g
,
function
(
tag
)
{
new_desc
=
new_desc
.
replace
(
/
[
&<>
]
/g
,
function
(
tag
)
{
return
tagsToReplace
[
tag
]
||
tag
;
return
tagsToReplace
[
tag
]
||
tag
;
});
});
...
@@ -271,7 +271,7 @@ $(function() {
...
@@ -271,7 +271,7 @@ $(function() {
$
(
".vm-details-home-edit-description-click"
).
show
();
$
(
".vm-details-home-edit-description-click"
).
show
();
$
(
"#vm-details-home-description"
).
hide
();
$
(
"#vm-details-home-description"
).
hide
();
// update the textareia
// update the textareia
$
(
"vm-details-home-description textarea"
).
text
(
data
[
'new_description'
]);
$
(
"vm-details-home-description textarea"
).
text
(
data
.
new_description
);
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
addMessage
(
"Error during renaming!"
,
"danger"
);
...
@@ -298,8 +298,8 @@ $(function() {
...
@@ -298,8 +298,8 @@ $(function() {
.
find
(
"i"
).
removeClass
(
"fa-spinner fa-spin"
);
.
find
(
"i"
).
removeClass
(
"fa-spinner fa-spin"
);
});
});
// screenshot close
// screenshot close
$
(
"#vm-console-screenshot button"
).
click
(
function
()
{
$
(
"#vm-console-screenshot button"
).
click
(
function
()
{
$
(
this
).
parent
(
"div"
).
slideUp
();
$
(
this
).
parent
(
"div"
).
slideUp
();
...
@@ -320,15 +320,15 @@ $(function() {
...
@@ -320,15 +320,15 @@ $(function() {
function
removePort
(
data
)
{
function
removePort
(
data
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
success
:
function
(
re
,
textStatus
,
xhr
)
{
$
(
"a[data-rule="
+
data
[
'rule'
]
+
"]"
).
each
(
function
()
{
$
(
"a[data-rule="
+
data
.
rule
+
"]"
).
each
(
function
()
{
$
(
this
).
closest
(
"tr"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
closest
(
"tr"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
});
});
});
});
addMessage
(
re
[
'message'
]
,
"success"
);
addMessage
(
re
.
message
,
"success"
);
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
...
@@ -345,7 +345,7 @@ function decideActivityRefresh() {
...
@@ -345,7 +345,7 @@ function decideActivityRefresh() {
/* 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
;
}
}
...
@@ -357,32 +357,32 @@ function checkNewActivity(runs) {
...
@@ -357,32 +357,32 @@ function checkNewActivity(runs) {
url
:
'/dashboard/vm/'
+
instance
+
'/activity/'
,
url
:
'/dashboard/vm/'
+
instance
+
'/activity/'
,
data
:
{
'show_all'
:
show_all
},
data
:
{
'show_all'
:
show_all
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
var
new_activity_hash
=
(
data
[
'activities'
]
+
""
).
hashCode
();
var
new_activity_hash
=
(
data
.
activities
+
""
).
hashCode
();
if
(
new_activity_hash
!=
activity_hash
)
{
if
(
new_activity_hash
!=
activity_hash
)
{
$
(
"#activity-refresh"
).
html
(
data
[
'activities'
]
);
$
(
"#activity-refresh"
).
html
(
data
.
activities
);
}
}
activity_hash
=
new_activity_hash
;
activity_hash
=
new_activity_hash
;
$
(
"#ops"
).
html
(
data
[
'ops'
]
);
$
(
"#ops"
).
html
(
data
.
ops
);
$
(
"#disk-ops"
).
html
(
data
[
'disk_ops'
]
);
$
(
"#disk-ops"
).
html
(
data
.
disk_ops
);
$
(
"[title]"
).
tooltip
();
$
(
"[title]"
).
tooltip
();
/* changing the status text */
/* changing the status text */
var
icon
=
$
(
"#vm-details-state i"
);
var
icon
=
$
(
"#vm-details-state i"
);
if
(
data
[
'is_new_state'
]
)
{
if
(
data
.
is_new_state
)
{
if
(
!
icon
.
hasClass
(
"fa-spin"
))
if
(
!
icon
.
hasClass
(
"fa-spin"
))
icon
.
prop
(
"class"
,
"fa fa-spinner fa-spin"
);
icon
.
prop
(
"class"
,
"fa fa-spinner fa-spin"
);
}
else
{
}
else
{
icon
.
prop
(
"class"
,
"fa "
+
data
[
'icon'
]
);
icon
.
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
());
if
(
data
[
'status'
]
==
"RUNNING"
)
{
if
(
data
.
status
==
"RUNNING"
)
{
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"pill"
).
attr
(
"href"
,
"#console"
).
parent
(
"li"
).
removeClass
(
"disabled"
);
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"pill"
).
attr
(
"href"
,
"#console"
).
parent
(
"li"
).
removeClass
(
"disabled"
);
}
else
{
}
else
{
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"_pill"
).
attr
(
"href"
,
"#"
).
parent
(
"li"
).
addClass
(
"disabled"
);
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"_pill"
).
attr
(
"href"
,
"#"
).
parent
(
"li"
).
addClass
(
"disabled"
);
}
}
if
(
data
[
'status'
]
==
"STOPPED"
||
data
[
'status'
]
==
"PENDING"
)
{
if
(
data
.
status
==
"STOPPED"
||
data
.
status
==
"PENDING"
)
{
$
(
".change-resources-button"
).
prop
(
"disabled"
,
false
);
$
(
".change-resources-button"
).
prop
(
"disabled"
,
false
);
$
(
".change-resources-help"
).
hide
();
$
(
".change-resources-help"
).
hide
();
}
else
{
}
else
{
...
@@ -392,7 +392,7 @@ function checkNewActivity(runs) {
...
@@ -392,7 +392,7 @@ function checkNewActivity(runs) {
if
(
runs
>
0
&&
decideActivityRefresh
())
{
if
(
runs
>
0
&&
decideActivityRefresh
())
{
setTimeout
(
setTimeout
(
function
()
{
checkNewActivity
(
runs
+
1
)
},
function
()
{
checkNewActivity
(
runs
+
1
)
;},
1000
+
Math
.
exp
(
runs
*
0.05
)
1000
+
Math
.
exp
(
runs
*
0.05
)
);
);
}
else
{
}
else
{
...
@@ -408,7 +408,7 @@ function checkNewActivity(runs) {
...
@@ -408,7 +408,7 @@ function checkNewActivity(runs) {
String
.
prototype
.
hashCode
=
function
()
{
String
.
prototype
.
hashCode
=
function
()
{
var
hash
=
0
,
i
,
chr
,
len
;
var
hash
=
0
,
i
,
chr
,
len
;
if
(
this
.
length
==
0
)
return
hash
;
if
(
this
.
length
==
=
0
)
return
hash
;
for
(
i
=
0
,
len
=
this
.
length
;
i
<
len
;
i
++
)
{
for
(
i
=
0
,
len
=
this
.
length
;
i
<
len
;
i
++
)
{
chr
=
this
.
charCodeAt
(
i
);
chr
=
this
.
charCodeAt
(
i
);
hash
=
((
hash
<<
5
)
-
hash
)
+
chr
;
hash
=
((
hash
<<
5
)
-
hash
)
+
chr
;
...
...
circle/dashboard/static/dashboard/vm-list.js
View file @
6cb335d7
...
@@ -25,7 +25,7 @@ $(function() {
...
@@ -25,7 +25,7 @@ $(function() {
retval
=
false
;
retval
=
false
;
}
else
if
(
shiftDown
)
{
}
else
if
(
shiftDown
)
{
if
(
selected
.
length
>
0
)
{
if
(
selected
.
length
>
0
)
{
start
=
selected
[
selected
.
length
-
1
]
[
'index'
]
+
1
;
start
=
selected
[
selected
.
length
-
1
]
.
index
+
1
;
end
=
$
(
this
).
index
();
end
=
$
(
this
).
index
();
if
(
start
>
end
)
{
if
(
start
>
end
)
{
...
@@ -115,7 +115,7 @@ $(function() {
...
@@ -115,7 +115,7 @@ $(function() {
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
updateStatuses
(
1
);
updateStatuses
(
1
);
/* if there are messages display them */
/* if there are messages display them */
if
(
data
.
messages
&&
data
.
messages
.
length
>
0
)
{
if
(
data
.
messages
&&
data
.
messages
.
length
>
0
)
{
addMessage
(
data
.
messages
.
join
(
"<br />"
),
"danger"
);
addMessage
(
data
.
messages
.
join
(
"<br />"
),
"danger"
);
...
@@ -123,7 +123,7 @@ $(function() {
...
@@ -123,7 +123,7 @@ $(function() {
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
$
(
'#confirmation-modal'
).
modal
(
"hide"
);
if
(
xhr
.
status
==
500
)
{
if
(
xhr
.
status
==
500
)
{
addMessage
(
"500 Internal Server Error"
,
"danger"
);
addMessage
(
"500 Internal Server Error"
,
"danger"
);
}
else
{
}
else
{
...
@@ -145,7 +145,7 @@ $(function() {
...
@@ -145,7 +145,7 @@ $(function() {
// this didn't work ;;
// this didn't work ;;
// var th = $("this").find("th");
// var th = $("this").find("th");
$
(
".table-sorting"
).
hide
();
$
(
".table-sorting"
).
hide
();
$
(
".vm-list-table thead th i"
).
remove
();
$
(
".vm-list-table thead th i"
).
remove
();
var
icon_html
=
'<i class="fa fa-sort-'
+
(
data
.
direction
==
"desc"
?
"desc"
:
"asc"
)
+
' pull-right"></i>'
;
var
icon_html
=
'<i class="fa fa-sort-'
+
(
data
.
direction
==
"desc"
?
"desc"
:
"asc"
)
+
' pull-right"></i>'
;
...
@@ -160,7 +160,7 @@ $(function() {
...
@@ -160,7 +160,7 @@ $(function() {
});
});
$
(
document
).
on
(
"click"
,
".mass-migrate-node"
,
function
()
{
$
(
document
).
on
(
"click"
,
".mass-migrate-node"
,
function
()
{
$
(
this
).
find
(
'input[type="radio"]'
).
prop
(
"checked"
,
true
);
$
(
this
).
find
(
'input[type="radio"]'
).
prop
(
"checked"
,
true
);
});
});
if
(
checkStatusUpdate
())
{
if
(
checkStatusUpdate
())
{
...
@@ -206,10 +206,10 @@ function updateStatuses(runs) {
...
@@ -206,10 +206,10 @@ function updateStatuses(runs) {
$
(
this
).
remove
();
$
(
this
).
remove
();
}
}
});
});
if
(
checkStatusUpdate
())
{
if
(
checkStatusUpdate
())
{
setTimeout
(
setTimeout
(
function
()
{
updateStatuses
(
runs
+
1
)},
function
()
{
updateStatuses
(
runs
+
1
)},
1000
+
Math
.
exp
(
runs
*
0.05
)
1000
+
Math
.
exp
(
runs
*
0.05
)
);
);
}
}
...
@@ -236,7 +236,7 @@ function collectIds(rows) {
...
@@ -236,7 +236,7 @@ function collectIds(rows) {
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
ids
.
push
(
rows
[
i
].
vm
);
ids
.
push
(
rows
[
i
].
vm
);
}
}
return
ids
;
return
ids
;
}
}
function
setRowColor
(
row
)
{
function
setRowColor
(
row
)
{
...
...
circle/dashboard/static/dashboard/vm-tour.js
View file @
6cb335d7
...
@@ -42,7 +42,7 @@ function createTemplateTour() {
...
@@ -42,7 +42,7 @@ function createTemplateTour() {
ttour
.
addStep
({
ttour
.
addStep
({
backdrop
:
true
,
backdrop
:
true
,
element
:
'a[href="#home"]'
,
element
:
'a[href="#home"]'
,
title
:
gettext
(
"Home tab"
),
title
:
gettext
(
"Home tab"
),
content
:
gettext
(
"In this tab you can tag your virtual machine and modify the name and description."
),
content
:
gettext
(
"In this tab you can tag your virtual machine and modify the name and description."
),
placement
:
'top'
,
placement
:
'top'
,
onShow
:
function
()
{
onShow
:
function
()
{
...
@@ -66,9 +66,9 @@ function createTemplateTour() {
...
@@ -66,9 +66,9 @@ function createTemplateTour() {
placement
:
'top'
,
placement
:
'top'
,
backdrop
:
true
,
backdrop
:
true
,
title
:
gettext
(
"Resources"
),
title
:
gettext
(
"Resources"
),
content
:
'<p><strong>'
+
gettext
(
"CPU priority"
)
+
":</strong> "
+
gettext
(
"higher is better"
)
+
"</p>"
+
content
:
'<p><strong>'
+
gettext
(
"CPU priority"
)
+
":</strong> "
+
gettext
(
"higher is better"
)
+
"</p>"
+
'<p><strong>'
+
gettext
(
"CPU count"
)
+
":</strong> "
+
gettext
(
"number of CPU cores."
)
+
"</p>"
+
'<p><strong>'
+
gettext
(
"CPU count"
)
+
":</strong> "
+
gettext
(
"number of CPU cores."
)
+
"</p>"
+
'<p><strong>'
+
gettext
(
"RAM amount"
)
+
":</strong> "
+
gettext
(
"amount of RAM."
)
+
"</p>"
,
'<p><strong>'
+
gettext
(
"RAM amount"
)
+
":</strong> "
+
gettext
(
"amount of RAM."
)
+
"</p>"
,
onShow
:
function
()
{
onShow
:
function
()
{
$
(
'a[href="#resources"]'
).
trigger
(
"click"
);
$
(
'a[href="#resources"]'
).
trigger
(
"click"
);
},
},
...
@@ -111,7 +111,7 @@ function createTemplateTour() {
...
@@ -111,7 +111,7 @@ function createTemplateTour() {
placement
:
"top"
,
placement
:
"top"
,
backdrop
:
true
,
backdrop
:
true
,
content
:
gettext
(
"Use the connection string or connect with your choice of client!"
),
content
:
gettext
(
"Use the connection string or connect with your choice of client!"
),
});
});
ttour
.
addStep
({
ttour
.
addStep
({
...
@@ -128,8 +128,8 @@ function createTemplateTour() {
...
@@ -128,8 +128,8 @@ function createTemplateTour() {
backdrop
:
true
,
backdrop
:
true
,
content
:
gettext
(
'Press the "Save as template" button and wait until the activity finishes.'
),
content
:
gettext
(
'Press the "Save as template" button and wait until the activity finishes.'
),
});
});
ttour
.
addStep
({
ttour
.
addStep
({
element
:
".alert-new-template"
,
element
:
".alert-new-template"
,
title
:
gettext
(
"Finish"
),
title
:
gettext
(
"Finish"
),
...
@@ -137,6 +137,6 @@ function createTemplateTour() {
...
@@ -137,6 +137,6 @@ function createTemplateTour() {
placement
:
"bottom"
,
placement
:
"bottom"
,
content
:
gettext
(
"This is the last message, if something is not clear you can do the the tour again!"
),
content
:
gettext
(
"This is the last message, if something is not clear you can do the the tour again!"
),
});
});
return
ttour
;
return
ttour
;
}
}
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