Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
39a7ffc9
authored
May 05, 2016
by
Estók Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setty: added server-side access management.
parent
ea8d0946
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
161 additions
and
158 deletions
+161
-158
circle/setty/static/setty/setty.js
+122
-150
circle/setty/templates/setty/index.html
+3
-3
circle/setty/views.py
+36
-5
No files found.
circle/setty/static/setty/setty.js
View file @
39a7ffc9
/* Settimng up csrf token, touch event and zoom options. */
/* Settimng up csrf token, touch event and zoom options. */
function
getCookie
(
name
)
{
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
...
@@ -83,98 +82,80 @@ jsPlumb.ready(function() {
...
@@ -83,98 +82,80 @@ jsPlumb.ready(function() {
var
nextStepConstraint
=
0
;
var
nextStepConstraint
=
0
;
/* Functions. */
/* Functions. */
setServiceStatus
=
function
(
status
)
{
setServiceStatus
=
function
(
status
)
{
if
(
status
==
"unsaved"
)
{
if
(
status
==
"unsaved"
)
{
$
(
"#serviceStatus"
).
text
(
"Unsaved"
);
$
(
"#serviceStatus"
).
text
(
gettext
(
"Unsaved"
));
}
}
else
{
else
{
$
(
"#serviceStatus"
).
empty
();
$
(
"#serviceStatus"
).
empty
();
}
}
};
};
addInfo
=
function
(
title
,
info
,
type
,
object
)
{
addInfo
=
function
(
title
,
info
,
object
,
type
)
{
/*
mainDiv
=
$
(
"<div>"
,
{
$("#informationContainer").empty();
class
:
"row"
,
html
:
$
(
"<div>"
,
{
switch(type){
class
:
"col-xs-12 text-center"
,
case "connection":
html
:
row
=
$
(
"<h4>"
,
{
div =
html
:
title
'<div class="row">' +
})
'<div class="col-xs-12 text-center">' +
})
'<h4>' + title + '</h4>' +
}).
add
(
$
(
"<div>"
,
{
'</div>' +
class
:
"row"
,
'</div> ' +
style
:
"margin-top: 16px"
,
'<div class="row">' +
html
:
$
(
"<div>"
,
{
'<div class="col-xs-12">' +
class
:
"col-xs-12 text-center"
,
'<textarea class="form-control" rows="28" id="infoInput" placeholder="Config data"></textarea>' +
html
:
row
=
$
(
"<textarea>"
,
{
'</div>' +
class
:
"form-control"
,
'</div> ' +
style
:
"text-align: justify;"
,
'<div class="row">' +
rows
:
"18"
,
'<div class="col-xs-12 text-center">' +
id
:
"infoInput"
,
'<button id="removeConnection" class="btn btn-info">Remove connection</button>' +
disabled
:
!
type
,
'</div>' +
text
:
info
'</div>';
})
break;
})
case "element":
}));
div =
controlDiv
=
$
(
"<div>"
,
{
'<div class="row">' +
class
:
"row"
,
'<div class="col-xs-12 text-center">' +
style
:
"margin-top: 16px"
,
'<h4>' + title + '</h4>' +
html
:
$
(
"<div>"
,
{
'</div>' +
class
:
"col-xs-3 text-center"
,
'</div> ' +
html
:
$
(
"<button>"
,
{
'<div class="row">' +
class
:
"btn btn-success btn-block"
,
'<div class="col-xs-12">' +
id
:
"addEndpoint"
,
'<textarea class="form-control" rows="24" id="infoInput" placeholder="Config data"></textarea>' +
html
:
gettext
(
"Add endpoint"
)
'</div>' +
})
'</div> ' +
}).
add
(
$
(
"<div>"
,
{
'<div class="row text-center">' +
class
:
"col-xs-3 text-center"
,
'<label>Endpoints</label>' +
html
:
$
(
"<button>"
,
{
'</div>' +
class
:
"btn btn-danger btn-block"
,
'<div class="row">' +
id
:
"removeEndpoint"
,
'<div class="col-xs-6 text-center">' +
html
:
gettext
(
"Delete endpoint"
)
'<button id="addEndpoint" class="btn btn-success"><i class="fa fa-plus"></i></button>' +
})
'</div>' +
})).
add
(
$
(
"<div>"
,
{
'<div class="col-xs-6 text-center">' +
class
:
"col-xs-6 text-center"
,
'<button id="removeEndpoint" class="btn btn-danger"><i class="fa fa-minus"></i></button>' +
html
:
$
(
"<button>"
,
{
'</div>' +
class
:
"btn btn-info btn-block"
,
'</div> ' +
id
:
"removeElementFromWorkspace"
,
'<div class="row">' +
html
:
gettext
(
"Remove from workspace"
)
'<div class="col-xs-12 text-center">' +
})
'<button id="removeElementFromWorkspace" class="btn btn-info">Remove from workspace</button>' +
}))
'</div>' +
});
'</div>';
addElementDiv
=
$
(
"<div>"
,
{
break;
class
:
"row"
,
case "elementTemplate":
style
:
"margin-top: 16px"
,
div =
html
:
$
(
"<div>"
,
{
'<div class="row">' +
class
:
"col-xs-12 text-center"
,
'<div class="col-xs-12 text-center">' +
html
:
row
=
$
(
"<button>"
,
{
'<h4>' + title + '</h4>' +
class
:
"btn btn-success"
,
'</div>' +
id
:
"addElementToWorkspace"
,
'</div> ' +
html
:
gettext
(
"Add to workspace"
)
'<div class="row">' +
})
'<div class="col-xs-12">' +
})
'<textarea class="form-control" rows="28" id="infoInput" placeholder="Config data"></textarea>' +
});
'</div>' +
'</div> ' +
$
(
"#informationContainer"
).
html
(
type
?
mainDiv
.
add
(
controlDiv
):
mainDiv
.
add
(
addElementDiv
));
'<div class="row">' +
'<div class="col-xs-12 text-center">' +
'<button id="addElementToWorkspace" class="btn btn-success">Add to workspace</button>' +
'</div>' +
'</div>';
break;
}*/
// Here comes the ajax getInformation post.
// elementtemplateid vagy hostname
div
=
0
;
$
(
"#informationContainer"
).
append
(
div
);
$
(
"#infoInput"
).
val
(
info
);
$
(
"#changeInformationDialog"
).
modal
(
'show'
);
$
(
"#changeInformationDialog"
).
modal
(
'show'
);
...
@@ -211,7 +192,7 @@ jsPlumb.ready(function() {
...
@@ -211,7 +192,7 @@ jsPlumb.ready(function() {
elementConnections
[
i
].
sourceId
==
elementConnections
[
i
].
sourceId
==
connection
.
targetId
))
&&
connection
.
targetId
))
&&
elementConnections
[
i
]
!=
connection
)
{
elementConnections
[
i
]
!=
connection
)
{
addMessage
(
"Twofold connection is forbidden."
,
"danger"
);
addMessage
(
gettext
(
"Twofold connection is forbidden."
),
"danger"
);
return
false
;
return
false
;
}
}
}
}
...
@@ -222,7 +203,7 @@ jsPlumb.ready(function() {
...
@@ -222,7 +203,7 @@ jsPlumb.ready(function() {
validTargets
=
$
(
"#"
+
sourceId
).
attr
(
"type"
).
split
(
','
);
validTargets
=
$
(
"#"
+
sourceId
).
attr
(
"type"
).
split
(
','
);
if
(
jQuery
.
inArray
(
targetId
.
split
(
'_'
)[
1
],
validTargets
)
==
-
1
)
{
if
(
jQuery
.
inArray
(
targetId
.
split
(
'_'
)[
1
],
validTargets
)
==
-
1
)
{
addMessage
(
"Connecting incompatible elements is forbidden."
,
"danger"
);
addMessage
(
gettext
(
"Connecting incompatible elements is forbidden."
),
"danger"
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -230,7 +211,7 @@ jsPlumb.ready(function() {
...
@@ -230,7 +211,7 @@ jsPlumb.ready(function() {
checkSourceTargetEquality
=
function
(
connection
)
{
checkSourceTargetEquality
=
function
(
connection
)
{
if
(
connection
.
targetId
==
connection
.
sourceId
)
{
if
(
connection
.
targetId
==
connection
.
sourceId
)
{
addMessage
(
"Connecting element to itself is forbidden."
,
"danger"
);
addMessage
(
gettext
(
"Connecting element to itself is forbidden."
),
"danger"
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -284,10 +265,8 @@ jsPlumb.ready(function() {
...
@@ -284,10 +265,8 @@ jsPlumb.ready(function() {
anchors
=
element
.
attr
(
"anchors"
);
anchors
=
element
.
attr
(
"anchors"
);
id
=
element
.
attr
(
"id"
);
id
=
element
.
attr
(
"id"
);
for
(
i
=
0
;
i
<
anchors
;
i
++
)
for
(
i
=
0
;
i
<
anchors
;
i
++
)
{
{
if
(
isConnected
(
i
+
"_"
+
id
))
{
if
(
isConnected
(
i
+
"_"
+
id
))
{
return
true
;
return
true
;
}
}
}
}
...
@@ -319,7 +298,7 @@ jsPlumb.ready(function() {
...
@@ -319,7 +298,7 @@ jsPlumb.ready(function() {
addEndpoint
=
function
(
element
)
{
addEndpoint
=
function
(
element
)
{
anchors
=
element
.
attr
(
"anchors"
);
anchors
=
element
.
attr
(
"anchors"
);
if
(
anchors
==
8
)
return
;
if
(
anchors
==
8
)
return
1
;
anchors
++
;
anchors
++
;
...
@@ -335,19 +314,21 @@ jsPlumb.ready(function() {
...
@@ -335,19 +314,21 @@ jsPlumb.ready(function() {
element
.
attr
(
"anchors"
,
anchors
);
element
.
attr
(
"anchors"
,
anchors
);
jsPlumbInstance
.
repaintEverything
();
jsPlumbInstance
.
repaintEverything
();
return
0
;
};
};
removeEndoint
=
function
(
element
)
{
removeEndoint
=
function
(
element
)
{
anchors
=
element
.
attr
(
"anchors"
);
anchors
=
element
.
attr
(
"anchors"
);
if
(
anchors
==
4
)
return
;
if
(
anchors
==
4
)
return
1
;
i
=
--
anchors
;
i
=
--
anchors
;
while
(
isConnected
(
i
+
"_"
+
element
.
attr
(
"id"
))
&&
i
>=
0
)
i
--
;
while
(
isConnected
(
i
+
"_"
+
element
.
attr
(
"id"
))
&&
i
>=
0
)
i
--
;
if
(
i
==
-
1
)
{
if
(
i
==
-
1
)
{
addMessage
(
"Removing anchors is obstructed."
,
"danger"
);
addMessage
(
gettext
(
"Removing anchors is obstructed."
),
"danger"
);
return
;
return
;
}
else
if
(
i
==
anchors
)
{
}
else
if
(
i
==
anchors
)
{
jsPlumbInstance
.
deleteEndpoint
(
jsPlumbInstance
.
getEndpoint
(
anchors
+
"_"
+
element
.
attr
(
"id"
)));
jsPlumbInstance
.
deleteEndpoint
(
jsPlumbInstance
.
getEndpoint
(
anchors
+
"_"
+
element
.
attr
(
"id"
)));
...
@@ -369,6 +350,8 @@ jsPlumb.ready(function() {
...
@@ -369,6 +350,8 @@ jsPlumb.ready(function() {
element
.
attr
(
"anchors"
,
anchors
);
element
.
attr
(
"anchors"
,
anchors
);
jsPlumbInstance
.
repaintEverything
();
jsPlumbInstance
.
repaintEverything
();
return
0
;
};
};
connectEndpoints
=
function
(
data
)
{
connectEndpoints
=
function
(
data
)
{
...
@@ -436,7 +419,7 @@ jsPlumb.ready(function() {
...
@@ -436,7 +419,7 @@ jsPlumb.ready(function() {
};
};
/* Registering events using JsPlumb. */
/* Registering events using JsPlumb. */
jsPlumbInstance
.
bind
(
"connection"
,
function
(
info
)
{
jsPlumbInstance
.
bind
(
"connection"
,
function
(
info
)
{
updateConnections
(
info
.
connection
);
updateConnections
(
info
.
connection
);
...
@@ -485,20 +468,12 @@ jsPlumb.ready(function() {
...
@@ -485,20 +468,12 @@ jsPlumb.ready(function() {
jsPlumbInstance
.
detach
(
info
);
jsPlumbInstance
.
detach
(
info
);
});
});
jsPlumbInstance
.
bind
(
"dblclick"
,
function
(
info
)
{
info
.
setPaintStyle
({
strokeStyle
:
"red"
,
lineWidth
:
8
});
addInfo
(
$
(
"#"
+
info
.
sourceId
.
split
(
'_'
)[
1
]).
attr
(
"alt"
)
+
' - '
+
$
(
"#"
+
info
.
targetId
.
split
(
'_'
)[
1
]).
attr
(
"alt"
),
info
.
parameters
,
"connection"
,
info
);
});
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".element"
),
{
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".element"
),
{
containment
:
$
(
"#dropContainer"
)
containment
:
$
(
"#dropContainer"
)
});
});
/* Registering events using JQuery. */
/* Registering events using JQuery. */
$
(
'body'
).
on
(
'click'
,
'.elementTemplate'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'.elementTemplate'
,
function
()
{
addElement
(
$
(
this
).
attr
(
"id"
),
addElement
(
$
(
this
).
attr
(
"id"
),
...
@@ -518,7 +493,7 @@ jsPlumb.ready(function() {
...
@@ -518,7 +493,7 @@ jsPlumb.ready(function() {
element
.
addClass
(
"elementSelected"
);
element
.
addClass
(
"elementSelected"
);
addInfo
(
element
.
attr
(
"alt"
),
addInfo
(
element
.
attr
(
"alt"
),
element
.
attr
(
"parameters"
),
element
.
attr
(
"parameters"
),
"element"
,
element
);
element
,
1
);
$
(
document
).
scrollTop
(
0
);
$
(
document
).
scrollTop
(
0
);
});
});
...
@@ -535,21 +510,16 @@ jsPlumb.ready(function() {
...
@@ -535,21 +510,16 @@ jsPlumb.ready(function() {
stackIndexer
++
;
stackIndexer
++
;
});
});
$
(
'body'
).
on
(
'click'
,
'#closeInfoPanel'
,
function
()
{
$
(
'body'
).
on
(
'keyup'
,
'#infoInput'
,
function
()
{
$
(
'#informationPanel'
).
hide
();
$
(
'#dragPanel'
).
show
();
});
$
(
'body'
).
on
(
'keyUp'
,
'#infoInput'
,
function
()
{
setServiceStatus
(
"unsaved"
);
setServiceStatus
(
"unsaved"
);
newParams
=
$
(
"#infoInput"
).
val
();
newParams
=
$
(
"#infoInput"
).
val
();
if
(
type
==
"connection"
)
object
.
parameters
=
newParams
;
sharedObject
.
attr
(
"parameters"
,
newParams
);
if
(
type
==
"element"
)
object
.
attr
(
"parameters"
,
newParams
);
});
});
$
(
'body'
).
on
(
'click'
,
'#addEndpoint'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#addEndpoint'
,
function
()
{
addEndpoint
(
sharedObject
);
setServiceStatus
(
"unsaved"
);
if
(
addEndpoint
(
sharedObject
))
return
;
undoStack
.
splice
(
stackIndexer
,
0
,
removeEndoint
);
undoStack
.
splice
(
stackIndexer
,
0
,
removeEndoint
);
redoStack
.
splice
(
stackIndexer
,
0
,
addEndpoint
);
redoStack
.
splice
(
stackIndexer
,
0
,
addEndpoint
);
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
...
@@ -558,7 +528,8 @@ jsPlumb.ready(function() {
...
@@ -558,7 +528,8 @@ jsPlumb.ready(function() {
});
});
$
(
'body'
).
on
(
'click'
,
'#removeEndpoint'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#removeEndpoint'
,
function
()
{
removeEndoint
(
sharedObject
);
setServiceStatus
(
"unsaved"
);
if
(
removeEndoint
(
sharedObject
))
return
;
undoStack
.
splice
(
stackIndexer
,
0
,
addEndpoint
);
undoStack
.
splice
(
stackIndexer
,
0
,
addEndpoint
);
redoStack
.
splice
(
stackIndexer
,
0
,
removeEndoint
);
redoStack
.
splice
(
stackIndexer
,
0
,
removeEndoint
);
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
...
@@ -575,6 +546,8 @@ jsPlumb.ready(function() {
...
@@ -575,6 +546,8 @@ jsPlumb.ready(function() {
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
objectStack
.
splice
(
stackIndexer
,
0
,
sharedObject
);
stackSize
++
;
stackSize
++
;
stackIndexer
++
;
stackIndexer
++
;
$
(
"#changeInformationDialog"
).
modal
(
'hide'
);
});
});
$
(
'body'
).
on
(
'click'
,
'#removeConnection'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#removeConnection'
,
function
()
{
...
@@ -595,7 +568,7 @@ jsPlumb.ready(function() {
...
@@ -595,7 +568,7 @@ jsPlumb.ready(function() {
});
});
$
(
'body'
).
on
(
'click'
,
'#clearService'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#clearService'
,
function
()
{
jsPlumbInstance
.
remove
(
"element"
);
//Todo
setServiceStatus
(
"unsaved"
);
setServiceStatus
(
"unsaved"
);
elementIndex
=
0
;
elementIndex
=
0
;
...
@@ -620,16 +593,12 @@ jsPlumb.ready(function() {
...
@@ -620,16 +593,12 @@ jsPlumb.ready(function() {
});
});
$
(
'body'
).
on
(
'click'
,
'#addMachineDialog'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#addMachineDialog'
,
function
()
{
// Here comes the ajax post of getMachineAvailableList
// Here comes the ajax post of getting machines
// 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"
);
addInfo
(
$
(
"#"
+
id
).
attr
(
"alt"
),
$
(
"#"
+
id
).
attr
(
"desc"
),
"elementTemplate"
,
$
(
"#"
+
id
));
addInfo
(
$
(
"#"
+
id
).
attr
(
"alt"
),
$
(
"#"
+
id
).
attr
(
"desc"
),
$
(
"#"
+
id
),
0
);
});
});
$
(
'body'
).
on
(
'click'
,
'#serviceName'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#serviceName'
,
function
()
{
...
@@ -653,9 +622,8 @@ jsPlumb.ready(function() {
...
@@ -653,9 +622,8 @@ jsPlumb.ready(function() {
scrollContainer
(
1
);
scrollContainer
(
1
);
});
});
$
(
'body'
).
on
(
'hide.bs.modal'
,
'#changeInformationDialog'
,
function
()
{
$
(
'body'
).
on
(
'hide.bs.modal'
,
'#changeInformationDialog'
,
function
()
{
$
(
'.element'
).
removeClass
(
'elementSelected'
);
$
(
'.element'
).
removeClass
(
'elementSelected'
);
jsPlumbInstance
.
select
().
setPaintStyle
({
strokeStyle
:
'#9932cc'
,
lineWidth
:
8
});
});
});
$
(
'body'
).
on
(
'keyup'
,
'#searchElementTemplate'
,
function
()
{
$
(
'body'
).
on
(
'keyup'
,
'#searchElementTemplate'
,
function
()
{
...
@@ -688,52 +656,53 @@ jsPlumb.ready(function() {
...
@@ -688,52 +656,53 @@ jsPlumb.ready(function() {
var
eventObject
=
window
.
event
?
event
:
e
;
var
eventObject
=
window
.
event
?
event
:
e
;
// Undo (CTRL + Z)
// Undo (CTRL + Z)
if
(
eventObject
.
keyCode
==
90
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
90
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#undoMovement'
).
click
();
$
(
'#undoMovement'
).
click
();
}
}
// Redo (CTRL + Y)
// Redo (CTRL + Y)
if
(
eventObject
.
keyCode
==
89
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
89
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#redoMovement'
).
click
();
$
(
'#redoMovement'
).
click
();
}
}
// Add element (CTRL + A)
// Add element (CTRL + A)
if
(
eventObject
.
keyCode
==
65
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
65
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#showAddElementDialog'
).
click
();
$
(
'#showAddElementDialog'
).
click
();
}
}
// Clean (CTRL + C)
// Clean (CTRL + C)
if
(
eventObject
.
keyCode
==
67
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
67
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#clearService'
).
click
();
$
(
'#clearService'
).
click
();
}
}
// Save (CTRL + S)
// Save (CTRL + S)
if
(
eventObject
.
keyCode
==
83
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
83
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#saveService'
).
click
();
$
(
'#saveService'
).
click
();
}
}
// Delete (CTRL + D)
// Delete (CTRL + D)
if
(
eventObject
.
keyCode
==
68
&&
eventObject
.
ctrlKey
)
if
(
eventObject
.
keyCode
==
68
&&
eventObject
.
ctrlKey
)
{
{
eventObject
.
preventDefault
();
eventObject
.
preventDefault
();
$
(
'#deleteService'
).
click
();
$
(
'#deleteService'
).
click
();
}
}
// Close dialog (ESC)
if
(
eventObject
.
keyCode
==
27
)
{
eventObject
.
preventDefault
();
$
(
"#changeInformationDialog"
).
modal
(
'hide'
);
$
(
"#addElementDialog"
).
modal
(
'hide'
);
}
});
});
$
(
window
).
on
(
'resize'
,
function
()
{
$
(
window
).
on
(
'resize'
,
function
()
{
$
(
".element"
).
each
(
function
()
{
$
(
".element"
).
each
(
function
()
{
rate
=
(
$
(
this
).
position
().
left
)
/
workspaceWidth
;
rate
=
(
$
(
this
).
position
().
left
)
/
workspaceWidth
;
left
=
rate
*
(
$
(
"#dropContainer"
).
width
());
left
=
rate
*
(
$
(
"#dropContainer"
).
width
());
$
(
this
).
css
(
"left"
,
left
);
$
(
this
).
css
(
"left"
,
left
);
});
});
workspaceWidth
=
$
(
"#dropContainer"
).
width
();
workspaceWidth
=
$
(
"#dropContainer"
).
width
();
...
@@ -741,7 +710,7 @@ jsPlumb.ready(function() {
...
@@ -741,7 +710,7 @@ jsPlumb.ready(function() {
});
});
/* Registering events concerning persistence. */
/* Registering events concerning persistence. */
$
(
'body'
).
on
(
'click'
,
'#saveService'
,
function
()
{
$
(
'body'
).
on
(
'click'
,
'#saveService'
,
function
()
{
serviceName
=
$
(
"#serviceName"
).
text
();
serviceName
=
$
(
"#serviceName"
).
text
();
...
@@ -754,16 +723,18 @@ jsPlumb.ready(function() {
...
@@ -754,16 +723,18 @@ jsPlumb.ready(function() {
"sourceEndpoint"
:
elementConnections
[
index
].
endpoints
[
0
].
getUuid
(),
"sourceEndpoint"
:
elementConnections
[
index
].
endpoints
[
0
].
getUuid
(),
"targetId"
:
elementConnections
[
index
].
targetId
,
"targetId"
:
elementConnections
[
index
].
targetId
,
"targetEndpoint"
:
elementConnections
[
index
].
endpoints
[
1
].
getUuid
(),
"targetEndpoint"
:
elementConnections
[
index
].
endpoints
[
1
].
getUuid
(),
"parameters"
:
elementConnections
[
index
].
parameters
});
"parameters"
:
elementConnections
[
index
].
parameters
});
});
});
$
.
each
(
$
(
".element"
),
function
()
{
$
.
each
(
$
(
".element"
),
function
()
{
instanceSet
.
push
({
instanceSet
.
push
({
"displayId"
:
$
(
this
).
prop
(
"id"
),
"displayId"
:
$
(
this
).
prop
(
"id"
),
"positionLeft"
:
$
(
this
).
position
().
left
/
workspaceWidth
,
"positionLeft"
:
$
(
this
).
position
().
left
/
workspaceWidth
,
"positionTop"
:
$
(
this
).
position
().
top
/
workspaceHeight
,
"positionTop"
:
$
(
this
).
position
().
top
/
workspaceHeight
,
"anchorNumber"
:
$
(
this
).
attr
(
"anchors"
),
"anchorNumber"
:
$
(
this
).
attr
(
"anchors"
),
"parameters"
:
$
(
this
).
attr
(
"parameters"
)});
"parameters"
:
$
(
this
).
attr
(
"parameters"
)
});
});
});
$
.
post
(
""
,
{
$
.
post
(
""
,
{
...
@@ -771,15 +742,16 @@ jsPlumb.ready(function() {
...
@@ -771,15 +742,16 @@ jsPlumb.ready(function() {
data
:
JSON
.
stringify
({
data
:
JSON
.
stringify
({
"serviceName"
:
serviceName
,
"serviceName"
:
serviceName
,
"elementConnections"
:
connectionSet
,
"elementConnections"
:
connectionSet
,
"elements"
:
instanceSet
})
"elements"
:
instanceSet
})
},
function
(
result
)
{
},
function
(
result
)
{
addMessage
(
result
.
serviceName
+
" saved successfully."
,
"success"
);
addMessage
(
result
.
serviceName
+
gettext
(
" saved successfully."
),
"success"
);
setServiceStatus
(
"saved"
);
setServiceStatus
(
"saved"
);
});
});
});
});
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
if
(
!
$
(
"#dropContainer"
).
length
)
return
;
// Protection for not posting sites that differ from setty sites.
if
(
!
$
(
"#dropContainer"
).
length
)
return
;
// Protection for not posting sites that differ from setty sites.
$
.
post
(
""
,
{
$
.
post
(
""
,
{
event
:
"loadService"
event
:
"loadService"
},
function
(
result
)
{
},
function
(
result
)
{
...
@@ -788,10 +760,10 @@ jsPlumb.ready(function() {
...
@@ -788,10 +760,10 @@ jsPlumb.ready(function() {
$
.
each
(
result
.
elements
,
function
(
i
,
element
)
{
$
.
each
(
result
.
elements
,
function
(
i
,
element
)
{
addElement
(
element
.
displayId
.
split
(
'_'
)[
1
],
addElement
(
element
.
displayId
.
split
(
'_'
)[
1
],
element
.
displayId
,
element
.
displayId
,
(
element
.
positionTop
*
workspaceHeight
)
+
"px"
,
(
element
.
positionTop
*
workspaceHeight
)
+
"px"
,
element
.
anchorNumber
,
element
.
anchorNumber
,
element
.
parameters
,
element
.
parameters
,
(
element
.
positionLeft
*
workspaceWidth
)
+
"px"
);
(
element
.
positionLeft
*
workspaceWidth
)
+
"px"
);
if
(
elementIndex
<
element
.
displayId
.
split
(
'_'
)[
0
])
if
(
elementIndex
<
element
.
displayId
.
split
(
'_'
)[
0
])
elementIndex
=
element
.
displayId
.
split
(
'_'
)[
0
];
elementIndex
=
element
.
displayId
.
split
(
'_'
)[
0
];
elementIndex
++
;
elementIndex
++
;
...
...
circle/setty/templates/setty/index.html
View file @
39a7ffc9
...
@@ -118,14 +118,14 @@
...
@@ -118,14 +118,14 @@
</div>
</div>
<div
class=
"panel-body container-fluid"
id=
"dragContainer"
>
<div
class=
"panel-body container-fluid"
id=
"dragContainer"
>
{% for element in elementTemplateList %}
{% for element in elementTemplateList %}
<div
class=
"col-md-
12
col-sm-4"
id=
"elementTemplatePanel"
>
<div
class=
"col-md-
6
col-sm-4"
id=
"elementTemplatePanel"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"panel-heading"
>
<div
class=
"row text-center"
>
<div
class=
"row text-center"
>
<div
class=
"col-xs-
10 col-xs-push-1
text-center"
>
<div
class=
"col-xs-
8 col-xs-push-2
text-center"
>
<label
class=
"no-margin"
>
{{ element.name }}
</label>
<label
class=
"no-margin"
>
{{ element.name }}
</label>
</div>
</div>
<div
class=
"col-xs-
1 col-xs-push-1 text-righ
t"
>
<div
class=
"col-xs-
2 col-xs-push-2 text-lef
t"
>
<button
class=
"btn btn-primary btn-xs elementTemplateInfo"
element=
"{{ element.id }}"
>
<button
class=
"btn btn-primary btn-xs elementTemplateInfo"
element=
"{{ element.id }}"
>
<i
class=
"fa fa-info"
></i>
<i
class=
"fa fa-info"
></i>
</button>
</button>
...
...
circle/setty/views.py
View file @
39a7ffc9
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.contrib
import
messages
# NOTE: ezt tettem ide
from
django.contrib
import
messages
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db.models
import
Q
from
django.db.models
import
Q
...
@@ -41,12 +41,24 @@ class DetailView(LoginRequiredMixin, TemplateView):
...
@@ -41,12 +41,24 @@ class DetailView(LoginRequiredMixin, TemplateView):
template_name
=
"setty/index.html"
template_name
=
"setty/index.html"
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
logger
.
debug
(
'DetailView.get_context_data() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
service
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
if
self
.
request
.
user
==
service
.
user
or
self
.
request
.
user
.
is_superuser
:
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'
]
return
context
return
context
else
:
raise
PermissionDenied
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
logger
.
debug
(
'DetailView.post() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
service
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
if
self
.
request
.
user
==
service
.
user
or
self
.
request
.
user
.
is_superuser
:
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'
])
...
@@ -122,15 +134,26 @@ class DetailView(LoginRequiredMixin, TemplateView):
...
@@ -122,15 +134,26 @@ class DetailView(LoginRequiredMixin, TemplateView):
else
:
else
:
raise
PermissionDenied
raise
PermissionDenied
else
:
raise
PermissionDenied
class
DeleteView
(
LoginRequiredMixin
,
DeleteView
):
class
DeleteView
(
LoginRequiredMixin
,
DeleteView
):
model
=
Service
model
=
Service
success_url
=
reverse_lazy
(
"dashboard.index"
)
success_url
=
reverse_lazy
(
"dashboard.index"
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
logger
.
debug
(
'DeleteView.post() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
service
=
Service
.
objects
.
get
(
id
=
kwargs
[
'pk'
])
if
self
.
request
.
user
==
service
.
user
or
self
.
request
.
user
.
is_superuser
:
return
super
(
DeleteView
,
self
)
.
post
(
request
,
*
args
,
**
kwargs
)
else
:
return
PermissionDenied
class
CreateView
(
LoginRequiredMixin
,
TemplateView
):
class
CreateView
(
LoginRequiredMixin
,
TemplateView
):
def
get_template_names
(
self
):
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
if
self
.
request
.
is_ajax
():
return
[
'dashboard/_modal.html'
]
return
[
'dashboard/_modal.html'
]
...
@@ -138,6 +161,8 @@ class CreateView(LoginRequiredMixin, TemplateView):
...
@@ -138,6 +161,8 @@ class CreateView(LoginRequiredMixin, TemplateView):
return
[
'dashboard/nojs-wrapper.html'
]
return
[
'dashboard/nojs-wrapper.html'
]
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
logger
.
debug
(
'CreateView.get_context_data() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
context
=
super
(
CreateView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
=
super
(
CreateView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
.
update
({
context
.
update
({
...
@@ -148,6 +173,8 @@ class CreateView(LoginRequiredMixin, TemplateView):
...
@@ -148,6 +173,8 @@ class CreateView(LoginRequiredMixin, TemplateView):
return
context
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
logger
.
debug
(
'CreateView.post() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
service_name
=
self
.
request
.
POST
.
get
(
'serviceName'
)
service_name
=
self
.
request
.
POST
.
get
(
'serviceName'
)
if
not
service_name
:
if
not
service_name
:
...
@@ -181,11 +208,15 @@ class ListView(LoginRequiredMixin, FilterMixin, SingleTableView):
...
@@ -181,11 +208,15 @@ class ListView(LoginRequiredMixin, FilterMixin, SingleTableView):
}
}
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
logger
.
debug
(
'ListView.get_context_data() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
context
=
super
(
ListView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
=
super
(
ListView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
[
'search_form'
]
=
self
.
search_form
context
[
'search_form'
]
=
self
.
search_form
return
context
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
def
get
(
self
,
*
args
,
**
kwargs
):
logger
.
debug
(
'ListView.get() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
self
.
search_form
=
ServiceListSearchForm
(
self
.
request
.
GET
)
self
.
search_form
=
ServiceListSearchForm
(
self
.
request
.
GET
)
self
.
search_form
.
full_clean
()
self
.
search_form
.
full_clean
()
...
@@ -203,14 +234,14 @@ class ListView(LoginRequiredMixin, FilterMixin, SingleTableView):
...
@@ -203,14 +234,14 @@ class ListView(LoginRequiredMixin, FilterMixin, SingleTableView):
return
super
(
ListView
,
self
)
.
get
(
*
args
,
**
kwargs
)
return
super
(
ListView
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
logger
.
debug
(
'ListView.get
_queryset() called. User:
%
s'
,
logger
.
debug
(
'ListView.get_queryset() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
unicode
(
self
.
request
.
user
))
qs
=
self
.
model
.
objects
.
all
()
qs
=
self
.
model
.
objects
.
all
()
self
.
create_fake_get
()
# NOTE: ezt tettem ide
self
.
create_fake_get
()
try
:
try
:
filters
,
excludes
=
self
.
get_queryset_filters
()
filters
,
excludes
=
self
.
get_queryset_filters
()
if
not
self
.
request
.
user
.
is_superuser
:
if
not
self
.
request
.
user
.
is_superuser
:
filters
[
'user'
]
=
self
.
request
.
user
# NOTE: ezt visszairtam
filters
[
'user'
]
=
self
.
request
.
user
qs
=
qs
.
filter
(
**
filters
)
.
exclude
(
**
excludes
)
.
distinct
()
qs
=
qs
.
filter
(
**
filters
)
.
exclude
(
**
excludes
)
.
distinct
()
except
ValueError
:
except
ValueError
:
messages
.
error
(
self
.
request
,
_
(
"Error during filtering."
))
messages
.
error
(
self
.
request
,
_
(
"Error during filtering."
))
...
...
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