Skip to content

Commit

Permalink
GDB-6329 - fix most review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
DesiBorisova committed May 13, 2024
1 parent 3316e94 commit ec89037
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/js/angular/core/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ function multiRequired() {

const SEARCH_DISPLAY_TYPE = {table: 'table', visual: 'visual'};

searchResourceInput.$inject = ['$location', 'toastr', 'ClassInstanceDetailsService', 'AutocompleteRestService', '$rootScope', '$q', '$sce', 'LocalStorageAdapter', 'LSKeys', '$repositories', '$translate', 'GuidesService', '$licenseService'];
searchResourceInput.$inject = ['$location', 'toastr', 'ClassInstanceDetailsService', 'AutocompleteRestService', '$rootScope', '$q', '$sce', 'LocalStorageAdapter', 'LSKeys', '$repositories', '$translate', 'GuidesService'];

function searchResourceInput($location, toastr, ClassInstanceDetailsService, AutocompleteRestService, $rootScope, $q, $sce, LocalStorageAdapter, LSKeys, $repositories, $translate, GuidesService, $licenseService) {
function searchResourceInput($location, toastr, ClassInstanceDetailsService, AutocompleteRestService, $rootScope, $q, $sce, LocalStorageAdapter, LSKeys, $repositories, $translate, GuidesService) {
return {
restrict: 'EA',
scope: {
Expand Down Expand Up @@ -333,7 +333,7 @@ function searchResourceInput($location, toastr, ClassInstanceDetailsService, Aut
};

$scope.$watch('namespacespromise', function () {
if (angular.isDefined($scope.namespacespromise) && $licenseService.isLicenseValid()) {
if (angular.isDefined($scope.namespacespromise)) {
$scope.namespacespromise.success(function (data) {
element.namespaces = data.results.bindings.map(function (e) {
return {
Expand Down
2 changes: 0 additions & 2 deletions src/js/angular/core/services/license.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ function licenseService($rootScope, LicenseRestService, $translate) {
that.loadingLicense = false;
updateProductType(that.license);
});
}).finally(function () {
$rootScope.$broadcast('license.set');
});
};

Expand Down
3 changes: 1 addition & 2 deletions src/js/angular/explore/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ 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 Down Expand Up @@ -586,7 +585,7 @@ function EditResourceCtrl($scope, $http, $location, toastr, $repositories, $uibM
$scope.$watch(function () {
return $repositories.getActiveRepository();
}, function () {
if ($licenseService.isLicenseValid() && $scope.activeRepository()) {
if ($scope.activeRepository()) {
$scope.getClassInstancesDetails();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,16 +1189,12 @@ function GraphsVisualizationsCtrl(
return $repositories.getActiveRepository();
};

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

// This method may be called twice - once by us explicitly and once by the repositoryInit event.
// In some race conditions getActiveRepository() will be already set when we enter it the first
// 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 (!$scope.isLicenseValid() || !$repositories.getActiveRepository() || $scope.hasInitedRepository && !newRepo) {
if (!$licenseService.isLicenseValid() || !$repositories.getActiveRepository() || $scope.hasInitedRepository && !newRepo) {
return;
}

Expand Down Expand Up @@ -1226,7 +1222,7 @@ function GraphsVisualizationsCtrl(
}

function checkAutocompleteStatus() {
if ($scope.isLicenseValid()) {
if ($licenseService.isLicenseValid()) {
$scope.getAutocompletePromise = AutocompleteRestService.checkAutocompleteStatus();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li
let selectedGraph = allGraphs;

const initView = function () {
if (!$scope.getActiveRepository() && !$licenseService.isLicenseValid()) {
if (!$scope.getActiveRepository() || !$licenseService.isLicenseValid()) {
return;
}
return RDF4JRepositoriesRestService.resolveGraphs($repositories.getActiveRepository())
Expand Down Expand Up @@ -452,12 +452,9 @@ function RdfClassHierarchyCtlr($scope, $rootScope, $location, $repositories, $li
}

function getClassHierarchyData() {
if (!$licenseService.isLicenseValid()) {
return;
}
refreshDiagramExternalElements();

if (!$scope.isSystemRepository()) {
if (!$scope.isSystemRepository() && $licenseService.isLicenseValid()) {
$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,7 +107,7 @@ 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() && $licenseService.isLicenseValid()) {
$rootScope.loader = true;
$rootScope.hierarchyError = false;
const selGraphFromCache = LocalStorageAdapter.get(`classHierarchy-selectedGraph-${$repositories.getActiveRepository()}`);
Expand All @@ -124,9 +124,6 @@ function classHierarchyDirective($rootScope, $location, GraphDataRestService, $w

}).error(function (response) {
$rootScope.loader = false;
if (!$licenseService.isLicenseValid()) {
return;
}
$rootScope.hierarchyError = getError(response);
toastr.error($translate.instant('graphexplore.error.request.failed', {name: ROOT_OBJ_NAME, error: getError(response)}));
});
Expand Down
18 changes: 12 additions & 6 deletions src/js/angular/jdbc/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ angular.module('graphdb.framework.jdbc.controllers', modules, [
.controller('JdbcListCtrl', JdbcListCtrl)
.controller('JdbcCreateCtrl', JdbcCreateCtrl);

JdbcListCtrl.$inject = ['$scope', '$repositories', 'JdbcRestService', 'toastr', 'ModalService', '$translate'];
JdbcListCtrl.$inject = ['$scope', '$repositories', 'JdbcRestService', 'toastr', 'ModalService', '$translate', '$licenseService'];

function JdbcListCtrl($scope, $repositories, JdbcRestService, toastr, ModalService, $translate) {
function JdbcListCtrl($scope, $repositories, JdbcRestService, toastr, ModalService, $translate, $licenseService) {

$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 ($scope.isLicenseValid()
if ($licenseService.isLicenseValid()
&& $repositories.getActiveRepository()
&& !$repositories.isActiveRepoOntopType()
&& !$repositories.isActiveRepoFedXType()) {
Expand Down Expand Up @@ -85,7 +85,8 @@ JdbcCreateCtrl.$inject = [
'ModalService',
'$translate',
'$languageService',
'EventEmitterService'];
'EventEmitterService',
'$licenseService'];

function JdbcCreateCtrl(
$q,
Expand All @@ -103,7 +104,8 @@ function JdbcCreateCtrl(
ModalService,
$translate,
$languageService,
EventEmitterService) {
EventEmitterService,
$licenseService) {

$scope.emptySparqlResponse = "{\"head\": {\"vars\": []},\"results\": {\"bindings\": []}}";
$scope.getSuggestionSqlType = '';
Expand All @@ -128,6 +130,10 @@ function JdbcCreateCtrl(
// Public functions
// =========================

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

$scope.saveJdbcConfiguration = () => {
$scope.saveOrUpdateExecuted = true;

Expand Down Expand Up @@ -316,7 +322,7 @@ function JdbcCreateCtrl(
};

const init = (prefixes, jdbcConfiguration = new JdbcConfigurationInfo()) => {
if (!$scope.isLicenseValid()) {
if (!$licenseService.isLicenseValid()) {
return;
}
$scope.jdbcConfigurationInfo.columns = jdbcConfiguration.columns;
Expand Down
4 changes: 4 additions & 0 deletions src/js/angular/namespaces/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespaces.controller('NamespacesCtrl', ['$scope', '$http', '$repositories', 'to
$scope.pageSize = $scope.pageSizeOptions[0];
$scope.displayedNamespaces = [];

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

$scope.getNamespaces = function () {
if (!$licenseService.isLicenseValid() || !$repositories.getActiveRepository()) {
return;
Expand Down
4 changes: 4 additions & 0 deletions src/js/angular/plugins/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function PluginsCtrl($scope, $interval, toastr, $repositories, $licenseService,
getPlugins();
};

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

$scope.clear = function () {
$scope.searchPluginsTerm = '';
$scope.plugins = [];
Expand Down
8 changes: 6 additions & 2 deletions src/js/angular/queries/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const queriesCtrl = angular.module('graphdb.framework.jmx.queries.controllers',
]);

queriesCtrl.controller('QueriesCtrl', ['$scope', '$uibModal', 'toastr', '$interval', '$repositories', '$jwtAuth', 'ModalService',
'MonitoringRestService', '$translate', 'AuthTokenService',
function ($scope, $uibModal, toastr, $interval, $repositories, $jwtAuth, ModalService, MonitoringRestService, $translate, AuthTokenService) {
'MonitoringRestService', '$translate', 'AuthTokenService', '$licenseService',
function ($scope, $uibModal, toastr, $interval, $repositories, $jwtAuth, ModalService, MonitoringRestService, $translate, AuthTokenService, $licenseService) {

$scope.loader = true;
$scope.stringLimit = 500;
Expand Down Expand Up @@ -140,6 +140,10 @@ queriesCtrl.controller('QueriesCtrl', ['$scope', '$uibModal', 'toastr', '$interv
$scope.toggleQueryExpanded = function (queryId) {
$scope.expanded[queryId] = !$scope.expanded[queryId];
};

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


Expand Down
10 changes: 8 additions & 2 deletions src/js/angular/sparql-editor/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ SparqlEditorCtrl.$inject = [
'GuidesService',
'ModalService',
'MonitoringRestService',
'EventEmitterService'];
'EventEmitterService',
'$licenseService'];

function SparqlEditorCtrl($rootScope,
$scope,
Expand All @@ -60,7 +61,8 @@ function SparqlEditorCtrl($rootScope,
GuidesService,
ModalService,
MonitoringRestService,
EventEmitterService) {
EventEmitterService,
$licenseService) {
this.repository = '';

const QUERY_EDITOR_ID = '#query-editor';
Expand Down Expand Up @@ -99,6 +101,10 @@ function SparqlEditorCtrl($rootScope,
};
};

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

$scope.getActiveRepositoryNoError = () => {
return $repositories.getActiveRepository();
};
Expand Down

0 comments on commit ec89037

Please sign in to comment.