Skip to content

Commit

Permalink
GDB-6329 - add license validation in core errors. Fix method calls to…
Browse files Browse the repository at this point in the history
… license service in templates and controllers.
  • Loading branch information
DesiBorisova committed May 2, 2024
1 parent 47e12f5 commit 1be4c29
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/js/angular/core/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut
const MIN_CHAR_LEN = 0;
const IS_SEARCH_PRESERVED = $scope.preserveSearch === 'true';
const SEARCH_INPUT_FIELD = element.find('.view-res-input');
const isLicenseValid = $licenseService.isLicenseValid();
$scope.textButtonLabel = $scope.textButton || 'query.editor.table.btn';
$scope.visualButtonLabel = $scope.visualButton || 'query.editor.visual.btn';

Expand Down Expand Up @@ -334,7 +333,7 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut
};

$scope.$watch('namespacespromise', function () {
if (angular.isDefined($scope.namespacespromise) && isLicenseValid) {
if (angular.isDefined($scope.namespacespromise) && $licenseService.isLicenseValid()) {
$scope.namespacespromise.success(function (data) {
element.namespaces = data.results.bindings.map(function (e) {
return {
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,7 +3,7 @@
<div class="mb-1 mt-1 ml-1 mr-1">
<div class="card repository-errors">
<div class="alert lead" ng-class="!getActiveRepository() ? 'alert-info' : 'alert-warning'">
<div ng-if="!getActiveRepository()" >{{'core.errors.no.connected.repository.warning.msg' | translate}}</div>
<div ng-if="isLicenseValid() && !getActiveRepository()" >{{'core.errors.no.connected.repository.warning.msg' | translate}}</div>
<div id="restrictedDiv" ng-if="getActiveRepository() && isRestricted">{{'core.errors.restricted.warning.msg' | translate}}
<span ng-if="!isLicenseValid()">{{'core.errors.not.valid.license.warning.msg' | translate}}
<p></p>
Expand Down Expand Up @@ -32,7 +32,7 @@
</div>
<ul class="list-group limit-height clearfix two-columns repos" ng-mouseleave="hidePopoverForRepo($event)">
<li ng-repeat="repository in getAccessibleRepositories() | orderBy: ['type === \'system\'', 'location', 'id']"
ng-if="repository.id !== getActiveRepository() || repository.location !== getActiveRepositoryObject().location"
ng-if="isLicenseValid() && repository.id !== getActiveRepository() || repository.location !== getActiveRepositoryObject().location"
class="list-group-item list-group-item-action repository"
ng-class="{'remote': !repository.local}"
ng-mouseenter="showPopoverForRepo($event, repository)" ngx-mouseleave="setPopoverForRepo($event, repository, false)">
Expand Down
10 changes: 4 additions & 6 deletions src/js/angular/explore/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function ExploreCtrl(
$scope.contextTypes = ContextType.getAllType();
$scope.currentContextTypeId = ContextTypes.EXPLICIT.id;
$scope.roles = [RoleType.SUBJECT, RoleType.PREDICATE, RoleType.OBJECT, RoleType.CONTEXT, RoleType.ALL];
$scope.isLicenseValid = $licenseService.isLicenseValid();
$scope.resourceInfo = undefined;

// Defaults
Expand Down Expand Up @@ -130,7 +129,7 @@ function ExploreCtrl(
};

$scope.loadResource = () => {
if (!$scope.isLicenseValid) {
if (!$licenseService.isLicenseValid()) {
return;
}
// Get resource details
Expand Down Expand Up @@ -535,7 +534,7 @@ function EditResourceCtrl($scope, $http, $location, toastr, $repositories, $uibM
};
$scope.newResource = false;
$scope.datatypeOptions = StatementsService.getDatatypeOptions();

$scope.isLicenseValid = $licenseService.isLicenseValid();
$scope.activeRepository = function () {
return $repositories.getActiveRepository();
};
Expand All @@ -548,10 +547,9 @@ function EditResourceCtrl($scope, $http, $location, toastr, $repositories, $uibM
$scope.validEditRow = validEditRow;
$scope.viewTrig = viewTrig;
$scope.save = save;
$scope.isLicenseValid = $licenseService.isLicenseValid();

function getClassInstancesDetails() {
if (!$scope.isLicenseValid) {
if (!$licenseService.isLicenseValid()) {
return;
}
RDF4JRepositoriesRestService.getNamespaces($scope.activeRepository())
Expand Down Expand Up @@ -588,7 +586,7 @@ function EditResourceCtrl($scope, $http, $location, toastr, $repositories, $uibM
$scope.$watch(function () {
return $repositories.getActiveRepository();
}, function () {
if ($scope.isLicenseValid && $scope.activeRepository()) {
if ($licenseService.isLicenseValid() && $scope.activeRepository()) {
$scope.getClassInstancesDetails();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li
let selectedGraph = allGraphs;

const initView = function () {
if (!$scope.getActiveRepository()) {
if (!$scope.getActiveRepository() && !$licenseService.isLicenseValid()) {
return;
}
return RDF4JRepositoriesRestService.resolveGraphs($repositories.getActiveRepository())
.success(function (graphsInRepo) {
$scope.graphsInRepo = graphsInRepo.results.bindings.length > 1002 ? graphsInRepo.results.bindings.slice(0, 1002) : 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'));
});
};

Expand Down Expand Up @@ -134,6 +134,10 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li
}
});

$scope.isLicenseValid = function() {
return $licenseService.isLicenseValid();
};

function instancesFilterFunc(inst) {
return inst.resolvedUri
.toLowerCase()
Expand Down Expand Up @@ -452,10 +456,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w

var g = appendMainGroup();

if (!scope.classHierarchyData.classCount && $repositories.getActiveRepository() && !$repositories.isSystemRepository()) {
if (!$licenseService.isLicenseValid()) {
return;
}
if (!scope.classHierarchyData.classCount && $repositories.getActiveRepository() && !$repositories.isSystemRepository() && $licenseService.isLicenseValid()) {
$rootScope.loader = true;
$rootScope.hierarchyError = false;
const selGraphFromCache = LocalStorageAdapter.get(`classHierarchy-selectedGraph-${$repositories.getActiveRepository()}`);
Expand Down
4 changes: 1 addition & 3 deletions src/js/angular/namespaces/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'to
$scope.page = 1;
$scope.pageSize = $scope.pageSizeOptions[0];
$scope.displayedNamespaces = [];
$scope.isLicenseValid = $licenseService.isLicenseValid();

$scope.getNamespaces = function () {
if (!$scope.isLicenseValid || !$repositories.getActiveRepository()) {
if (!$licenseService.isLicenseValid() || !$repositories.getActiveRepository()) {
return;
}

Expand Down Expand Up @@ -117,7 +116,6 @@ namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'to
$scope.searchNamespaces = '';
$scope.getNamespaces();
$scope.selectedAll = false;
$scope.isLicenseValid = $licenseService.isLicenseValid();
});

$scope.onNamespaceSearch = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function SimilarityCtrl(
$scope.isGraphDBRepository = undefined;
$scope.canEditRepo = $scope.canWriteActiveRepo();
$scope.loadSimilarityIndexesTimer = undefined;
$scope.isLicenseValid = $licenseService.isLicenseValid();

// =========================
// Public functions
Expand Down Expand Up @@ -275,7 +274,7 @@ function SimilarityCtrl(
};

const init = () => {
if (!$scope.isLicenseValid) {
if (!$licenseService.isLicenseValid()) {
return;
}
const activeRepository = $scope.getActiveRepository();
Expand All @@ -284,7 +283,7 @@ function SimilarityCtrl(
$scope.activeRepository = activeRepository;
$scope.isGraphDBRepository = checkIsGraphDBRepository();
if ($scope.isGraphDBRepository) {
if ($scope.isLicenseValid) {
if ($licenseService.isLicenseValid()) {
$scope.reloadSimilarityIndexes();
}
loadSearchQueries();
Expand Down
10 changes: 5 additions & 5 deletions src/pages/explore.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<link href="css/explore.css?v=[AIV]{version}[/AIV]" rel="stylesheet"/>

<div core-errors license></div>
<div class="page fit-content-on-mobile">
<div class="resource-info" ng-if="resourceInfo && !isTripleResource() && isLicenseValid">
<div class="page fit-content-on-mobile" ng-if="isLicenseValid()">
<div class="resource-info" ng-if="resourceInfo && !isTripleResource()">
<div class="thumb" ng-if="resourceInfo.details.img">
<a href="{{resourceInfo.details.img}}">
<img ng-src="{{details.img}}" alt="details image"/>
Expand Down Expand Up @@ -55,7 +55,7 @@ <h1 fit-text fit-text-min="30">
</p>
</div>

<div class="pull-right" ng-if="resourceInfo && isLicenseValid">
<div class="pull-right" ng-if="resourceInfo">

<label for="inference-select" class="mb-0">
<select id="inference-select"
Expand Down Expand Up @@ -122,7 +122,7 @@ <h1 fit-text fit-text-min="30">

</div>

<div id="selection" class="selection mb-1" ng-if="resourceInfo && isLicenseValid">
<div id="selection" class="selection mb-1" ng-if="resourceInfo">
<ul class="nav nav-tabs">
<li ng-repeat="role in roles" class="nav-item">
<a class="nav-link" href
Expand All @@ -136,7 +136,7 @@ <h1 fit-text fit-text-min="30">
</ul>
</div>

<yasgui-component id="query-editor" ng-if="isLicenseValid" yasgui-config="yasguiConfig"></yasgui-component>
<yasgui-component id="query-editor" yasgui-config="yasguiConfig"></yasgui-component>

<loader-component ng-if="isLoading"></loader-component>
</div>
2 changes: 1 addition & 1 deletion src/pages/namespaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>
<div class="ot-loader ot-main-loader" onto-loader size="50" ng-show="loader"></div>
<div id="wb-namespaces" ng-hide="loader">
<div core-errors license></div>
<div ng-show="getActiveRepository() && isLicenseValid">
<div ng-show="getActiveRepository() && isLicenseValid()">
<div class="clearfix mb-2">
<form novalidate name="form" class="form-inline pull-right add-namespace-form" ng-show="canWriteActiveRepo()">
<div class="form-group" style="width: 130px;">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/rdfClassHierarchyInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1>

<div class="top-offset" core-errors license></div>
<div class="top-offset" system-repo-warning></div>
<div class="top-offset alert alert-danger" ng-show="repositoryError">
<div class="top-offset alert alert-danger" ng-show="repositoryError && isLicenseValid()">
<p>{{'not.usable.active.repo.error' | translate}}</p>

<p>{{repositoryError}}</p>
Expand Down Expand Up @@ -135,7 +135,7 @@ <h1>
show-external-elements="showExternalElements"
hide-prefixes="hidePrefixes"
current-browser-limit="currentBrowserLimit"
ng-show="isLicenseValid() && hasClassHierarchy()">
ng-show="hasClassHierarchy()">
</rdf-class-hierarchy>

<pageslide
Expand Down
2 changes: 1 addition & 1 deletion test-cypress/integration/explore/similarity-index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Confirmations when try to change repository', () => {
let repositoryId;

beforeEach(() => {
const repositoryId = 'similarity-index-' + Date.now();
repositoryId = 'similarity-index-' + Date.now();
cy.createRepository({id: repositoryId});
cy.presetRepository(repositoryId);
cy.importServerFile(repositoryId, FILE_TO_IMPORT);
Expand Down

0 comments on commit 1be4c29

Please sign in to comment.