diff --git a/public/dist/main.js b/public/dist/main.js index f8989e7..bf5230d 100644 --- a/public/dist/main.js +++ b/public/dist/main.js @@ -325,7 +325,7 @@ eval("const DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \". \***************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -eval("const DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\n\n// hinzufügen eines Controllers zum Modul\nfunction ArtifactPageController($scope, $http, $sce, $location, collectionManager) {\n\n $scope.collectionManager = collectionManager;\n $scope.authenticated = data.auth.authenticated;\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.tabNavigation = new TabNavigation($scope, $location, [\n 'files', 'versions', 'edit'\n ]);\n\n $scope.versions = data.versions;\n $scope.artifact = data.artifact;\n $scope.accountName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.artifact.uri, 2));\n $scope.canEdit = $scope.accountName == data.auth.info.accountName;\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.artifact.title,\n DatabusUtils.uriToTitle($scope.artifact.uri));\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n $scope.formData = {};\n $scope.formData.group = {};\n $scope.formData.group.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.artifact.uri));\n $scope.formData.artifact = {};\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.artifact.description);\n $scope.formData.artifact.generateAbstract = abstract == $scope.artifact.abstract;\n $scope.formData.artifact.name = $scope.artifact.name;\n $scope.formData.artifact.title = $scope.artifact.title;\n $scope.formData.artifact.abstract = $scope.artifact.abstract;\n $scope.formData.artifact.description = $scope.artifact.description;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'version', label: 'Version', width: '30%' });\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '30%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '12%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '12%' });\n\n $scope.artifactNode = new QueryNode($scope.artifact.uri, 'databus:artifact');\n $scope.artifactNode.setFacet('http://purl.org/dc/terms/hasVersion', '$latest', true);\n\n $scope.groupNode = new QueryNode(DatabusUtils.navigateUp($scope.artifact.uri), 'databus:group');\n $scope.groupNode.addChild($scope.artifactNode);\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n $scope.onFacetSettingsChanged();\n\n\n $scope.onFileSelectionChanged = function (numFiles, totalSize) {\n $scope.fileSelector.numFiles = numFiles;\n $scope.fileSelector.totalSize = totalSize;\n };\n\n $scope.formatId = function (id) {\n return DatabusCollectionUtils.formatId(id);\n };\n\n $scope.addArtifactNodeToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n wrapper.addArtifactNode(\n $scope.artifact.uri,\n $scope.artifact.title,\n $scope.fileSelector.settings);\n\n $scope.collectionManager.saveLocally();\n $scope.statusCode = 1;\n };\n\n $scope.changeCollection = function (collection) {\n if (!$scope.authenticated) {\n return;\n }\n\n $scope.collectionManager.setActive(collection.uuid);\n }\n\n\n $scope.hideAutofill = function () {\n $scope.fileSelector.clearAutofill(function () {\n $scope.$apply();\n });\n }\n\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.artifact.generateAbstract) {\n return;\n }\n\n $scope.formData.artifact.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.artifact.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.artifact.title = $scope.artifact.title;\n $scope.formData.artifact.abstract = $scope.artifact.abstract;\n $scope.formData.artifact.description = $scope.artifact.description;\n }\n\n $scope.saveArtifact = async function () {\n\n if ($scope.dataidCreator == null) {\n return;\n }\n\n var artifactUpdate = $scope.dataidCreator.createArtifactUpdate();\n\n var relativeUri = new URL($scope.artifact.uri).pathname;\n var response = await $http.put(relativeUri, artifactUpdate);\n\n if (response.status == 200) {\n $scope.artifact.title = $scope.formData.artifact.title;\n $scope.artifact.abstract = $scope.formData.artifact.abstract;\n $scope.artifact.description = $scope.formData.artifact.description;\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.artifact.title,\n DatabusUtils.uriToTitle($scope.artifact.uri));\n\n DatabusAlert.alert($scope, true, \"Artifact Saved!\");\n $scope.$apply();\n }\n }\n\n\n}\n\n\nmodule.exports = ArtifactPageController;\n\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/artifact-controller.js?"); +eval("const DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\n\n// hinzufügen eines Controllers zum Modul\nfunction ArtifactPageController($scope, $http, $sce, $location, collectionManager) {\n\n $scope.collectionManager = collectionManager;\n $scope.authenticated = data.auth.authenticated;\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.tabNavigation = new TabNavigation($scope, $location, [\n 'files', 'versions', 'edit'\n ]);\n\n $scope.versions = data.versions;\n $scope.artifact = data.artifact;\n $scope.accountName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.artifact.uri, 2));\n $scope.canEdit = $scope.accountName == data.auth.info.accountName;\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.artifact.title,\n DatabusUtils.uriToTitle($scope.artifact.uri));\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n $scope.formData = {};\n $scope.formData.group = {};\n $scope.formData.group.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.artifact.uri));\n $scope.formData.artifact = {};\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.artifact.description);\n $scope.formData.artifact.generateAbstract = abstract == $scope.artifact.abstract;\n $scope.formData.artifact.name = $scope.artifact.name;\n $scope.formData.artifact.title = $scope.artifact.title;\n $scope.formData.artifact.abstract = $scope.artifact.abstract;\n $scope.formData.artifact.description = $scope.artifact.description;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.authenticated = $scope.authenticated;\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'version', label: 'Version', width: '30%' });\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '30%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '12%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '12%' });\n\n $scope.artifactNode = new QueryNode($scope.artifact.uri, 'databus:artifact');\n $scope.artifactNode.setFacet('http://purl.org/dc/terms/hasVersion', '$latest', true);\n\n $scope.groupNode = new QueryNode(DatabusUtils.navigateUp($scope.artifact.uri), 'databus:group');\n $scope.groupNode.addChild($scope.artifactNode);\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n $scope.onFacetSettingsChanged();\n\n\n $scope.onFileSelectionChanged = function (numFiles, totalSize) {\n $scope.fileSelector.numFiles = numFiles;\n $scope.fileSelector.totalSize = totalSize;\n };\n\n $scope.formatId = function (id) {\n return DatabusCollectionUtils.formatId(id);\n };\n\n $scope.addArtifactNodeToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n wrapper.addArtifactNode(\n $scope.artifact.uri,\n $scope.artifact.title,\n $scope.fileSelector.settings);\n\n $scope.collectionManager.saveLocally();\n $scope.statusCode = 1;\n };\n\n $scope.changeCollection = function (collection) {\n if (!$scope.authenticated) {\n return;\n }\n\n $scope.collectionManager.setActive(collection.uuid);\n }\n\n\n $scope.hideAutofill = function () {\n $scope.fileSelector.clearAutofill(function () {\n $scope.$apply();\n });\n }\n\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.artifact.generateAbstract) {\n return;\n }\n\n $scope.formData.artifact.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.artifact.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.artifact.title = $scope.artifact.title;\n $scope.formData.artifact.abstract = $scope.artifact.abstract;\n $scope.formData.artifact.description = $scope.artifact.description;\n }\n\n $scope.saveArtifact = async function () {\n\n if ($scope.dataidCreator == null) {\n return;\n }\n\n var artifactUpdate = $scope.dataidCreator.createArtifactUpdate();\n\n var relativeUri = new URL($scope.artifact.uri).pathname;\n var response = await $http.put(relativeUri, artifactUpdate);\n\n if (response.status == 200) {\n $scope.artifact.title = $scope.formData.artifact.title;\n $scope.artifact.abstract = $scope.formData.artifact.abstract;\n $scope.artifact.description = $scope.formData.artifact.description;\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.artifact.title,\n DatabusUtils.uriToTitle($scope.artifact.uri));\n\n DatabusAlert.alert($scope, true, \"Artifact Saved!\");\n $scope.$apply();\n }\n }\n\n\n}\n\n\nmodule.exports = ArtifactPageController;\n\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/artifact-controller.js?"); /***/ }), @@ -365,7 +365,7 @@ eval("const DatabusUris = __webpack_require__(/*! ../utils/databus-uris */ \"./j \************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -eval("const DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusConstants = __webpack_require__(/*! ../utils/databus-constants */ \"./js/utils/databus-constants.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\n\nfunction GroupPageController($scope, $http, $sce, $interval, $location, collectionManager) {\n\n $scope.group = data.group;\n $scope.accountName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.group.uri));\n\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.tabNavigation = new TabNavigation($scope, $location, [\n 'files', 'artifacts', 'edit'\n ]);\n\n $scope.dataSearchInput = \"\";\n $scope.dataSearchSettings = {\n minRelevance: 0.01,\n maxResults: 10,\n placeholder: `Search ${$scope.accountName}'s data...`,\n resourceTypes: ['Artifact'],\n filter: `&publisher=${$scope.accountName}&typeNameWeight=0&group=${$scope.group.name}`\n };\n\n\n $scope.group.hasData = false;\n $scope.group.hasArtifacts = false;\n $scope.isLoading = true;\n\n $http({\n method: 'GET',\n url: `/app/group/get-artifacts?uri=${encodeURIComponent($scope.group.uri)}`\n }).then(function successCallback(response) {\n\n $scope.artifacts = response.data;\n\n for (var artifact of $scope.artifacts) {\n if (artifact.latestVersionDate != undefined) {\n $scope.group.hasData = true;\n }\n\n artifact.title = DatabusUtils.stringOrFallback(artifact.title, artifact.latestVersionTitle);\n artifact.abstract = DatabusUtils.stringOrFallback(artifact.abstract, artifact.latestVersionAbstract);\n artifact.description = DatabusUtils.stringOrFallback(artifact.description, artifact.latestVersionDescription);\n }\n\n $scope.group.hasArtifacts = $scope.artifacts.length > 0;\n $scope.isLoading = false;\n }, function errorCallback(response) {\n $scope.isLoading = false;\n });\n\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.group.title,\n DatabusUtils.uriToTitle($scope.group.uri));\n\n\n $scope.canEdit = $scope.accountName == data.auth.info.accountName;\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.group.description);\n $scope.formData = {};\n $scope.formData.group = {};\n $scope.formData.group.generateAbstract = abstract == $scope.group.abstract;\n $scope.formData.group.name = $scope.group.name;\n $scope.formData.group.title = $scope.group.title;\n $scope.formData.group.abstract = $scope.group.abstract;\n $scope.formData.group.description = $scope.group.description;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.group.generateAbstract) {\n return;\n }\n\n $scope.formData.group.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.group.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.group.title = $scope.group.title;\n $scope.formData.group.abstract = $scope.group.abstract;\n $scope.formData.group.description = $scope.group.description;\n }\n\n $scope.saveGroup = async function () {\n\n if ($scope.dataidCreator == null) {\n return;\n }\n\n var groupUpdate = $scope.dataidCreator.createGroupUpdate();\n\n var relativeUri = new URL($scope.group.uri).pathname;\n var response = await $http.put(relativeUri, groupUpdate);\n\n if (response.status == 200) {\n $scope.group.title = $scope.formData.group.title;\n $scope.group.abstract = $scope.formData.group.abstract;\n $scope.group.description = $scope.formData.group.description;\n\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.group.title,\n DatabusUtils.uriToTitle($scope.group.uri));\n\n DatabusAlert.alert($scope, true, \"Group Saved!\");\n $scope.$apply();\n }\n }\n\n $scope.facetsView = {};\n $scope.facetsView.resourceUri = $scope.group.uri;\n $scope.facetsView.settings = [];\n $scope.facetsView.parentSettings = null;\n $scope.authenticated = data.auth.authenticated;\n $scope.selection = [];\n\n $scope.input = {};\n $scope.input.search = '';\n $scope.searchCooldown = 500;\n $scope.searchChanged = true;\n $scope.searchReady = true;\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'artifact', label: 'Artifact', width: '30%', uriToName: true });\n $scope.fileSelector.config.columns.push({ field: 'version', label: 'Version', width: '21%' });\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '16%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '9%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '6%' });\n\n $scope.groupNode = new QueryNode($scope.group.uri, 'databus:group');\n $scope.groupNode.setFacet('http://purl.org/dc/terms/hasVersion', DatabusConstants.FACET_LATEST_VERSION_VALUE, true);\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.groupNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.groupNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n // $scope.onFacetSettingsChanged();\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFileQueryResult = function (args) {\n if (args == null) return;\n $scope.collectionWidgetSelectionData.query = args.query;\n }\n\n $scope.collectionManager = collectionManager;\n\n $scope.findArtifact = function (uri) {\n return $scope.artifacts.find(function (a) { a.uri === uri; });\n }\n\n $scope.formatResult = function (result) {\n return $sce.trustAsHtml(result);\n }\n\n\n $scope.formatLicense = function (licenseUri) {\n var licenseName = DatabusUtils.uriToName(licenseUri);\n\n var html = '
' + licenseName + '
'\n return $sce.trustAsHtml(html);\n }\n\n for (var a in $scope.artifacts) {\n $scope.artifacts[a].date = $scope.formatDate($scope.artifacts[a].date);\n $scope.artifacts[a].licenseTag = $scope.formatLicense($scope.artifacts[a].license);\n }\n\n $scope.setSelectionStateAll = function (val) {\n if (val) {\n for (var a in $scope.artifacts) {\n $scope.select($scope.artifacts[a]);\n }\n } else {\n for (var a in $scope.artifacts) {\n $scope.deselect($scope.artifacts[a]);\n }\n }\n }\n\n $scope.toggleSelect = function (artifact) {\n if ($scope.isSelected(artifact)) {\n $scope.deselect(artifact);\n } else {\n $scope.select(artifact);\n }\n }\n\n $scope.select = function (artifact) {\n artifact.isSelected = true;\n $scope.selection.push(artifact.uri);\n }\n\n $scope.deselect = function (artifact) {\n artifact.isSelected = false;\n $scope.selection = $scope.selection.filter(function (value, index, arr) {\n return value !== artifact.uri;\n });\n }\n\n $scope.isSelected = function (artifact) {\n for (var s in $scope.selection) {\n if ($scope.selection[s] === artifact.uri) {\n return true;\n }\n }\n return false;\n }\n\n $scope.changeCollection = function (collection) {\n $scope.collectionManager.setActive(collection.uuid);\n $scope.search();\n }\n\n $scope.showCollectionModal = function () {\n $('#add-to-collection-modal').addClass('is-active');\n }\n\n $scope.hideCollectionModal = function () {\n $('#add-to-collection-modal').removeClass('is-active');\n }\n\n $scope.markdownToHtml = function (markdown) {\n\n var converter = window.markdownit();\n return $sce.trustAsHtml(converter.render(markdown));\n };\n\n\n $scope.invokeSearch = function () {\n if ($scope.searchReady) {\n $scope.search();\n $scope.searchReady = false;\n } else {\n $scope.searchChanged = true;\n }\n }\n\n $interval(function () {\n if ($scope.searchChanged) {\n $scope.search();\n $scope.searchChanged = false;\n }\n $scope.searchReady = true;\n }, $scope.searchCooldown);\n\n\n $scope.addSelectionToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n\n for (var s in $scope.selection) {\n var artifact = $scope.artifacts.find(function (a) { return a.uri === $scope.selection[s]; });\n wrapper.addArtifactNode(artifact.uri, artifact.label);\n }\n $scope.collectionManager.saveLocally();\n $scope.search();\n }\n\n $scope.updateArtifactState = function (wrapper, artifact) {\n artifact.alreadyAdded = wrapper.hasArtifact(artifact.uri);\n artifact.isSelected = artifact.alreadyAdded || $scope.selection.includes(artifact.uri);\n }\n\n\n\n $scope.search = function () {\n\n $scope.searchResult = [];\n\n var typeFilters = `&publisher=${$scope.accountName}&publisherWeight=0&typeName=Artifact&typeNameWeight=0&group=${$scope.group.name}&minRelevance=0.1`;\n\n $http({\n method: 'GET',\n url: '/api/search?query=' + $scope.input.search + typeFilters\n }).then(function successCallback(response) {\n\n for (var r in response.data.docs) {\n var result = response.data.docs[r];\n\n for (var artifact of $scope.artifacts) {\n if (result.resource[0] == artifact.uri) {\n $scope.searchResult.push(artifact);\n }\n }\n }\n }, function errorCallback(response) {\n });\n }\n}\n\nmodule.exports = GroupPageController;\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/group-controller.js?"); +eval("const DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusConstants = __webpack_require__(/*! ../utils/databus-constants */ \"./js/utils/databus-constants.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\n\nfunction GroupPageController($scope, $http, $sce, $interval, $location, collectionManager) {\n\n $scope.group = data.group;\n $scope.accountName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.group.uri));\n\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.tabNavigation = new TabNavigation($scope, $location, [\n 'files', 'artifacts', 'edit'\n ]);\n\n $scope.dataSearchInput = \"\";\n $scope.dataSearchSettings = {\n minRelevance: 0.01,\n maxResults: 10,\n placeholder: `Search ${$scope.accountName}'s data...`,\n resourceTypes: ['Artifact'],\n filter: `&publisher=${$scope.accountName}&typeNameWeight=0&group=${$scope.group.name}`\n };\n\n\n $scope.group.hasData = false;\n $scope.group.hasArtifacts = false;\n $scope.isLoading = true;\n\n $http({\n method: 'GET',\n url: `/app/group/get-artifacts?uri=${encodeURIComponent($scope.group.uri)}`\n }).then(function successCallback(response) {\n\n $scope.artifacts = response.data;\n\n for (var artifact of $scope.artifacts) {\n if (artifact.latestVersionDate != undefined) {\n $scope.group.hasData = true;\n }\n\n artifact.title = DatabusUtils.stringOrFallback(artifact.title, artifact.latestVersionTitle);\n artifact.abstract = DatabusUtils.stringOrFallback(artifact.abstract, artifact.latestVersionAbstract);\n artifact.description = DatabusUtils.stringOrFallback(artifact.description, artifact.latestVersionDescription);\n }\n\n $scope.group.hasArtifacts = $scope.artifacts.length > 0;\n $scope.isLoading = false;\n }, function errorCallback(response) {\n $scope.isLoading = false;\n });\n\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.group.title,\n DatabusUtils.uriToTitle($scope.group.uri));\n\n\n $scope.canEdit = $scope.accountName == data.auth.info.accountName;\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.group.description);\n $scope.formData = {};\n $scope.formData.group = {};\n $scope.formData.group.generateAbstract = abstract == $scope.group.abstract;\n $scope.formData.group.name = $scope.group.name;\n $scope.formData.group.title = $scope.group.title;\n $scope.formData.group.abstract = $scope.group.abstract;\n $scope.formData.group.description = $scope.group.description;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.group.generateAbstract) {\n return;\n }\n\n $scope.formData.group.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.group.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.group.title = $scope.group.title;\n $scope.formData.group.abstract = $scope.group.abstract;\n $scope.formData.group.description = $scope.group.description;\n }\n\n $scope.saveGroup = async function () {\n\n if ($scope.dataidCreator == null) {\n return;\n }\n\n var groupUpdate = $scope.dataidCreator.createGroupUpdate();\n\n var relativeUri = new URL($scope.group.uri).pathname;\n var response = await $http.put(relativeUri, groupUpdate);\n\n if (response.status == 200) {\n $scope.group.title = $scope.formData.group.title;\n $scope.group.abstract = $scope.formData.group.abstract;\n $scope.group.description = $scope.formData.group.description;\n\n\n $scope.pageTitle = DatabusUtils.stringOrFallback($scope.group.title,\n DatabusUtils.uriToTitle($scope.group.uri));\n\n DatabusAlert.alert($scope, true, \"Group Saved!\");\n $scope.$apply();\n }\n }\n\n $scope.facetsView = {};\n $scope.facetsView.resourceUri = $scope.group.uri;\n $scope.facetsView.settings = [];\n $scope.facetsView.parentSettings = null;\n $scope.authenticated = data.auth.authenticated;\n $scope.selection = [];\n\n $scope.input = {};\n $scope.input.search = '';\n $scope.searchCooldown = 500;\n $scope.searchChanged = true;\n $scope.searchReady = true;\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.authenticated = $scope.authenticated;\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'artifact', label: 'Artifact', width: '30%', uriToName: true });\n $scope.fileSelector.config.columns.push({ field: 'version', label: 'Version', width: '21%' });\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '16%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '9%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '6%' });\n\n $scope.groupNode = new QueryNode($scope.group.uri, 'databus:group');\n $scope.groupNode.setFacet('http://purl.org/dc/terms/hasVersion', DatabusConstants.FACET_LATEST_VERSION_VALUE, true);\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.groupNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.groupNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n // $scope.onFacetSettingsChanged();\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFileQueryResult = function (args) {\n if (args == null) return;\n $scope.collectionWidgetSelectionData.query = args.query;\n }\n\n $scope.collectionManager = collectionManager;\n\n $scope.findArtifact = function (uri) {\n return $scope.artifacts.find(function (a) { a.uri === uri; });\n }\n\n $scope.formatResult = function (result) {\n return $sce.trustAsHtml(result);\n }\n\n\n $scope.formatLicense = function (licenseUri) {\n var licenseName = DatabusUtils.uriToName(licenseUri);\n\n var html = '
' + licenseName + '
'\n return $sce.trustAsHtml(html);\n }\n\n for (var a in $scope.artifacts) {\n $scope.artifacts[a].date = $scope.formatDate($scope.artifacts[a].date);\n $scope.artifacts[a].licenseTag = $scope.formatLicense($scope.artifacts[a].license);\n }\n\n $scope.setSelectionStateAll = function (val) {\n if (val) {\n for (var a in $scope.artifacts) {\n $scope.select($scope.artifacts[a]);\n }\n } else {\n for (var a in $scope.artifacts) {\n $scope.deselect($scope.artifacts[a]);\n }\n }\n }\n\n $scope.toggleSelect = function (artifact) {\n if ($scope.isSelected(artifact)) {\n $scope.deselect(artifact);\n } else {\n $scope.select(artifact);\n }\n }\n\n $scope.select = function (artifact) {\n artifact.isSelected = true;\n $scope.selection.push(artifact.uri);\n }\n\n $scope.deselect = function (artifact) {\n artifact.isSelected = false;\n $scope.selection = $scope.selection.filter(function (value, index, arr) {\n return value !== artifact.uri;\n });\n }\n\n $scope.isSelected = function (artifact) {\n for (var s in $scope.selection) {\n if ($scope.selection[s] === artifact.uri) {\n return true;\n }\n }\n return false;\n }\n\n $scope.changeCollection = function (collection) {\n $scope.collectionManager.setActive(collection.uuid);\n $scope.search();\n }\n\n $scope.showCollectionModal = function () {\n $('#add-to-collection-modal').addClass('is-active');\n }\n\n $scope.hideCollectionModal = function () {\n $('#add-to-collection-modal').removeClass('is-active');\n }\n\n $scope.markdownToHtml = function (markdown) {\n\n var converter = window.markdownit();\n return $sce.trustAsHtml(converter.render(markdown));\n };\n\n\n $scope.invokeSearch = function () {\n if ($scope.searchReady) {\n $scope.search();\n $scope.searchReady = false;\n } else {\n $scope.searchChanged = true;\n }\n }\n\n $interval(function () {\n if ($scope.searchChanged) {\n $scope.search();\n $scope.searchChanged = false;\n }\n $scope.searchReady = true;\n }, $scope.searchCooldown);\n\n\n $scope.addSelectionToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n\n for (var s in $scope.selection) {\n var artifact = $scope.artifacts.find(function (a) { return a.uri === $scope.selection[s]; });\n wrapper.addArtifactNode(artifact.uri, artifact.label);\n }\n $scope.collectionManager.saveLocally();\n $scope.search();\n }\n\n $scope.updateArtifactState = function (wrapper, artifact) {\n artifact.alreadyAdded = wrapper.hasArtifact(artifact.uri);\n artifact.isSelected = artifact.alreadyAdded || $scope.selection.includes(artifact.uri);\n }\n\n\n\n $scope.search = function () {\n\n $scope.searchResult = [];\n\n var typeFilters = `&publisher=${$scope.accountName}&publisherWeight=0&typeName=Artifact&typeNameWeight=0&group=${$scope.group.name}&minRelevance=0.1`;\n\n $http({\n method: 'GET',\n url: '/api/search?query=' + $scope.input.search + typeFilters\n }).then(function successCallback(response) {\n\n for (var r in response.data.docs) {\n var result = response.data.docs[r];\n\n for (var artifact of $scope.artifacts) {\n if (result.resource[0] == artifact.uri) {\n $scope.searchResult.push(artifact);\n }\n }\n }\n }, function errorCallback(response) {\n });\n }\n}\n\nmodule.exports = GroupPageController;\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/group-controller.js?"); /***/ }), @@ -415,7 +415,7 @@ eval("var DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-u \**************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -eval("const DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst JsonldUtils = __webpack_require__(/*! ../utils/jsonld-utils */ \"./js/utils/jsonld-utils.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\nconst DatabusUris = __webpack_require__(/*! ../utils/databus-uris */ \"./js/utils/databus-uris.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst AppJsonFormatter = __webpack_require__(/*! ../utils/app-json-formatter */ \"./js/utils/app-json-formatter.js\");\n\nfunction VersionPageController($scope, $http, $sce, $location, collectionManager) {\n\n $scope.navigation = new TabNavigation($scope, $location, [\n 'files', 'mods', 'edit'\n ]);\n\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.collectionManager = collectionManager;\n $scope.authenticated = data.auth.authenticated;\n $scope.versionGraph = data.graph;\n $scope.version = AppJsonFormatter.formatVersionData(data.graph);\n\n $scope.queryResult = {};\n $scope.addToCollectionQuery = \"\";\n $scope.collectionModalVisible = false;\n\n $scope.publisherName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 3));\n $scope.canEdit = $scope.publisherName == data.auth.info.accountName;\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n $scope.licenseQuery = \"\";\n $scope.filterLicenses = function (licenseQuery) {\n\n if (data.licenseData == null) {\n return;\n }\n\n // billo-suche mit lowercase und tokenization \n var tokens = licenseQuery.toLowerCase().split(' ');\n $scope.filteredLicenseList = data.licenseData.results.bindings.filter(function (l) {\n for (var token of tokens) {\n if (!l.title.value.toLowerCase().includes(token)) {\n return false;\n }\n }\n\n return true;\n });\n }\n\n $scope.filterLicenses(\"\");\n\n $scope.formData = {};\n\n $scope.formData.group = {};\n $scope.formData.group.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 2));\n\n $scope.formData.artifact = {};\n $scope.formData.artifact.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 1));\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.version.description);\n\n $scope.formData.version = {};\n $scope.formData.version.generateAbstract = abstract == $scope.version.abstract;\n $scope.formData.version.name = $scope.version.name;\n $scope.formData.version.title = $scope.version.title;\n $scope.formData.version.abstract = $scope.version.abstract;\n $scope.formData.version.description = $scope.version.description;\n $scope.formData.version.license = $scope.version.license;\n $scope.formData.version.attribution = $scope.version.attribution;\n $scope.formData.version.wasDerivedFrom = $scope.version.wasDerivedFrom;\n\n $scope.formData.signature = {};\n $scope.formData.signature.autoGenerateSignature = true;\n $scope.formData.signature.selectedPublisherUri = $scope.version.publisher;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.version.generateAbstract) {\n return;\n }\n\n $scope.formData.version.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.version.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.version.title = $scope.version.title;\n $scope.formData.version.abstract = $scope.version.abstract;\n $scope.formData.version.description = $scope.version.description;\n }\n\n $scope.saveVersion = async function () {\n\n try {\n if ($scope.dataidCreator == null) {\n return;\n }\n var relativeUri = new URL($scope.version.uri).pathname;\n\n var response = await $http({\n method: 'GET',\n url: relativeUri,\n headers: {\n 'Accept': 'application/ld+json',\n 'X-Jsonld-Formatting': 'flatten'\n }\n });\n\n var graphs = response.data;\n var versionGraph = JsonldUtils.getTypedGraph(graphs, DatabusUris.DATABUS_VERSION);\n\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_TITLE, DatabusUris.XSD_STRING,\n $scope.formData.version.title);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_ABSTRACT, DatabusUris.XSD_STRING,\n $scope.formData.version.abstract);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_DESCRIPTION, DatabusUris.XSD_STRING,\n $scope.formData.version.description);\n JsonldUtils.setLink(versionGraph, DatabusUris.DCT_LICENSE, $scope.formData.version.license);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DATABUS_ATTRIBUTION, DatabusUris.XSD_STRING,\n $scope.formData.version.attribution);\n\n if ($scope.formData.version.wasDerivedFrom) {\n JsonldUtils.setLink(versionGraph, DatabusUris.PROV_WAS_DERIVED_FROM,\n $scope.formData.version.wasDerivedFrom);\n }\n\n var relativeUri = new URL($scope.version.uri).pathname;\n var response = await $http.put(relativeUri, graphs);\n\n if (response.status == 200) {\n $scope.version.title = $scope.formData.version.title;\n $scope.version.abstract = $scope.formData.version.abstract;\n $scope.version.description = $scope.formData.version.description;\n $scope.version.license = $scope.formData.version.license;\n $scope.version.attribution = $scope.formData.version.attribution;\n $scope.version.wasDerivedFrom = $scope.formData.version.wasDerivedFrom;\n\n DatabusAlert.alert($scope, true, \"Version Saved!\");\n $scope.$apply();\n }\n } catch (err) {\n DatabusAlert.alert($scope, false, \"Failed to save version!\");\n }\n }\n\n $scope.modsAmountMinimized = 5;\n $scope.modsMaxAmount = $scope.modsAmountMinimized;\n\n $scope.showAllMods = function () {\n $scope.modsMaxAmount = 10000000;\n }\n\n $scope.hideAllMods = function () {\n $scope.modsMaxAmount = $scope.modsAmountMinimized;\n }\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '45%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '15%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '15%' });\n\n $scope.artifactNode = new QueryNode($scope.version.artifact, 'databus:artifact');\n $scope.artifactNode.setFacet('http://purl.org/dc/terms/hasVersion', $scope.version.name, true);\n\n $scope.groupNode = new QueryNode(DatabusUtils.navigateUp($scope.version.artifact), 'databus:group');\n $scope.groupNode.addChild($scope.artifactNode);\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n $scope.onFacetSettingsChanged();\n\n $scope.hideAutofill = function () {\n $scope.fileSelector.clearAutofill(function () {\n $scope.$apply();\n });\n }\n\n $scope.onFileSelectionChanged = function (numFiles, totalSize, query) {\n $scope.addToCollectionQuery = query;\n }\n\n $scope.showCollectionModal = function () {\n $scope.collectionModalVisible = true;\n }\n\n $scope.hideCollectionModal = function () {\n $scope.collectionModalVisible = false;\n }\n\n $scope.addFilter = function (selected, key) {\n $scope.fileSelector.addFilter(selected, key);\n $scope.updateQueryBuilder();\n }\n\n $scope.addQueryToCollection = function () {\n $scope.collectionManager.addElement($scope.queryBuilder.query);\n $scope.hideCollectionModal();\n };\n\n $scope.addQueryToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n wrapper.addCustomQueryNode('Select ' + $scope.versionData.label + ' files', $scope.addToCollectionQuery);\n $scope.collectionManager.saveLocally();\n $scope.collectionModalVisible = false;\n }\n\n $scope.formatMods = function (results) {\n var mods = results.replace(\",\", \" \");\n return $sce.trustAsHtml(mods);\n }\n\n $scope.formatModFile = function (uri) {\n return DatabusUtils.uriToName(uri);\n }\n\n $scope.downloadMetadataAsFile = async function() {\n var response = await $http({\n method: 'GET',\n url: $scope.version.uri,\n headers: {\n 'Accept': 'application/ld+json',\n }\n });\n\n $scope.download(`${$scope.version.name}.jsonld`, JSON.stringify(response.data, null, 3));\n }\n\n $scope.download = function(filename, text) {\n var element = document.createElement('a');\n element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));\n element.setAttribute('download', filename);\n element.style.display = 'none';\n document.body.appendChild(element);\n \n element.click();\n \n document.body.removeChild(element);\n }\n\n\n}\n\nmodule.exports = VersionPageController;\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/version-controller.js?"); +eval("const DatabusWebappUtils = __webpack_require__(/*! ../utils/databus-webapp-utils */ \"./js/utils/databus-webapp-utils.js\");\nconst JsonldUtils = __webpack_require__(/*! ../utils/jsonld-utils */ \"./js/utils/jsonld-utils.js\");\nconst DatabusUtils = __webpack_require__(/*! ../utils/databus-utils */ \"./js/utils/databus-utils.js\");\nconst DatabusAlert = __webpack_require__(/*! ../components/databus-alert/databus-alert */ \"./js/components/databus-alert/databus-alert.js\");\nconst QueryNode = __webpack_require__(/*! ../query-builder/query-node */ \"./js/query-builder/query-node.js\");\nconst TabNavigation = __webpack_require__(/*! ../utils/tab-navigation */ \"./js/utils/tab-navigation.js\");\nconst DatabusUris = __webpack_require__(/*! ../utils/databus-uris */ \"./js/utils/databus-uris.js\");\nconst DataIdCreator = __webpack_require__(/*! ../publish/dataid-creator */ \"./js/publish/dataid-creator.js\");\nconst QueryTemplates = __webpack_require__(/*! ../query-builder/query-templates */ \"./js/query-builder/query-templates.js\");\nconst DatabusCollectionWrapper = __webpack_require__(/*! ../collections/databus-collection-wrapper */ \"./js/collections/databus-collection-wrapper.js\");\nconst QueryBuilder = __webpack_require__(/*! ../query-builder/query-builder */ \"./js/query-builder/query-builder.js\");\nconst AppJsonFormatter = __webpack_require__(/*! ../utils/app-json-formatter */ \"./js/utils/app-json-formatter.js\");\n\nfunction VersionPageController($scope, $http, $sce, $location, collectionManager) {\n\n $scope.navigation = new TabNavigation($scope, $location, [\n 'files', 'mods', 'edit'\n ]);\n\n $scope.utils = new DatabusWebappUtils($scope, $sce);\n $scope.collectionManager = collectionManager;\n $scope.authenticated = data.auth.authenticated;\n $scope.versionGraph = data.graph;\n $scope.version = AppJsonFormatter.formatVersionData(data.graph);\n\n $scope.queryResult = {};\n $scope.addToCollectionQuery = \"\";\n $scope.collectionModalVisible = false;\n\n $scope.publisherName = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 3));\n $scope.canEdit = $scope.publisherName == data.auth.info.accountName;\n\n if (data.auth.authenticated && $scope.canEdit) {\n\n $scope.licenseQuery = \"\";\n $scope.filterLicenses = function (licenseQuery) {\n\n if (data.licenseData == null) {\n return;\n }\n\n // billo-suche mit lowercase und tokenization \n var tokens = licenseQuery.toLowerCase().split(' ');\n $scope.filteredLicenseList = data.licenseData.results.bindings.filter(function (l) {\n for (var token of tokens) {\n if (!l.title.value.toLowerCase().includes(token)) {\n return false;\n }\n }\n\n return true;\n });\n }\n\n $scope.filterLicenses(\"\");\n\n $scope.formData = {};\n\n $scope.formData.group = {};\n $scope.formData.group.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 2));\n\n $scope.formData.artifact = {};\n $scope.formData.artifact.name = DatabusUtils.uriToName(DatabusUtils.navigateUp($scope.version.uri, 1));\n\n var abstract = DatabusUtils.createAbstractFromDescription($scope.version.description);\n\n $scope.formData.version = {};\n $scope.formData.version.generateAbstract = abstract == $scope.version.abstract;\n $scope.formData.version.name = $scope.version.name;\n $scope.formData.version.title = $scope.version.title;\n $scope.formData.version.abstract = $scope.version.abstract;\n $scope.formData.version.description = $scope.version.description;\n $scope.formData.version.license = $scope.version.license;\n $scope.formData.version.attribution = $scope.version.attribution;\n $scope.formData.version.wasDerivedFrom = $scope.version.wasDerivedFrom;\n\n $scope.formData.signature = {};\n $scope.formData.signature.autoGenerateSignature = true;\n $scope.formData.signature.selectedPublisherUri = $scope.version.publisher;\n\n $scope.dataidCreator = new DataIdCreator($scope.formData, data.auth.info.accountName);\n }\n\n $scope.onDescriptionChanged = function () {\n if ($scope.formData == null) {\n return;\n }\n\n if (!$scope.formData.version.generateAbstract) {\n return;\n }\n\n $scope.formData.version.abstract =\n DatabusUtils.createAbstractFromDescription($scope.formData.version.description);\n }\n\n $scope.resetEdits = function () {\n $scope.formData.version.title = $scope.version.title;\n $scope.formData.version.abstract = $scope.version.abstract;\n $scope.formData.version.description = $scope.version.description;\n }\n\n $scope.saveVersion = async function () {\n\n try {\n if ($scope.dataidCreator == null) {\n return;\n }\n var relativeUri = new URL($scope.version.uri).pathname;\n\n var response = await $http({\n method: 'GET',\n url: relativeUri,\n headers: {\n 'Accept': 'application/ld+json',\n 'X-Jsonld-Formatting': 'flatten'\n }\n });\n\n var graphs = response.data;\n var versionGraph = JsonldUtils.getTypedGraph(graphs, DatabusUris.DATABUS_VERSION);\n\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_TITLE, DatabusUris.XSD_STRING,\n $scope.formData.version.title);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_ABSTRACT, DatabusUris.XSD_STRING,\n $scope.formData.version.abstract);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DCT_DESCRIPTION, DatabusUris.XSD_STRING,\n $scope.formData.version.description);\n JsonldUtils.setLink(versionGraph, DatabusUris.DCT_LICENSE, $scope.formData.version.license);\n JsonldUtils.setLiteral(versionGraph, DatabusUris.DATABUS_ATTRIBUTION, DatabusUris.XSD_STRING,\n $scope.formData.version.attribution);\n\n if ($scope.formData.version.wasDerivedFrom) {\n JsonldUtils.setLink(versionGraph, DatabusUris.PROV_WAS_DERIVED_FROM,\n $scope.formData.version.wasDerivedFrom);\n }\n\n var relativeUri = new URL($scope.version.uri).pathname;\n var response = await $http.put(relativeUri, graphs);\n\n if (response.status == 200) {\n $scope.version.title = $scope.formData.version.title;\n $scope.version.abstract = $scope.formData.version.abstract;\n $scope.version.description = $scope.formData.version.description;\n $scope.version.license = $scope.formData.version.license;\n $scope.version.attribution = $scope.formData.version.attribution;\n $scope.version.wasDerivedFrom = $scope.formData.version.wasDerivedFrom;\n\n DatabusAlert.alert($scope, true, \"Version Saved!\");\n $scope.$apply();\n }\n } catch (err) {\n DatabusAlert.alert($scope, false, \"Failed to save version!\");\n }\n }\n\n $scope.modsAmountMinimized = 5;\n $scope.modsMaxAmount = $scope.modsAmountMinimized;\n\n $scope.showAllMods = function () {\n $scope.modsMaxAmount = 10000000;\n }\n\n $scope.hideAllMods = function () {\n $scope.modsMaxAmount = $scope.modsAmountMinimized;\n }\n\n $scope.fileSelector = {};\n $scope.fileSelector.config = {};\n $scope.fileSelector.config.authenticated = $scope.authenticated;\n $scope.fileSelector.config.columns = [];\n $scope.fileSelector.config.columns.push({ field: 'variant', label: 'Variant', width: '45%' });\n $scope.fileSelector.config.columns.push({ field: 'format', label: 'Format', width: '15%' });\n $scope.fileSelector.config.columns.push({ field: 'compression', label: 'Compression', width: '15%' });\n\n $scope.artifactNode = new QueryNode($scope.version.artifact, 'databus:artifact');\n $scope.artifactNode.setFacet('http://purl.org/dc/terms/hasVersion', $scope.version.name, true);\n\n $scope.groupNode = new QueryNode(DatabusUtils.navigateUp($scope.version.artifact), 'databus:group');\n $scope.groupNode.addChild($scope.artifactNode);\n\n $scope.collectionWidgetSelectionData = {};\n $scope.collectionWidgetSelectionData.groupNode = $scope.groupNode;\n\n $scope.onFacetSettingsChanged = function () {\n $scope.fileSelector.query = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.DEFAULT_FILE_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n\n $scope.fileSelector.fullQuery = QueryBuilder.build({\n node: $scope.artifactNode,\n template: QueryTemplates.GROUP_PAGE_FILE_BROWSER_TEMPLATE,\n resourceBaseUrl: DATABUS_RESOURCE_BASE_URL\n });\n }\n\n $scope.onFacetSettingsChanged();\n\n $scope.hideAutofill = function () {\n $scope.fileSelector.clearAutofill(function () {\n $scope.$apply();\n });\n }\n\n $scope.onFileSelectionChanged = function (numFiles, totalSize, query) {\n $scope.addToCollectionQuery = query;\n }\n\n $scope.showCollectionModal = function () {\n $scope.collectionModalVisible = true;\n }\n\n $scope.hideCollectionModal = function () {\n $scope.collectionModalVisible = false;\n }\n\n $scope.addFilter = function (selected, key) {\n $scope.fileSelector.addFilter(selected, key);\n $scope.updateQueryBuilder();\n }\n\n $scope.addQueryToCollection = function () {\n $scope.collectionManager.addElement($scope.queryBuilder.query);\n $scope.hideCollectionModal();\n };\n\n $scope.addQueryToCollection = function () {\n\n if ($scope.collectionManager.activeCollection == null) {\n return;\n }\n\n var wrapper = new DatabusCollectionWrapper($scope.collectionManager.activeCollection);\n wrapper.addCustomQueryNode('Select ' + $scope.versionData.label + ' files', $scope.addToCollectionQuery);\n $scope.collectionManager.saveLocally();\n $scope.collectionModalVisible = false;\n }\n\n $scope.formatMods = function (results) {\n var mods = results.replace(\",\", \" \");\n return $sce.trustAsHtml(mods);\n }\n\n $scope.formatModFile = function (uri) {\n return DatabusUtils.uriToName(uri);\n }\n\n $scope.downloadMetadataAsFile = async function() {\n var response = await $http({\n method: 'GET',\n url: $scope.version.uri,\n headers: {\n 'Accept': 'application/ld+json',\n }\n });\n\n $scope.download(`${$scope.version.name}.jsonld`, JSON.stringify(response.data, null, 3));\n }\n\n $scope.download = function(filename, text) {\n var element = document.createElement('a');\n element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));\n element.setAttribute('download', filename);\n element.style.display = 'none';\n document.body.appendChild(element);\n \n element.click();\n \n document.body.removeChild(element);\n }\n\n\n}\n\nmodule.exports = VersionPageController;\n\n//# sourceURL=webpack://databus-webapp/./js/page-controller/version-controller.js?"); /***/ }),