Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
969805c
GDB-6329 - add new license is expired message to views that need SPAR…
DesislavaBorisova Apr 11, 2022
a5a3f7b
GDB-6329 - add new license is expired message to views that need SPAR…
DesislavaBorisova Apr 11, 2022
49288f8
Merge branch 'GDB-6329-add_expired_license_msg' of github.com:Ontotex…
DesislavaBorisova Apr 27, 2022
599bc34
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesislavaBorisova Apr 27, 2022
50e60b6
GDB-6329 - fix failing karma tests due to new license expired message
DesislavaBorisova Apr 27, 2022
63e675e
GDB-6329 - fix failing karma tests due to new license expired message…
DesislavaBorisova Apr 27, 2022
0a7f487
GDB-6329 - add new license is expired message to views that need SPAR…
DesislavaBorisova Apr 11, 2022
3c1de4c
GDB-6329 - fix failing karma tests due to new license expired message
DesislavaBorisova Apr 27, 2022
c896c2a
GDB-6329 - fix failing karma tests due to new license expired message…
DesislavaBorisova Apr 27, 2022
7e69fe8
GDB-6329 - hide new toastr messages when license expired. Now only ne…
DesislavaBorisova May 12, 2022
f1df7b7
GDB-6329 - correct calls to License Service
DesislavaBorisova May 13, 2022
216c705
Merge remote-tracking branch 'origin/GDB-6329-add_expired_license_msg…
DesislavaBorisova May 13, 2022
10a0d96
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesiBorisova May 16, 2022
ae2dc56
GDB-6329 - correct concurrency problem with initView which failed som…
DesiBorisova May 16, 2022
d1c8185
GDB-6329 - hide remaining toastr messages, by stopping requests sent …
DesiBorisova May 16, 2022
c5ca9be
GDB-6329 - remove unnecessary event listener.
DesiBorisova May 16, 2022
c9f9908
Merge branch 'master' into GDB-6329-add_expired_license_msg
sava-savov-ontotext May 16, 2022
a0b5135
GDB-6329 Update package-lock.json file and removed on load event from…
sava-savov-ontotext May 16, 2022
782fd89
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesiBorisova May 17, 2022
19cf12a
Merge remote-tracking branch 'origin/GDB-6329-add_expired_license_msg…
DesiBorisova May 17, 2022
c3210be
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesiBorisova May 18, 2022
9d2117b
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesiBorisova May 23, 2022
e66c90c
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesiBorisova May 23, 2022
61a88dd
GDB-6329 - correct tests due to CI build fail.
DesiBorisova May 23, 2022
219de91
GDB-6329 - correct tests due to CI build fail.
DesiBorisova May 23, 2022
a415117
Merge branch 'master' into GDB-6329-add_expired_license_msg
DesislavaBorisova May 23, 2022
d10fdd0
GDB-6329 Removed unnecessary cy.visit in "Test class-hierarchy for gi…
sava-savov-ontotext May 23, 2022
dc93da6
GDB-6329 Added retry of getting delete btn in namespaces.spec
sava-savov-ontotext May 23, 2022
fdafc31
GDB-6329 Added retry of blocker when confirm btn is clicked
sava-savov-ontotext May 23, 2022
5c007dc
GDB-6329 Fixed cypress test in class.hierarchy.spec
sava-savov-ontotext May 23, 2022
09a5238
GDB-6329 Removed repository creation before each test
sava-savov-ontotext May 23, 2022
c484fde
GDB-6329 Removed repository creation before each test
sava-savov-ontotext May 23, 2022
7fb0f7f
GDB-6329 Added on direction listener
sava-savov-ontotext May 23, 2022
fc9e823
GDB-6329 Added on direction listener
sava-savov-ontotext May 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/js/angular/core/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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 {
Expand All @@ -339,6 +339,10 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut
}
});

$scope.isLicenseValid = function() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this method. As far as I can see the license status is loaded once and is stored in the license service, so in each $licenseService.isLicenseValid() call you get the same status. That being said, this additional method in each controller where you need to check the status is just meaningless and also using it in directive templates is quite overwhelming than using a plain variable binding.
So, can you consider resolving the license status in a boolean flag where you need it and use it instead of this method. @sava-savov-ontotext what do you think?

return $licenseService.isLicenseValid();
}

$scope.$watch('autocompletepromisestatus', function () {
if (!$repositories.isActiveRepoFedXType() && angular.isDefined($scope.autocompletepromisestatus)) {
$scope.autocompletepromisestatus.success(function (response) {
Expand Down
2 changes: 2 additions & 0 deletions src/js/angular/core/services/license.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ function licenseService($rootScope, LicenseRestService, $translate) {
that.loadingLicense = false;
updateProductType(that.license);
});
}). finally(function () {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra space before finally

$rootScope.$broadcast('license.set')
});
};

Expand Down
7 changes: 7 additions & 0 deletions src/js/angular/core/services/repositories.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,11 @@ repositories.service('$repositories', ['$http', 'toastr', '$rootScope', '$timeou
that.init();
}
});

window.addEventListener('load', function () {
that.repository = {
id: localStorage.getItem(that.repositoryStorageName) || '',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the adapter from src/js/angular/utils/local-storage-adapter.js! You can also move the keys in there as constants.

location: localStorage.getItem(that.repositoryStorageLocationName) || ''
};
});
}]);
8 changes: 5 additions & 3 deletions src/js/angular/explore/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const allGraphs = {
}
};
Object.defineProperty(global, 'allGraphs', {
get: () => {return allGraphs;}
get: () => {
return allGraphs;
}
});

angular
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -301,6 +303,11 @@ function DependenciesChordCtrl($scope, $rootScope, $repositories, toastr, $timeo
$scope.status = STATUS.NO_REPO;
return;
}

if (!$scope.isLicenseValid()) {
return;
}

initView();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,27 @@ 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()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the method above

return;
}
return RDF4JRepositoriesRestService.resolveGraphs()
.success(function (graphsInRepo) {
$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)) {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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'));
}
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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();
Expand All @@ -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);
});
}
Loading