Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
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 () {
var
template
=
$
(
this
).
data
(
"template"
);
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/vm/create/'
+
(
typeof
template
===
"undefined"
?
''
:
'?template='
+
template
),
success
:
function
(
data
)
{
url
:
'/dashboard/vm/create/'
+
(
typeof
template
===
"undefined"
?
''
:
'?template='
+
template
),
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
vmCreateLoaded
();
addSliderMiscs
();
...
...
@@ -16,12 +16,12 @@ $(function () {
});
return
false
;
});
$
(
'.node-create'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/node/create/'
,
success
:
function
(
data
)
{
url
:
'/dashboard/node/create/'
,
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
nodeCreateLoaded
();
addSliderMiscs
();
...
...
@@ -53,8 +53,8 @@ $(function () {
$
(
'.template-choose'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/template/choose/'
,
success
:
function
(
data
)
{
url
:
'/dashboard/template/choose/'
,
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
...
...
@@ -154,7 +154,7 @@ $(function () {
$
(
'.vm-delete'
).
click
(
function
()
{
var
vm_pk
=
$
(
this
).
data
(
'vm-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/vm/delete/'
+
vm_pk
+
'/'
,
'data'
:
[],
'pk'
:
vm_pk
,
...
...
@@ -162,11 +162,11 @@ $(function () {
'redirect'
:
dir
});
return
false
;
});
/* for disk remove buttons */
$
(
'.disk-remove'
).
click
(
function
()
{
var
disk_pk
=
$
(
this
).
data
(
'disk-pk'
);
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/disk/'
+
disk_pk
+
'/remove/'
,
'data'
:
[],
'pk'
:
disk_pk
,
...
...
@@ -179,13 +179,13 @@ $(function () {
$
(
'.node-delete'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/node/delete/'
+
node_pk
+
'/'
,
'data'
:
[],
'pk'
:
node_pk
,
'type'
:
"node"
,
'redirect'
:
dir
});
return
false
;
});
...
...
@@ -194,8 +194,8 @@ $(function () {
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
postto
=
$
(
this
).
attr
(
'href'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
function
(){},
{
'url'
:
postto
,
addModalConfirmation
(
function
(){},
{
'url'
:
postto
,
'data'
:
[],
'pk'
:
node_pk
,
'type'
:
"node"
,
...
...
@@ -208,18 +208,18 @@ $(function () {
$
(
'.group-delete'
).
click
(
function
()
{
var
group_pk
=
$
(
this
).
data
(
'group-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/group/delete/'
+
group_pk
+
'/'
,
'data'
:
[],
'type'
:
"group"
,
'pk'
:
group_pk
,
'redirect'
:
dir
});
return
false
;
});
/* search for vms */
var
my_vms
=
[]
var
my_vms
=
[]
;
$
(
"#dashboard-vm-search-input"
).
keyup
(
function
(
e
)
{
// if my_vms is empty get a list of our vms
if
(
my_vms
.
length
<
1
)
{
...
...
@@ -241,7 +241,7 @@ $(function () {
}
input
=
$
(
"#dashboard-vm-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
for
(
var
i
in
my_vms
)
{
if
(
my_vms
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
...
...
@@ -249,12 +249,12 @@ $(function () {
}
}
search_result
.
sort
(
compareVmByFav
);
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
for
(
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
search_result
[
i
].
host
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
fav
,
(
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>'
;
$
(
"#dashboard-vm-list"
).
html
(
html
);
$
(
'.title-favourite'
).
tooltip
({
'placement'
:
'right'
});
...
...
@@ -270,7 +270,7 @@ $(function () {
});
/* search for nodes */
var
my_nodes
=
[]
var
my_nodes
=
[]
;
$
(
"#dashboard-node-search-input"
).
keyup
(
function
(
e
)
{
// if my_nodes is empty get a list of our nodes
if
(
my_nodes
.
length
<
1
)
{
...
...
@@ -290,29 +290,29 @@ $(function () {
}
input
=
$
(
"#dashboard-node-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
for
(
var
i
in
my_nodes
)
{
if
(
my_nodes
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
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
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
url
,
(
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>'
;
$
(
"#dashboard-node-list"
).
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
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
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>'
;
$
(
"#dashboard-node-taglist"
).
html
(
html
);
...
...
@@ -326,7 +326,7 @@ $(function () {
});
/* search for groups */
var
my_groups
=
[]
var
my_groups
=
[]
;
$
(
"#dashboard-group-search-input"
).
keyup
(
function
(
e
)
{
// if my_groups is empty get a list of our groups
if
(
my_groups
.
length
<
1
)
{
...
...
@@ -343,16 +343,16 @@ $(function () {
}
input
=
$
(
"#dashboard-group-search-input"
).
val
().
toLowerCase
();
var
search_result
=
[]
var
search_result
=
[]
;
var
html
=
''
;
for
(
var
i
in
my_groups
)
{
if
(
my_groups
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
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
);
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
=
0
)
html
+=
'<div class="list-group-item list-group-item-last">No result</div>'
;
$
(
"#dashboard-group-list"
).
html
(
html
);
...
...
@@ -374,30 +374,30 @@ $(function () {
/* don't close notifications window on missclick */
$
(
document
).
on
(
"click"
,
".notification-messages"
,
function
(
e
)
{
if
(
$
(
e
.
target
).
closest
(
"a"
).
length
)
return
true
return
true
;
else
return
false
;
});
$
(
"#notification-button a"
).
click
(
function
()
{
$
(
'.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
)
{
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item'
+
(
is_last
?
' list-group-item-last'
:
''
)
+
'">'
+
'<span class="index-vm-list-name">'
+
(
is_last
?
' list-group-item-last'
:
''
)
+
'">'
+
'<span class="index-vm-list-name">'
+
'<i class="fa '
+
icon
+
'" title="'
+
_status
+
'"></i> '
+
name
+
'</span>'
+
'</span>'
+
'<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>'
:
'<i class="fa fa-star-o text-primary title-favourite" title="Mark as favorite"></i>'
)
+
'</div>'
+
'<div style="clear: both;"></div>'
+
'</a>'
;
'</div>'
+
'<div style="clear: both;"></div>'
+
'</a>'
;
}
function
generateGroupHTML
(
url
,
name
,
is_last
)
{
...
...
@@ -424,7 +424,7 @@ function generateNodeTagHTML(name, icon, _status, label , url) {
/* copare vm-s by fav, pk order */
function
compareVmByFav
(
a
,
b
)
{
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
)
{
return
-
1
;
...
...
@@ -433,13 +433,13 @@ function compareVmByFav(a, b) {
return
1
;
}
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
)
{
$
(
".cpu-priority-input"
).
trigger
(
"change"
);
$
(
".cpu-count-input, .ram-input"
).
trigger
(
"input"
);
})
})
;
function
addSliderMiscs
()
{
// set max values based on inputs
...
...
@@ -470,7 +470,7 @@ function addSliderMiscs() {
if
(
!
val
)
return
;
$
(
".cpu-count-slider"
).
simpleSlider
(
"setValue"
,
val
);
});
var
ram_fire
=
false
;
$
(
".ram-slider"
).
bind
(
"slider:changed"
,
function
(
event
,
data
)
{
...
...
@@ -508,21 +508,21 @@ function setDefaultSliderValues() {
function
deleteObject
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
data
:
{
'redirect'
:
data
[
'redirect'
]
},
url
:
data
[
'url'
]
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
[
'redirect'
]
)
{
data
:
{
'redirect'
:
data
.
redirect
},
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
.
redirect
)
{
selected
=
[];
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
if
(
data
.
type
===
"disk"
)
{
// no need to remove them from DOM
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"li"
).
fadeOut
();
$
(
'a[data-disk-pk="'
+
data
.
pk
+
'"]'
).
parent
(
"h4"
).
fadeOut
();
}
else
{
$
(
'a[data-'
+
data
[
'type'
]
+
'-pk="'
+
data
[
'pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
}
else
{
$
(
'a[data-'
+
data
.
type
+
'-pk="'
+
data
.
pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
});
}
}
else
{
...
...
@@ -530,32 +530,33 @@ function deleteObject(data) {
}
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
});
}
function
massDeleteVm
(
data
)
{
$
.
ajax
({
traditional
:
true
,
url
:
data
[
'url'
],
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
type
:
'POST'
,
data
:
{
'vms'
:
data
[
'data'
][
'v'
]},
success
:
function
(
re
,
textStatus
,
xhr
)
{
for
(
var
i
=
0
;
i
<
data
[
'data'
][
'v'
].
length
;
i
++
)
$
(
'.vm-list-table tbody tr[data-vm-pk="'
+
data
[
'data'
][
'v'
][
i
]
+
'"]'
).
fadeOut
(
500
,
function
()
{
selected
=
[];
// reset group buttons
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
$
(
this
).
remove
();
});
addMessage
(
re
[
'message'
],
'success'
);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
// TODO this
}
});
f
=
function
()
{
selected
=
[];
// reset group buttons
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
$
(
this
).
remove
();
};
$
.
ajax
({
traditional
:
true
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
type
:
'POST'
,
data
:
{
'vms'
:
data
.
data
.
v
},
success
:
function
(
re
,
textStatus
,
xhr
)
{
for
(
var
i
=
0
;
i
<
data
.
data
.
v
.
length
;
i
++
)
$
(
'.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
}
});
}
...
...
@@ -573,8 +574,8 @@ function addMessage(text, type) {
function
addModalConfirmation
(
func
,
data
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
data
[
'url'
]
,
data
:
jQuery
.
param
(
data
[
'data'
]
),
url
:
data
.
url
,
data
:
jQuery
.
param
(
data
.
data
),
success
:
function
(
result
)
{
$
(
'body'
).
append
(
result
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
...
...
@@ -590,25 +591,25 @@ function addModalConfirmation(func, data) {
}
// for AJAX calls
/**
* Getter for user cookies
* @param {String} name Cookie name
* @return {String} Cookie value
*/
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
/**
* Getter for user cookies
* @param {String} name Cookie name
* @return {String} Cookie value
*/
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
break
;
}
}
}
return
cookieValue
;
}
...
...
circle/dashboard/static/dashboard/disk-list.js
View file @
6cb335d7
...
...
@@ -8,16 +8,16 @@ $(function() {
function
refreshDisk
(
disk
,
element
)
{
$
.
get
(
"/dashboard/disk/"
+
disk
+
"/status/"
,
function
(
result
)
{
if
(
result
.
percentage
==
null
||
result
.
failed
==
"True"
)
{
location
.
reload
();
if
(
result
.
percentage
==
=
null
||
result
.
failed
==
"True"
)
{
location
.
reload
();
}
else
{
var
diff
=
result
.
percentage
-
parseInt
(
element
.
html
());
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
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 @@
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
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
();
// addMessage(data['message'], "success");
},
...
...
@@ -51,14 +51,14 @@
function
removeMember
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
data
[
'tr'
]
.
fadeOut
(
function
()
{
data
.
tr
.
fadeOut
(
function
()
{
$
(
this
).
remove
();});
},
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() {
/* rename ajax */
$
(
'.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
url
=
'/dashboard/group/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
$
.
ajax
({
...
...
@@ -16,12 +16,12 @@ $(function() {
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#group-list-column-name"
,
row
).
html
(
$
(
"<a/>"
,
{
'class'
:
"real-link"
,
href
:
"/dashboard/group/"
+
data
[
'group_pk'
]
+
"/"
,
text
:
data
[
'new_name'
]
href
:
"/dashboard/group/"
+
data
.
group_pk
+
"/"
,
text
:
data
.
new_name
})
).
show
();
$
(
'#group-list-rename'
,
row
).
hide
();
...
...
circle/dashboard/static/dashboard/node-details.js
View file @
6cb335d7
...
...
@@ -15,9 +15,9 @@ $(function() {
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
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
();
// addMessage(data
['message']
, "success");
// addMessage(data
.message
, "success");
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
...
...
@@ -34,7 +34,7 @@ $(function() {
$
(
'.node-enable'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
changeNodeStatus
,
addModalConfirmation
(
changeNodeStatus
,
{
'url'
:
'/dashboard/node/status/'
+
node_pk
+
'/'
,
'data'
:
[],
'pk'
:
node_pk
,
...
...
@@ -51,17 +51,17 @@ $(function() {
$
.
ajax
({
type
:
'POST'
,
url
:
location
.
href
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
data
:
{
'to_remove'
:
to_remove
},
success
:
function
(
re
)
{
if
(
re
[
'message'
]
.
toLowerCase
()
==
"success"
)
{
if
(
re
.
message
.
toLowerCase
()
==
"success"
)
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
});
}
},
error
:
function
()
{
addMessage
(
re
[
'message'
]
,
'danger'
);
addMessage
(
re
.
message
,
'danger'
);
}
});
...
...
@@ -73,18 +73,18 @@ $(function() {
function
changeNodeStatus
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
[
'url'
]
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
[
'redirect'
]
)
{
if
(
!
data
.
redirect
)
{
selected
=
[];
addMessage
(
re
[
'message'
]
,
'success'
);
addMessage
(
re
.
message
,
'success'
);
}
else
{
window
.
location
.
replace
(
'/dashboard'
);
}
},
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() {
});
// find disabled nodes, set danger (red) on the rows
function
colortable
()
function
colortable
()
{
var
tr
=
$
(
'.false'
).
closest
(
"tr"
);
tr
.
addClass
(
'danger'
);
var
tr
=
$
(
'.true'
).
closest
(
"tr"
);
tr
.
removeClass
(
'danger'
);
$
(
'.false'
).
closest
(
"tr"
).
addClass
(
'danger'
);
$
(
'.true'
).
closest
(
"tr"
).
removeClass
(
'danger'
);
}
/* rename */
...
...
@@ -20,7 +18,7 @@ $(function() {
/* rename ajax */
$
(
'.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
url
=
'/dashboard/node/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
$
.
ajax
({
...
...
@@ -29,12 +27,12 @@ $(function() {
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#node-list-column-name"
,
row
).
html
(
$
(
"<a/>"
,
{
'class'
:
"real-link"
,
href
:
"/dashboard/node/"
+
data
[
'node_pk'
]
+
"/"
,
text
:
data
[
'new_name'
]
href
:
"/dashboard/node/"
+
data
.
node_pk
+
"/"
,
text
:
data
.
new_name
})
).
show
();
$
(
'#node-list-rename'
,
row
).
hide
();
...
...
@@ -50,7 +48,7 @@ $(function() {
function
statuschangeSuccess
(
tr
){
var
tspan
=
tr
.
children
(
'.enabled'
).
children
();
var
buttons
=
tr
.
children
(
'.actions'
).
children
(
'.btn-group'
).
children
(
'.dropdown-menu'
).
children
(
'li'
).
children
(
'.node-enable'
);
buttons
.
each
(
function
(
index
){
if
(
$
(
this
).
css
(
"display"
)
==
"block"
){
$
(
this
).
css
(
"display"
,
"none"
);
...
...
@@ -58,12 +56,12 @@ $(function() {
else
{
$
(
this
).
css
(
"display"
,
"block"
);
}
});
});
if
(
tspan
.
hasClass
(
"false"
)){
tspan
.
removeClass
(
"false"
);
tspan
.
addClass
(
"true"
);
tspan
.
text
(
"✔"
);
}
}
else
{
tspan
.
removeClass
(
"true"
);
tspan
.
addClass
(
"false"
);
...
...
circle/dashboard/static/dashboard/profile.js
View file @
6cb335d7
...
...
@@ -7,10 +7,10 @@ $(function() {
$
.
ajax
({
type
:
'POST'
,
url
:
"/dashboard/profile/"
+
user
+
"/use_gravatar/"
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
)
{
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
)
{
...
...
circle/dashboard/static/dashboard/store.js
View file @
6cb335d7
...
...
@@ -25,18 +25,18 @@ $(function() {
$
(
'#store-upload-form button[type="submit"] i'
).
addClass
(
"fa-spinner fa-spin"
);
var
current_dir
=
$
(
"#store-upload-form"
).
find
(
'[name="current_dir"]'
).
val
();
$
.
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
();
});
return
false
;
});
/* "fake" browse button */
$
(
"#store-list-container"
).
on
(
"click"
,
"#store-upload-browse"
,
function
()
{
$
(
'#store-upload-form input[type="file"]'
).
click
();
});
$
(
"#store-list-container"
).
on
(
"change"
,
"#store-upload-file"
,
function
()
{
var
input
=
$
(
this
);
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() {
});
return
false
;
});
/* template table sort */
var
ttable
=
$
(
".template-list-table"
).
stupidtable
();
...
...
@@ -37,7 +37,7 @@ $(function() {
// only if js is enabled
$
(
".template-list-table thead th"
).
css
(
"cursor"
,
"pointer"
);
$
(
".template-list-table th a"
).
on
(
"click"
,
function
(
event
)
{
event
.
preventDefault
();
});
...
...
@@ -48,16 +48,16 @@ $(function() {
function
deleteTemplate
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
[
'url'
]
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
[
'message'
]
,
'success'
);
$
(
'a[data-template-pk="'
+
data
[
'template_pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
.
message
,
'success'
);
$
(
'a[data-template-pk="'
+
data
.
template_pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
addMessage
(
'Uh oh :('
,
'danger'
)
;
}
});
}
...
...
@@ -67,16 +67,16 @@ function deleteTemplate(data) {
function
deleteLease
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
[
'url'
]
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
[
'message'
]
,
'success'
);
$
(
'a[data-lease-pk="'
+
data
[
'lease_pk'
]
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
addMessage
(
re
.
message
,
'success'
);
$
(
'a[data-lease-pk="'
+
data
.
lease_pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
});