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
7bc6e462
authored
8 years ago
by
Sulyok Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Machine handling fixes
parent
f7a8b0d6
Pipeline
#257
failed with stage
in 0 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
227 additions
and
120 deletions
+227
-120
circle/setty/controller.py
+19
-11
circle/setty/models.py
+3
-3
circle/setty/static/setty/setty.js
+175
-106
circle/setty/static/setty/style.css
+27
-0
circle/setty/templates/setty/index.html
+3
-0
No files found.
circle/setty/controller.py
View file @
7bc6e462
...
...
@@ -114,19 +114,27 @@ class SettyController:
@staticmethod
def
getMachineAvailableList
(
serviceId
,
used_hostnames
,
current_user
):
all_minions
=
[]
# SettyController.salthelper.getAllMinionsUngrouped()
usedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
user_instances
=
Instance
.
objects
.
filter
(
owner
=
current_user
)
userMachines
=
[]
def
getMachineAvailableList
(
serviceId
,
usedHostnames
,
current_user
):
saltMinions
=
[]
#SettyController.salthelper.getAllMinionsUngrouped()
savedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
savedHostNames
=
[]
for
machine
in
savedMachines
:
savedHostNames
.
append
(
machine
.
hostname
)
userInstances
=
Instance
.
objects
.
filter
(
owner
=
current_user
)
userMachines
=
[]
for
instance
in
user
_i
nstances
:
for
instance
in
user
I
nstances
:
if
instance
.
vm_name
:
print
instance
.
vm_name
userMachines
.
append
(
instance
.
vm_name
)
return
{
'machinedata'
:
userMachines
}
usedHostnamesByUser
=
set
(
savedHostNames
+
usedHostnames
)
if
not
usedHostnamesByUser
:
return
{
'machinedata'
:
userMachines
}
#{'machinedata': [machineName for machineName in userMachines if machineName in saltMinions] }
availableInstanceNames
=
list
(
set
(
userMachines
)
-
usedHostnamesByUser
)
return
{
'machinedata'
:
availableInstanceNames
}
#[ machineName for machineName in availableInstanceNames if machineName in saltMinions ]}
@staticmethod
def
addMachine
(
hostname
):
...
...
@@ -135,12 +143,12 @@ class SettyController:
return
{
'error'
:
'already added or doesnt exists'
}
except
:
pass
if
SettyController
.
salthelper
.
checkMinionExists
(
hostname
):
#
if SettyController.salthelper.checkMinionExists(hostname):
machine
=
Machine
.
clone
()
machine
.
hostname
=
hostname
return
machine
.
getDataDictionary
()
else
:
return
{
'error'
:
'already added or doesnt exists'
}
#
else:
#
return {'error': 'already added or doesnt exists'}
@staticmethod
def
addServiceNode
(
elementTemplateId
):
...
...
This diff is collapsed.
Click to expand it.
circle/setty/models.py
View file @
7bc6e462
...
...
@@ -152,9 +152,9 @@ class Machine(Element): # As a real machine
@staticmethod
def
getInformation
():
return
{
'hostname'
:
hostname
.
get_internal_type
(),
'alias'
:
alias
.
get_internal_type
(),
'description'
:
description
.
get_internal_type
()}
return
{
'hostname'
:
Machine
.
_meta
.
get_field
(
'hostname'
)
.
get_internal_type
(),
'alias'
:
Machine
.
_meta
.
get_field
(
'alias'
)
.
get_internal_type
(),
'description'
:
Machine
.
_meta
.
get_field
(
'description'
)
.
get_internal_type
()}
def
getDataDictionary
(
self
):
element_data
=
self
.
getDisplayData
()
...
...
This diff is collapsed.
Click to expand it.
circle/setty/static/setty/setty.js
View file @
7bc6e462
...
...
@@ -70,6 +70,7 @@ jsPlumb.ready(function() {
};
var
elementConnections
=
[];
var
elementIndex
=
0
;
var
machineIndex
=
0
;
var
dragContainerScroll
=
0
;
var
workspaceWidth
=
$
(
"#dropContainer"
).
width
();
var
workspaceHeight
=
$
(
"#dropContainer"
).
height
();
...
...
@@ -94,37 +95,32 @@ jsPlumb.ready(function() {
}
};
addInfo
=
function
(
title
,
info
,
type
,
object
)
{
addMachineClicked
=
function
(
machineButton
){
machineHostname
=
$
(
machineButton
.
currentTarget
).
attr
(
"data-hostname"
);
$
.
post
(
""
,
{
event
:
"addMachine"
,
data
:
JSON
.
stringify
({
"hostname"
:
machineHostname
}
)
},
function
(
result
)
{
addMachine
(
result
);
undoStack
.
splice
(
stackIndexer
,
0
,
removeElement
);
redoStack
.
splice
(
stackIndexer
,
0
,
addElement
);
objectStack
.
splice
(
stackIndexer
,
0
,
newInstance
);
stackSize
++
;
stackIndexer
++
;
});
}
addInfo
=
function
(
title
,
object
)
{
id
=
object
.
attr
(
"id"
).
split
(
"_"
)[
1
];
information
=
undefined
;
$
.
post
(
""
,
{
event
:
"getInformation"
,
data
:
JSON
.
stringify
({
"elementTemplateId"
:
object
.
attr
(
"id"
).
split
(
"_"
)[
1
]
,
"hostname"
:
object
.
attr
(
"
hostname"
)
}
)
"elementTemplateId"
:
object
.
attr
(
"
data-hostname"
)
?
""
:
object
.
attr
(
"
id"
).
split
(
"_"
)[
1
]
,
"hostname"
:
object
.
attr
(
"
data-hostname"
)?
object
.
attr
(
"data-hostname"
)
:
""
}
)
},
function
(
result
)
{
$
(
"#informationContainer"
).
empty
();
switch
(
type
){
/*case "connection":
div =
'<div class="row">' +
'<div class="col-xs-12 text-center">' +
'<h4>' + title + '</h4>' +
'</div>' +
'</div> ' +
'<div class="row">' +
'<div class="col-xs-12">' +
'<textarea class="form-control" rows="28" id="infoInput" placeholder="Config data"></textarea>' +
'</div>' +
'</div> ' +
'<div class="row">' +
'<div class="col-xs-12 text-center">' +
'<button id="removeConnection" class="btn btn-info">Remove connection</button>' +
'</div>' +
'</div>';
break;*/
case
"element"
:
$
.
each
(
result
,
function
(
fieldName
,
fieldType
)
{
form_group
=
$
(
"<div class='form-group'></div>"
);
...
...
@@ -160,28 +156,6 @@ jsPlumb.ready(function() {
form_group
.
append
(
input
);
$
(
"#informationContainer"
).
append
(
form_group
)
}
);
break
;
/*case "elementTemplate":
div =
'<div class="row">' +
'<div class="col-xs-12 text-center">' +
'<h4>' + title + '</h4>' +
'</div>' +
'</div> ' +
'<div class="row">' +
'<div class="col-xs-12">' +
'<textarea class="form-control" rows="28" id="infoInput" placeholder="Config data"></textarea>' +
'</div>' +
'</div> ' +
'<div class="row">' +
'<div class="col-xs-12 text-center">' +
'<button id="addElementToWorkspace" class="btn btn-success">Add to workspace</button>' +
'</div>' +
'</div>';
break;*/
}
$
(
"#infoInput"
).
val
(
info
);
$
(
"#changeInformationDialog"
).
modal
(
'show'
);
...
...
@@ -443,35 +417,6 @@ jsPlumb.ready(function() {
return
newInstance
;
};
addMachine
=
function
(
idOrInstance
,
newId
,
newPositionY
,
endpoints
,
parameters
,
newPositionX
)
{
newInstance
=
""
;
newInstance
=
$
(
'<div>'
)
.
prop
(
"id"
,
newId
)
.
prop
(
"title"
,
"Right click to delete"
)
.
removeClass
()
.
addClass
(
"element"
)
.
attr
(
"anchors"
,
0
)
.
attr
(
"parameters"
,
parameters
)
.
css
(
"top"
,
newPositionY
)
.
css
(
"left"
,
newPositionX
);
$
(
"#dropContainer"
).
append
(
newInstance
);
for
(
i
=
0
;
i
<=
endpoints
;
i
++
)
{
addEndpoint
(
newInstance
);
}
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".element"
),
{
containment
:
$
(
"#dropContainer"
)
});
setServiceStatus
(
"unsaved"
);
jsPlumbInstance
.
repaintEverything
();
return
newInstance
;
}
removeElement
=
function
(
object
)
{
jsPlumbInstance
.
detachAllConnections
(
object
);
jsPlumbInstance
.
remove
(
object
.
attr
(
"id"
));
...
...
@@ -529,15 +474,18 @@ jsPlumb.ready(function() {
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
);
//
addInfo($("#" + info.sourceId.split('_')[1]).attr("alt") + ' - ' + $("#" + info.targetId.split('_')[1]).attr("alt"),
//
info.parameters,
//
"connection",
//
info);
});
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".element"
),
{
containment
:
$
(
"#dropContainer"
)
});
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".machine"
),
{
containment
:
$
(
"#dropContainer"
)
});
/* Registering general events using JQuery. */
...
...
@@ -572,14 +520,17 @@ jsPlumb.ready(function() {
/* ---------------------------------------- */
$
(
'body'
).
on
(
'dblclick'
,
'.element'
,
function
()
{
element
=
$
(
this
);
element
.
addClass
(
"elementSelected"
);
addInfo
(
element
.
attr
(
"alt"
),
element
.
attr
(
"parameters"
),
"element"
,
element
);
addInfo
(
element
.
attr
(
"alt"
),
element
);
$
(
document
).
scrollTop
(
0
);
});
$
(
'body'
).
on
(
'dblclick'
,
'.machine'
,
function
()
{
element
=
$
(
this
);
element
.
addClass
(
"elementSelected"
);
addInfo
(
element
.
attr
(
"alt"
),
element
);
$
(
document
).
scrollTop
(
0
);
});
...
...
@@ -596,6 +547,19 @@ jsPlumb.ready(function() {
stackIndexer
++
;
});
$
(
'body'
).
on
(
'contextmenu'
,
'.machine'
,
function
(
event
)
{
setServiceStatus
(
"unsaved"
);
removeElement
(
$
(
this
));
undoStack
.
splice
(
stackIndexer
,
0
,
addElement
);
redoStack
.
splice
(
stackIndexer
,
0
,
removeElement
);
objectStack
.
splice
(
stackIndexer
,
0
,
$
(
this
));
nextStepConstraint
=
0
;
stackSize
++
;
stackIndexer
++
;
});
$
(
'body'
).
on
(
'click'
,
'#closeInfoPanel'
,
function
()
{
$
(
'#informationPanel'
).
hide
();
$
(
'#dragPanel'
).
show
();
...
...
@@ -680,18 +644,36 @@ jsPlumb.ready(function() {
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'
,
'#showAddMachineDialog'
,
function
()
{
usedHostnames
=
[]
$
(
".machine"
).
each
(
function
()
{
usedHostnames
.
push
(
$
(
this
).
attr
(
"data-hostname"
))
}
);
$
.
post
(
""
,
{
event
:
"getMachineAvailableList"
,
data
:
JSON
.
stringify
({
"usedHostnames"
:
usedHostnames
}
)
},
function
(
result
)
{
$
(
"#availableMachineListContainer"
).
empty
();
$
.
each
(
result
.
machinedata
,
function
(
key
,
hostname
)
{
listItem
=
$
(
"<button/>"
)
//.class("list-group-item").data("hostname",hostname);
listItem
.
addClass
(
"list-group-item"
).
attr
(
"data-hostname"
,
hostname
).
attr
(
"data-dismiss"
,
"modal"
).
attr
(
"type"
,
"button"
);
listItem
.
append
(
hostname
);
listItem
.
on
(
"click"
,
{
hostname
:
listItem
},
addMachineClicked
);
$
(
"#availableMachineListContainer"
).
append
(
listItem
);
});
$
(
'body'
).
on
(
'click'
,
'.elementTemplateInfo'
,
function
()
{
id
=
$
(
this
).
attr
(
"element"
);
addInfo
(
$
(
"#"
+
id
).
attr
(
"alt"
),
$
(
"#"
+
id
).
attr
(
"desc"
),
"elementTemplate"
,
$
(
"#"
+
id
));
$
(
"#addMachineDialog"
).
modal
(
'show'
);
});
});
//$('body').on('click', '.elementTemplateInfo', function() {
// id = $(this).attr("element");
// addInfo($("#" + id).attr("alt"), $("#" + id).attr("desc"), "elementTemplate", $("#" + id));
//});
$
(
'body'
).
on
(
'click'
,
'#serviceName'
,
function
()
{
$
(
'#serviceName'
).
hide
();
...
...
@@ -818,6 +800,7 @@ jsPlumb.ready(function() {
serviceName
=
$
(
"#serviceName"
).
text
();
connectionSet
=
[];
instanceSet
=
[];
machineSet
=
[];
$
.
each
(
elementConnections
,
function
(
index
)
{
connectionSet
.
push
({
...
...
@@ -834,7 +817,6 @@ jsPlumb.ready(function() {
"displayId"
:
$
(
item
).
prop
(
"id"
)
};
attributes
=
item
.
attributes
$
.
each
(
attributes
,
function
(
key
,
attribute
){
if
(
attribute
.
name
.
indexOf
(
"data-"
)
!=
-
1
){
basic_data
[
attribute
.
name
.
substring
(
attribute
.
name
.
indexOf
(
'-'
)
+
1
)
]
=
attribute
.
value
||
""
;
}
...
...
@@ -843,13 +825,28 @@ jsPlumb.ready(function() {
instanceSet
.
push
(
basic_data
);
});
$
.
each
(
$
(
".machine"
),
function
(
index
,
item
)
{
basic_data
=
{
"anchorNumber"
:
$
(
item
).
attr
(
"anchors"
),
"positionLeft"
:
$
(
item
).
position
().
left
/
workspaceWidth
,
"positionTop"
:
$
(
item
).
position
().
top
/
workspaceHeight
,
"displayId"
:
$
(
item
).
prop
(
"id"
)
};
attributes
=
item
.
attributes
$
.
each
(
attributes
,
function
(
key
,
attribute
){
if
(
attribute
.
name
.
indexOf
(
"data-"
)
!=
-
1
){
basic_data
[
attribute
.
name
.
substring
(
attribute
.
name
.
indexOf
(
'-'
)
+
1
)
]
=
attribute
.
value
||
""
;
}
});
machineSet
.
push
(
basic_data
);
});
$
.
post
(
""
,
{
event
:
"saveService"
,
data
:
JSON
.
stringify
({
"serviceName"
:
serviceName
,
"elementConnections"
:
connectionSet
,
"serviceNodes"
:
instanceSet
,
"machines"
:
[]
})
"machines"
:
machineSet
})
},
function
(
result
)
{
addMessage
(
result
.
serviceName
+
gettext
(
" saved successfully."
),
"success"
);
setServiceStatus
(
"saved"
);
...
...
@@ -866,7 +863,7 @@ jsPlumb.ready(function() {
$
(
"#serviceName"
).
text
(
result
.
serviceName
);
$
.
each
(
result
.
serviceNodes
,
function
(
i
,
element
)
{
addElement
2
(
element
);
addElement
OnLoad
(
element
);
if
(
elementIndex
<
element
.
displayId
.
split
(
'_'
)[
0
])
elementIndex
=
element
.
displayId
.
split
(
'_'
)[
0
];
...
...
@@ -874,15 +871,11 @@ jsPlumb.ready(function() {
});
$
.
each
(
result
.
machines
,
function
(
i
,
element
)
{
addMachine
(
element
.
displayId
.
split
(
'_'
)[
1
],
element
.
displayId
,
(
element
.
positionTop
*
workspaceHeight
)
+
"px"
,
element
.
anchorNumber
,
element
.
parameters
,
(
element
.
positionLeft
*
workspaceWidth
)
+
"px"
);
if
(
elementIndex
<
element
.
displayId
.
split
(
'_'
)[
0
])
elementIndex
=
element
.
displayId
.
split
(
'_'
)[
0
];
elementIndex
++
;
addMachineOnLoad
(
element
);
if
(
machineIndex
<
element
.
displayId
.
split
(
'_'
)[
1
])
machineIndex
=
element
.
displayId
.
split
(
'_'
)[
1
];
machineIndex
++
;
});
clickEvent
=
1
;
...
...
@@ -896,11 +889,87 @@ jsPlumb.ready(function() {
});
});
addElement2
=
function
(
elementData
)
{
addMachine
=
function
(
elementData
){
newInstance
=
$
(
'<img id="machine_'
+
machineIndex
+
'"/>'
)
.
prop
(
"title"
,
"Right click to delete"
)
.
removeClass
()
.
attr
(
"anchors"
,
0
)
.
addClass
(
"machine"
);
var
skippedVariables
=
[
"anchorNumber"
,
"displayId"
]
$
.
each
(
elementData
,
function
(
key
,
value
)
{
if
(
skippedVariables
.
indexOf
(
key
)
==
-
1
)
{
if
(
key
===
"positionTop"
)
newInstance
.
css
(
"top"
,
value
*
workspaceHeight
);
else
if
(
key
===
"positionLeft"
)
newInstance
.
css
(
"left"
,
value
*
workspaceWidth
);
else
newInstance
.
attr
(
"data-"
+
key
,
value
);
}
});
$
(
"#dropContainer"
).
append
(
newInstance
);
for
(
idx
=
0
;
idx
<
4
;
idx
++
)
addEndpoint
(
newInstance
);
setServiceStatus
(
"unsaved"
);
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".machine"
),
{
containment
:
$
(
"#dropContainer"
)
});
jsPlumbInstance
.
repaintEverything
();
machineIndex
++
;
return
newInstance
;
}
addMachineOnLoad
=
function
(
elementData
){
newInstance
=
$
(
'<img id="'
+
elementData
[
"displayId"
]
+
'"/>'
)
.
prop
(
"title"
,
"Right click to delete"
)
.
removeClass
()
.
attr
(
"anchors"
,
0
)
.
addClass
(
"machine"
);
var
skippedVariables
=
[
"anchorNumber"
,
"displayId"
]
$
.
each
(
elementData
,
function
(
key
,
value
)
{
if
(
skippedVariables
.
indexOf
(
key
)
==
-
1
)
{
if
(
key
===
"positionTop"
)
newInstance
.
css
(
"top"
,
value
*
workspaceHeight
);
else
if
(
key
===
"positionLeft"
)
newInstance
.
css
(
"left"
,
value
*
workspaceWidth
);
else
newInstance
.
attr
(
"data-"
+
key
,
value
);
}
});
$
(
"#dropContainer"
).
append
(
newInstance
);
for
(
idx
=
0
;
idx
<
elementData
[
"anchorNumber"
];
idx
++
)
addEndpoint
(
newInstance
);
setServiceStatus
(
"unsaved"
);
jsPlumbInstance
.
draggable
(
jsPlumb
.
getSelector
(
".machine"
),
{
containment
:
$
(
"#dropContainer"
)
});
jsPlumbInstance
.
repaintEverything
();
return
newInstance
;
}
addElementOnLoad
=
function
(
elementData
)
{
templateId
=
elementData
.
displayId
.
split
(
'_'
)[
1
]
template
=
$
(
".elementTemplate"
).
filter
(
"#"
+
templateId
);
id
=
elementData
.
displayId
.
split
(
'_'
)[
0
]
//
id = elementData.displayId.split('_')[0]
newInstance
=
$
(
'<img id="'
+
elementData
[
"displayId"
]
+
'"/>'
)
.
prop
(
"title"
,
"Right click to delete"
)
.
removeClass
()
...
...
This diff is collapsed.
Click to expand it.
circle/setty/static/setty/style.css
View file @
7bc6e462
...
...
@@ -97,6 +97,33 @@ textarea {
z-index
:
2000
;
}
.machine
{
position
:
absolute
;
left
:
10px
;
display
:
inline
;
width
:
75px
;
height
:
75px
;
background
:
red
;
border-radius
:
8px
;
border-color
:
black
;
-webkit-border-radius
:
8px
;
border-style
:
solid
;
border-width
:
5px
;
z-index
:
40
;
cursor
:
grab
;
}
.machine
:hover
{
border
:
5px
solid
#123456
;
box-shadow
:
2px
2px
19px
#444
;
-o-box-shadow
:
2px
2px
19px
#444
;
-webkit-box-shadow
:
2px
2px
19px
#444
;
-moz-box-shadow
:
2px
2px
19px
#fff
;
opacity
:
0.9
;
filter
:
alpha
(
opacity
=
90
);
z-index
:
2000
;
}
._jsPlumb_connector
{
z-index
:
10
;
}
...
...
This diff is collapsed.
Click to expand it.
circle/setty/templates/setty/index.html
View file @
7bc6e462
...
...
@@ -192,8 +192,11 @@
<h4
class=
"modal-title"
><i
class=
"fa fa-outdent"
></i>
{% trans 'Machines' %}
</h4>
</div>
<div
class=
"modal-body"
id=
"addMachineDialogBody"
>
<div
class=
"list-group"
id=
"availableMachineListContainer"
>
</div>
</div>
<div
class=
"modal-footer"
>
<div
class=
"btn btn-primary"
data-dismiss=
"modal"
/>
Mégsem
</div>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
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