diff --git a/src/js/angular/core/directives.js b/src/js/angular/core/directives.js index 5b54e60d91..4f7b4fbb4b 100644 --- a/src/js/angular/core/directives.js +++ b/src/js/angular/core/directives.js @@ -258,9 +258,9 @@ function multiRequired() { const SEARCH_DISPLAY_TYPE = {table: 'table', visual: 'visual'}; -searchResourceInput.$inject = ['$location', 'toastr', 'ClassInstanceDetailsService', 'AutocompleteRestService', '$rootScope', '$q', '$sce', 'LocalStorageAdapter', 'LSKeys', '$repositories', '$translate']; +searchResourceInput.$inject = ['$location', 'toastr', 'ClassInstanceDetailsService', 'AutocompleteRestService', '$rootScope', '$q', '$sce', 'LocalStorageAdapter', 'LSKeys', '$repositories', '$translate', '$licenseService']; -function searchResourceInput($location, toastr, ClassInstanceDetailsService, AutocompleteRestService, $rootScope, $q, $sce, LocalStorageAdapter, LSKeys, $repositories, $translate) { +function searchResourceInput($location, toastr, ClassInstanceDetailsService, AutocompleteRestService, $rootScope, $q, $sce, LocalStorageAdapter, LSKeys, $repositories, $translate, $licenseService) { return { restrict: 'EA', scope: { @@ -324,7 +324,7 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut }; $scope.$watch('namespacespromise', function () { - if (angular.isDefined($scope.namespacespromise)) { + if (angular.isDefined($scope.namespacespromise) && $scope.isLicenseValid()) { $scope.namespacespromise.success(function (data) { element.namespaces = data.results.bindings.map(function (e) { return { @@ -339,6 +339,10 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut } }); + $scope.isLicenseValid = function() { + return $licenseService.isLicenseValid(); + } + $scope.$watch('autocompletepromisestatus', function () { if (!$repositories.isActiveRepoFedXType() && angular.isDefined($scope.autocompletepromisestatus)) { $scope.autocompletepromisestatus.success(function (response) { diff --git a/src/js/angular/core/services/license.service.js b/src/js/angular/core/services/license.service.js index a03a28351c..0bc93129d5 100644 --- a/src/js/angular/core/services/license.service.js +++ b/src/js/angular/core/services/license.service.js @@ -23,6 +23,8 @@ function licenseService($rootScope, LicenseRestService, $translate) { that.loadingLicense = false; updateProductType(that.license); }); + }). finally(function () { + $rootScope.$broadcast('license.set') }); }; diff --git a/src/js/angular/core/services/repositories.service.js b/src/js/angular/core/services/repositories.service.js index 011bdd4076..c948e117a5 100644 --- a/src/js/angular/core/services/repositories.service.js +++ b/src/js/angular/core/services/repositories.service.js @@ -419,4 +419,11 @@ repositories.service('$repositories', ['$http', 'toastr', '$rootScope', '$timeou that.init(); } }); + + window.addEventListener('load', function () { + that.repository = { + id: localStorage.getItem(that.repositoryStorageName) || '', + location: localStorage.getItem(that.repositoryStorageLocationName) || '' + }; + }); }]); diff --git a/src/js/angular/explore/controllers.js b/src/js/angular/explore/controllers.js index ad9cb181b1..2fb1dd553f 100644 --- a/src/js/angular/explore/controllers.js +++ b/src/js/angular/explore/controllers.js @@ -2,6 +2,7 @@ import 'angular/utils/file-types'; import YASR from 'lib/yasr.bundled'; import {saveAs} from 'lib/FileSaver-patch'; import {decodeHTML} from "../../../app"; +import 'angular/core/services/license.service'; const modules = [ 'ngCookies', @@ -11,7 +12,8 @@ const modules = [ 'graphdb.framework.core', 'graphdb.framework.core.services.repositories', 'graphdb.framework.explore.services', - 'graphdb.workbench.utils.filetypes' + 'graphdb.workbench.utils.filetypes', + 'graphdb.framework.core.services.licenseService' ]; angular @@ -82,9 +84,9 @@ function ExploreCtrl($scope, $http, $location, toastr, $routeParams, $repositori }; $scope.$watch(function () { - return $repositories.getActiveRepository(); + return $repositories.getActiveRepository(); }, function () { - if ($scope.getActiveRepository()) { + if ($scope.getActiveRepository() && $scope.isLicenseValid()) { if ($scope.usedPrefixes) { $scope.loadResource(); } else { diff --git a/src/js/angular/graphexplore/controllers/dependencies-chord.controller.js b/src/js/angular/graphexplore/controllers/dependencies-chord.controller.js index 8896d0c855..e00ddb30e7 100644 --- a/src/js/angular/graphexplore/controllers/dependencies-chord.controller.js +++ b/src/js/angular/graphexplore/controllers/dependencies-chord.controller.js @@ -22,7 +22,9 @@ const allGraphs = { } }; Object.defineProperty(global, 'allGraphs', { - get: () => {return allGraphs;} + get: () => { + return allGraphs; + } }); angular @@ -145,7 +147,7 @@ function DependenciesChordCtrl($scope, $rootScope, $repositories, toastr, $timeo } if ($scope.status.indexOf('ERROR;') === 0) { $scope.status = STATUS.ERROR; - toastr.error($translate.instant('graphexplore.error.dependencies.calc', {error:$scope.status.substring('ERROR;'.length)})); + toastr.error($translate.instant('graphexplore.error.dependencies.calc', {error: $scope.status.substring('ERROR;'.length)})); } }) .error(function (data) { @@ -208,7 +210,7 @@ function DependenciesChordCtrl($scope, $rootScope, $repositories, toastr, $timeo $scope.$watch('direction', function () { if (!$repositories.getActiveRepository() || - $scope.isSystemRepository() || $repositories.isActiveRepoFedXType()) { + $scope.isSystemRepository() || $repositories.isActiveRepoFedXType() || !$scope.isLicenseValid()) { return; } initView(); @@ -239,7 +241,7 @@ function DependenciesChordCtrl($scope, $rootScope, $repositories, toastr, $timeo GraphDataRestService.calculateRelationships(selectedGraph.contextID.uri) .success(function (data) { if (data.indexOf('ERROR;') === 0) { - toastr.error($translate.instant('graphexplore.error.dependencies.calc', {error:$scope.status.substring('ERROR;'.length)})); + toastr.error($translate.instant('graphexplore.error.dependencies.calc', {error: $scope.status.substring('ERROR;'.length)})); } else { getRelationshipsStatus(); } @@ -301,6 +303,11 @@ function DependenciesChordCtrl($scope, $rootScope, $repositories, toastr, $timeo $scope.status = STATUS.NO_REPO; return; } + + if (!$scope.isLicenseValid()) { + return; + } + initView(); } diff --git a/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js b/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js index b7011b7dc5..6cbdb9722e 100644 --- a/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js +++ b/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js @@ -1111,7 +1111,7 @@ function GraphsVisualizationsCtrl($scope, $rootScope, $repositories, $licenseSer // time but then we'll be called again by the event, so we need the above flag to avoid double // initialization and weirdness. function initForRepository(newRepo) { - if (!$repositories.getActiveRepository() || $scope.hasInitedRepository && !newRepo) { + if (!$scope.isLicenseValid() || !$repositories.getActiveRepository() || $scope.hasInitedRepository && !newRepo) { return; } @@ -1134,12 +1134,12 @@ function GraphsVisualizationsCtrl($scope, $rootScope, $repositories, $licenseSer checkAutocompleteStatus(); }).error(function (data) { - toastr.error(getError(data), $translate.instant('graphexplore.error.view.will.not.work')); + toastr.error(getError(data), $translate.instant('graphexplore.error.view.will.not.work')); }); } function checkAutocompleteStatus() { - if ($licenseService.isLicenseValid()) { + if ($scope.isLicenseValid()) { $scope.getAutocompletePromise = AutocompleteRestService.checkAutocompleteStatus(); } } diff --git a/src/js/angular/graphexplore/controllers/rdf-class-hierarchy.controller.js b/src/js/angular/graphexplore/controllers/rdf-class-hierarchy.controller.js index 950f10fd28..36c5182cbb 100644 --- a/src/js/angular/graphexplore/controllers/rdf-class-hierarchy.controller.js +++ b/src/js/angular/graphexplore/controllers/rdf-class-hierarchy.controller.js @@ -53,8 +53,13 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li let selectedGraph = allGraphs; + $scope.isLicenseValid = function () { + return $licenseService.isLicenseValid(); + }; + const initView = function () { - if (!$scope.getActiveRepository()) { + if (!$scope.getActiveRepository() || + !$licenseService.isLicenseValid()) { return; } return RDF4JRepositoriesRestService.resolveGraphs() @@ -62,11 +67,13 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li $scope.graphsInRepo = graphsInRepo.results.bindings; setSelectedGraphFromCache(); }).error(function (data) { - $scope.repositoryError = getError(data); - toastr.error(getError(data), $translate.instant('graphexplore.error.getting.graphs')); - }); + $scope.repositoryError = getError(data); + toastr.error(getError(data), $translate.instant('graphexplore.error.getting.graphs')); + }); }; + initView(); + const setSelectedGraphFromCache = function () { const selGraphFromCache = LocalStorageAdapter.get(`classHierarchy-selectedGraph-${$repositories.getActiveRepository()}`); if (selGraphFromCache !== null && $scope.graphsInRepo.some(graph => graph.contextID.uri === selGraphFromCache.contextID.uri)) { @@ -115,8 +122,6 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li $scope.instancesQueryObj.query = ""; $scope.instancesFilterFunc = instancesFilterFunc; - initView(); - $scope.$watch('instancesObj.items', function () { if ($scope.instancesObj.items.length > 0) { $timeout(function () { @@ -156,7 +161,10 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li toastr.warning($translate.instant('graphexplore.disabling.animations', {classLimit: classLimit}), $translate.instant('graphexplore.reducing.visual.effects')); } else { - toastr.warning($translate.instant('graphexplore.browser.performance', {browser: bowser.name, classLimit: classLimit}), + toastr.warning($translate.instant('graphexplore.browser.performance', { + browser: bowser.name, + classLimit: classLimit + }), $translate.instant('graphexplore.reducing.visual.effects')); } }; @@ -264,8 +272,8 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li .search("name", name); } }).error(function () { - toastr.error($translate.instant('graphexplore.error.request.failed', {name: name})); - }); + toastr.error($translate.instant('graphexplore.error.request.failed', {name: name})); + }); } function onGoToDomainRangeGraphView(event, selectedClass) { @@ -317,7 +325,7 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li _.each(response, function (value, key) { const obj = {}; // TODO extract in core function isTriple(str) - obj.type = (value.startsWith("<<") && value.endsWith(">>")) ? "triple": "uri"; + obj.type = (value.startsWith("<<") && value.endsWith(">>")) ? "triple" : "uri"; obj.absUri = encodeURIComponent(value); obj.absUriNonEncoded = value; obj.resolvedUri = key; @@ -426,10 +434,8 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li } let currentActiveRepository = $repositories.getActiveRepository(); + function onRepositoryIsSet() { - if (!$licenseService.isLicenseValid()) { - return; - } if (currentActiveRepository === $repositories.getActiveRepository()) { return; } else { @@ -445,10 +451,12 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li } function getClassHierarchyData() { - + if (!$licenseService.isLicenseValid()) { + return; + } refreshDiagramExternalElements(); - if (!$scope.isSystemRepository() && $scope.isLicenseValid()) { + if (!$scope.isSystemRepository()) { $scope.hierarchyError = false; $scope.loader = true; GraphDataRestService.getClassHierarchyData(selectedGraph.contextID.uri) @@ -472,11 +480,6 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li return $scope.classHierarchyData.classCount && $scope.getActiveRepositoryNoError() && !$scope.isSystemRepository(); }; - $scope.isLicenseValid = function () { - return $licenseService.isLicenseValid(); - }; - - $scope.chosenGraph = function (graph) { selectedGraph = graph; getClassHierarchyData(); @@ -490,4 +493,10 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li $scope.isAllGraphsSelected = function () { return $scope.getSelGraphValue() === 'all.graphs.label' } + + window.addEventListener('load', initView); + + $scope.$on('$destroy', function (event) { + window.removeEventListener('load', initView); + }); } diff --git a/src/js/angular/graphexplore/directives/rdf-class-hierarchy.directive.js b/src/js/angular/graphexplore/directives/rdf-class-hierarchy.directive.js index 6763354fe9..d1813edf33 100644 --- a/src/js/angular/graphexplore/directives/rdf-class-hierarchy.directive.js +++ b/src/js/angular/graphexplore/directives/rdf-class-hierarchy.directive.js @@ -13,11 +13,12 @@ angular .constant("ROOT_OBJ_NAME", "RDF Class Hierarchy") .directive('rdfClassHierarchy', classHierarchyDirective); -classHierarchyDirective.$inject = ['$rootScope', '$location', 'GraphDataRestService', '$window', '$timeout', '$repositories', '$licenseService', 'toastr', 'ZOOM_DURATION', 'ROOT_OBJ_NAME', 'LocalStorageAdapter', 'LSKeys', '$translate']; +classHierarchyDirective.$inject = ['$rootScope', '$location', 'GraphDataRestService', '$window', '$timeout', '$repositories', 'toastr', 'ZOOM_DURATION', 'ROOT_OBJ_NAME', 'LocalStorageAdapter', 'LSKeys', '$translate']; -function classHierarchyDirective($rootScope, $location, GraphDataRestService, $window, $timeout, $repositories, $licenseService, toastr, ZOOM_DURATION, ROOT_OBJ_NAME, LocalStorageAdapter, LSKeys, $translate) { +function classHierarchyDirective($rootScope, $location, GraphDataRestService, $window, $timeout, $repositories, toastr, ZOOM_DURATION, ROOT_OBJ_NAME, LocalStorageAdapter, LSKeys, $translate) { return { restrict: 'AE', + transclude: true, template: '
', scope: { classHierarchyData: '=', @@ -27,23 +28,22 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w showClassInfoPanel: '=', showExternalElements: '=', hidePrefixes: '=', - currentBrowserLimit: '=' + currentBrowserLimit: '=', + isLicenseValid: '&' }, link: linkFunc }; - function linkFunc(scope, element, attrs) { - renderCirclePacking(scope, element); + function linkFunc(scope) { + renderCirclePacking(scope); } - function renderCirclePacking(scope, element) { + function renderCirclePacking(scope) { var width = 800, height = 800, diameter = height, - margin = 20, - node, - root; + margin = 20; var pack = d3.layout.pack() .size([diameter - margin, diameter - margin]) @@ -51,15 +51,6 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w return d.size; }); - var colors = [ - "hsl(33, 75%, 75%)", - "hsl(213, 75%, 75%)", - "hsl(333, 75%, 75%)", - "hsl(153, 75%, 75%)", - "hsl(273, 75%, 75%)", - "hsl(93, 75%, 75%)" - ]; - var color = d3.scale.linear() .domain([0, 4]) .range(["hsl(19, 70%, 90%)", "hsl(19, 70%, 50%)"]) @@ -119,12 +110,12 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w var g = appendMainGroup(); - if (!scope.classHierarchyData.classCount && $repositories.getActiveRepository() && !$repositories.isSystemRepository()) { + if (!scope.classHierarchyData.classCount && $repositories.getActiveRepository() && !$repositories.isSystemRepository() && scope.isLicenseValid()) { $rootScope.loader = true; $rootScope.hierarchyError = false; const selGraphFromCache = LocalStorageAdapter.get(`classHierarchy-selectedGraph-${$repositories.getActiveRepository()}`); GraphDataRestService.getClassHierarchyData(selGraphFromCache !== null ? selGraphFromCache.contextID.uri : "") - .success(function (response, status, headers) { + .success(function (response, status) { $rootScope.loader = false; if (status === 207) { toastr.warning($translate.instant('graphexplore.update.diagram'), $translate.instant('graphexplore.repository.data.changed')); @@ -177,7 +168,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w var tip = d3tip() .attr('class', 'd3-tip') //.offset([-10, 0]) - .customPosition(function (d) { + .customPosition(function () { return { top: 'inherit', bottom: ($window.innerHeight - d3.event.clientY) + 'px', @@ -195,7 +186,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w .enter().append("g"); if (config.doFade) { - circleGroup.each(function (d) { + circleGroup.each(function () { D3.Transition.fadeIn(d3.select(this), 550); }); } @@ -259,8 +250,6 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w } var clickCancel = D3.Click.delayDblClick(); - var parentCircles = d3.selectAll(".parent, .topLevelParent, .child, .root") - .call(clickCancel); doFocus = function (obj) { zoom(obj); @@ -273,7 +262,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w showClassInfoPanel(); // FIXME: is it ok to bind this event handler every time and not just once? - scope.$on('sidePanelClosed', function (event) { + scope.$on('sidePanelClosed', function () { d3.selectAll(".selected").classed("selected", obj.selected = false); }); } @@ -437,7 +426,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w }); if (config.doFade && !config.keepPrevState) { - text.each(function (d) { + text.each(function () { D3.Transition.fadeIn(d3.select(this), 550); }); } @@ -446,7 +435,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w function focusOnCurrentClass(focusHistoryId) { if (focusHistoryId) { circle.each(function (d) { - if (focusHistoryId == d.id) { + if (focusHistoryId === d.id) { doFocus(d); } }); @@ -608,7 +597,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w // the fancy version for faster browsers var transition = d3.transition() .duration(ZOOM_DURATION) - .tween("zoom", function (d) { + .tween("zoom", function () { var i = d3.interpolateZoom(view, [focus.x, focus.y, adjustRadius(focus.r)]); return function (t) { zoomTo(i(t)); @@ -815,7 +804,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w // hit enter again on the already selected class in order again react and zoom to it again // if we are not at the moment var currentSearchedClass; - onEnterClassSearchBroadcast = scope.$on('onEnterKeypressSearchAction', function (event) { + onEnterClassSearchBroadcast = scope.$on('onEnterKeypressSearchAction', function () { if (currentSearchedClass) { doFocus(currentSearchedClass); } diff --git a/src/js/angular/jdbc/controllers.js b/src/js/angular/jdbc/controllers.js index 73f34c2605..ba196fc3b5 100644 --- a/src/js/angular/jdbc/controllers.js +++ b/src/js/angular/jdbc/controllers.js @@ -24,7 +24,8 @@ function JdbcListCtrl($scope, $repositories, JdbcRestService, toastr, ModalServi $scope.getSqlConfigurations = function () { // Only do this if there is an active repo that isn't an Ontop or FedX repo. // Ontop and FedX repos don't support JDBC. - if ($repositories.getActiveRepository() + if ($scope.isLicenseValid() + && $repositories.getActiveRepository() && !$repositories.isActiveRepoOntopType() && !$repositories.isActiveRepoFedXType()) { JdbcRestService.getJdbcConfigurations().success(function (data) { @@ -407,7 +408,7 @@ function JdbcCreateCtrl($scope, $location, toastr, $repositories, $window, $time }; function getSuggestions() { - if (!validateQuery()) { + if (!validateQuery() || !$scope.isLicenseValid()) { return; } diff --git a/src/js/angular/namespaces/controllers.js b/src/js/angular/namespaces/controllers.js index 19d36cb2a3..2916702989 100644 --- a/src/js/angular/namespaces/controllers.js +++ b/src/js/angular/namespaces/controllers.js @@ -30,8 +30,8 @@ function validatePrefix(prefix) { return prefix === '' || prefix.match(pnPrefixRe); } -namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'toastr', '$modal', 'ModalService', 'RepositoriesRestService', 'RDF4JRepositoriesRestService', '$translate', - function ($scope, $http, $repositories, toastr, $modal, ModalService, RepositoriesRestService, RDF4JRepositoriesRestService, $translate) { +namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'toastr', '$modal', 'ModalService', 'RepositoriesRestService', 'RDF4JRepositoriesRestService', '$translate', '$licenseService', + function ($scope, $http, $repositories, toastr, $modal, ModalService, RepositoriesRestService, RDF4JRepositoriesRestService, $translate, $licenseService) { $scope.namespaces = {}; $scope.namespace = {}; $scope.loader = false; @@ -41,11 +41,19 @@ namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'to $scope.pageSize = $scope.pageSizeOptions[0]; $scope.displayedNamespaces = []; + $scope.isLicenseValid = function() { + return $licenseService.isLicenseValid(); + } + $scope.getNamespaces = function () { if (!$repositories.getActiveRepository()) { return; } + if (!$scope.isLicenseValid()) { + return; + } + $scope.loader = true; $scope.namespaces = {}; RDF4JRepositoriesRestService.getNamespaces($repositories.getActiveRepository()) @@ -112,6 +120,12 @@ namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'to $scope.selectedAll = false; }); + $scope.$on('license.set', function () { + $scope.searchNamespaces = ''; + $scope.getNamespaces(); + $scope.selectedAll = false; + }); + $scope.onNamespaceSearch = function() { $scope.haveSelected = false; $scope.selectedAll = false; diff --git a/src/js/angular/similarity/controllers/similarity-list.controller.js b/src/js/angular/similarity/controllers/similarity-list.controller.js index 3abc21aebb..31896c8a7b 100644 --- a/src/js/angular/similarity/controllers/similarity-list.controller.js +++ b/src/js/angular/similarity/controllers/similarity-list.controller.js @@ -99,7 +99,7 @@ function SimilarityCtrl($scope, $interval, toastr, $repositories, $licenseServic return $repositories.getActiveRepository(); }, function () { // Don't try to get namespaces for ontop or fedx repository - if ($scope.getActiveRepository() && !$scope.isActiveRepoOntopType() && !$scope.isActiveRepoFedXType()) { + if ($scope.isLicenseValid() && $scope.getActiveRepository() && !$scope.isActiveRepoOntopType() && !$scope.isActiveRepoFedXType()) { $scope.getNamespacesPromise = RDF4JRepositoriesRestService.getNamespaces($scope.getActiveRepository()) .success(function (data) { checkAutocompleteStatus(); diff --git a/src/pages/create-index.html b/src/pages/create-index.html index f5b13665ee..3c23a5a138 100644 --- a/src/pages/create-index.html +++ b/src/pages/create-index.html @@ -17,7 +17,7 @@

popover-placement="bottom-right" popover-append-to-body="true">

-
+

{{'current.repo.error' | translate}}

diff --git a/src/pages/explore.html b/src/pages/explore.html index 6fe84cc13c..679a21f1a3 100644 --- a/src/pages/explore.html +++ b/src/pages/explore.html @@ -1,6 +1,6 @@ -
-
+
+
details image diff --git a/src/pages/jdbc-create.html b/src/pages/jdbc-create.html index b2c6e2c6f5..aacac0c157 100644 --- a/src/pages/jdbc-create.html +++ b/src/pages/jdbc-create.html @@ -17,7 +17,7 @@

popover-placement="bottom-right" popover-append-to-body="true">

-
+

{{'not.usable.active.repo.error' | translate}}

@@ -25,7 +25,7 @@

{{repositoryError}}

-
+

{{'table.name' | translate}}

@@ -116,7 +116,7 @@

- + ng-if="canWriteActiveRepo() && isLicenseValid()"> {{'common.cancel.btn' | translate}} + ng-if="!canWriteActiveRepo() && isLicenseValid()"> {{'common.close' | translate}} -
+

-
+
-
+
diff --git a/src/pages/namespaces.html b/src/pages/namespaces.html index 29813e458e..5672f27bbb 100644 --- a/src/pages/namespaces.html +++ b/src/pages/namespaces.html @@ -15,8 +15,8 @@

-
-
+
+
diff --git a/src/pages/rdfClassHierarchyInfo.html b/src/pages/rdfClassHierarchyInfo.html index 93e19c94f3..5b676d42fb 100644 --- a/src/pages/rdfClassHierarchyInfo.html +++ b/src/pages/rdfClassHierarchyInfo.html @@ -140,7 +140,8 @@

show-external-elements="showExternalElements" hide-prefixes="hidePrefixes" current-browser-limit="currentBrowserLimit" - ng-show="isLicenseValid() && hasClassHierarchy()"> + is-license-valid="isLicenseValid" + ng-show="hasClassHierarchy() && isLicenseValid()"> popover-append-to-body="true">

-
-
+
+

{{'not.usable.active.repo.error' | translate}}

{{repositoryError}}

diff --git a/test-cypress/integration/explore/class.hierarchy.spec.js b/test-cypress/integration/explore/class.hierarchy.spec.js index 974688b990..aca3f55ef1 100644 --- a/test-cypress/integration/explore/class.hierarchy.spec.js +++ b/test-cypress/integration/explore/class.hierarchy.spec.js @@ -10,13 +10,18 @@ const CLASS_HIERARCHY = 'class hierarchy'; describe('Class hierarchy screen validation', () => { let repositoryId; - beforeEach(() => { + before(() => { repositoryId = 'repo' + Date.now(); cy.createRepository({id: repositoryId}); - cy.presetRepository(repositoryId); - cy.importServerFile(repositoryId, FILE_TO_IMPORT); + }); + beforeEach(() => { + waitUntilPageIsLoaded(); + }) + + function waitUntilPageIsLoaded() { + cy.presetRepository(repositoryId); cy.visit('/hierarchy'); cy.window(); // Wait for the chart and diagram to be visible, also check if a class is displayed. @@ -25,9 +30,9 @@ describe('Class hierarchy screen validation', () => { findClassByName('food:Grape'); cy.get('@classInHierarchy').scrollIntoView().should('be.visible'); }); - }); + } - afterEach(() => { + after(() => { cy.deleteRepository(repositoryId); }); @@ -172,7 +177,7 @@ describe('Class hierarchy screen validation', () => { it('Test class-hierarchy for given graph', () => { cy.importServerFile(repositoryId, GRAPH_FILE, {"context": NEWS_GRAPH}); // Should re-enter page to display Graph dropdown - cy.visit('/hierarchy'); + waitUntilPageIsLoaded(); ClassViewsSteps.verifyDataChangedWarning(); verifyCounterValue(INITIAL_CLASS_COUNT); ClassViewsSteps.verifyGraphIsDisplayed(ALL_GRAPHS); @@ -182,12 +187,15 @@ describe('Class hierarchy screen validation', () => { ClassViewsSteps.confirmReloadWarningAppear(CLASS_HIERARCHY); ClassViewsSteps.confirmReload(); - cy.visit('/hierarchy#1'); + cy.url().should('contain', `${Cypress.config('baseUrl')}/hierarchy#1`); + ClassViewsSteps.verifyGraphIsDisplayed(ALL_GRAPHS); verifyCounterValue(INITIAL_CLASS_COUNT + CLASS_COUNT_OF_NEWS_GRAPH); - ClassViewsSteps.clickGraphBtn(); - ClassViewsSteps.selectGraphFromDropDown(NEWS_GRAPH); - ClassViewsSteps.verifyGraphIsDisplayed(NEWS_GRAPH); - verifyCounterValue(CLASS_COUNT_OF_NEWS_GRAPH); + ClassViewsSteps.clickGraphBtn() + .then(() => { + ClassViewsSteps.selectGraphFromDropDown(NEWS_GRAPH); + ClassViewsSteps.verifyGraphIsDisplayed(NEWS_GRAPH); + verifyCounterValue(CLASS_COUNT_OF_NEWS_GRAPH); + }); }); function getDomainRangeGraphButton() { diff --git a/test-cypress/integration/explore/class.relationships.spec.js b/test-cypress/integration/explore/class.relationships.spec.js index 6ccdd6e9b6..755fdb2ad1 100644 --- a/test-cypress/integration/explore/class.relationships.spec.js +++ b/test-cypress/integration/explore/class.relationships.spec.js @@ -6,7 +6,7 @@ describe('Class relations screen validation', () => { let repositoryId; - beforeEach(() => { + before(() => { repositoryId = 'class-relations-repo' + Date.now(); cy.createRepository({id: repositoryId}); cy.presetRepository(repositoryId); @@ -20,7 +20,7 @@ describe('Class relations screen validation', () => { cy.get('#wb-dependencies-classInClasses').should('be.visible'); }); - afterEach(() => { + after(() => { cy.deleteRepository(repositoryId); }); @@ -65,6 +65,7 @@ describe('Class relations screen validation', () => { it('Test class relationships for given graph', () => { cy.importServerFile(repositoryId, GRAPH_FILE, {"context": NEWS_GRAPH}); + cy.presetRepository(repositoryId); // Should re-enter page to display Graph dropdown cy.visit('/relationships'); ClassViewsSteps.verifyDataChangedWarning(); diff --git a/test-cypress/integration/setup/namespaces.spec.js b/test-cypress/integration/setup/namespaces.spec.js index 50a21a3cdc..ae44fc58fd 100644 --- a/test-cypress/integration/setup/namespaces.spec.js +++ b/test-cypress/integration/setup/namespaces.spec.js @@ -14,13 +14,11 @@ describe('Namespaces', () => { DEFAULT_NAMESPACES[e.prefix.value] = e.namespace.value; }); }).then(() => { + cy.visit('/namespaces'); + cy.window(); + waitUntilPageIsLoaded(); }); - - cy.visit('/namespaces'); - cy.window(); - - waitUntilPageIsLoaded(); }); afterEach(() => { @@ -46,7 +44,7 @@ describe('Namespaces', () => { getAddNamespaceButton().should('be.visible').and('not.be.disabled'); // Should render a table with some default namespaces - getNamespacesTable().should('be.visible'); + getNamespacesTable().scrollIntoView().should('be.visible'); getNamespaces().should('have.length', getDefaultNamespacesLength()); // Should provide pagination options @@ -54,12 +52,14 @@ describe('Namespaces', () => { // Should show all namespaces by default (they are only 6 so they can be visualized all at once) cy.get('.dropdown-toggle') .should('contain', 'All') - .click(); - cy.get('.page-size-option') - .should('have.length', 1) - .and('contain', 'All'); - // Close the menu to avoid overlapping other elements - cy.get('.dropdown-toggle').click(); + .click() + .then(() => { + cy.get('.page-size-option') + .should('have.length', 1) + .and('contain', 'All'); + // Close the menu to avoid overlapping other elements + cy.get('.dropdown-toggle').click(); + }); }); // Should show summary of results @@ -123,20 +123,24 @@ describe('Namespaces', () => { it('should filter existing namespaces', () => { getNamespacesFilterField() .should('have.value', '') - .type('owl') - .should('have.value', 'owl'); - getNamespaces() - .should('have.length', 1) - .and('contain', DEFAULT_NAMESPACES['owl']); - getNamespacesHeaderPaginationInfo() - .should('be.visible') - .and('contain', 'Showing 1 - 1 of 1 results'); - - getNamespacesFilterField() - .clear() - .type('missing_prefix'); - getNamespacesTable().should('not.be.visible'); - getNoNamespacesMatchAlert().should('be.visible'); + .then((el) => { + cy.wrap(el).type('owl'); + }).then(() => { + getNamespacesFilterField() + .should('have.value', 'owl'); + getNamespaces() + .should('have.length', 1) + .and('contain', DEFAULT_NAMESPACES['owl']); + getNamespacesHeaderPaginationInfo() + .should('be.visible') + .and('contain', 'Showing 1 - 1 of 1 results'); + + getNamespacesFilterField() + .clear() + .type('missing_prefix'); + getNamespacesTable().should('not.be.visible'); + getNoNamespacesMatchAlert().should('be.visible'); + }); }); it('should allow to add new namespace', () => { @@ -210,7 +214,7 @@ describe('Namespaces', () => { selectNamespace('rdf'); selectNamespace('rdfs'); - getDeleteNamespacesButton().click(); + clickDeleteNamespacesButton(); confirmModal(); updatedCount = updatedCount - 2; @@ -220,7 +224,7 @@ describe('Namespaces', () => { .should('contain', `Showing 1 - ${updatedCount} of ${updatedCount} results`); getSelectAllNamespacesCheckbox().click(); - getDeleteNamespacesButton().click(); + clickDeleteNamespacesButton(); confirmModal(); getNamespacesTable().should('not.be.visible'); @@ -318,8 +322,10 @@ describe('Namespaces', () => { return getNamespacesTable().find('.select-all-namespaces'); } - function getDeleteNamespacesButton() { - return getNamespacesTable().find('.delete-namespaces-btn'); + function clickDeleteNamespacesButton() { + cy.waitUntil(() => + cy.get('.delete-namespaces-btn') + .then(deleteBtn => deleteBtn && Cypress.dom.isAttached(deleteBtn) && deleteBtn.trigger('click'))); } function getNamespaces() { diff --git a/test-cypress/steps/class-views-steps.js b/test-cypress/steps/class-views-steps.js index a6313fa1ed..5efb5cca10 100644 --- a/test-cypress/steps/class-views-steps.js +++ b/test-cypress/steps/class-views-steps.js @@ -7,21 +7,28 @@ const ALL_GRAPHS = 'All graphs'; const NEWS_GRAPH = 'http://example.org/news'; Object.defineProperty(global, 'GRAPH_FILE', { - get: () => {return GRAPH_FILE;} + get: () => { + return GRAPH_FILE; + } }); Object.defineProperty(global, 'ALL_GRAPHS', { - get: () => {return ALL_GRAPHS;} + get: () => { + return ALL_GRAPHS; + } }); Object.defineProperty(global, 'NEWS_GRAPH', { - get: () => {return NEWS_GRAPH;} + get: () => { + return NEWS_GRAPH; + } }); class ClassViewsSteps { static selectGraphFromDropDown(graph) { - cy.get('#selectGraphDropdown .dropdown-item') + cy.get('#selectGraphDropdown') + .find('.dropdown-item') .each(($el, index, $list) => { if ($el.text().trim() === graph) { cy.wrap($el).click(); @@ -30,12 +37,15 @@ class ClassViewsSteps { } static verifyGraphIsDisplayed(graph) { - cy.get('#selectGraphDropdown').should('be.visible') - .and('contain', graph); + cy.waitUntil(() => + cy.get('#selectGraphDropdown') + .then(dropDown => dropDown && Cypress.dom.isAttached(dropDown) && dropDown.text().indexOf(graph) !== -1)); } static clickGraphBtn() { - cy.get('#graphsBtnGroup').click(); + return cy.waitUntil(() => + cy.get('#graphsBtnGroup') + .then(graphsBtn => graphsBtn && Cypress.dom.isAttached(graphsBtn) && graphsBtn.trigger('click'))); } @@ -52,8 +62,11 @@ class ClassViewsSteps { } static confirmReload() { - cy.get('.modal-footer .confirm-btn').click(); - cy.get('.modal').should('not.exist'); + cy.get('.modal-footer .confirm-btn') + .click() + .then(() => { + cy.get('.modal').should('not.exist'); + }); } static reloadDiagram() { diff --git a/test/namespaces/controllers.spec.js b/test/namespaces/controllers.spec.js index 353e31f580..d00a2c6125 100644 --- a/test/namespaces/controllers.spec.js +++ b/test/namespaces/controllers.spec.js @@ -23,9 +23,10 @@ describe('=> NamespacesCtrl tests', function () { toastr, httpGetNamespaces, modalInstance, - $translate; + $translate, + $licenseService; - beforeEach(angular.mock.inject(function (_$httpBackend_, _$repositories_, _RDF4JRepositoriesRestService_, _toastr_, _$location_, _$controller_, _$window_, _$timeout_, $rootScope, $q, _$translate_) { + beforeEach(angular.mock.inject(function (_$httpBackend_, _$repositories_, _RDF4JRepositoriesRestService_, _toastr_, _$location_, _$controller_, _$window_, _$timeout_, $rootScope, $q, _$translate_, _$licenseService_) { $httpBackend = _$httpBackend_; $controller = _$controller_; $timeout = _$timeout_; @@ -34,6 +35,7 @@ describe('=> NamespacesCtrl tests', function () { toastr = _toastr_; $scope = $rootScope.$new(); $translate = _$translate_; + $licenseService = _$licenseService_; $translate.instant = function (key) { return bundle[key]; @@ -41,6 +43,11 @@ describe('=> NamespacesCtrl tests', function () { modalInstance = new FakeModal($q, $rootScope); + $licenseService.isLicenseValid = function () { + return true; + } + $httpBackend.when('GET', 'rest/graphdb-settings/license').respond(200, 'licenseinfo'); + $httpBackend.when('GET', 'rest/graphdb-settings/license/hardcoded').respond(200, 'true'); $httpBackend.when('GET', 'rest/locations').respond(200, {}); $repositories.getActiveRepositoryObject = function () { @@ -100,7 +107,8 @@ describe('=> NamespacesCtrl tests', function () { return modalInstance; } }, - $translate: $translate + $translate: $translate, + $licenseService: $licenseService }); })); diff --git a/test/resource/controllers.spec.js b/test/resource/controllers.spec.js index 67413cbabe..a648e69bce 100644 --- a/test/resource/controllers.spec.js +++ b/test/resource/controllers.spec.js @@ -20,9 +20,10 @@ describe('=> ExploreCtrl tests', function () { $window, $scope, $jwtAuth, - $languageService; + $languageService, + $licenseService; - beforeEach(angular.mock.inject(function (_$repositories_, _ClassInstanceDetailsService_, _$httpBackend_, _$location_, _$controller_, _$window_, _$timeout_, $rootScope, _$jwtAuth_, _$languageService_) { + beforeEach(angular.mock.inject(function (_$repositories_, _ClassInstanceDetailsService_, _$httpBackend_, _$location_, _$controller_, _$window_, _$timeout_, $rootScope, _$jwtAuth_, _$licenseService_, _$languageService_) { $repositories = _$repositories_; ClassInstanceDetailsService = _ClassInstanceDetailsService_; $httpBackend = _$httpBackend_; @@ -31,6 +32,7 @@ describe('=> ExploreCtrl tests', function () { $window = _$window_; $timeout = _$timeout_; $jwtAuth = _$jwtAuth_; + $licenseService = _$licenseService_; $languageService = _$languageService_; $scope = $rootScope.$new(); @@ -47,6 +49,8 @@ describe('=> ExploreCtrl tests', function () { $controller('ExploreCtrl', {$scope: $scope, $jwtAuth: $jwtAuth, $languageService: $languageService}); + $httpBackend.when('GET', 'rest/graphdb-settings/license').respond(200, 'licenseinfo'); + $httpBackend.when('GET', 'rest/graphdb-settings/license/hardcoded').respond(200, 'true'); $httpBackend.when('GET', 'rest/security/all').respond(200, { enabled: true, freeAccess: {enabled: false},