Skip to content

Commit

Permalink
Revert "GDB-9211: Add Pop-Up Menus for JSON-LD Export Selection" (#1227)
Browse files Browse the repository at this point in the history
* Revert "GDB-9211: Add Pop-Up Menus for JSON-LD Export Selection (#1183)"

This reverts commit d978f7a.

* disable sonar analysis

---------

Co-authored-by: svilen.velikov <svilen.velikov@ontotext.com>
  • Loading branch information
VPetrova00 and svilenvelikov authored Feb 1, 2024
1 parent 60c1d1b commit ae2aec4
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 299 deletions.
9 changes: 0 additions & 9 deletions src/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,6 @@
"required.field": "This field is required",
"created.repo.success.msg": "The repository {{repoId}} has been created.",
"empty.repoid.warning": "Repository ID cannot be empty",
"empty.context.or.frame.link": "Link cannot be empty",
"invalid.ruleset.file.error": "Invalid rule-set file. Please upload a valid one.",
"wrong.repo.name.error": "Wrong repo name",
"edit.system.repo.warning": "<b>System</b> repository can't be edited",
Expand Down Expand Up @@ -1649,14 +1648,6 @@
"error": "error",
"import.rdf.data.label": "Import RDF data",
"export.rdf.data": "Export RDF data",
"export.settings": "Export settings: JSON-LD",
"export": "Export",
"jsonld.mode": "JSON-LD mode",
"jsonld.mode.info": "JSON-LD mode allows you to choose different data formats for export",
"jsonld.context.link": "Context link",
"jsonld.frame.link": "Frame link",
"jsonld.frame.uri.placeholder": "http://example.com/frame.jsonld",
"jsonld.context.uri.placeholder": "http://example.com/context.jsonld",
"saved.sparql.queries.label": "Saved SPARQL queries",
"saved.sparql.queries.tooltip": "Execute a saved SPARQL query directly",
"common.execute": "Execute",
Expand Down
9 changes: 0 additions & 9 deletions src/i18n/locale-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,6 @@
"required.field": "Ce champ est requis",
"created.repo.success.msg": "Le dépôt {{repoId}} a été créé.",
"empty.repoid.warning": "L'identifiant du dépôt ne peut pas être vide",
"empty.context.or.frame.link": "Lien vers le cadre",
"invalid.ruleset.file.error": "Fichier de jeu de règles invalide. Veuillez en télécharger un valide.",
"wrong.repo.name.error": "Mauvais nom de repo",
"edit.system.repo.warning": "Le dépôt <b>System</b> ne peut pas être modifié.",
Expand Down Expand Up @@ -1641,14 +1640,6 @@
"error": "erreur",
"import.rdf.data.label": "Importer des données RDF",
"export.rdf.data": "Exporter des données RDF",
"export.settings": "Paramètres d'exportation: JSON-LD",
"export": "Exportation",
"jsonld.mode": "Mode JSON-LD",
"jsonld.mode.info": "Le mode JSON-LD vous permet de choisir différents formats de données pour l'exportation",
"jsonld.context.link": "Lien contextuel",
"jsonld.frame.link": "Lien vers le cadre",
"jsonld.frame.uri.placeholder": "http://example.com/frame.jsonld",
"jsonld.context.uri.placeholder": "http://example.com/context.jsonld",
"saved.sparql.queries.label": "Requêtes SPARQL sauvegardées",
"saved.sparql.queries.tooltip": "Exécuter directement une requête SPARQL sauvegardée",
"common.execute": "Exécuter",
Expand Down
130 changes: 7 additions & 123 deletions src/js/angular/export/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@ import 'angular/core/services';
import 'angular/core/services/repositories.service';
import 'angular/core/services/jwt-auth.service';
import 'angular/utils/file-types';
import 'angular/rest/export.rest.service';
import {saveAs} from 'lib/FileSaver-patch';
import {decodeHTML} from "../../../app";
import {cloneDeep, find} from "lodash";
import {cloneDeep} from "lodash";

const modules = [
'ngCookies',
'ui.bootstrap',
'toastr',
'graphdb.framework.core.services.repositories',
'graphdb.framework.core.services.jwtauth',
'graphdb.workbench.utils.filetypes',
'graphdb.framework.rest.export.service'
'graphdb.workbench.utils.filetypes'
];

const exportCtrl = angular.module('graphdb.framework.impex.export.controllers', modules);

exportCtrl.controller('ExportCtrl',
['$scope', '$http', '$location', '$timeout', 'ModalService', 'filterFilter', '$repositories', 'toastr', 'ExportRestService', 'RDF4JRepositoriesRestService',
'FileTypes', '$translate', 'AuthTokenService', '$uibModal',
function($scope, $http, $location, $timeout, ModalService, filterFilter, $repositories, toastr, ExportRestService, RDF4JRepositoriesRestService,
FileTypes, $translate, AuthTokenService, $uibModal) {
['$scope', '$http', '$location', '$timeout', 'ModalService', 'filterFilter', '$repositories', 'toastr', 'RDF4JRepositoriesRestService',
'FileTypes', '$translate', 'AuthTokenService',
function($scope, $http, $location, $timeout, ModalService, filterFilter, $repositories, toastr, RDF4JRepositoriesRestService,
FileTypes, $translate, AuthTokenService) {

$scope.getActiveRepository = function () {
return $repositories.getActiveRepository();
Expand Down Expand Up @@ -131,7 +128,7 @@ exportCtrl.controller('ExportCtrl',
if (auth) {
url = url + '&authToken=' + encodeURIComponent(auth);
}
const win = window.open(url);
let win = window.open(url);
$timeout(function () {
if (win.document.location.href !== 'about:blank') {
win.close();
Expand All @@ -141,40 +138,6 @@ exportCtrl.controller('ExportCtrl',

};

/*
*
* @method downloadJSONLDExport
* @param {String} data format
* @param {String} string context if there is any (or string from multiple contexts if there are multiple selected graphs)
* @param {String} context/frame link
* @param {Boolean} true if the method is invoked for export of multiple selected graphs
* @param {Object} current repository
* @param {Object} graphsByValue
* @param {Object} JSONLDMode (name and mode link)
*/
function downloadJSONLDExport(format, context, link, forSelectedGraphs, repo, graphsByValue, JSONLDMode) {
const acceptHeader = format.type + ';profile=' + JSONLDMode.link;
const headers = {
'accept': acceptHeader,
'link': link
};
ExportRestService.getExportedStatementsAsJSONLD(context, forSelectedGraphs, repo, graphsByValue, AuthTokenService.getAuthToken(), headers)
.then(function ({data, filename}) {
saveAs(data, filename);
})
.catch(function (res) {
// data is received as blob
res.data.text()
.then((message) => {
if (res.status === 431) {
toastr.error(res.statusText, $translate.instant('common.error'));
} else {
toastr.error(message, $translate.instant('common.error'));
}
});
});
};

/// <summary>Trigger the custom event for DD tooltip.</summary>
$scope.openExportDDTooltip = function () {
if ($scope.showExportDDTooltip) {
Expand Down Expand Up @@ -207,27 +170,6 @@ exportCtrl.controller('ExportCtrl',
}
};

/*
* Open a dialog with additional export settings for JSONLD format.
*
* @method openJSONLDExportSettings
* @param {String} data format
* @param {String} string context if there is any (or string from multiple contexts if there are multiple selected graphs for export)
* @param {Boolean} true if the method is invoked for multiple selected graphs export
*/
$scope.openJSONLDExportSettings = function (format, context, forSelectedGraphs) {
const modalInstance = $uibModal.open({
templateUrl: 'js/angular/export/templates/exportSettingsModal.html',
controller: 'ExportSettingsCtrl',
size: 'lg',
scope: $scope
});

modalInstance.result.then(function (data) {
downloadJSONLDExport(format, context, data.link, forSelectedGraphs, $repositories.getActiveRepositoryObject(), $scope.graphsByValue, data.currentMode);
});
};

$scope.startDownload = function (format, contextID) {
//If it's graph set the url for ?context=
let downloadUrl;
Expand All @@ -253,22 +195,6 @@ exportCtrl.controller('ExportCtrl',
}
};

$scope.openJSONLDExportSettingsForSelectedGraphs = function (format) {
const contextStr = Object.keys($scope.selectedGraphs.exportGraphs)
.map((index) => 'context=' + $scope.graphsByValue[index].exportUri)
.join('&');

if (contextStr) {
$scope.openJSONLDExportSettings(format, contextStr, true);
} else {
ModalService.openSimpleModal({
title: $translate.instant('export.multiple.graph'),
message: $translate.instant('export.check.graphs.msg'),
warning: true
});
}
};

$scope.exportSelectedGraphs = function (format) {
let contextStr = '';
for (const index in $scope.selectedGraphs.exportGraphs) {
Expand Down Expand Up @@ -480,45 +406,3 @@ exportCtrl.controller('ExportCtrl',
}
};
}]);

exportCtrl.controller("ExportSettingsCtrl",
['$scope', '$uibModalInstance', '$translate', 'toastr', function ($scope, $uibModalInstance, $translate, toastr) {
$scope.JSONLDModes = [
{name: "frame", link: "http://www.w3.org/ns/json-ld#frame"},
{name: "framed", link: "http://www.w3.org/ns/json-ld#framed"},
{name: "context", link: "http://www.w3.org/ns/json-ld#context"},
{name: "expanded", link: "http://www.w3.org/ns/json-ld#expanded"},
{name: "flattened", link: "http://www.w3.org/ns/json-ld#flattened"},
{name: "compacted", link: "http://www.w3.org/ns/json-ld#compacted"}
];

$scope.JSONLDModesNames = $scope.JSONLDModes.reduce(function (acc, cur) {
acc[cur.name] = cur.name;
return acc;
}, {});

$scope.JSONLDFramedModes = [$scope.JSONLDModesNames.framed, $scope.JSONLDModesNames.frame];
$scope.JSONLDContextModes = [$scope.JSONLDModesNames.context, $scope.JSONLDModesNames.compacted, $scope.JSONLDModesNames.flattened];
$scope.defaultMode = find($scope.JSONLDModes, {name: "expanded"});
$scope.currentMode = $scope.defaultMode;

$scope.cancel = function () {
$uibModalInstance.dismiss();
};

$scope.reset = function () {
$scope.currentMode = $scope.defaultMode;
};

$scope.exportJsonLD = function () {
if ($scope.currentMode !== $scope.defaultMode && !$scope.link) {
toastr.error($translate.instant('empty.context.or.frame.link'));
return;
}

$uibModalInstance.close({
currentMode: $scope.currentMode,
link: $scope.link
});
};
}]);
57 changes: 0 additions & 57 deletions src/js/angular/export/templates/exportSettingsModal.html

This file was deleted.

60 changes: 0 additions & 60 deletions src/js/angular/rest/export.rest.service.js

This file was deleted.

20 changes: 1 addition & 19 deletions src/pages/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,11 @@ <h1>
<span class="icon-trash"></span> {{'clear.repo.label' | translate}}
</button>
<div class="btn-group" uib-dropdown>
<button type="button" class="btn btn-primary dropdown-toggle export-repository-btn" uib-dropdown-toggle>
<button type="button" class="btn btn-primary dropdown-toggle" uib-dropdown-toggle>
<span class="icon-export"></span> {{'export.repository.label' | translate}}
</button>
<ul class="dropdown-menu">
<li ng-repeat="format in exportFormats" class="export-repo-format-JSONLD"
ng-if="format.name === 'JSON-LD';"
ng-click="openJSONLDExportSettings(format, false, false);">
<span class="dropdown-item">{{format.name}}</span>
</li>
<li ng-repeat="format in exportFormats" class="export-repo-format-{{format.name}}"
ng-if="format.name !== 'JSON-LD';"
ng-click="exportRepo(format, false);">
<span class="dropdown-item">{{format.name}}</span>
</li>
Expand Down Expand Up @@ -98,13 +92,7 @@ <h1>
<button type="button" class="btn btn-link dropdown-toggle" uib-dropdown-toggle gdb-tooltip="{{'export.selected.graphs.tooltip' | translate}}" ng-disabled="!hasMultipleSelected()">
<span class="icon-export"></span></button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="format in exportFormats" class="export-repo-format-{{format.name}}"
ng-if="format.name === 'JSON-LD';"
ng-click="openJSONLDExportSettingsForSelectedGraphs(format);">
<span class="dropdown-item">{{format.name}}</span>
</li>
<li ng-repeat="format in exportFormats"
ng-if="format.name !== 'JSON-LD';"
ng-click="exportSelectedGraphs(format)">
<span class="dropdown-item">{{format.name}}</span>
</li>
Expand Down Expand Up @@ -150,13 +138,7 @@ <h1>
ng-disabled="!graph.contextID.uri">
<span class="icon-export"></span></button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="format in exportFormats" class="export-repo-format-{{format.name}}"
ng-if="format.name === 'JSON-LD';"
ng-click="openJSONLDExportSettings(format, graph.contextID, false);">
<span class="dropdown-item">{{format.name}}</span>
</li>
<li ng-repeat="format in exportFormats"
ng-if="format.name !== 'JSON-LD';"
ng-click="exportRepo(format, graph.contextID);">
<span class="dropdown-item">{{format.name}}</span>
</li>
Expand Down
Loading

0 comments on commit ae2aec4

Please sign in to comment.