Error Correction

This commit is contained in:
Eole 2016-05-04 20:03:15 +02:00
parent 4b978d4584
commit d24d569f1c
2 changed files with 215 additions and 221 deletions

View file

@ -3,10 +3,10 @@
* *
* @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)
{ {
// 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();
@ -31,11 +31,6 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
tryToRetrieveData(); tryToRetrieveData();
}); });
$scope.raiseShowMachineCreationEvent = function () {
$rootScope.$broadcast("showMachineCreationEvent", Compute.getData().axioms);
};
// Function to call from view to display the details of a machine // Function to call from view to display the details of a machine
$scope.raiseShowMachineDetailsEvent = function (id) { $scope.raiseShowMachineDetailsEvent = function (id) {
@ -55,10 +50,10 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
tryToRetrieveData(); tryToRetrieveData();
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++;
}) })
@ -85,7 +80,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)
}); });
@ -114,13 +109,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();
@ -171,11 +166,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
@ -187,11 +182,11 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
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 } }}
] ]
}); });
} }
@ -200,9 +195,7 @@ 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) { var maxLineLength = _.max(label.split('\n'), function(l) { return l.length; }).length;
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
@ -213,28 +206,28 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
//console.log(data.machines[vm[1]]); //console.log(data.machines[vm[1]]);
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 }
} }
}); });
} }
} }
}]); }]);

View file

@ -1,5 +1,6 @@
{ {
"require": { "require": {
"php-opencloud/openstack": "dev-master" "php-opencloud/openstack": "dev-master",
"phpdocumentor/phpdocumentor": "2.*"
} }
} }