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
37c7213d
authored
Jan 25, 2016
by
Estók Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved dashboard-integration and refactor.
parent
6aa74424
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
112 deletions
+116
-112
circle/setty/models.py
+2
-2
circle/setty/static/setty/setty.js
+0
-0
circle/setty/templates/setty/index.html
+53
-12
circle/setty/templates/setty/service_confirm_delete.html
+0
-6
circle/setty/urls.py
+7
-1
circle/setty/views.py
+54
-91
No files found.
circle/setty/models.py
View file @
37c7213d
...
...
@@ -53,7 +53,7 @@ class Element(Model):
anchors
=
models
.
PositiveSmallIntegerField
()
def
__unicode__
(
self
):
return
self
.
service
.
name
+
", id: "
+
self
.
display_id
return
"
%
s (
%
s)"
%
(
self
.
service
.
name
,
self
.
display_id
)
class
ElementConnection
(
Model
):
...
...
@@ -70,4 +70,4 @@ class ElementConnection(Model):
parameters
=
models
.
TextField
()
def
__unicode__
(
self
):
return
self
.
target
.
service
.
name
+
", "
+
str
(
self
.
id
)
return
"
%
s (
%
d)"
%
(
self
.
target
.
service
.
name
,
self
.
id
)
circle/setty/static/setty/setty.js
View file @
37c7213d
This diff is collapsed.
Click to expand it.
circle/setty/templates/setty/index.html
View file @
37c7213d
...
...
@@ -7,6 +7,8 @@
{% block content %}
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"{% static 'setty/style.css' %}"
>
<div
class=
"row"
id=
"workspace"
>
...
...
@@ -14,16 +16,14 @@
<div
class=
"panel panel-default initHidden"
id=
"informationPanel"
>
<div
class=
"panel-heading text-center"
>
<div
class=
"row"
>
<div
class=
"col-xs-2 text-left"
>
<div
class=
"col-xs-10 text-left"
>
<h3
class=
"no-margin"
><i
class=
"fa fa-info"
></i>
{% trans 'Information' %}
</h3>
</div>
<div
class=
"col-xs-2"
>
<button
class=
"btn btn-danger btn-xs"
id=
"closeInfoPanel"
>
<i
class=
"fa fa-times"
></i>
</button>
</div>
<div
class=
"col-xs-8"
>
<h3
class=
"no-margin"
>
{% trans 'Information' %}
</h3>
</div>
<div
class=
"col-xs-2"
>
</div>
</div>
</div>
<div
class=
"panel-body"
id=
"informationContainer"
>
...
...
@@ -36,7 +36,9 @@
<div
class=
"panel panel-default text-center"
id=
"dragPanel"
>
<div
class=
"panel-heading"
>
<div
class=
"row"
>
<h3
class=
"no-margin"
>
{% trans 'Elements' %}
</h3>
<div
class=
"col-xs-12 text-left"
>
<h3
class=
"no-margin"
><i
class=
"fa fa-outdent"
></i>
{% trans 'Elements' %}
</h3>
</div>
</div>
</div>
<div
class=
"panel-heading text-center"
>
...
...
@@ -90,17 +92,17 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading text-center"
>
<div
class=
"row"
>
<div
class=
"col-xs-2"
>
<div
class=
"col-xs-2
text-left
"
>
<button
class=
"btn btn-info btn-xs"
id=
"undoMovement"
title=
"{% trans 'Undo' %}"
><i
class=
"fa fa-undo"
></i></button>
</div>
<div
class=
"col-xs-2"
>
<div
class=
"col-xs-2
text-left
"
>
<button
class=
"btn btn-info btn-xs"
id=
"redoMovement"
title=
"{% trans 'Redo' %}"
><i
class=
"fa fa-repeat"
></i></button>
</div>
<div
class=
"col-xs-4"
>
<h3
class=
"no-margin"
id=
"serviceName"
contenteditable=
"true"
>
Service
</h3>
<h3
class=
"no-margin"
id=
"serviceName"
>
Service
</h3>
</div>
<div
class=
"col-xs-2 text-right"
>
<button
class=
"btn btn-info btn-xs"
id=
"clearService"
title=
"{% trans 'Clear workspace' %}"
><i
class=
"fa fa-
trash-o
"
></i></button>
<button
class=
"btn btn-info btn-xs"
id=
"clearService"
title=
"{% trans 'Clear workspace' %}"
><i
class=
"fa fa-
eraser
"
></i></button>
</div>
<div
class=
"col-xs-2 text-right"
>
<button
class=
"btn btn-success btn-xs"
id=
"saveService"
title=
"{% trans 'Save workspace' %}"
><i
class=
"fa fa-floppy-o"
></i></button>
...
...
@@ -109,12 +111,51 @@
</div>
<div
class=
"panel-body"
id=
"dropContainer"
oncontextmenu=
"return false;"
></div>
<div
class=
"panel-footer no-margin text-left"
>
<label
class=
"no-margin"
id=
"serviceStatus"
></label>
<div
class=
"row"
>
<div
class=
"col-xs-2 text-left"
>
<label
class=
"no-margin"
id=
"serviceStatus"
></label>
</div>
<div
class=
"col-xs-2 col-xs-push-8 text-right"
>
<button
class=
"btn btn-danger btn-xs"
id=
"deteleService"
title=
"{% trans 'Delete service' %}"
data-toggle=
"modal"
data-target=
"#deleteServiceDialog"
><i
class=
"fa fa-trash-o"
></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
{% if actualId %}
<!-- Modal -->
<div
id=
"deleteServiceDialog"
class=
"modal fade"
role=
"dialog"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
>
×
</button>
<h4
class=
"modal-title"
><i
class=
"fa fa-trash-o"
></i>
{% trans 'Deleting service' %}
</h4>
</div>
<div
class=
"modal-body"
>
<p>
{% trans 'Are you sure you want to delete this service?' %}
</p>
</div>
<div
class=
"modal-footer"
>
<div
class=
"row"
>
<div
class=
"col-xs-2 col-xs-push-8"
>
<form
method=
"post"
action=
"{% url 'setty.views.service-delete' actualId %}"
>
{% csrf_token %}
<input
type=
"submit"
class=
"btn btn-danger btn-sm"
value=
"{% trans 'Delete' %}"
/>
</form>
</div>
<div
class=
"col-xs-2 col-xs-push-8"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
data-dismiss=
"modal"
>
{% trans 'Close' %}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}
circle/setty/templates/setty/service_confirm_delete.html
deleted
100644 → 0
View file @
6aa74424
<!DOCTYPE html>
<form
method=
"post"
>
{% csrf_token %}
Are you sure you want to delete "{{ object }}" ?
<input
type=
"submit"
value=
"Submit"
/>
</form>
\ No newline at end of file
circle/setty/urls.py
View file @
37c7213d
...
...
@@ -20,7 +20,7 @@ from . import views
urlpatterns
=
[
url
(
r'^create/$'
,
views
.
Index
View
.
as_view
(),
views
.
Create
View
.
as_view
(),
name
=
'setty.views.service-create'
),
url
(
r'^delete/(?P<pk>\d+)$'
,
views
.
DeleteView
.
as_view
(),
...
...
@@ -28,6 +28,12 @@ urlpatterns = [
url
(
r'^start/(?P<pk>\d+)$'
,
views
.
StartView
.
as_view
(),
name
=
'setty.views.service-start'
),
url
(
r'^stop/(?P<pk>\d+)$'
,
views
.
StopView
.
as_view
(),
name
=
'setty.views.service-start'
),
url
(
r'^stop/(?P<pk>\d+)$'
,
views
.
StartView
.
as_view
(),
name
=
'setty.views.service-stop'
),
url
(
r'^list/$'
,
views
.
ListView
.
as_view
(),
name
=
'setty.views.service-list'
),
...
...
circle/setty/views.py
View file @
37c7213d
...
...
@@ -15,67 +15,46 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.template
import
RequestContext
from
django.http
import
HttpResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.generic
import
TemplateView
,
DeleteView
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse_lazy
from
django.db.models
import
Q
from
django.http
import
HttpResponseForbidden
,
Http404
from
django.shortcuts
import
redirect
from
django.contrib
import
auth
from
.models
import
(
Element
,
ElementTemplate
,
ElementConnection
,
Service
)
from
django.http
import
JsonResponse
from
braces.views
import
LoginRequiredMixin
from
django.views.generic
import
TemplateView
,
DeleteView
,
CreateView
from
.models
import
Element
,
ElementTemplate
,
ElementConnection
,
Service
import
json
class
IndexView
(
TemplateView
):
class
DetailView
(
LoginRequiredMixin
,
TemplateView
):
template_name
=
"setty/index.html"
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
is_authenticated
():
return
TemplateView
.
get
(
self
,
request
,
*
args
,
**
kwargs
)
else
:
return
redirect
(
auth
.
views
.
login
)
def
get_context_data
(
self
,
**
kwargs
):
elementTemplateList
=
ElementTemplate
.
objects
.
all
()
context
=
RequestContext
(
self
.
request
,
{
'elementTemplateList'
:
elementTemplateList
})
context
=
super
(
DetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'elementTemplateList'
]
=
ElementTemplate
.
objects
.
all
()
return
context
@csrf_exempt
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
is_authenticated
():
return
redirect
(
auth
.
views
.
login
)
if
self
.
request
.
POST
.
get
(
'event'
)
==
"saveService"
:
jsonData
=
json
.
loads
(
self
.
request
.
POST
.
get
(
'data'
))
serviceName
=
jsonData
[
'serviceName'
]
data
=
json
.
loads
(
self
.
request
.
POST
.
get
(
'data'
))
service_name
=
data
[
'serviceName'
]
if
'pk'
in
kwargs
:
service
Object
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
service
Object
.
name
=
serviceN
ame
service
Object
.
save
()
service
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
service
.
name
=
service_n
ame
service
.
save
()
Element
.
objects
.
filter
(
service
=
service
Object
)
.
delete
()
Element
.
objects
.
filter
(
service
=
service
)
.
delete
()
else
:
service
Object
=
Service
(
name
=
service
N
ame
,
service
=
Service
(
name
=
service
_n
ame
,
user
=
self
.
request
.
user
)
service
Object
.
save
()
service
.
save
()
for
element
in
jsonD
ata
[
'elements'
]:
for
element
in
d
ata
[
'elements'
]:
elementObject
=
Element
(
service
=
service
Object
,
service
=
service
,
parameters
=
element
[
'parameters'
],
display_id
=
element
[
'displayId'
],
pos_x
=
element
[
'posX'
],
...
...
@@ -84,7 +63,7 @@ class IndexView(TemplateView):
)
elementObject
.
save
()
for
elementConnection
in
jsonD
ata
[
'elementConnections'
]:
for
elementConnection
in
d
ata
[
'elementConnections'
]:
sourceId
=
elementConnection
[
'sourceId'
]
targetId
=
elementConnection
[
'targetId'
]
sourceEndpoint
=
elementConnection
[
'sourceEndpoint'
]
...
...
@@ -93,11 +72,11 @@ class IndexView(TemplateView):
targetObject
=
Element
.
objects
.
get
(
display_id
=
targetId
,
service
=
service
Object
)
service
=
service
)
sourceObject
=
Element
.
objects
.
get
(
display_id
=
sourceId
,
service
=
service
Object
)
service
=
service
)
connectionObject
=
ElementConnection
(
target
=
targetObject
,
...
...
@@ -108,46 +87,11 @@ class IndexView(TemplateView):
)
connectionObject
.
save
()
return
HttpResponse
(
serviceObject
.
pk
)
else
:
return
HttpResponse
()
class
DeleteView
(
DeleteView
):
model
=
Service
success_url
=
reverse_lazy
(
"dashboard.index"
)
class
StartView
(
TemplateView
):
pass
class
ListView
(
TemplateView
):
pass
class
DetailView
(
IndexView
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
serviceObject
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
if
serviceObject
.
user
!=
self
.
request
.
user
:
return
HttpResponseForbidden
(
"You don't have permission to open the service."
)
except
:
raise
Http404
else
:
return
IndexView
.
get
(
self
,
request
,
*
args
,
**
kwargs
)
@csrf_exempt
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
is_authenticated
():
return
redirect
(
auth
.
views
.
login
)
return
JsonResponse
({
'serviceName'
:
service
.
name
})
if
self
.
request
.
POST
.
get
(
'event'
)
==
"loadService"
:
service
Object
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
elementList
=
Element
.
objects
.
filter
(
service
=
service
Object
)
el
if
self
.
request
.
POST
.
get
(
'event'
)
==
"loadService"
:
service
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
elementList
=
Element
.
objects
.
filter
(
service
=
service
)
elementConnectionList
=
ElementConnection
.
objects
.
filter
(
Q
(
target__in
=
elementList
)
|
Q
(
source__in
=
elementList
))
...
...
@@ -160,20 +104,39 @@ class DetailView(IndexView):
'displayId'
:
item
.
display_id
,
'posX'
:
item
.
pos_x
,
'posY'
:
item
.
pos_y
,
'anchors'
:
item
.
anchors
})
'anchors'
:
item
.
anchors
})
for
item
in
elementConnectionList
:
elementConnections
.
append
({
'targetEndpoint'
:
item
.
target_endpoint
,
'sourceEndpoint'
:
item
.
source_endpoint
,
'parameters'
:
item
.
parameters
})
'parameters'
:
item
.
parameters
})
return
HttpResponse
(
json
.
dumps
(
{
"elements"
:
elements
,
"elementConnections"
:
elementConnections
,
"serviceName"
:
serviceObject
.
name
})
)
return
JsonResponse
(
{
'elements'
:
elements
,
'elementConnections'
:
elementConnections
,
'serviceName'
:
service
.
name
}
)
else
:
return
IndexView
.
post
(
self
,
request
,
*
args
,
**
kwargs
)
raise
PermissionDenied
class
DeleteView
(
LoginRequiredMixin
,
DeleteView
):
model
=
Service
success_url
=
reverse_lazy
(
"dashboard.index"
)
class
CreateView
(
LoginRequiredMixin
,
CreateView
):
pass
class
StartView
(
LoginRequiredMixin
,
TemplateView
):
pass
class
StopView
(
LoginRequiredMixin
,
TemplateView
):
pass
class
ListView
(
LoginRequiredMixin
,
TemplateView
):
pass
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