Skip to content

Commit be9ccfd

Browse files
committed
Fix #9
1 parent 4a04126 commit be9ccfd

File tree

2 files changed

+7
-39
lines changed

2 files changed

+7
-39
lines changed

jsondiscoverer.web/WebContent/app/controllers/composition.js

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ angular.module("jsonDiscoverer").controller("CompositionCtrl", ["$scope", "$wind
55
$scope.name = "";
66
$scope.graph = "";
77

8+
$scope.layoutPosible = false;
89
$scope.sigmaGraph = new sigma('sigma-container');
910
$scope.layoutButton = "Start Layout";
1011
$scope.layoutRunning = false;
1112

13+
$scope.pathPosible = false;
1214
$scope.sourcePath = {};
1315
$scope.sourcePreviousColor = "";
1416
$scope.targetPath = {};
@@ -83,50 +85,14 @@ angular.module("jsonDiscoverer").controller("CompositionCtrl", ["$scope", "$wind
8385
})
8486
}
8587
$scope.sigmaGraph.refresh();
86-
88+
$scope.layoutPosible = true;
8789
},
8890
function(data, status, headers, config) {
8991
$scope.alertsGeneral.push({ type: 'error', msg: 'Oops, we found an error in the composition discovery process. Could you check your JSON and try again?' });
9092
}
9193
);
9294
};
9395

94-
$scope.test = function() {
95-
$scope.sigmaGraph.graph.clear();
96-
$scope.sigmaGraph.graph.addNode({
97-
id : "A",
98-
label : "labelA",
99-
x : Math.random(),
100-
y : Math.random(),
101-
size : 1,
102-
color : '#f00'
103-
}).addNode({
104-
id : "B",
105-
label : "labelB",
106-
x : Math.random(),
107-
y : Math.random(),
108-
size : 1,
109-
color : '#f00'
110-
}).addNode({
111-
id : "C",
112-
label : "labelC",
113-
x : Math.random(),
114-
y : Math.random(),
115-
size : 1,
116-
color : '#f00'
117-
}).addEdge({
118-
id : "EAB",
119-
source : "A",
120-
target : "B"
121-
}).addEdge({
122-
id : "EBC",
123-
source : "B",
124-
target : "C"
125-
});
126-
$scope.sigmaGraph.refresh();
127-
};
128-
129-
13096
$scope.updateCompositionPosible = function() {
13197
if(typeof defs === "undefined") $scope.compositionPosible = false;
13298
for(def in $scope.defs) {
@@ -157,6 +123,7 @@ angular.module("jsonDiscoverer").controller("CompositionCtrl", ["$scope", "$wind
157123
$scope.targetPath.color = $scope.targetPreviousColor;
158124
$scope.sourcePath = null;
159125
$scope.targetPath = null;
126+
$scope.pathPosible = false;
160127
}
161128

162129
if($scope.sourcePath === null){
@@ -165,6 +132,7 @@ angular.module("jsonDiscoverer").controller("CompositionCtrl", ["$scope", "$wind
165132
} else {
166133
$scope.targetPreviousColor = event.data.node.color;
167134
$scope.targetPath = event.data.node;
135+
$scope.pathPosible = true;
168136
}
169137
event.data.node.color = '#000';
170138
$scope.sigmaGraph.refresh();

jsondiscoverer.web/WebContent/app/partials/composition.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ <h3 class="modal-title">Provide your JSON for your {{json.name}} source</h3>
9494

9595
<h4 style="padding-top: 20px;">Step 3. Composition Graph </h4>
9696
<div style="float:right;">
97-
<button style="margin-top: -10px;"class="btn" ng-click="layout()">{{layoutButton}}</button>
97+
<button style="margin-top: -10px;"class="btn" ng-disabled="!layoutPosible" ng-click="layout()">{{layoutButton}}</button>
9898
</div>
9999
<p>Same-colored nodes represent concepts of an API. White nodes represent attributes of the concepts while red nodes represent input concepts</p>
100100
<p class="text-center">
@@ -114,7 +114,7 @@ <h4 style="padding-top: 20px;">Step 4. Calculate a Path</h4>
114114
<div class="col-md-2">
115115
<input type="text" class="form-control" id="targetNode" placeholder="Select a target node" ng-model="targetPath.label" readonly>
116116
</div>
117-
<button class="btn col-md-3 col-md-offset-1" ng-click="calculatePath()">Calculate</button>
117+
<button class="btn col-md-3 col-md-offset-1" ng-disabled="!pathPosible" ng-click="calculatePath()">Calculate</button>
118118
</form>
119119
</div>
120120

0 commit comments

Comments
 (0)