Skip to content

Commit

Permalink
Merge branch 'master' into GDB-2179-As-A-User-I-Want-To-Share-Visual-…
Browse files Browse the repository at this point in the history
…Graph-With-Other-Users
  • Loading branch information
desislava-hristova-ontotext authored Aug 13, 2020
2 parents e1433a8 + 96912e1 commit 79d7a0a
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 46 deletions.
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphdb-workbench",
"version": "1.3.0-RC9",
"version": "1.4.0-TR2",
"description": "The web application for GraphDB APIs",
"scripts": {
"build": "webpack --config=webpack.config.prod.js",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/Ontotext-AD/graphdb-workbench/issues"
},
"versions": {
"graphdb": "9.2.0-RC5"
"graphdb": "9.4.0-TR17"
},
"homepage": "https://github.com/Ontotext-AD/graphdb-workbench#readme",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/angular/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ function mainCtrl($scope, $menuItems, $jwtAuth, $http, $cookies, toastr, $locati
}

if (!$repositories.getActiveRepository() || $repositories.getActiveRepository() === 'SYSTEM'
|| !$scope.hasRole(UserRole.ROLE_REPO_MANAGER)) {
|| !$scope.hasRole(UserRole.ROLE_USER)) {
// No monitoring if no active repo, the active repo is the system repo or the current user
// isn't a repo admin.
$scope.queryCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ <h6>Error<span ng-show="yasr.results.getException().status > 0"> {{yasr.results.
popover-placement="left">
<div ng-class="abortRequested ? 'disabled' : ''"> <!-- Keep this div -->
<button ng-disabled="abortRequested" class="btn btn-xs btn-primary"
ng-click="abortCurrentQuery()">
ng-click="abortCurrentQuery()" ng-hide="!isUserLoggedIn() && isSecurityEnabled()">
{{abortRequested ? 'Stop has been requested' : (lastRunQueryMode === 'update' ? 'Abort update' : 'Abort query')}}
</button>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/js/angular/core/services/jwt-auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,13 @@ angular.module('graphdb.framework.core.services.jwtauth', [

this.setAuthHeaders = function () {
$http.defaults.headers.common['Authorization'] = this.auth;
// Angular doesn't send this header by default and we need it to detect XHR requests
// so that we don't advertise Basic auth with them.
$http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
$.ajaxSetup()['headers'] = $.ajaxSetup()['headers'] || {};
$.ajaxSetup()['headers']['Authorization'] = this.auth;
// jQuery seems to send the header by default but it doesn't hurt to be explicit
$.ajaxSetup()['headers']['X-Requested-With'] = 'XMLHttpRequest';
};
this.setAuthHeaders();

Expand Down
4 changes: 2 additions & 2 deletions src/js/angular/core/templates/core-errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="mb-1 mt-1 ml-1 mr-1">
<div class="card repository-errors">
<div class="alert alert-warning lead">
<div ng-hide="getActiveRepository()" >Some functionality is not available because you are not connected to any repository.</div>
<div ng-show="getActiveRepository() && isWriteRequired && !canWriteActiveRepo()">Some functionality is not available because you have no write permission to repository <strong>{{getActiveRepository()}}</strong>.</div>
<div ng-hide="getActiveRepository()" >Some functionalities are not available because you are not connected to any repository.</div>
<div ng-show="getActiveRepository() && isWriteRequired && !canWriteActiveRepo()">Some functionalities are not available because you have no write permission to repository <strong>{{getActiveRepository()}}</strong>.</div>
<small>
<span ng-show="getAccessibleRepositories().length">
Click one of the repositories below to connect to it<span ng-show="canManageRepositories()"> or create a new repository</span>.
Expand Down
18 changes: 18 additions & 0 deletions src/js/angular/ontorefine/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const ontorefine = angular.module('graphdb.framework.ontorefine', ['graphdb.fram

ontorefine.controller('OntoRefineCtrl', ['$scope', '$routeParams', '$window', '$location', '$timeout', function ($scope, $routeParams, $window, $location, $timeout) {
$scope.refineDisabled = false;
window.addEventListener("message", isProjectPristine);
var isPristine = true;
if ($routeParams.project) {
$scope.page = 'orefine/project?project=' + $routeParams.project;
} else if ($routeParams.page) {
Expand Down Expand Up @@ -48,4 +50,20 @@ ontorefine.controller('OntoRefineCtrl', ['$scope', '$routeParams', '$window', '$
iframeElement.style.height = 'calc(100vh - 75px)';
}
};

function isProjectPristine(e) {
isPristine = e.data === 'pristine';
}

$scope.$on('$locationChangeStart', (event) => {
if (!isPristine) {
if (!confirm("There are unsaved changes! Are you sure, you want to exit?")) {
event.preventDefault();
}
}
});

$scope.$on("$destroy", function () {
window.removeEventListener('message', isProjectPristine);
});
}]);
23 changes: 10 additions & 13 deletions src/js/angular/queries/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ queriesCtrl.controller('QueriesCtrl', ['$scope', '$modal', 'toastr', '$interval'

const parser = document.createElement('a');

$scope.parseTrackId = function (trackId) {
if (trackId.indexOf('#') < 0) {
return [trackId, '', $repositories.getActiveRepository()];
// Parses a node of the kind http://host.example.com:7200/repositories/repo#NN,
// where NN is the track ID into an array [NN, host:7200, repo].
$scope.parseNode = function (node) {
if (node == null) {
return null;
}

let shortUrl = 'local';
if (trackId.indexOf('://localhost:') < 0 && trackId.indexOf('://localhost/') < 0) {
parser.href = trackId;
if (node.indexOf('://localhost:') < 0 && node.indexOf('://localhost/') < 0) {
parser.href = node;
let hostname = parser.hostname;
if (!containsIPV4(parser.hostname)) {
hostname = parser.hostname.split('.')[0];
}
shortUrl = hostname + ':' + parser.port;
}
const match = trackId.match(/\/repositories\/([^\/]+)#(\d+)/); // eslint-disable-line no-useless-escape
const match = node.match(/\/repositories\/([^\/]+)#(\d+)/); // eslint-disable-line no-useless-escape

return [match[2], shortUrl, match[1]];
};
Expand All @@ -67,7 +69,7 @@ queriesCtrl.controller('QueriesCtrl', ['$scope', '$modal', 'toastr', '$interval'
// it doesn't recreate DOM elements for queries that are already displayed.
$scope.queries = {};
for (let i = 0; i < newQueries.length; i++) {
newQueries[i].compositeTrackId = $scope.parseTrackId(newQueries[i].trackId);
newQueries[i].parsedNode = $scope.parseNode(newQueries[i].node);
$scope.queries[newQueries[i].trackId] = newQueries[i];
}

Expand Down Expand Up @@ -114,12 +116,7 @@ queriesCtrl.controller('QueriesCtrl', ['$scope', '$modal', 'toastr', '$interval'
};

$scope.downloadQuery = function (queryId) {
const parsed = $scope.parseTrackId(queryId);
let filename = 'query_' + parsed[0] + '_' + parsed[2];
if (parsed[1]) {
filename += '_' + parsed[1];
}
filename += '.rq';
const filename = 'query_' + queryId + '.rq';
let link = 'rest/monitor/query/download?queryId=' + encodeURIComponent(queryId)
+ '&repository=' + encodeURIComponent($repositories.getActiveRepository())
+ '&filename=' + encodeURIComponent(filename);
Expand Down
3 changes: 2 additions & 1 deletion src/js/angular/queries/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ PluginRegistry.add('main.menu', {
label: 'Monitor',
href: '#',
order: 3,
role: 'ROLE_REPO_MANAGER',
// Changed to role user as now users can monitor their own queries
role: 'ROLE_USER',
icon: 'icon-monitoring'
}, {
label: 'Queries and Updates',
Expand Down
4 changes: 3 additions & 1 deletion src/js/angular/resources/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ PluginRegistry.add('main.menu', {
label: 'Monitor',
href: '#',
order: 3,
role: 'ROLE_REPO_MANAGER',
role: 'ROLE_MONITORING',
icon: 'icon-monitoring'
}, {
label: 'Resources',
href: 'monitor/resources',
// Added role requirement here to assert that users cannot see Resources menu item
role: 'ROLE_MONITORING',
order: 2,
parent: 'Monitor'
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h4 class="card-header">GraphDB {{productTypeHuman}} Edition</h4>
<div class="alert alert-warning" role="alert" ng-hide="license.valid">
<p>
<strong>{{license.message}}</strong><br>
Please supply a valid license or contact Ontotext AD sales department to aquire one.
Please supply a valid license or contact Ontotext AD sales department to acquire one.
</p>
<a href="license/register" ng-href="license/register" ng-hide="isLicenseHardcoded">
<button class="btn btn-primary license-button">
Expand Down
10 changes: 8 additions & 2 deletions src/pages/monitor/queries.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ <h1>
</thead>
<tbody>
<tr ng-repeat="query in queries">
<td>{{query.compositeTrackId[0]}}</td>
<td><div>{{query.compositeTrackId[2]}}</div><div>{{query.compositeTrackId[1]}}</div></td>
<td>{{query.trackId}}</td>
<td>
<div>{{ getActiveRepository() }}</div>
<div ng-show="query.parsedNode">
<div>&rarr; {{ query.parsedNode[2] }} #{{ query.parsedNode[0] }}</div>
<div>{{ query.parsedNode[1] }}</div>
</div>
</td>
<td>{{query.type}}</td>
<td>
<button class="pull-left btn btn-primary btn-sm" ng-click="downloadQuery(query.trackId)">Download</button>
Expand Down
2 changes: 1 addition & 1 deletion test-cypress/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphdb-workbench-tests",
"version": "1.3.0-RC9",
"version": "1.4.0-TR2",
"description": "Cypress tests for GraphDB workbench",
"scripts": {
"start": "cypress open",
Expand Down
28 changes: 27 additions & 1 deletion test/queries/controllers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ describe('=> QueriesCtrl tests', function () {
"isRequestedToStop": false,
"msSinceCreated": 6689,
"running": true
}, {
"queryString": "SELECT ?s ?p ?o\nWHERE {\n\t?s ?p ?o .\n} LIMIT 123",
"trackId": "1234",
"node": "http://example.com:7300/repositories/repo#678",
"nsTotalSpentInNext": 1234567,
"nsAverageForOneNext": 1234,
"state": "IN_HAS_NEXT",
"nNext": 12345,
"msLifetime": 123,
"isRequestedToStop": false,
"msSinceCreated": 12345678,
"running": true
}]);

$httpBackend.when('GET', 'rest/security/all').respond(200, {
Expand Down Expand Up @@ -99,7 +111,7 @@ describe('=> QueriesCtrl tests', function () {
"21107": {
"queryString": "SELECT ?s ?p ?o\nWHERE {\n\t?s ?p ?o .\n} LIMIT 100567123123123",
"trackId": "21107",
"compositeTrackId": ["21107", "", "activeRepository"],
"parsedNode": null,
"nsTotalSpentInNext": 6406320151,
"nsAverageForOneNext": 5616,
"state": "IN_NEXT",
Expand All @@ -108,6 +120,20 @@ describe('=> QueriesCtrl tests', function () {
"isRequestedToStop": false,
"msSinceCreated": 6689,
"running": true
},
"1234": {
"queryString": "SELECT ?s ?p ?o\nWHERE {\n\t?s ?p ?o .\n} LIMIT 123",
"trackId": "1234",
"node": "http://example.com:7300/repositories/repo#678",
"parsedNode": ["678", "example:7300", "repo"],
"nsTotalSpentInNext": 1234567,
"nsAverageForOneNext": 1234,
"state": "IN_HAS_NEXT",
"nNext": 12345,
"msLifetime": 123,
"isRequestedToStop": false,
"msSinceCreated": 12345678,
"running": true
}
})
expect($scope.jolokiaError).toEqual('')
Expand Down

0 comments on commit 79d7a0a

Please sign in to comment.