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
7fed7d2c
authored
Jan 01, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-remove-garbage'
parents
32e83265
f876f926
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
477 additions
and
1369 deletions
+477
-1369
circle/circle/settings/base.py
+1
-0
circle/common/operations.py
+2
-0
circle/dashboard/forms.py
+31
-1
circle/dashboard/static/dashboard/activity.js
+116
-4
circle/dashboard/static/dashboard/dashboard.js
+27
-171
circle/dashboard/static/dashboard/group-details.js
+0
-36
circle/dashboard/static/dashboard/group-list.js
+3
-3
circle/dashboard/static/dashboard/node-create.js
+0
-10
circle/dashboard/static/dashboard/node-details.js
+0
-33
circle/dashboard/static/dashboard/node-list.js
+0
-45
circle/dashboard/static/dashboard/template-list.js
+0
-86
circle/dashboard/static/dashboard/vm-create.js
+16
-18
circle/dashboard/static/dashboard/vm-details.js
+1
-219
circle/dashboard/templates/dashboard/confirm/ajax-delete.html
+14
-8
circle/dashboard/templates/dashboard/confirm/ajax-node-status.html
+0
-27
circle/dashboard/templates/dashboard/confirm/ajax-remove.html
+0
-22
circle/dashboard/templates/dashboard/confirm/base-delete.html
+10
-4
circle/dashboard/templates/dashboard/confirm/base-remove.html
+0
-14
circle/dashboard/templates/dashboard/confirm/base-renew.html
+0
-32
circle/dashboard/templates/dashboard/confirm/mass-delete.html
+0
-18
circle/dashboard/templates/dashboard/confirm/node-flush.html
+0
-33
circle/dashboard/templates/dashboard/confirm/node-status.html
+0
-35
circle/dashboard/templates/dashboard/group-list/column-name.html
+1
-1
circle/dashboard/templates/dashboard/index-templates.html
+1
-1
circle/dashboard/templates/dashboard/modal-wrapper.html
+0
-19
circle/dashboard/templates/dashboard/node-detail.html
+2
-1
circle/dashboard/templates/dashboard/node-detail/_activity-timeline.html
+30
-29
circle/dashboard/templates/dashboard/node-detail/activity.html
+1
-1
circle/dashboard/templates/dashboard/vm-detail.html
+2
-1
circle/dashboard/templates/dashboard/vm-detail/network.html
+14
-7
circle/dashboard/tests/test_views.py
+22
-96
circle/dashboard/urls.py
+7
-8
circle/dashboard/views/group.py
+20
-78
circle/dashboard/views/node.py
+28
-87
circle/dashboard/views/template.py
+19
-95
circle/dashboard/views/user.py
+10
-48
circle/dashboard/views/util.py
+43
-1
circle/dashboard/views/vm.py
+50
-73
circle/vm/models/instance.py
+6
-4
No files found.
circle/circle/settings/base.py
View file @
7fed7d2c
...
...
@@ -198,6 +198,7 @@ PIPELINE_JS = {
"jquery-knob/dist/jquery.knob.min.js"
,
"jquery-simple-slider/js/simple-slider.js"
,
"dashboard/dashboard.js"
,
"dashboard/activity.js"
,
"dashboard/group-details.js"
,
"dashboard/group-list.js"
,
"dashboard/js/stupidtable.min.js"
,
# no bower file
...
...
circle/common/operations.py
View file @
7fed7d2c
...
...
@@ -282,6 +282,8 @@ def register_operation(op_cls, op_id=None, target_cls=None):
"in the 'target_cls' parameter to this "
"call."
)
assert
not
hasattr
(
target_cls
,
op_id
),
(
"target class already has an attribute with this id"
)
if
not
issubclass
(
target_cls
,
OperatedMixin
):
raise
TypeError
(
"
%
r is not a subclass of
%
r"
%
(
target_cls
.
__name__
,
OperatedMixin
.
__name__
))
...
...
circle/dashboard/forms.py
View file @
7fed7d2c
...
...
@@ -898,7 +898,7 @@ class VmDownloadDiskForm(OperationForm):
def
clean
(
self
):
cleaned_data
=
super
(
VmDownloadDiskForm
,
self
)
.
clean
()
if
not
cleaned_data
[
'name'
]:
if
cleaned_data
[
'url'
]
:
if
cleaned_data
.
get
(
'url'
)
:
cleaned_data
[
'name'
]
=
urlparse
(
cleaned_data
[
'url'
])
.
path
.
split
(
'/'
)[
-
1
]
if
not
cleaned_data
[
'name'
]:
...
...
@@ -908,6 +908,36 @@ class VmDownloadDiskForm(OperationForm):
return
cleaned_data
class
VmRemoveInterfaceForm
(
OperationForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
self
.
interface
=
kwargs
.
pop
(
'default'
)
super
(
VmRemoveInterfaceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
.
insert
(
0
,
'interface'
,
forms
.
ModelChoiceField
(
queryset
=
choices
,
initial
=
self
.
interface
,
required
=
True
,
empty_label
=
None
,
label
=
_
(
'Interface'
)))
if
self
.
interface
:
self
.
fields
[
'interface'
]
.
widget
=
HiddenInput
()
@property
def
helper
(
self
):
helper
=
super
(
VmRemoveInterfaceForm
,
self
)
.
helper
if
self
.
interface
:
helper
.
layout
=
Layout
(
AnyTag
(
"div"
,
HTML
(
format_html
(
_
(
"<label>Vlan:</label> {0}"
),
self
.
interface
.
vlan
)),
css_class
=
"form-group"
,
),
Field
(
"interface"
),
)
return
helper
class
VmAddInterfaceForm
(
OperationForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
...
...
circle/dashboard/static/dashboard/
vm-common
.js
→
circle/dashboard/static/dashboard/
activity
.js
View file @
7fed7d2c
/* for functions in both vm list and vm detail */
$
(
function
()
{
var
in_progress
=
false
;
var
activity_hash
=
5
;
var
show_all
=
false
;
var
reload_vm_detail
=
false
;
/* do we need to check for new activities */
if
(
decideActivityRefresh
())
{
if
(
!
in_progress
)
{
checkNewActivity
(
1
);
in_progress
=
true
;
}
}
/* vm operations */
$
(
'a[href="#activity"]'
).
click
(
function
(){
$
(
'a[href="#activity"] i'
).
addClass
(
'fa-spin'
);
if
(
!
in_progress
)
{
checkNewActivity
(
1
);
in_progress
=
true
;
}
});
$
(
"#activity-refresh"
).
on
(
"click"
,
"#show-all-activities"
,
function
()
{
$
(
this
).
find
(
"i"
).
addClass
(
"fa-spinner fa-spin"
);
show_all
=
!
show_all
;
$
(
'a[href="#activity"]'
).
trigger
(
"click"
);
return
false
;
});
/* operations */
$
(
'#ops, #vm-details-resources-disk, #vm-details-renew-op, #vm-details-pw-reset, #vm-details-add-interface, .operation-wrapper'
).
on
(
'click'
,
'.operation'
,
function
(
e
)
{
var
icon
=
$
(
this
).
children
(
"i"
).
addClass
(
'fa-spinner fa-spin'
);
...
...
@@ -23,7 +48,7 @@ $(function() {
});
/* if the operation fails show the modal again */
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
$
(
"body"
).
on
(
"click"
,
"#
confirmation-modal #
op-form-send"
,
function
()
{
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
$
.
ajax
({
...
...
@@ -77,4 +102,91 @@ $(function() {
return
false
;
});
function
decideActivityRefresh
()
{
var
check
=
false
;
/* if something is still spinning */
if
(
$
(
'.timeline .activity i'
).
hasClass
(
'fa-spin'
))
check
=
true
;
return
check
;
}
function
checkNewActivity
(
runs
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
$
(
'a[href="#activity"]'
).
attr
(
'data-activity-url'
),
data
:
{
'show_all'
:
show_all
},
success
:
function
(
data
)
{
var
new_activity_hash
=
(
data
.
activities
+
""
).
hashCode
();
if
(
new_activity_hash
!=
activity_hash
)
{
$
(
"#activity-refresh"
).
html
(
data
.
activities
);
}
activity_hash
=
new_activity_hash
;
$
(
"#ops"
).
html
(
data
.
ops
);
$
(
"#disk-ops"
).
html
(
data
.
disk_ops
);
$
(
"[title]"
).
tooltip
();
/* changing the status text */
var
icon
=
$
(
"#vm-details-state i"
);
if
(
data
.
is_new_state
)
{
if
(
!
icon
.
hasClass
(
"fa-spin"
))
icon
.
prop
(
"class"
,
"fa fa-spinner fa-spin"
);
}
else
{
icon
.
prop
(
"class"
,
"fa "
+
data
.
icon
);
}
var
vm_state
=
$
(
"#vm-details-state"
);
if
(
vm_state
.
length
)
{
vm_state
.
data
(
"status"
,
data
[
'status'
]);
$
(
"#vm-details-state span"
).
html
(
data
[
'human_readable_status'
].
toUpperCase
());
}
if
(
data
[
'status'
]
==
"RUNNING"
)
{
if
(
data
[
'connect_uri'
])
{
$
(
"#dashboard-vm-details-connect-button"
).
removeClass
(
'disabled'
);
}
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"pill"
).
attr
(
"href"
,
"#console"
).
parent
(
"li"
).
removeClass
(
"disabled"
);
}
else
{
if
(
data
[
'connect_uri'
])
{
$
(
"#dashboard-vm-details-connect-button"
).
addClass
(
'disabled'
);
}
$
(
"[data-target=#_console]"
).
attr
(
"data-toggle"
,
"_pill"
).
attr
(
"href"
,
"#"
).
parent
(
"li"
).
addClass
(
"disabled"
);
}
if
(
data
.
status
==
"STOPPED"
||
data
.
status
==
"PENDING"
)
{
$
(
".change-resources-button"
).
prop
(
"disabled"
,
false
);
$
(
".change-resources-help"
).
hide
();
}
else
{
$
(
".change-resources-button"
).
prop
(
"disabled"
,
true
);
$
(
".change-resources-help"
).
show
();
}
if
(
runs
>
0
&&
decideActivityRefresh
())
{
setTimeout
(
function
()
{
checkNewActivity
(
runs
+
1
);},
1000
+
Math
.
exp
(
runs
*
0.05
)
);
}
else
{
in_progress
=
false
;
if
(
reload_vm_detail
)
location
.
reload
();
}
$
(
'a[href="#activity"] i'
).
removeClass
(
'fa-spin'
);
},
error
:
function
()
{
in_progress
=
false
;
}
});
}
});
String
.
prototype
.
hashCode
=
function
()
{
var
hash
=
0
,
i
,
chr
,
len
;
if
(
this
.
length
==
0
)
return
hash
;
for
(
i
=
0
,
len
=
this
.
length
;
i
<
len
;
i
++
)
{
chr
=
this
.
charCodeAt
(
i
);
hash
=
((
hash
<<
5
)
-
hash
)
+
chr
;
hash
|=
0
;
// Convert to 32bit integer
}
return
hash
;
};
circle/dashboard/static/dashboard/dashboard.js
View file @
7fed7d2c
...
...
@@ -5,63 +5,39 @@ $(function () {
var
template
=
$
(
this
).
data
(
"template"
);
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/vm/create/'
+
(
typeof
template
===
"undefined"
?
''
:
'?template='
+
template
),
url
:
$
(
this
).
attr
(
'href'
),
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
vmCreateLoaded
();
addSliderMiscs
();
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#create-modal'
).
remove
();
var
modal
=
$
(
'#confirmation-modal'
);
modal
.
modal
(
'show'
);
modal
.
on
(
'hidden.bs.modal'
,
function
()
{
modal
.
remove
();
});
}
});
return
false
;
});
$
(
'.
node-create
'
).
click
(
function
(
e
)
{
$
(
'.
group-create, .node-create, .tx-tpl-ownership, .group-delete, .node-delete, .disk-remove, .template-delete, .delete-from-group
'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/node/create/'
,
url
:
$
(
this
).
prop
(
'href'
)
,
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
nodeCreateLoaded
();
addSliderMiscs
();
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#create-modal'
).
remove
();
});
}
});
return
false
;
});
$
(
'.group-create'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/group/create/'
,
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
addSliderMiscs
();
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#create-modal'
).
remove
();
});
}
});
return
false
;
});
$
(
'.tx-tpl-ownership'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
$
(
'.tx-tpl-ownership'
).
attr
(
'href'
),
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
$
(
'#confirmation-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#confirmation-modal'
).
remove
();
var
modal
=
$
(
'#confirmation-modal'
);
modal
.
modal
(
'show'
);
modal
.
on
(
'hidden.bs.modal'
,
function
()
{
modal
.
remove
();
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
if
(
xhr
.
status
===
403
)
{
addMessage
(
gettext
(
"Only the owners can delete the selected object."
),
"warning"
);
}
else
{
addMessage
(
gettext
(
"An error occurred. ("
)
+
xhr
.
status
+
")"
,
'danger'
)
}
}
});
return
false
;
...
...
@@ -70,12 +46,13 @@ $(function () {
$
(
'.template-choose'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/template/choose/'
,
url
:
$
(
this
).
prop
(
'href'
)
,
success
:
function
(
data
)
{
$
(
'body'
).
append
(
data
);
$
(
'#create-modal'
).
modal
(
'show'
);
$
(
'#create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#create-modal'
).
remove
();
var
modal
=
$
(
'#confirmation-modal'
);
modal
.
modal
(
'show'
);
modal
.
on
(
'hidden.bs.modal'
,
function
()
{
modal
.
remove
();
});
// check if user selected anything
$
(
"#template-choose-next-button"
).
click
(
function
()
{
...
...
@@ -101,6 +78,7 @@ $(function () {
e
.
stopImmediatePropagation
();
return
false
;
});
$
(
'[href=#index-list-view]'
).
click
(
function
(
e
)
{
var
box
=
$
(
this
).
data
(
'index-box'
);
$
(
'#'
+
box
+
'-graph-view'
).
hide
();
...
...
@@ -110,9 +88,10 @@ $(function () {
e
.
stopImmediatePropagation
();
return
false
;
});
$
(
'body [title]:not(.title-favourite)'
).
tooltip
();
$
(
'body .title-favourite'
).
tooltip
({
'placement'
:
'right'
});
$
(
'body :input[title]'
).
tooltip
({
trigger
:
'focus'
,
placement
:
'auto right'
});
$
(
'body [title]'
).
tooltip
();
$
(
".knob"
).
knob
();
$
(
'[data-toggle="pill"]'
).
click
(
function
()
{
...
...
@@ -167,74 +146,6 @@ $(function () {
addSliderMiscs
();
/* for VM removes buttons */
$
(
'.vm-delete'
).
click
(
function
()
{
var
vm_pk
=
$
(
this
).
data
(
'vm-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/vm/delete/'
+
vm_pk
+
'/'
,
'data'
:
[],
'pk'
:
vm_pk
,
'type'
:
"vm"
,
'redirect'
:
dir
});
return
false
;
});
/* for disk remove buttons */
$
(
'.disk-remove'
).
click
(
function
()
{
var
disk_pk
=
$
(
this
).
data
(
'disk-pk'
);
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/disk/'
+
disk_pk
+
'/remove/'
,
'data'
:
[],
'pk'
:
disk_pk
,
'type'
:
"disk"
,
});
return
false
;
});
/* for Node removes buttons */
$
(
'.node-delete'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/node/delete/'
+
node_pk
+
'/'
,
'data'
:
[],
'pk'
:
node_pk
,
'type'
:
"node"
,
'redirect'
:
dir
});
return
false
;
});
/* for Node flush buttons */
$
(
'.node-flush'
).
click
(
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
,
'data'
:
[],
'pk'
:
node_pk
,
'type'
:
"node"
,
'redirect'
:
dir
});
return
false
;
});
/* for Group removes buttons */
$
(
'.group-delete'
).
click
(
function
()
{
var
group_pk
=
$
(
this
).
data
(
'group-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
deleteObject
,
{
'url'
:
'/dashboard/group/delete/'
+
group_pk
+
'/'
,
'data'
:
[],
'type'
:
"group"
,
'pk'
:
group_pk
,
'redirect'
:
dir
});
return
false
;
});
/* search for vms */
var
my_vms
=
[];
$
(
"#dashboard-vm-search-input"
).
keyup
(
function
(
e
)
{
...
...
@@ -558,62 +469,6 @@ function setDefaultSliderValues() {
}
/* deletes the VM with the pk
* if dir is true, then redirect to the dashboard landing page
* else it adds a success message */
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
)
{
selected
=
[];
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
{
window
.
location
.
replace
(
'/dashboard'
);
}
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
);
}
});
}
function
massDeleteVm
(
data
)
{
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
}
});
}
function
addMessage
(
text
,
type
)
{
...
...
@@ -701,6 +556,7 @@ function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
$
.
ajaxSetup
({
beforeSend
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
...
...
circle/dashboard/static/dashboard/group-details.js
View file @
7fed7d2c
...
...
@@ -28,39 +28,3 @@
$
(
".group-details-help-button"
).
click
(
function
()
{
$
(
".group-details-help"
).
stop
().
slideToggle
();
});
/* for Node removes buttons */
$
(
'.delete-from-group'
).
click
(
function
()
{
var
href
=
$
(
this
).
attr
(
'href'
);
var
tr
=
$
(
this
).
closest
(
'tr'
);
var
group
=
$
(
this
).
data
(
'group_pk'
);
var
member
=
$
(
this
).
data
(
'member_pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
removeMember
,
{
'url'
:
href
,
'data'
:
[],
'tr'
:
tr
,
'group_pk'
:
group
,
'member_pk'
:
member
,
'type'
:
"user"
,
'redirect'
:
dir
});
return
false
;
});
function
removeMember
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
data
.
tr
.
fadeOut
(
function
()
{
$
(
this
).
remove
();});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
);
}
});
}
circle/dashboard/static/dashboard/group-list.js
View file @
7fed7d2c
$
(
function
()
{
/* rename */
$
(
"#group-list-rename-button, .group-details-rename-button"
).
click
(
function
()
{
$
(
"
#
group-list-column-name"
,
$
(
this
).
closest
(
"tr"
)).
hide
();
$
(
"
.
group-list-column-name"
,
$
(
this
).
closest
(
"tr"
)).
hide
();
$
(
"#group-list-rename"
,
$
(
this
).
closest
(
"tr"
)).
css
(
'display'
,
'inline'
);
$
(
"#group-list-rename"
).
find
(
"input"
).
select
();
});
...
...
@@ -10,7 +10,7 @@ $(function() {
$
(
'.group-list-rename-submit'
).
click
(
function
()
{
var
row
=
$
(
this
).
closest
(
"tr"
);
var
name
=
$
(
'#group-list-rename-name'
,
row
).
val
();
var
url
=
'/dashboard/group/'
+
row
.
children
(
"td:first-child"
).
text
().
replace
(
" "
,
""
)
+
'/'
;
var
url
=
row
.
find
(
".group-list-column-name a"
).
prop
(
"href"
)
;
$
.
ajax
({
method
:
'POST'
,
url
:
url
,
...
...
@@ -18,7 +18,7 @@ $(function() {
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"
#
group-list-column-name"
,
row
).
html
(
$
(
"
.
group-list-column-name"
,
row
).
html
(
$
(
"<a/>"
,
{
'class'
:
"real-link"
,
href
:
"/dashboard/group/"
+
data
.
group_pk
+
"/"
,
...
...
circle/dashboard/static/dashboard/node-create.js
deleted
100644 → 0
View file @
32e83265
$
(
function
()
{
nodeCreateLoaded
();
});
function
nodeCreateLoaded
()
{
/* no js compatibility */
$
(
'.no-js-hidden'
).
show
();
$
(
'.js-hidden'
).
hide
();
}
circle/dashboard/static/dashboard/node-details.js
View file @
7fed7d2c
...
...
@@ -30,20 +30,6 @@ $(function() {
$
(
".node-details-help"
).
stop
().
slideToggle
();
});
/* for Node removes buttons */
$
(
'.node-enable'
).
click
(
function
()
{
var
node_pk
=
$
(
this
).
data
(
'node-pk'
);
var
dir
=
window
.
location
.
pathname
.
indexOf
(
'list'
)
==
-
1
;
addModalConfirmation
(
changeNodeStatus
,
{
'url'
:
'/dashboard/node/status/'
+
node_pk
+
'/'
,
'data'
:
[],
'pk'
:
node_pk
,
'type'
:
"node"
,
'redirect'
:
dir
});
return
false
;
});
// remove trait
$
(
'.node-details-remove-trait'
).
click
(
function
()
{
var
to_remove
=
$
(
this
).
data
(
"trait-pk"
);
...
...
@@ -69,22 +55,3 @@ $(function() {
});
});
function
changeNodeStatus
(
data
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
data
.
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
if
(
!
data
.
redirect
)
{
selected
=
[];
addMessage
(
re
.
message
,
'success'
);
}
else
{
window
.
location
.
replace
(
'/dashboard'
);
}
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
);
}
});
}
circle/dashboard/static/dashboard/node-list.js
View file @
7fed7d2c
...
...
@@ -9,49 +9,4 @@ $(function() {
$
(
'.false'
).
closest
(
"tr"
).
addClass
(
'danger'
);
$
(
'.true'
).
closest
(
"tr"
).
removeClass
(
'danger'
);
}
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"
);
}
else
{
$
(
this
).
css
(
"display"
,
"block"
);
}
});
if
(
tspan
.
hasClass
(
"false"
)){
tspan
.
removeClass
(
"false"
);
tspan
.
addClass
(
"true"
);
tspan
.
text
(
"✔"
);
}
else
{
tspan
.
removeClass
(
"true"
);
tspan
.
addClass
(
"false"
);
tspan
.
text
(
"✘"
);
}
colortable
();
}
$
(
'#table_container'
).
on
(
'click'
,
'.node-enable'
,
function
()
{
var
tr
=
$
(
this
).
closest
(
"tr"
);
var
pk
=
$
(
this
).
attr
(
'data-node-pk'
);
var
url
=
$
(
this
).
attr
(
'href'
);
$
.
ajax
({
method
:
'POST'
,
url
:
url
,
data
:
{
'change_status'
:
''
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
statuschangeSuccess
(
tr
);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error!"
,
"danger"
);
}
});
return
false
;
});
});
circle/dashboard/static/dashboard/template-list.js
View file @
7fed7d2c
$
(
function
()
{
/* for template removes buttons */
$
(
'.template-delete'
).
click
(
function
()
{
var
template_pk
=
$
(
this
).
data
(
'template-pk'
);
addModalConfirmationOrDisplayMessage
(
deleteTemplate
,
{
'url'
:
'/dashboard/template/delete/'
+
template_pk
+
'/'
,
'data'
:
[],
'template_pk'
:
template_pk
,
});
return
false
;
});
/* for lease removes buttons */
$
(
'.lease-delete'
).
click
(
function
()
{
var
lease_pk
=
$
(
this
).
data
(
'lease-pk'
);
addModalConfirmationOrDisplayMessage
(
deleteLease
,
{
'url'
:
'/dashboard/lease/delete/'
+
lease_pk
+
'/'
,
'data'
:
[],
'lease_pk'
:
lease_pk
,
});
return
false
;
});
/* template table sort */
var
ttable
=
$
(
".template-list-table"
).
stupidtable
();
...
...
@@ -43,67 +21,3 @@ $(function() {
event
.
preventDefault
();
});
});
// send POST request then delete the row in table
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
()
{
$
(
this
).
remove
();
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
);
}
});
}
// send POST request then delete the row in table
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
()
{
$
(
this
).
remove
();
});
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
);
}
});
}
function
addModalConfirmationOrDisplayMessage
(
func
,
data
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
data
[
'url'
],
data
:
jQuery
.
param
(
data
[
'data'
]),