diff --git a/Variants/ConceptAndGo.vdm b/Variants/ConceptAndGo.vdm index 27faff1b..d77fb60c 100644 --- a/Variants/ConceptAndGo.vdm +++ b/Variants/ConceptAndGo.vdm @@ -78,7 +78,7 @@ xabiergarmendia - 2022-10-05T17:22:50.859Z + 2022-10-19T07:56:41.993Z cag @@ -90,7 +90,7 @@ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh62oqu5gL13CQVRafRtqaTWkS6UQru7zvTinTn2UxJvFUjsOttkumdEhKh4g4fOvBdYtT07LNsxgVpehKNRiZqdlwSBVIrNTO2vdDKIIHGd4WGYZ/DJLJ7IMgoIvVgvDozH+WwqMEhaeldI+flDAPPswBClT8Sve3npYpM1pZAd9MPyi8HPUXOyJd83gJY3n156rS+DKIEvlR3Ree1Hs8Jns7oNG0AN4+XNZQ3U4vE3W8+YWBfgIn0GOqKnAtza2WPQ2Pml3wupILypaVP7fIt4yQ++YI9ucvOqYzhaD1l1aFi2OMCOZSXNaixQ4PrRooLqGsWoKuiechYE92dijOQIDAQAB - 0.2.0 + 0.2.1 /~https://github.com/onekin/WacLine/wiki/User-manual-for-Concept&Go diff --git a/WebAnnotator.ccfm b/WebAnnotator.ccfm index 8877db9a..1c5ad8ca 100644 --- a/WebAnnotator.ccfm +++ b/WebAnnotator.ccfm @@ -3685,6 +3685,7 @@ ./ib1JTI6Ov0wapinr7OT24AEQaD3a ./iJck5J0LDjFd6JJY-xb05-n0RzPj ./imcvlrpddj1cuPRxxDffgdFZ9xIf + ./i2amDBb4gjhHga6JBcSNxQQAnQrc ./i7cWh8h-5SCGhxpnKDf0y8ea0vel ./iJsveSeanLzR6XH6Mm1vPFe8Octl ./i0F-nwATlsfqVJ85gohvin7M8Afj @@ -3720,7 +3721,7 @@ xabiergarmendia - 2022-10-05T17:11:13.703Z + 2022-11-21T14:35:37.124Z @@ -4824,6 +4825,7 @@ ./iH4OU8lhwRTp_Y-6RSjXIgy-QXvk ./ihrUxou85Um6kgiJDA-eOTQtkL7m ./i4vPwVvM96iZmPemzQ0_iG7EPgRa + ./i-s7yfT7kCqMK8sAVe0MS1Q5PwDf ./ilPQdSuZoHPAttvVeg11kwK81jxm ./iySLezbiHxqt1vgXHysUH3q_WvOl ./isk-zB4yoLNL_SN3BwgBlXe4HlUd @@ -4851,10 +4853,10 @@ 2019-05-03T13:43:34.658Z - pirqu + xabiergarmendia - 2020-08-06T10:18:39.808Z + 2022-10-27T10:25:30.363Z @@ -29026,6 +29028,7 @@ ./iH2_M8os-cLIrtq05OeZqA81SxNn ./iQrkA4oirhaRLyoHK0YTX9DaPAOh ./iRvUlJFof7uZY9EhoJEmQ2tdingc + ./iQh0STeobAppPUHWdj0_SMZGAgCl @@ -29045,7 +29048,7 @@ xabiergarmendia - 2021-01-26T11:21:35.486Z + 2022-11-14T12:21:34.743Z @@ -32322,5 +32325,194 @@ ImageUtilsOCR.js + + + + + + ./icGR_X9_Zyy0IoAOQZXE1w12CA_f + + + + + ./i8FxnhYFpHIOMivTuVduYKOnAIzo + + + + + xabiergarmendia + + + 2022-10-27T10:25:30.363Z + + + xabiergarmendia + + + 2022-10-27T10:25:30.363Z + + + + cmapCloudPage + + + + + + + + ./i-s7yfT7kCqMK8sAVe0MS1Q5PwDf + + + + + cmapCloudPage.js + + + misc + + + xabiergarmendia + + + 2022-10-27T10:25:30.363Z + + + xabiergarmendia + + + 2022-10-27T10:25:30.363Z + + + + cmapCloudPage.js + + + + + + + + ./i8FO2lSObqpGcYcK7aG0E8BE5_om + + + + + ./iqYSy38qvD7AK3JHk2OHGpLLHGOd + + + + + xabiergarmendia + + + 2022-11-14T12:21:34.743Z + + + xabiergarmendia + + + 2022-11-14T12:21:34.743Z + + + + PreviousVersionAnnotationImporter + + + + + + + + ./iQh0STeobAppPUHWdj0_SMZGAgCl + + + + + PreviousVersionAnnotationImporter.js + + + misc + + + xabiergarmendia + + + 2022-11-14T12:21:34.743Z + + + xabiergarmendia + + + 2022-11-14T12:21:34.743Z + + + + PreviousVersionAnnotationImporter.js + + + + + + + + ./ioJ-QRIr3cFE-pFAcFkgXQwua-Ed + + + + + ./ie5gpf9R2DvtgaxaUE2vb6pTgHUi + + + + + xabiergarmendia + + + 2022-11-21T14:35:37.124Z + + + xabiergarmendia + + + 2022-11-21T14:35:37.124Z + + + + cmapCloudHome + + + + + + + + ./i2amDBb4gjhHga6JBcSNxQQAnQrc + + + + + cmapCloudHome.png + + + misc + + + xabiergarmendia + + + 2022-11-21T14:35:37.124Z + + + xabiergarmendia + + + 2022-11-21T14:35:37.124Z + + + + cmapCloudHome.png + + diff --git a/input/app/_locales/en/messages.json b/input/app/_locales/en/messages.json index 735dac9c..9d46a70a 100644 --- a/input/app/_locales/en/messages.json +++ b/input/app/_locales/en/messages.json @@ -109,9 +109,6 @@ "CurrentSelectionNotAnnotable": { "message": "The selected content cannot be highlighted, is not part of the document" }, - "annotationServerLoginRequired": { - "message": "You need to login in the corresponding annotation server to start annotating. Check instructions to login in the sidebar and reload the page if it is not done automatically." - }, "ErrorContactDeveloper": { "message": "If the error continues, please open an issue.", "placeholders": { diff --git a/input/app/images/cmapCloudHome.png b/input/app/images/cmapCloudHome.png new file mode 100644 index 00000000..92cea80b Binary files /dev/null and b/input/app/images/cmapCloudHome.png differ diff --git a/input/app/manifest.json b/input/app/manifest.json index 5ccfad9e..1089ca0c 100644 --- a/input/app/manifest.json +++ b/input/app/manifest.json @@ -26,6 +26,9 @@ // PVSCL:IFCOND(MoodleProvider,LINE) "exclude_matches": ["*://*/*grade/grading/*", "*://*/*mod/assign/view.php*", "*://*/*course/modedit.php?add=assign*"PVSCL:IFCOND(Manual and Hypothesis), "https://hypothes.is/login"PVSCL:ENDCOND], //PVSCL:ENDCOND + // PVSCL:IFCOND(CXLExportCmapCloud,LINE) + "exclude_matches": ["https://cmapcloud.ihmc.us/cmaps/myCmaps.html"], + //PVSCL:ENDCOND "js": ["scripts/contentScript.js"], "css": ["styles/contentScript.css"], "run_at": "document_start", @@ -78,6 +81,11 @@ "matches": ["*://*/*mod/assign/view.php*"], "js": ["scripts/moodleEstimation.js"], "run_at": "document_end" + }PVSCL:ENDCONDPVSCL:IFCOND(CXLExportCmapCloud), + { + "matches": ["https://cmapcloud.ihmc.us/cmaps/myCmaps.html"], + "js": ["scripts/cmapCloudPage.js"], + "run_at": "document_end" }PVSCL:ENDCOND ], "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", diff --git a/input/app/scripts/cmapCloudPage.js b/input/app/scripts/cmapCloudPage.js new file mode 100644 index 00000000..d30be09f --- /dev/null +++ b/input/app/scripts/cmapCloudPage.js @@ -0,0 +1,20 @@ +// import AnnotationBasedInitializer from './contentScript/AnnotationBasedInitializer' +// import ContentScriptManager from './contentScript/ContentScriptManager' +///import _ from 'lodash' + + + +let kudeatzaileakHasieratu = function(){ + let checkDOM = setInterval(function () { + let lista = document.getElementById("actions") + let luList = document.getElementById("actions").getElementsByTagName('ul') + let clone = luList[0].firstChild.cloneNode(true) + if (clone.nodeName != '#comment') { + clone.firstChild.innerHTML='Import from Concept&Go' + lista.children[0].appendChild(clone) + clearInterval(checkDOM); + } + }, 1000); +} + +window.onload = kudeatzaileakHasieratu diff --git a/input/app/scripts/codebook/operations/read/ReadCodebook.js b/input/app/scripts/codebook/operations/read/ReadCodebook.js index 2d972f49..0c2376ca 100644 --- a/input/app/scripts/codebook/operations/read/ReadCodebook.js +++ b/input/app/scripts/codebook/operations/read/ReadCodebook.js @@ -628,11 +628,13 @@ class ReadCodebook { items.removeTheme = { name: 'Remove ' + Config.tags.grouped.group } // PVSCL:IFCOND(Linking,LINE) items.manageRelationships = { name: 'Manage links' } + items.showAnnotations = { name: 'Show annotations' } // PVSCL:ENDCOND } else { items.updateTheme = { name: 'Modify topic' } // PVSCL:IFCOND(Linking,LINE) items.manageRelationships = { name: 'Manage links' } + items.showAnnotations = { name: 'Show annotations' } // PVSCL:ENDCOND } // PVSCL:ELSECOND @@ -640,6 +642,7 @@ class ReadCodebook { items.removeTheme = { name: 'Remove ' + Config.tags.grouped.group } // PVSCL:IFCOND(Linking,LINE) items.manageRelationships = { name: 'Manage links' } + items.showAnnotations = { name: 'Show annotations' } // PVSCL:ENDCOND // PVSCL:ENDCOND // PVSCL:ENDCOND @@ -675,6 +678,24 @@ class ReadCodebook { window.abwa.mapContentManager.manageRelationships(theme) } } + if (key === 'showAnnotations') { + let theme = this.codebook.getCodeOrThemeFromId(themeId) + if (LanguageUtils.isInstanceOf(theme, Theme)) { + window.abwa.annotationServerManager.client.getUserProfile((err, userProfile) => { + if (err) { + console.error('Error while retrieving user profile in hypothesis') + } else { + console.log(userProfile) + let groupId = window.abwa.groupSelector.currentGroup.id + let groupName = window.abwa.groupSelector.currentGroup.name.toLowerCase().replace(/ /g,"-"); + let query = '?q=tag:' + Config.namespace + ':' + Config.tags.grouped.group + ':' + theme.name.replace(/ /g,"+"); + let url = 'https://hypothes.is/groups/'+groupId+'/'+groupName+query + console.log(url) + window.open(url) + } + }) + } + } // PVSCL:ENDCOND // PVSCL:ENDCOND // PVSCL:IFCOND(SidebarNavigation, LINE) diff --git a/input/app/scripts/contentScript/Toolset.js b/input/app/scripts/contentScript/Toolset.js index bce7d0e2..dcd546e3 100644 --- a/input/app/scripts/contentScript/Toolset.js +++ b/input/app/scripts/contentScript/Toolset.js @@ -27,9 +27,10 @@ import AnnotationList from '../annotationManagement/read/AnnotationList' // PVSCL:IFCOND(ImportAnnotations, LINE) import AnnotationImporter from '../importExport/AnnotationImporter' // PVSCL:ENDCOND -// PVSCL:IFCOND(Export, LINE) +// PVSCL:IFCOND(JSON, LINE) import AnnotationExporter from '../importExport/AnnotationExporter' // PVSCL:ENDCOND +import PreviousVersionAnnotationImporter from '../importExport/PreviousVersionAnnotationImporter' // PVSCL:IFCOND(CXLExport, LINE) import { CXLExporter } from '../importExport/cmap/CXLExporter' // PVSCL:ENDCOND @@ -171,6 +172,17 @@ class Toolset { this.CXLArchiveFileButtonHandler() // PVSCL:ENDCOND // PVSCL:IFCOND(CXLExportCmapCloud, LINE) + const cxlCloudHomeImageUrl = chrome.extension.getURL('/images/cmapCloudHome.png') + this.cxlCloudHomeImage = $(toolsetButtonTemplate.content.firstElementChild).clone().get(0) + this.cxlCloudHomeImage.src = cxlCloudHomeImageUrl + this.cxlCloudHomeImage.id = 'cxlCloudHomeButton' + this.cxlCloudHomeImage.title = 'Open CmapCloud folder' // TODO i18n + this.toolsetBody.appendChild(this.cxlCloudHomeImage) + // Add menu when clicking on the button + this.cxlCloudHomeImage.addEventListener('click', () => { + this.CXLCloudHomeButtonHandler() + }) + const cxlCloudImageUrl = chrome.extension.getURL('/images/cmapCloud.png') this.cxlCloudImage = $(toolsetButtonTemplate.content.firstElementChild).clone().get(0) this.cxlCloudImage.src = cxlCloudImageUrl @@ -190,6 +202,21 @@ class Toolset { // Add menu when clicking on the button this.seroButtonHandler() // PVSCL:ENDCOND + const importPreviousVersionImageUrl = chrome.extension.getURL('/images/importExport.png') + this.importPreviousVersionImage = $(toolsetButtonTemplate.content.firstElementChild).clone().get(0) + this.importPreviousVersionImage.src = importPreviousVersionImageUrl + this.importPreviousVersionImage.id = 'importPreviousVersion' + this.importPreviousVersionImage.title = 'Import previous version' // TODO i18n + this.toolsetBody.appendChild(this.importPreviousVersionImage) + this.importPreviousVersionImage.addEventListener('click', () => { + let annotatedResources = window.abwa.annotationManagement.annotationReader.allGroupAnnotations.map(annotation => annotation.target[0].source.url) + annotatedResources = _.uniq(annotatedResources).filter(anno => anno != undefined) + if (annotatedResources) { + PreviousVersionAnnotationImporter.importPreviousVersionAnnotations() + } else { + Alerts.infoAlert({ text: 'You have not annotated documents.', title: 'Problem'}) + } + }) // Check if exist any element in the tools and show it if (!_.isEmpty(this.toolsetBody.innerHTML)) { this.show() @@ -361,6 +388,22 @@ class Toolset { // PVSCL:ENDCOND // PVSCL:IFCOND(CXLExportCmapCloud, LINE) + CXLCloudHomeButtonHandler () { + chrome.runtime.sendMessage({ scope: 'cmapCloud', cmd: 'getUserData' }, (response) => { + if (response.data) { + let data = response.data + if (data.userData.user && data.userData.password && data.userData.uid) { + window.open('https://cmapcloud.ihmc.us/cmaps/myCmaps.html') + } + } else { + let callback = () => { + window.open(chrome.extension.getURL('pages/options.html#cmapCloudConfiguration')) + } + Alerts.infoAlert({ text: 'Please, provide us your Cmap Cloud login credentials in the configuration page of the Web extension.', title: 'We need your Cmap Cloud credentials', callback: callback() }) + } + }) + } + CXLCloudButtonHandler () { // Create context menu for import export $.contextMenu({ diff --git a/input/app/scripts/importExport/PreviousVersionAnnotationImporter.js b/input/app/scripts/importExport/PreviousVersionAnnotationImporter.js new file mode 100644 index 00000000..56adaa66 --- /dev/null +++ b/input/app/scripts/importExport/PreviousVersionAnnotationImporter.js @@ -0,0 +1,116 @@ +import Alerts from '../utils/Alerts' +import _ from 'lodash' +import Annotation from "../annotationManagement/Annotation"; + +class PreviousVersionAnnotationImporter { + static askUserToSelectAnnotatedResource (callback) { + // Close sidebar if opened + window.abwa.sidebar.closeSidebar() + let title = 'Select the previous version of this source' + // Get body for classifying + let showForm = () => { + // Create form + let html = PreviousVersionAnnotationImporter.generateFormHTML() + let form = PreviousVersionAnnotationImporter.generateForm() + Alerts.multipleInputAlert({ + title: title || '', + html: html, + onBeforeOpen: form.onBeforeOpen, + confirmButtonText: 'Import', + callback: form.callback, + customClass: 'large-swal', + preConfirm: form.preConfirm, + preDeny: form.preDeny + }) + } + showForm() + } + + static importPreviousVersionAnnotations () { + PreviousVersionAnnotationImporter.askUserToSelectAnnotatedResource((err, jsonObject) => { + if (err) { + Alerts.errorAlert({text: 'Unable to parse json file. Error:
' + err.message}) + } else { + } + }) + } + + static generateForm () { + + // Preconfirm + let preConfirmData = {} + let preConfirm = () => { + preConfirmData.value = document.querySelector('#categorizeDropdownPreviousResources').value + } + // Callback + let callback = () => { + console.log(preConfirmData.value) + let selectedResourceAnnotations = _.filter(window.abwa.annotationManagement.annotationReader.allGroupAnnotations, (annotation) => { + return annotation.target[0].source.url === preConfirmData.value + }) + if (selectedResourceAnnotations) { + let annotationsForNewVersion = [] + let source = window.abwa.targetManager.getDocumentURIs() + // Get document title + source.title = window.abwa.targetManager.documentTitle || '' + // Get UUID for current target + source.id = window.abwa.targetManager.getDocumentId() + selectedResourceAnnotations.forEach( annotation => { + let target = [{}] + target[0].source = source + target[0].selector = annotation.target[0].selector + let annotationToCreate = new Annotation({ + target: target, + tags: annotation.tags, + body: annotation.body + }) + annotationToCreate.serialize() + // annotationsForNewVersion.push(annotationToCreate) + window.abwa.annotationServerManager.client.createNewAnnotation(annotationToCreate.serialize(), (err, annotation) => { + if (err) { + Alerts.errorAlert({text: 'Unable to create new group.'}) + } else { + // Parse annotations and dispatch created codebook + console.log(annotation) + } + }) + }) + console.log(annotationsForNewVersion) + Alerts.simpleSuccessAlert({ text: 'Saved' }) + } + } + return { preConfirm: preConfirm, callback: callback } + } + + static generateFormHTML () { + let html = '' + + // Create input + let inputFrom = document.createElement('select') + inputFrom.id = 'categorizeDropdownPreviousResources' + inputFrom.className = 'annotatedResourceInput' + inputFrom.placeholder = 'Select an annotated resource' + inputFrom.setAttribute('list', 'resources') + + let annotatedResources = window.abwa.annotationManagement.annotationReader.allGroupAnnotations.map(annotation => annotation.target[0].source.url) + annotatedResources = _.uniq(annotatedResources).filter(anno => anno != undefined) + console.log(annotatedResources) + + // create options + + if (annotatedResources) { + annotatedResources.forEach(anno => { + let option = document.createElement('option') + option.value = anno + option.text = anno + inputFrom.add(option) + }) + } + // RENDER + html += inputFrom.outerHTML + + return html + } +} + +export default PreviousVersionAnnotationImporter diff --git a/input/app/scripts/utils/Alerts.js b/input/app/scripts/utils/Alerts.js index 8d26a207..8af5d1a5 100644 --- a/input/app/scripts/utils/Alerts.js +++ b/input/app/scripts/utils/Alerts.js @@ -6,7 +6,7 @@ if (document && document.head) { } class Alerts { - static confirmAlert ({ alertType = Alerts.alertType.info, title = '', text = '', confirmButtonText = 'OK', cancelButtonText = 'Cancel', reverseButtons, allowOutsideClick = true, allowEscapeKey = true, callback, cancelCallback }) { + static confirmAlert ({ alertType = Alerts.alertType.info, title = '', text = '', confirmButtonText = 'OK', cancelButtonText = 'Cancel', onBeforeOpen, reverseButtons, allowOutsideClick = true, allowEscapeKey = true, callback, cancelCallback }) { Alerts.tryToLoadSwal() if (_.isNull(swal)) { if (_.isFunction(callback)) { @@ -20,6 +20,7 @@ class Alerts { confirmButtonText, cancelButtonText, reverseButtons, + willOpen: onBeforeOpen, allowOutsideClick, allowEscapeKey, showCancelButton: true