-
Notifications
You must be signed in to change notification settings - Fork 5
/
orrclientdemo.html
199 lines (171 loc) · 5.26 KB
/
orrclientdemo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html>
<!--
A single HTML page that demonstrates basic term search and listing of ontologies.
Although powered by Angular (the framework currently used by ORR portal), it should
give a good basis of how to make the requests from a web application, which can
certainly be done with vanilla JavaScript, jQuery, Vue.js, and so many other frameworks.
The source of this file: https://github.com/mmisw/orr-portal/blob/master/orrclientdemo.html
-->
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<script>
(function() {
'use strict';
angular.module('simpleOrrClient', [])
.controller('SimpleController', SimpleController)
;
SimpleController.$inject = ['$scope', '$http'];
function SimpleController($scope, $http) {
var vm = this;
vm.ontApiEndpoint = 'https://xdomes.org/ont/api/v0';
vm.ontSparqlEndpoint = 'https://xdomes.org/sparql';
//vm.ontSparqlEndpoint = 'http://mmisw.org/sparql';
//vm.ontSparqlEndpoint = 'http://cor.esipfed.org/sparql';
vm.term = 'pressure';
vm.limit = '5';
vm.query = getQuery();
$scope.$watch("vm.term", function() { vm.query = getQuery(); });
$scope.$watch("vm.limit", function() { vm.query = getQuery(); });
function getQuery() {
return 'select distinct ?subject ?predicate ?object\n' +
'where {\n' +
' ?subject ?predicate ?object.\n' +
' filter (regex(str(?subject), "pressure[^/#]*$", "i")\n' +
' || regex(str(?object), "' +vm.term+ '", "i"))\n' +
'}\n' +
'order by ?subject\n' +
'limit ' +vm.limit;
}
$scope.getOntologies = function() {
vm.status = 'getting ontologies...';
vm.response = vm.error = vm.ontologyList = undefined;
$http({
method: 'GET',
url: vm.ontApiEndpoint + '/ont'
}).then(function successCallback(response) {
console.debug(" GET /ont response=", response);
vm.status = '';
vm.response = response;
vm.ontologyList = response.data || [];
}, function errorCallback(response) {
//console.error(" GET /ont error: ", response);
vm.status = '';
vm.error = response;
});
};
$scope.searchTerm = function() {
vm.status = 'performing query...';
vm.response = vm.error = vm.ontologyList = undefined;
$http({
method: 'GET',
url: vm.ontSparqlEndpoint,
params: {
query: vm.query
}
}).then(function successCallback(response) {
//console.debug(" GET /ont response=", response);
vm.status = '';
vm.response = response;
}, function errorCallback(response) {
console.error(" GET /ont error: ", response);
vm.status = '';
vm.error = response;
});
};
}
})();
</script>
<style>
body { margin: 20px; }
</style>
</head>
<body ng-app="simpleOrrClient" ng-controller="SimpleController as vm">
<h3>Simple ORR client demo</h3>
<table>
<tbody>
<tr>
<th>ORR API endpoint</th>
<td>
<input ng-model="vm.ontApiEndpoint" style="width: 20em">
</td>
</tr>
<tr>
<th>ORR SPARQL endpoint</th>
<td>
<input ng-model="vm.ontSparqlEndpoint" style="width: 20em">
</td>
</tr>
</tbody>
</table>
<table style="margin-top: 10px; margin-bottom: 10px"
class="table table-border">
<tbody>
<tr>
<td>
<button ng-click="searchTerm()"
class="btn btn-primary"
>Search term:</button>
<input ng-model="vm.term" style="width: 20em">
Limit= <input ng-model="vm.limit" style="width: 2em">
<pre ng-bind="vm.query" style="margin-left: 20px"></pre>
</td>
</tr>
<tr>
<td>
<button ng-click="getOntologies()"
class="btn btn-primary"
>Get ontologies</button>
</td>
</tr>
</tbody>
</table>
<div ng-if="vm.status" style="color:green" ng-bind="vm.status">
</div>
<hr>
<div ng-if="vm.ontologyList">
<h4>Ontologies</h4>
<table class="table table-border">
<thead>
<tr>
<th>iri</th>
<th>version</th>
<th>name</th>
<th>ownerName</th>
<th>status</th>
<th>ontologyType</th>
<th>visibility</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in vm.ontologyList">
<td ng-bind="row.uri"></td>
<td ng-bind="row.version"></td>
<td ng-bind="row.name"></td>
<td ng-bind="row.ownerName"></td>
<td ng-bind="row.status"></td>
<td ng-bind="row.ontologyType"></td>
<td ng-bind="row.visibility"></td>
</tr>
</tbody>
</table>
</div>
<hr>
<div ng-if="vm.response">
<label>Response:</label>
<div style="margin-left: 20px">
Status: <status ng-bind="vm.response.status"></status>
<br>
Data:
<pre ng-bind="vm.response.data | json"></pre>
</div>
</div>
<div ng-if="vm.error">
<label>Error:</label>
<div style="margin-left: 20px">
<pre ng-bind="vm.error | json"></pre>
</div>
</div>
</body>
</html>