Add option
This commit is contained in:
parent
a9e8c8e664
commit
4daec471a3
2 changed files with 180 additions and 174 deletions
|
@ -3,15 +3,15 @@
|
||||||
*
|
*
|
||||||
* @param {$scope} $scope The $scope service from angular
|
* @param {$scope} $scope The $scope service from angular
|
||||||
*/
|
*/
|
||||||
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
|
mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
|
||||||
{
|
{
|
||||||
$scope.raiseShowMachineCreationEvent = function () {
|
$scope.raiseShowMachineCreationEvent = function () {
|
||||||
$rootScope.$broadcast("showMachineCreationEvent", Compute.getData().axioms);
|
$rootScope.$broadcast("showMachineCreationEvent", Compute.getData().axioms);
|
||||||
};
|
};
|
||||||
var displayMachine = function(){
|
var displayMachine = function () {
|
||||||
var machineNames = [];
|
var machineNames = [];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
$.each(Compute.getData().machines, function(){
|
$.each(Compute.getData().machines, function () {
|
||||||
machineNames[i] = [this.name, this.id];
|
machineNames[i] = [this.name, this.id];
|
||||||
i++;
|
i++;
|
||||||
})
|
})
|
||||||
|
@ -38,7 +38,7 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
defaults: joint.util.deepSupplement({
|
defaults: joint.util.deepSupplement({
|
||||||
type: 'html.Element',
|
type: 'html.Element',
|
||||||
attrs: {
|
attrs: {
|
||||||
rect: { stroke: 'none', 'fill-opacity': 0 }
|
rect: {stroke: 'none', 'fill-opacity': 0}
|
||||||
}
|
}
|
||||||
}, joint.shapes.basic.Rect.prototype.defaults)
|
}, joint.shapes.basic.Rect.prototype.defaults)
|
||||||
});
|
});
|
||||||
|
@ -67,13 +67,13 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
|
|
||||||
paper.setDimensions(test.width, test.height);
|
paper.setDimensions(test.width, test.height);
|
||||||
|
|
||||||
$(".Member").bind('click', function() {
|
$(".Member").bind('click', function () {
|
||||||
$scope.raiseShowMachineDetailsEvent($(this).attr('model-id'));
|
$scope.raiseShowMachineDetailsEvent($(this).attr('model-id'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to call after pull all data about machines
|
// Function to call after pull all data about machines
|
||||||
var callMeAfterPullData=function(data){
|
var callMeAfterPullData = function (data) {
|
||||||
//$scope.machines=Compute.getData().machines;
|
//$scope.machines=Compute.getData().machines;
|
||||||
Loading.stop();
|
Loading.stop();
|
||||||
displayMachine();
|
displayMachine();
|
||||||
|
@ -124,11 +124,11 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
var elements = [];
|
var elements = [];
|
||||||
var links = [];
|
var links = [];
|
||||||
|
|
||||||
_.each(adjacencyList['vms'], function(vm) {
|
_.each(adjacencyList['vms'], function (vm) {
|
||||||
elements.push(makeElement(vm));
|
elements.push(makeElement(vm));
|
||||||
});
|
});
|
||||||
_.each(adjacencyList['links'], function(link) {
|
_.each(adjacencyList['links'], function (link) {
|
||||||
links.push(makeLink(link[0], link[1] , link[2], link[3]));
|
links.push(makeLink(link[0], link[1], link[2], link[3]));
|
||||||
});
|
});
|
||||||
// Links must be added after all the elements. This is because when the links
|
// Links must be added after all the elements. This is because when the links
|
||||||
// are added to the graph, link source/target
|
// are added to the graph, link source/target
|
||||||
|
@ -136,15 +136,19 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
return elements.concat(links);
|
return elements.concat(links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On user login
|
||||||
|
$scope.$on('updateGraphEvent', function () {
|
||||||
|
// call update graph
|
||||||
|
});
|
||||||
//Return a new link linking the parent and child elements with the interfaces names given in parameters
|
//Return a new link linking the parent and child elements with the interfaces names given in parameters
|
||||||
function makeLink(parentElementLabel, childElementLabel, Iparent, Ichild) {
|
function makeLink(parentElementLabel, childElementLabel, Iparent, Ichild) {
|
||||||
|
|
||||||
return new joint.dia.Link({
|
return new joint.dia.Link({
|
||||||
source: { id: parentElementLabel },
|
source: {id: parentElementLabel},
|
||||||
target: { id: childElementLabel },
|
target: {id: childElementLabel},
|
||||||
labels: [
|
labels: [
|
||||||
{ position: 20, attrs: { text: { text: Iparent } }},
|
{position: 20, attrs: {text: {text: Iparent}}},
|
||||||
{ position: -20, attrs: { text: { text: Ichild } }}
|
{position: -20, attrs: {text: {text: Ichild}}}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -153,7 +157,9 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
function makeElement(vm) {
|
function makeElement(vm) {
|
||||||
var label = vm[0];
|
var label = vm[0];
|
||||||
|
|
||||||
var maxLineLength = _.max(label.split('\n'), function(l) { return l.length; }).length;
|
var maxLineLength = _.max(label.split('\n'), function (l) {
|
||||||
|
return l.length;
|
||||||
|
}).length;
|
||||||
|
|
||||||
// Compute width/height of the rectangle based on the number
|
// Compute width/height of the rectangle based on the number
|
||||||
// of lines in the label and the letter size. 0.6 * letterSize is
|
// of lines in the label and the letter size. 0.6 * letterSize is
|
||||||
|
@ -162,28 +168,28 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I
|
||||||
var height = 80;
|
var height = 80;
|
||||||
var data = Compute.getData();
|
var data = Compute.getData();
|
||||||
|
|
||||||
if(data.machines[vm[1]].status == "ACTIVE"){
|
if (data.machines[vm[1]].status == "ACTIVE") {
|
||||||
return new joint.shapes.org.Member({
|
return new joint.shapes.org.Member({
|
||||||
id: vm[1],
|
id: vm[1],
|
||||||
position: { x: 0, y: 0 },
|
position: {x: 0, y: 0},
|
||||||
attrs: {
|
attrs: {
|
||||||
'.card': { fill: 'blue', stroke: 'none'},
|
'.card': {fill: 'blue', stroke: 'none'},
|
||||||
image: { 'xlink:href': './images/ON.png', opacity: 0.7 },
|
image: {'xlink:href': './images/ON.png', opacity: 0.7},
|
||||||
//'.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0},
|
//'.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0},
|
||||||
'.name': { text: label, fill: 'white', 'font-size': 13, 'font-family': 'Arial', 'letter-spacing': 0 }
|
'.name': {text: label, fill: 'white', 'font-size': 13, 'font-family': 'Arial', 'letter-spacing': 0}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
return new joint.shapes.org.Member({
|
return new joint.shapes.org.Member({
|
||||||
id: vm[1],
|
id: vm[1],
|
||||||
position: { x: 0, y: 0 },
|
position: {x: 0, y: 0},
|
||||||
attrs: {
|
attrs: {
|
||||||
'.card': { fill: 'blue', stroke: 'none'},
|
'.card': {fill: 'blue', stroke: 'none'},
|
||||||
image: { 'xlink:href': './images/OFF.png', opacity: 0.7 },
|
image: {'xlink:href': './images/OFF.png', opacity: 0.7},
|
||||||
//'.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0},
|
//'.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0},
|
||||||
'.name': { text: label, fill: 'white', 'font-size': 13, 'font-family': 'Arial', 'letter-spacing': 0 }
|
'.name': {text: label, fill: 'white', 'font-size': 13, 'font-family': 'Arial', 'letter-spacing': 0}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
|
@ -42,7 +42,7 @@ mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$t
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteMachine=function(){
|
$scope.deleteMachine=function(){
|
||||||
Compute.deleteMachine(function(){Compute.pullData(function(){});},$scope.machine.id);
|
Compute.deleteMachine(function(){Compute.pullData(function(){$rootScope.$broadcast("updateGraphEvent")});},$scope.machine.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue