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
61883c5b
authored
Nov 15, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: js confirmation for mass delete vm
parent
c5b3cd6a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
26 deletions
+34
-26
circle/dashboard/static/dashboard/dashboard.js
+24
-0
circle/dashboard/static/dashboard/vm-list.js
+10
-26
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
61883c5b
...
@@ -83,6 +83,7 @@ function deleteVm(pk, dir) {
...
@@ -83,6 +83,7 @@ function deleteVm(pk, dir) {
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
success
:
function
(
data
,
textStatus
,
xhr
)
{
if
(
!
dir
)
{
if
(
!
dir
)
{
selected
=
[];
addMessage
(
data
[
'message'
],
'success'
);
addMessage
(
data
[
'message'
],
'success'
);
$
(
'a[data-vm-pk="'
+
pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
'a[data-vm-pk="'
+
pk
+
'"]'
).
closest
(
'tr'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
$
(
this
).
remove
();
...
@@ -97,6 +98,29 @@ function deleteVm(pk, dir) {
...
@@ -97,6 +98,29 @@ function deleteVm(pk, dir) {
});
});
}
}
function
massDeleteVm
()
{
$
.
ajax
({
traditional
:
true
,
url
:
'/dashboard/vm/mass-delete/'
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
type
:
'POST'
,
data
:
{
'vms'
:
collectIds
(
selected
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
for
(
var
i
=
0
;
i
<
selected
.
length
;
i
++
)
$
(
'.vm-list-table tbody tr'
).
eq
(
selected
[
i
]).
fadeOut
(
500
,
function
()
{
// reset group buttons
selected
=
[]
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
$
(
this
).
remove
();
addMessage
(
data
[
'message'
],
'success'
);
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
// TODO this
}
});
}
function
addMessage
(
text
,
type
)
{
function
addMessage
(
text
,
type
)
{
div
=
'<div style="display: none;" class="alert alert-'
+
type
+
'">'
+
text
+
'</div>'
;
div
=
'<div style="display: none;" class="alert alert-'
+
type
+
'">'
+
text
+
'</div>'
;
...
...
circle/dashboard/static/dashboard/vm-list.js
View file @
61883c5b
$
(
function
()
{
var
ctrlDown
,
shiftDown
=
false
;
var
ctrlDown
,
shiftDown
=
false
;
var
ctrlKey
=
17
;
var
ctrlKey
=
17
;
var
shiftKey
=
16
;
var
shiftKey
=
16
;
var
selected
=
[];
var
selected
=
[];
$
(
function
()
{
$
(
document
).
keydown
(
function
(
e
)
{
$
(
document
).
keydown
(
function
(
e
)
{
if
(
e
.
keyCode
==
ctrlKey
)
ctrlDown
=
true
;
if
(
e
.
keyCode
==
ctrlKey
)
ctrlDown
=
true
;
if
(
e
.
keyCode
==
shiftKey
)
shiftDown
=
true
;
if
(
e
.
keyCode
==
shiftKey
)
shiftDown
=
true
;
...
@@ -96,32 +96,16 @@ $(function() {
...
@@ -96,32 +96,16 @@ $(function() {
$
(
this
).
addClass
(
'vm-list-selected'
);
$
(
this
).
addClass
(
'vm-list-selected'
);
}
}
});
});
console
.
log
(
selected
);
if
(
selected
.
length
>
0
)
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
false
);
return
false
;
return
false
;
});
});
/* mass vm delete */
/* mass vm delete */
$
(
'#vm-list-group-delete'
).
click
(
function
()
{
$
(
'#vm-list-group-delete'
).
click
(
function
()
{
$
.
ajax
({
text
=
"Are you sure you want to delete the selected VMs?"
;
traditional
:
true
,
random_vm_pk
=
$
(
'.vm-delete'
).
eq
(
0
).
data
(
'vm-pk'
);
url
:
'/dashboard/vm/mass-delete/'
,
addModalConfirmation
(
text
,
random_vm_pk
,
massDeleteVm
,
false
);
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
type
:
'POST'
,
data
:
{
'vms'
:
collectIds
(
selected
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
for
(
var
i
=
0
;
i
<
selected
.
length
;
i
++
)
$
(
'.vm-list-table tbody tr'
).
eq
(
selected
[
i
]).
fadeOut
(
500
,
function
()
{
// reset group buttons
selected
=
[]
$
(
'.vm-list-group-control a'
).
attr
(
'disabled'
,
true
);
$
(
this
).
remove
();
addMessage
(
data
[
'message'
],
'success'
);
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
// TODO this
}
});
return
false
;
return
false
;
});
});
});
});
...
...
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