Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit c761bc4

Browse files
committed
change graph directives
1 parent e27887c commit c761bc4

File tree

13 files changed

+117
-46
lines changed

13 files changed

+117
-46
lines changed

src/main/webapp/js/directives.js

Lines changed: 87 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,77 @@
22

33
var module = angular.module('app.directives', []);
44

5+
/**
6+
* Date format directives, credits are to http://plnkr.co/edit/NzeauIDVHlgeb6qF75hX?p=preview
7+
**/
8+
module.directive('moChangeProxy', function ($parse) {
9+
return {
10+
require:'^ngModel',
11+
restrict:'A',
12+
link:function (scope, elm, attrs, ctrl) {
13+
var proxyExp = attrs.moChangeProxy;
14+
var modelExp = attrs.ngModel;
15+
scope.$watch(proxyExp, function (nVal) {
16+
if (nVal != ctrl.$modelValue){
17+
$parse(modelExp).assign(scope, nVal);
18+
}
19+
});
20+
elm.bind('blur', function () {
21+
var proxyVal = scope.$eval(proxyExp);
22+
if(ctrl.$modelValue != proxyVal) {
23+
scope.$apply(function(){
24+
$parse(proxyExp).assign(scope, ctrl.$modelValue);
25+
});
26+
}
27+
});
28+
}
29+
};
30+
});
31+
32+
module.directive('moDateInput', function ($window) {
33+
return {
34+
require:'^ngModel',
35+
restrict:'A',
36+
link:function (scope, elm, attrs, ctrl) {
37+
var moment = $window.moment;
38+
var dateFormat = attrs.moDateInput;
39+
attrs.$observe('moDateInput', function (newValue) {
40+
if (dateFormat == newValue || !ctrl.$modelValue) return;
41+
dateFormat = newValue;
42+
ctrl.$modelValue = new Date(ctrl.$setViewValue);
43+
});
44+
45+
ctrl.$formatters.unshift(function (modelValue) {
46+
scope = scope;
47+
if (!dateFormat || !modelValue) return "";
48+
var retVal = moment(modelValue).format(dateFormat);
49+
return retVal;
50+
});
51+
52+
ctrl.$parsers.unshift(function (viewValue) {
53+
scope = scope;
54+
var date = moment(viewValue, dateFormat);
55+
return (date && date.isValid() && date.year() > 1950 ) ? date.toDate() : "";
56+
});
57+
}
58+
};
59+
});
60+
561
/**
662
This requres that the parent scope defines in its scope:
7-
- newTarget {prefix, label, description}
63+
- target.isNew {prefix, label, description}
864
- target.graph
65+
- target.label
966
*/
1067
module.directive('targetGraph', ['$parse', 'GraphService', function($parse, GraphService){
1168
return {
1269
restrict: 'E',
1370
templateUrl: 'js/workbench/partials/target-graph.html',
14-
scope: true,
71+
// scope: true,
72+
scope: {
73+
graphInfo: '=graphInfo',
74+
hasChanged : '&hasChanged'
75+
},
1576
link : function ($scope, elem, attrs, ctrl) {
1677

1778
$scope.refreshWritableGraphs = function() {
@@ -26,37 +87,45 @@ module.directive('targetGraph', ['$parse', 'GraphService', function($parse, Grap
2687

2788
$scope.createTargetGraph = function(){
2889
// create a new graph to save data
29-
var name = $scope.newTarget.prefix + "_" + new Date().getTime();
30-
var label = $scope.newTarget.label;
31-
var description = $scope.newTarget.description;
32-
console.log($scope.newTarget);
90+
var name = $scope.graphInfo.isNew.prefix + "_" + new Date().getTime();
91+
var label = $scope.graphInfo.isNew.label;
92+
var description = $scope.graphInfo.isNew.description;
93+
console.log($scope.graphInfo.isNew);
3394
GraphService.addSimpleGraph(name, label, description).then(function(response){
3495
$scope.refreshWritableGraphs().then(function(){
35-
$scope.target.graph = ":"+name;
96+
$scope.graphInfo.graph = ":"+name;
3697
})
3798
});
3899
};
39100

40-
// notify that the input changed
41-
$scope.targetChanged = function(){
42-
var invoker = $parse(attrs.targetChanged);
43-
invoker($scope);
101+
$scope.notify = function(){
102+
console.log($scope.graphInfo.graph);
103+
$scope.hasChanged();
44104
}
45105

106+
// notify that the input changed
107+
// $scope.targetChanged = function(){
108+
// var invoker = $parse(attrs.targetChanged);
109+
// invoker($scope);
110+
// }
111+
46112
$scope.refreshWritableGraphs();
47113
}
48114
};
49115
}]);
50116

51117
/**
52118
* This directive requres that the parent scope defines in its scope:
53-
* $scope.source = {label, graph}
119+
* Uses an isolated scope to be able to define more than one source
54120
*/
55121
module.directive('sourceGraph', ['$parse', 'GraphService', 'GraphGroupService', function($parse, GraphService, GraphGroupService){
56122
return {
57123
restrict: 'E',
58124
templateUrl: 'js/workbench/partials/source-graph.html',
59-
scope: true,
125+
scope: {
126+
graphInfo: '=graphInfo',
127+
hasChanged : '&hasChanged'
128+
},
60129
link : function ($scope, elem, attrs, ctrl) {
61130

62131
$scope.refreshReadableGraphs = function() {
@@ -77,9 +146,11 @@ module.directive('sourceGraph', ['$parse', 'GraphService', 'GraphGroupService',
77146
}
78147

79148
// notify that the input changed
80-
$scope.sourceChanged = function(){
81-
var invoker = $parse(attrs.sourceChanged);
82-
invoker($scope);
149+
$scope.notify = function(){
150+
console.log($scope.graphInfo.graph);
151+
$scope.hasChanged();
152+
// var invoker = $parse(attrs.sourceChanged);
153+
// invoker($scope);
83154
}
84155

85156
$scope.refreshReadableGraphs();

src/main/webapp/js/workbench/extraction-and-loading/import-rdf.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ <h3 class="green bold">Import RDF Data</h3>
2323
<div class="error">{{uploadMessageError}}</div>
2424
<br>
2525
<ul ng-show="uploadSuceed()">
26-
<li ng-repeat="f in importRdf.source">{{f}}</li>
26+
<li ng-repeat="f in importRdf.files">{{f}}</li>
2727
</ul>
2828

2929
</div>
3030
</div>
3131

32-
<target-graph></target-graph>
32+
<target-graph graph-info="target"></target-graph>
3333

3434
<div class="form-group">
3535
<div class="col-sm-2"></div>
@@ -53,7 +53,7 @@ <h3 class="green bold">Import RDF Data</h3>
5353
</div>
5454
</div>
5555
</div>
56-
<target-graph></target-graph>
56+
<target-graph graph-info="target"></target-graph>
5757

5858
<div class="form-group">
5959
<div class="col-sm-2"></div>
@@ -84,7 +84,7 @@ <h3 class="green bold">Import RDF Data</h3>
8484
</div>
8585
</div>
8686

87-
<target-graph></target-graph>
87+
<target-graph graph-info="target"></target-graph>
8888

8989
<div class="form-group">
9090
<div class="col-sm-2"></div>
@@ -99,8 +99,8 @@ <h3 class="green bold">Import RDF Data</h3>
9999
<!-- Import from LOCAL sparql -->
100100
<form ng-show="localQueryElements" class="form-horizontal InputForm" role="form" name="localForm" novalidate>
101101

102-
<source-graph source-changed="updateNewTargetInfo()"></source-graph>
103-
<target-graph></target-graph>
102+
<source-graph graph-info="source" has-changed="updateNewTargetInfo()"></source-graph>
103+
<target-graph graph-info="target"></target-graph>
104104

105105
<div class="form-group">
106106
<div class="col-sm-2"></div>

src/main/webapp/js/workbench/linking-and-fusing/fagi-gis-controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ app.controller('FagiGisCtrl', function($q, $scope, ConfigurationService, Compone
100100
$scope.refreshGraphList();
101101
$scope.fagi.targetGraph = ":"+name;
102102
});
103-
$scope.updateServiceParams();
103+
104104
};
105105

106106
$scope.updateGraphsA = function(){
@@ -110,7 +110,7 @@ app.controller('FagiGisCtrl', function($q, $scope, ConfigurationService, Compone
110110
});
111111
else
112112
$scope.namedGraphsA = {};
113-
$scope.updateServiceParams();
113+
114114
};
115115

116116
$scope.updateGraphsB = function(){
@@ -120,7 +120,7 @@ app.controller('FagiGisCtrl', function($q, $scope, ConfigurationService, Compone
120120
});
121121
else
122122
$scope.namedGraphsB = {};
123-
$scope.updateServiceParams();
123+
124124
};
125125

126126

src/main/webapp/js/workbench/linking-and-fusing/fagi-gis.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ <h5 class="green bold">Dataset B</h5>
3939
<label for="DatasetA">Graph</label>
4040
</div>
4141
<div class="col-xs-4">
42-
<select id="DatasetA" class="form-control" ng-model="fagi.datasetA" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in namedGraphsA" ng-change="updateServiceParams();">
42+
<select id="DatasetA" class="form-control" ng-model="fagi.datasetA" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in namedGraphsA">
4343
</select>
4444
</div>
4545
<div class="col-xs-2">
4646
<label for="DatasetB">Graph</label>
4747
</div>
4848
<div class="col-xs-4">
49-
<select id="DatasetB" class="form-control" ng-model="fagi.datasetB" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in namedGraphsB" ng-change="updateServiceParams();">
49+
<select id="DatasetB" class="form-control" ng-model="fagi.datasetB" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in namedGraphsB">
5050
</select>
5151
</div>
5252
</div>
@@ -79,7 +79,7 @@ <h5 class="green bold">Dataset B</h5>
7979
<label for="DataSet">Target DataSet</label>
8080
</div>
8181
<div class="col-xs-8">
82-
<select id="DataSet" class="form-control" ng-model="fagi.targetGraph" ng-options="namedgraph.name as namedgraph.name for namedgraph in namedGraphs" required ng-change="updateServiceParams();">
82+
<select id="DataSet" class="form-control" ng-model="fagi.targetGraph" ng-options="namedgraph.name as namedgraph.name for namedgraph in namedGraphs" required>
8383
</select>
8484
</div>
8585
<div class="col-xs-2">
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<div class="form-group">
2-
<label for="sourceGraph" class="col-xs-2 control-label" >{{source.label}}</label>
2+
<label for="sourceGraph" class="col-xs-2 control-label" >{{graphInfo.label}}</label>
33
<div class="col-xs-8">
4-
<select id="sourceGraph" class="form-control" ng-model="source.graph" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in readableGraphs" ng-change="sourceChanged()" required>
4+
<select id="sourceGraph" class="form-control" ng-model="graphInfo.graph" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in readableGraphs" ng-change="notify()" required>
55
</select>
6-
</div>
7-
</div>
8-
<br/>
6+
</div>
7+
</div>

src/main/webapp/js/workbench/partials/target-graph.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<div class="row">
2-
<label for="targetGraph" class="col-xs-2 control-label" >Target Graph</label>
2+
<label for="targetGraph" class="col-xs-2 control-label" >{{graphInfo.label}}</label>
33
<div class="col-xs-8">
4-
<select id="targetGraph" class="form-control" ng-model="target.graph" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in writableGraphs" ng-change="targetChanged()" required>
4+
5+
<select id="targetGraph" class="form-control" ng-model="graphInfo.graph" ng-options="namedgraph.name as describeGraph(namedgraph) for namedgraph in writableGraphs" ng-change="notify()" required>
56
</select>
7+
68
</div>
79
<div class="col-xs-2">
810
<a class="btn btn-default" ng-click="createTargetGraph();" >New Graph</a>

src/main/webapp/js/workbench/search-querying-and-exploration/esta-ld.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111

1212

13-
<source-graph ng-show="isLocalEndpoint()"></source-graph>
13+
<source-graph graph-info="source" ng-show="isLocalEndpoint()"></source-graph>
1414

1515
<div class="form-group">
1616
<div class="col-sm-2"></div>

src/main/webapp/js/workbench/search-querying-and-exploration/facete.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111

1212

13-
<source-graph ng-show="isLocalEndpoint()"></source-graph>
13+
<source-graph graph-info="source" ng-show="isLocalEndpoint()"></source-graph>
1414

1515
<div class="form-group">
1616
<div class="col-sm-2"></div>

src/main/webapp/js/workbench/search-querying-and-exploration/virtuoso-controller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ app.controller('VirtuosoCtrl', function($scope, ConfigurationService, Components
3333
dataset : "",
3434
}
3535

36-
3736
$scope.updateServiceParams = function(){
3837
console.log($scope.source.graph);
3938
if (AccountService.getAccount().getUsername()==null) { //user is not authorized

src/main/webapp/js/workbench/search-querying-and-exploration/virtuoso.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h4>Launch Virtuoso endpoint Interface</h4>
1414
</div>
1515

1616

17-
<source-graph source-changed="updateServiceParams()"></source-graph>
17+
<source-graph graph-info="source" has-changed="updateServiceParams()"></source-graph>
1818

1919

2020
<div class="form-group">

0 commit comments

Comments
 (0)