diff --git a/src/i18n/locale-en.json b/src/i18n/locale-en.json index aaabaa6a9..28fbe4a34 100644 --- a/src/i18n/locale-en.json +++ b/src/i18n/locale-en.json @@ -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": "System repository can't be edited", @@ -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", diff --git a/src/i18n/locale-fr.json b/src/i18n/locale-fr.json index 10b4af7ee..8ad43754f 100644 --- a/src/i18n/locale-fr.json +++ b/src/i18n/locale-fr.json @@ -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 System ne peut pas être modifié.", @@ -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", diff --git a/src/js/angular/export/controllers.js b/src/js/angular/export/controllers.js index 9c8e0c966..af7eff4fd 100644 --- a/src/js/angular/export/controllers.js +++ b/src/js/angular/export/controllers.js @@ -2,10 +2,8 @@ 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', @@ -13,17 +11,16 @@ const modules = [ '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(); @@ -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(); @@ -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')); - } - }); - }); - }; - /// Trigger the custom event for DD tooltip. $scope.openExportDDTooltip = function () { if ($scope.showExportDDTooltip) { @@ -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; @@ -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) { @@ -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 - }); - }; - }]); diff --git a/src/js/angular/export/templates/exportSettingsModal.html b/src/js/angular/export/templates/exportSettingsModal.html deleted file mode 100644 index 3a8361625..000000000 --- a/src/js/angular/export/templates/exportSettingsModal.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - diff --git a/src/js/angular/rest/export.rest.service.js b/src/js/angular/rest/export.rest.service.js deleted file mode 100644 index 668f484bc..000000000 --- a/src/js/angular/rest/export.rest.service.js +++ /dev/null @@ -1,60 +0,0 @@ -angular - .module('graphdb.framework.rest.export.service', []) - .factory('ExportRestService', ExportRestService); - -ExportRestService.$inject = ['$http', '$repositories', '$translate']; - -const REPOSITORIES_ENDPOINT = 'repositories'; -function ExportRestService($http, $repositories, $translate) { - return { - getExportedStatementsAsJSONLD - }; - - /* - * - * @method getExportedStatementsAsJSONLD - * @param {String} data format - * @param {Boolean} true if the method is invoked for export of multiple selected graphs - * @param {Object} current repository - * @param {Object} graphsByValue - * @param {Object} authentication token - * @param {Object} request Accept and Link headers - */ - function getExportedStatementsAsJSONLD(context, forSelectedGraphs, repo, graphsByValue, auth, headers) { - let url = `${REPOSITORIES_ENDPOINT}/${repo.id}/statements?infer=false`; - if (forSelectedGraphs) { - url += `&${context}`; - } else { - if (context) { - url += `&context=${graphsByValue[context.value].exportUri}&location=${encodeURIComponent(repo.location)}`; - } else { - url += `&location=${encodeURIComponent(repo.location)}`; - } - } - - if (auth) { - url = url + '&authToken=' + encodeURIComponent(auth); - } - - if (headers.link === undefined) { - headers.link = ""; - } - - return $http({ - url: url, - method: 'GET', - headers: { - 'Accept': headers.accept, - 'Link': headers.link - }, - responseType: "blob" - }).then(function (res) { - const data = res.data; - const headers = res.headers(); - const contentDisposition = headers['content-disposition']; - let filename = contentDisposition.split('filename=')[1]; - filename = filename.substring(0, filename.length); - return {data, filename}; - }); - } -} diff --git a/src/pages/export.html b/src/pages/export.html index 650874d91..3a0c32e89 100644 --- a/src/pages/export.html +++ b/src/pages/export.html @@ -57,17 +57,11 @@

{{'clear.repo.label' | translate}}
-