Commit 406efb10 by Estók Dániel

Separate machine and element panel. Modified client-server communication

due to backend modifications.
parent e7c08ebc
Pipeline #54 failed with stage
in 0 seconds
...@@ -71,7 +71,6 @@ jsPlumb.ready(function() { ...@@ -71,7 +71,6 @@ jsPlumb.ready(function() {
var elementConnections = []; var elementConnections = [];
var elementIndex = 0; var elementIndex = 0;
var dragContainerScroll = 0; var dragContainerScroll = 0;
var clickEvent = 0;
var workspaceWidth = $("#dropContainer").width(); var workspaceWidth = $("#dropContainer").width();
var workspaceHeight = $("#dropContainer").height(); var workspaceHeight = $("#dropContainer").height();
...@@ -80,6 +79,8 @@ jsPlumb.ready(function() { ...@@ -80,6 +79,8 @@ jsPlumb.ready(function() {
var objectStack = []; var objectStack = [];
var undoStack = []; var undoStack = [];
var redoStack = []; var redoStack = [];
var clickEvent = 0;
var nextStepConstraint = 0;
/* Functions. */ /* Functions. */
...@@ -94,6 +95,7 @@ jsPlumb.ready(function() { ...@@ -94,6 +95,7 @@ jsPlumb.ready(function() {
}; };
addInfo = function(title, info, type, object) { addInfo = function(title, info, type, object) {
/*
$("#informationContainer").empty(); $("#informationContainer").empty();
switch(type){ switch(type){
...@@ -140,7 +142,7 @@ jsPlumb.ready(function() { ...@@ -140,7 +142,7 @@ jsPlumb.ready(function() {
'</div>&nbsp;' + '</div>&nbsp;' +
'<div class="row">' + '<div class="row">' +
'<div class="col-xs-12 text-center">' + '<div class="col-xs-12 text-center">' +
'<button id="removeFromWorkspace" class="btn btn-info">Remove from workspace</button>' + '<button id="removeElementFromWorkspace" class="btn btn-info">Remove from workspace</button>' +
'</div>' + '</div>' +
'</div>'; '</div>';
break; break;
...@@ -162,7 +164,13 @@ jsPlumb.ready(function() { ...@@ -162,7 +164,13 @@ jsPlumb.ready(function() {
'</div>' + '</div>' +
'</div>'; '</div>';
break; break;
} }*/
// Here comes the ajax getInformation post.
// elementtemplateid vagy hostname
div = 0;
$("#informationContainer").append(div); $("#informationContainer").append(div);
...@@ -271,6 +279,21 @@ jsPlumb.ready(function() { ...@@ -271,6 +279,21 @@ jsPlumb.ready(function() {
}); });
return returnValue; return returnValue;
}; };
elementIsConnected = function(element) {
anchors = element.attr("anchors");
id = element.attr("id");
for(i=0;i<anchors;i++)
{
if(isConnected(i + "_" + id))
{
return true;
}
}
return false;
};
getConnectionparamAndAnchor = function(anchorId) { getConnectionparamAndAnchor = function(anchorId) {
parameters = ""; parameters = "";
...@@ -391,11 +414,11 @@ jsPlumb.ready(function() { ...@@ -391,11 +414,11 @@ jsPlumb.ready(function() {
} }
$("#dropContainer").append(newInstance); $("#dropContainer").append(newInstance);
for (i = 0; i <= endpoints; i++) { for (i = 0; i <= endpoints; i++) {
addEndpoint(newInstance); addEndpoint(newInstance);
} }
jsPlumbInstance.draggable(jsPlumb.getSelector(".element"), { jsPlumbInstance.draggable(jsPlumb.getSelector(".element"), {
containment: $("#dropContainer") containment: $("#dropContainer")
}); });
...@@ -501,12 +524,13 @@ jsPlumb.ready(function() { ...@@ -501,12 +524,13 @@ jsPlumb.ready(function() {
$('body').on('contextmenu', '.element', function(event) { $('body').on('contextmenu', '.element', function(event) {
setServiceStatus("unsaved"); setServiceStatus("unsaved");
removeElement($(this)); removeElement($(this));
undoStack.splice(stackIndexer, 0, addElement); undoStack.splice(stackIndexer, 0, addElement);
redoStack.splice(stackIndexer, 0, removeElement); redoStack.splice(stackIndexer, 0, removeElement);
objectStack.splice(stackIndexer, 0, $(this)); objectStack.splice(stackIndexer, 0, $(this));
nextStepConstraint = 0;
stackSize++; stackSize++;
stackIndexer++; stackIndexer++;
}); });
...@@ -542,7 +566,8 @@ jsPlumb.ready(function() { ...@@ -542,7 +566,8 @@ jsPlumb.ready(function() {
stackSize++; stackSize++;
}); });
$('body').on('click', '#removeFromWorkspace', function() { $('body').on('click', '#removeElementFromWorkspace', function() {
setServiceStatus("unsaved");
removeElement(sharedObject); removeElement(sharedObject);
undoStack.splice(stackIndexer, 0, addElement); undoStack.splice(stackIndexer, 0, addElement);
...@@ -570,8 +595,7 @@ jsPlumb.ready(function() { ...@@ -570,8 +595,7 @@ jsPlumb.ready(function() {
}); });
$('body').on('click', '#clearService', function() { $('body').on('click', '#clearService', function() {
jsPlumbInstance.reset(); jsPlumbInstance.remove("element");
$(".element").remove();
setServiceStatus("unsaved"); setServiceStatus("unsaved");
elementIndex = 0; elementIndex = 0;
...@@ -590,9 +614,18 @@ jsPlumb.ready(function() { ...@@ -590,9 +614,18 @@ jsPlumb.ready(function() {
if (stackIndexer >= stackSize) return; if (stackIndexer >= stackSize) return;
clickEvent = 1; clickEvent = 1;
object = objectStack[stackIndexer]; object = objectStack[stackIndexer];
redoStack[stackIndexer++](object); redoStack[stackIndexer](object);
stackIndexer++;
clickEvent = 0; clickEvent = 0;
}); });
$('body').on('click', '#addMachineDialog', function() {
// Here comes the ajax post of getMachineAvailableList
// posting usedhostnames
//
//
// after it, appending obtained content to addmachinedialogbody
});
$('body').on('click', '.elementTemplateInfo', function() { $('body').on('click', '.elementTemplateInfo', function() {
id = $(this).attr("element"); id = $(this).attr("element");
......
...@@ -17,33 +17,37 @@ ...@@ -17,33 +17,37 @@
<div class="panel-heading"> <div class="panel-heading">
<div class="row"> <div class="row">
<div class="col-xs-1 text-left"> <div class="col-xs-1 text-left">
<button class="btn btn-info btn-xs hidden-xs hidden-sm" id="undoMovement">{% trans 'Undo' %}</button> <button class="btn btn-info btn-xs btn-block hidden-xs hidden-sm hidden-md" id="undoMovement">{% trans 'Undo' %}</button>
<button class="btn btn-info btn-xs hidden-md hidden-lg" id="undoMovement"><i class="fa fa-undo"></i></button> <button class="btn btn-info btn-xs hidden-lg" id="undoMovement"><i class="fa fa-undo"></i></button>
</div> </div>
<div class="col-xs-1 text-left"> <div class="col-xs-1 text-left">
<button class="btn btn-info btn-xs hidden-xs hidden-sm" id="redoMovement">{% trans 'Redo' %}</button> <button class="btn btn-info btn-xs btn-block hidden-xs hidden-sm hidden-md" id="redoMovement">{% trans 'Redo' %}</button>
<button class="btn btn-info btn-xs hidden-md hidden-lg" id="redoMovement"><i class="fa fa-repeat"></i></button> <button class="btn btn-info btn-xs hidden-lg" id="redoMovement"><i class="fa fa-repeat"></i></button>
</div> </div>
<div class="col-xs-1 text-left"> <div class="col-xs-1 text-left">
<button class="btn btn-success btn-xs hidden-xs hidden-sm" id="showAddElementDialog" data-toggle="modal" data-target="#addElementDialog">{% trans 'Add element' %}</button> <button class="btn btn-success btn-xs btn-block hidden-xs hidden-sm hidden-md" id="showAddElementDialog" data-toggle="modal" data-target="#addElementDialog">{% trans 'Elements' %}</button>
<button class="btn btn-success btn-xs hidden-md hidden-lg" id="showAddElementDialog" data-toggle="modal" data-target="#addElementDialog"><i class="fa fa-plus"></i></button> <button class="btn btn-success btn-xs hidden-lg" id="showAddElementDialog" data-toggle="modal" data-target="#addElementDialog"><i class="fa fa-plus"></i></button>
</div> </div>
<div class="col-xs-6 text-center"> <div class="col-xs-1 text-left">
<button class="btn btn-success btn-xs btn-block hidden-xs hidden-sm hidden-md" id="showAddMachineDialog">{% trans 'Machines' %}</button>
<button class="btn btn-success btn-xs hidden-lg" id="showAddMachineDialog" ><i class="fa fa-plus-circle"></i></button>
</div>
<div class="col-xs-4 text-center">
<h3 class="no-margin" id="serviceName"></h3> <h3 class="no-margin" id="serviceName"></h3>
<input class="form-control form-control-sm initHidden" id="serviceNameEdit" type="text" style="margin-top: -4px !important; margin-bottom: -4px !important;width:80%;" /> <input class="form-control form-control-sm initHidden" id="serviceNameEdit" type="text" style="margin-top: -4px !important; margin-bottom: -4px !important; width: 80%;" />
<button class="btn btn-success btn-xs initHidden" id="serviceNameSave">{% trans 'OK' %}</button> <button class="btn btn-success btn-xs initHidden" id="serviceNameSave">{% trans 'OK' %}</button>
</div> </div>
<div class="col-xs-1 text-right"> <div class="col-xs-1 text-right">
<button class="btn btn-info btn-xs hidden-xs hidden-sm" id="clearService">{% trans 'Clean' %}</button> <button class="btn btn-info btn-xs btn-block hidden-xs hidden-sm hidden-md" id="clearService">{% trans 'Clean' %}</button>
<button class="btn btn-info btn-xs hidden-md hidden-lg" id="clearService"><i class="fa fa-eraser"></i></button> <button class="btn btn-info btn-xs hidden-lg" id="clearService"><i class="fa fa-eraser"></i></button>
</div> </div>
<div class="col-xs-1 text-right"> <div class="col-xs-1 text-right">
<button class="btn btn-success btn-xs hidden-xs hidden-sm" id="saveService">{% trans 'Save' %}</button> <button class="btn btn-success btn-xs btn-block hidden-xs hidden-sm hidden-md" id="saveService">{% trans 'Save' %}</button>
<button class="btn btn-success btn-xs hidden-md hidden-lg" id="saveService"><i class="fa fa-floppy-o"></i></button> <button class="btn btn-success btn-xs hidden-lg" id="saveService"><i class="fa fa-floppy-o"></i></button>
</div> </div>
<div class="col-xs-1 text-right"> <div class="col-xs-1 text-right">
<button class="btn btn-danger btn-xs hidden-xs hidden-sm" id="deleteService" data-toggle="modal" data-target="#deleteServiceDialog">{% trans 'Delete' %}</button> <button class="btn btn-danger btn-xs btn-block hidden-xs hidden-sm hidden-md" id="deleteService" data-toggle="modal" data-target="#deleteServiceDialog">{% trans 'Delete' %}</button>
<button class="btn btn-danger btn-xs hidden-md hidden-lg" id="deleteService" data-toggle="modal" data-target="#deleteServiceDialog"><i class="fa fa-trash-o"></i></button> <button class="btn btn-danger btn-xs hidden-lg" id="deleteService" data-toggle="modal" data-target="#deleteServiceDialog"><i class="fa fa-trash-o"></i></button>
</div> </div>
</div> </div>
</div> </div>
...@@ -152,7 +156,7 @@ ...@@ -152,7 +156,7 @@
</div> </div>
</div> </div>
<!-- changing information dialog --> <!-- Changing information dialog -->
<div class="modal fade" id="changeInformationDialog" role="dialog"> <div class="modal fade" id="changeInformationDialog" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
...@@ -169,5 +173,22 @@ ...@@ -169,5 +173,22 @@
</div> </div>
</div> </div>
<!-- Adding machine dialog -->
<div class="modal fade" id="addMachineDialog" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><i class="fa fa-outdent"></i>&nbsp;{% trans 'Machines' %}</h4>
</div>
<div class="modal-body" id="addMachineDialogBody">
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}
...@@ -34,13 +34,11 @@ class DetailView(LoginRequiredMixin, TemplateView): ...@@ -34,13 +34,11 @@ class DetailView(LoginRequiredMixin, TemplateView):
context = super(DetailView, self).get_context_data(**kwargs) context = super(DetailView, self).get_context_data(**kwargs)
context['elementTemplateList'] = ElementTemplate.objects.all() context['elementTemplateList'] = ElementTemplate.objects.all()
context['actualId'] = kwargs['pk'] context['actualId'] = kwargs['pk']
# context['elementCategoryList'] = ...
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
if self.request.POST.get('event') == "saveService": if self.request.POST.get('event') == "saveService":
data = json.loads(self.request.POST.get('data')) data = json.loads(self.request.POST.get('data'))
service = Service.objects.get(id=kwargs['pk']) service = Service.objects.get(id=kwargs['pk'])
service.name = data['serviceName'] service.name = data['serviceName']
service.save() service.save()
...@@ -129,7 +127,6 @@ class CreateView(LoginRequiredMixin, TemplateView): ...@@ -129,7 +127,6 @@ class CreateView(LoginRequiredMixin, TemplateView):
else: else:
return ['dashboard/nojs-wrapper.html'] return ['dashboard/nojs-wrapper.html']
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(CreateView, self).get_context_data(*args, **kwargs) context = super(CreateView, self).get_context_data(*args, **kwargs)
...@@ -144,7 +141,7 @@ class CreateView(LoginRequiredMixin, TemplateView): ...@@ -144,7 +141,7 @@ class CreateView(LoginRequiredMixin, TemplateView):
service_name = self.request.POST.get('serviceName') service_name = self.request.POST.get('serviceName')
if not service_name: if not service_name:
service_name="Noname" service_name = "Noname"
service = Service( service = Service(
name=service_name, name=service_name,
......
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