Commit c500500c by Estók Dániel

First commit for branch.

parent 72cc63fe
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"bootbox": "~4.3.0", "bootbox": "~4.3.0",
"intro.js": "0.9.0", "intro.js": "0.9.0",
"favico.js": "~0.3.5", "favico.js": "~0.3.5",
"datatables": "~1.10.4" "datatables": "~1.10.4",
"jsPlumb": "~1.7.5"
} }
} }
...@@ -199,6 +199,7 @@ PIPELINE_JS = { ...@@ -199,6 +199,7 @@ PIPELINE_JS = {
"jquery-simple-slider/js/simple-slider.js", "jquery-simple-slider/js/simple-slider.js",
"favico.js/favico.js", "favico.js/favico.js",
"datatables/media/js/jquery.dataTables.js", "datatables/media/js/jquery.dataTables.js",
"jsPlumb/dist/js/dom.jsPlumb-1.7.5-min.js",
"dashboard/dashboard.js", "dashboard/dashboard.js",
"dashboard/activity.js", "dashboard/activity.js",
"dashboard/group-details.js", "dashboard/group-details.js",
...@@ -214,6 +215,7 @@ PIPELINE_JS = { ...@@ -214,6 +215,7 @@ PIPELINE_JS = {
"dashboard/vm-create.js", "dashboard/vm-create.js",
"dashboard/vm-list.js", "dashboard/vm-list.js",
"dashboard/help.js", "dashboard/help.js",
"setty/setty.js",
"js/host.js", "js/host.js",
"js/network.js", "js/network.js",
"js/switch-port.js", "js/switch-port.js",
...@@ -358,6 +360,7 @@ LOCAL_APPS = ( ...@@ -358,6 +360,7 @@ LOCAL_APPS = (
'acl', 'acl',
'monitor', 'monitor',
'request', 'request',
'setty',
) )
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
......
...@@ -38,6 +38,7 @@ urlpatterns = patterns( ...@@ -38,6 +38,7 @@ urlpatterns = patterns(
url(r'^network/', include('network.urls')), url(r'^network/', include('network.urls')),
url(r'^blacklist-add/', add_blacklist_item), url(r'^blacklist-add/', add_blacklist_item),
url(r'^dashboard/', include('dashboard.urls')), url(r'^dashboard/', include('dashboard.urls')),
url(r'^setty/', include('setty.urls')),
url(r'^request/', include('request.urls')), url(r'^request/', include('request.urls')),
# django/contrib/auth/urls.py (care when new version) # django/contrib/auth/urls.py (care when new version)
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<img class="elementTemplate" type="{% for target in element.compatibles.all %}{{ target.id }},{% endfor %}" <img class="elementTemplate" type="{% for target in element.compatibles.all %}{{ target.id }},{% endfor %}"
id="{{ element.id }}" data-container="body" data-placement="right" title="{{ element.description }}" id="{{ element.id }}" desc="{{ element.description }}"
src="{% static element.logo %}" alt="{{ element.name }}" src="{% static element.logo %}" alt="{{ element.name }}"
ondragstart="return false;"/> ondragstart="return false;"/>
</div> </div>
...@@ -79,14 +79,14 @@ ...@@ -79,14 +79,14 @@
</div> </div>
</div> </div>
<div class="col-xs-2 col-md-2"> <div class="col-xs-2" id="informationPanel">
<div class="panel panel-default"> <div class="panel panel-default no-margin">
<div class="panel-heading text-center"> <div class="panel-heading text-center">
<div class="row"> <div class="row">
<h3 class="no-margin">{% trans 'Information' %}</h3> <h3 class="no-margin">{% trans 'Information' %}</h3>
</div> </div>
</div> </div>
<div class="panel-body" id="informationContainer"></div> <div class="panel-body no-margin" id="informationContainer"></div>
<div class="panel-footer"></div> <div class="panel-footer"></div>
</div> </div>
</div> </div>
...@@ -95,7 +95,8 @@ ...@@ -95,7 +95,8 @@
<!-- Modal dialogs --> <!-- Modal dialogs -->
<div class="modal fade" id="connectionInfoDialog" role="dialog">
<div class="modal fade" id="saveWarningDialog" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content--> <!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
...@@ -109,10 +110,10 @@ ...@@ -109,10 +110,10 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="row"> <div class="row">
<div class="col-md-2 col-md-push-8"> <div class="col-md-2 col-md-push-8">
<button id="connectionInfoSave" type="button" class="btn btn-success" data-dismiss="modal">{% trans 'Save' %}</button> <button type="button" class="btn btn-success" data-dismiss="modal" onclick="return false;">{% trans 'Return' %}</button>
</div> </div>
<div class="col-md-2 col-md-push-8"> <div class="col-md-2 col-md-push-8">
<button type="button" class="btn btn-danger" data-dismiss="modal">{% trans 'Close' %}</button> <button type="button" class="btn btn-danger" data-dismiss="modal" onclick="return true;">{% trans 'Close' %}</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -120,6 +121,5 @@ ...@@ -120,6 +121,5 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
from django.template import RequestContext, loader
from django.template import RequestContext, loader
from django.http import HttpResponse
from django.db.models import Q
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from .models import (
Element,
ElementTemplate,
ElementConnection,
Service,
User,
)
import json
class IndexView(TemplateView):
template_name = "setty/index.html"
def get_context_data(self, **kwargs):
pass
@csrf_exempt
def index(request):
if request.method == 'POST':
if request.POST.get('event') == "getLoggedInUser":
username = None
if request.user.is_authenticated():
return HttpResponse(request.user.username)
else:
return HttpResponse("unauthenticated!")
elif request.POST.get('event') == "deleteConfig":
try:
siteUser = User.objects.get(name=request.POST.get('user'))
workSpace = Workspace.objects.get(
name=request.POST.get('data'),
user=siteUser,
)
serviceInstances = ServiceInstance.objects.all().filter(
workspace=workSpace,
)
for instance in serviceInstances:
connectionTargets = ServiceConnection.objects.all().filter(
target=instance,
)
connectionSources = ServiceConnection.objects.all().filter(
source=instance,
)
for connection in connectionSources:
connection.delete()
for connection in connectionTargets:
connection.delete()
instance.delete()
workSpace.delete()
return HttpResponse(
"Workspace (" +
request.POST.get('data') +
") deleted successfully."
)
except:
return HttpResponse(
"Failed deleting workspace (" +
request.POST.get('data') +
")."
)
elif request.POST.get('event') == "saveConfig":
jsonData = json.loads(request.POST.get('data'))
userName = jsonData['exportData']['user']
try:
siteUser = User.objects.get(name=userName)
except User.DoesNotExist:
siteUser = User(name=userName)
siteUser.save()
try:
siteWorkspace = Workspace.objects.get(
name=jsonData['exportData']['workspace'],
user=siteUser,
)
siteWorkspace.delete()
siteWorkspace = Workspace(
user=siteUser,
name=jsonData['exportData']['workspace'],
)
siteWorkspace.save()
except Workspace.DoesNotExist:
siteWorkspace = Workspace(
user=siteUser,
name=jsonData['exportData']['workspace'],
)
siteWorkspace.save()
for connection in jsonData['exportData']['connections']:
tempData = jsonData['exportData']['connections']
sourceId = tempData[connection]['sourceid']
targetId = tempData[connection]['targetid']
sourcePosX = tempData[connection]['sourceposx']
sourcePosY = tempData[connection]['sourceposy']
targetPosX = tempData[connection]['targetposx']
targetPosY = tempData[connection]['targetposy']
sourceendpoint = tempData[connection]['sourceendpoint']
targetendpoint = tempData[connection]['targetendpoint']
targetParent = Service.objects.get(id=targetId)
sourceParent = Service.objects.get(id=sourceId)
serviceInstanceSource = ServiceInstance(
parentservice=sourceParent,
workspace=siteWorkspace,
parameters=Service.objects.get(id=sourceId).configuration,
posX=sourcePosX,
posY=sourcePosY,
)
serviceInstanceSource.save()
serviceInstanceTarget = ServiceInstance(
parentservice=targetParent,
workspace=siteWorkspace,
parameters=Service.objects.get(id=targetId).configuration,
posX=targetPosX,
posY=targetPosY,
)
serviceInstanceTarget.save()
serviceConnection = ServiceConnection(
target=serviceInstanceTarget,
source=serviceInstanceSource,
sourceEndpoint=sourceendpoint,
targetEndpoint=targetendpoint,
parameters='Not yet configured',
)
serviceConnection.save()
print jsonData
return HttpResponse(siteWorkspace.name)
elif request.POST.get('event') == "loadConfig":
i = 0
data = []
siteUser = User.objects.get(name=request.POST.get('user'))
workSpace = Workspace.objects.get(
name=request.POST.get('data'),
user=siteUser,
)
connectionList = ServiceConnection.objects.all().filter(
Q(source__workspace=workSpace) |
Q(target__workspace=workSpace)
)
for connection in connectionList:
++i
seged = {}
seged['targetposx'] = connection.target.posX
seged['targetposy'] = connection.target.posY
seged['targetendpoint'] = connection.targetEndpoint
seged['targetid'] = connection.target.parentservice.id
seged['sourceposx'] = connection.source.posX
seged['sourceposy'] = connection.source.posY
seged['sourceendpoint'] = connection.sourceEndpoint
seged['sourceid'] = connection.source.parentservice.id
data.append(seged)
jsonData = json.dumps(data)
return HttpResponse(jsonData)
elif request.POST.get('event') == "startConfig":
siteUser = User.objects.get(name=request.POST.get('user'))
workSpace = Workspace.objects.get(
name=request.POST.get('data'),
user=siteUser,
)
print request.POST.get('data')
return HttpResponse("Configuration started.")
return HttpResponse("adsf")
elementList = ElementTemplate.objects.all()
template = loader.get_template('builder/index.html')
context = RequestContext(request, {'elementList': elementList})
return HttpResponse(template.render(context))
...@@ -34,6 +34,9 @@ class IndexView(TemplateView): ...@@ -34,6 +34,9 @@ class IndexView(TemplateView):
@csrf_exempt @csrf_exempt
def post(self, request, *args, **kwargs): 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": if self.request.POST.get('event') == "saveService":
jsonData = json.loads(self.request.POST.get('data')) jsonData = json.loads(self.request.POST.get('data'))
...@@ -56,7 +59,7 @@ class IndexView(TemplateView): ...@@ -56,7 +59,7 @@ class IndexView(TemplateView):
for element in jsonData['elements']: for element in jsonData['elements']:
elementObject = Element( elementObject = Element(
service=serviceObject, service=serviceObject,
parameters="none", # further plan parameters=element['parameters'],
display_id=element['displayId'], display_id=element['displayId'],
pos_x=element['posX'], pos_x=element['posX'],
pos_y=element['posY'], pos_y=element['posY'],
...@@ -122,6 +125,9 @@ class DetailView(IndexView): ...@@ -122,6 +125,9 @@ class DetailView(IndexView):
@csrf_exempt @csrf_exempt
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
if not self.request.user.is_authenticated():
return redirect(auth.views.login)
if self.request.POST.get('event') == "loadService": if self.request.POST.get('event') == "loadService":
serviceObject = Service.objects.get(id=kwargs['pk']) serviceObject = Service.objects.get(id=kwargs['pk'])
elementList = Element.objects.filter(service=serviceObject) elementList = Element.objects.filter(service=serviceObject)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment