-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
154 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/resources/db/migration/V14__Add_Resource_Annotation.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
CREATE TABLE IF NOT EXISTS `lw_resource_annotation` ( | ||
`annotation_id` INT(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
`resource_id` INT(10) UNSIGNED NOT NULL, | ||
`user_id` INT(10) UNSIGNED NOT NULL, | ||
`action` CHAR(25) NOT NULL, | ||
`selection` LONGTEXT NOT NULL, | ||
`annotation` MEDIUMTEXT NOT NULL, | ||
`annotation` MEDIUMTEXT NULL, | ||
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 60 additions & 53 deletions
113
src/main/webapp/WEB-INF/templates/blocks/resourceview/embedded_text.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,80 @@ | ||
<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" | ||
xmlns:h="jakarta.faces.html" | ||
xmlns:f="jakarta.faces.core" | ||
xmlns:c="jakarta.tags.core" | ||
xmlns:p="http://primefaces.org/ui" | ||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> | ||
xmlns:faces="jakarta.faces" | ||
xmlns:ui="jakarta.faces.facelets"> | ||
|
||
<!--@elvariable id="res" type="de.l3s.learnweb.resource.Resource"--> | ||
|
||
<h:outputStylesheet name="bundle/pickr.min.css"/> | ||
<h:outputScript name="bundle/pickr.min.js" target="body"/> | ||
<h:outputScript name="bundle/jquery.contextMenu.min.js" target="body"/> | ||
<h:outputScript name="learnweb/js/lib/annotator.js" target="body"/> | ||
|
||
<h:form styleClass="d-none"> | ||
<p:remoteCommand name="commandSaveLog" actionListener="${resourceAnnotationBean.commandLogAnnotation(resourceDetailBean.resource)}" immediate="true" process="@this" update="@none"/> | ||
<p:remoteCommand name="commandSaveResource" actionListener="${resourceAnnotationBean.commandSaveAnnotation(resourceDetailBean.resource)}" immediate="true" process="@this"/> | ||
<p:remoteCommand name="commandGetDefinition" actionListener="${resourceAnnotationBean.commandGetDefinition()}" immediate="true" process="@this" oncomplete="annotator.saveDefinition(xhr,status,args);" async="false"/> | ||
</h:form> | ||
|
||
<h:outputStylesheet name="bundle/pickr.min.css"/> | ||
<h:outputScript name="bundle/pickr.min.js" target="body"/> | ||
<h:outputScript name="bundle/jquery.contextMenu.min.js" target="body"/> | ||
<h:outputScript name="learnweb/js/lib/annotator.js" target="body"/> | ||
<h:form styleClass="text_res_toolbar mx-3 my-1"> | ||
<p:commandButton styleClass="ui-button-warning" value="#{msg.convert_to_edit}" | ||
actionListener="#{resourceAnnotationBean.convert()}" update="@form :text_res_content" rendered="#{empty res.transcript}"/> | ||
<p:tooltip for="@previous" value="#{msg.convert_to_edit_tooltip}"/> | ||
|
||
<p:tabView styleClass="res-view-tabs res-embedded-tabs"> | ||
<p:tab title="Normal"> | ||
<iframe src="#{res.downloadUrl}" title="#{res.title}" class="bg-body p-1"></iframe> | ||
</p:tab> | ||
<p:tab title="Annotated"> | ||
<h:form> | ||
<div class="d-block position-absolute top-0 end-0 mx-3 my-1"> | ||
<p:commandButton styleClass="me-2" value="#{msg.save}" onclick="annotator.saveAnnotatedText();"/> | ||
<p:tooltip for="@previous" value="#{msg.save_tooltip}" position="left"/> | ||
</div> | ||
</h:form> | ||
<p:commandButton styleClass="me-2" value="#{msg.save}" onclick="annotator.saveAnnotatedText();" rendered="#{false}"/> | ||
<p:tooltip for="@previous" value="#{msg.save_tooltip}" position="left"/> | ||
</h:form> | ||
|
||
<div faces:id="text_res_content" class="p-3 h-100"> | ||
<ui:fragment rendered="#{empty res.transcript}"> | ||
<iframe id="embedded_text" src="#{res.downloadUrl}" title="#{res.title}" class="bg-body-secondary"></iframe> | ||
</ui:fragment> | ||
|
||
<ui:fragment rendered="#{not empty res.transcript}"> | ||
<div id="annotated_text" class="w-100 bg-body" style="padding: 12px;"> | ||
<pre style="height: 100%"> | ||
<h:outputText value="testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" escape="false"/> | ||
</pre> | ||
<h:outputText value="#{res.transcript}" escape="false"/> | ||
</div> | ||
</p:tab> | ||
</p:tabView> | ||
|
||
<p:dialog widgetVar="updateNote" header="#{msg.userAnnotation}" | ||
modal="true" resizable="false" draggable="false" responsive="true" closeOnEscape="true" dynamic="true"> | ||
<h:form id="update_note_form" prependId="false" styleClass="d-flex flex-column"> | ||
<p:outputLabel for="@next" value="#{msg.justify_selection}:"/> | ||
<p:inputText/> | ||
<p:dialog widgetVar="updateNote" header="#{msg.userAnnotation}" modal="true" dynamic="true" | ||
closeOnEscape="true" resizable="false" draggable="false" closable="false"> | ||
<h:form id="update_note_form" prependId="false"> | ||
<div class="field"> | ||
<p:outputLabel for="@next" value="#{msg.justify_selection}:"/> | ||
<p:inputText/> | ||
</div> | ||
|
||
<div class="d-flex flex-row-reverse mt-2"> | ||
<p:commandButton value="#{msg['save']}" onclick="annotator.saveAnnotation(); return false;"/> | ||
<p:commandButton styleClass="secondary-btn" value="#{msg.cancel}" onclick="annotator.cancelAnnotation(); return false;"/> | ||
</div> | ||
</h:form> | ||
</p:dialog> | ||
<div class="d-flex flex-row-reverse"> | ||
<p:commandButton value="#{msg.save}" styleClass="ms-1" onclick="annotator.saveAnnotation(); return false;"/> | ||
<p:commandButton styleClass="ui-button-secondary" value="#{msg.cancel}" onclick="annotator.cancelAnnotation(); return false;"/> | ||
</div> | ||
</h:form> | ||
</p:dialog> | ||
|
||
<h:outputScript target="body"> | ||
const annotator = new Annotator('#annotated_text', { | ||
readOnly: false, | ||
lastNoteId: 0, | ||
editNoteFormSelector: '#update_note_form', | ||
noteContextMenu: [ | ||
{ action: 'add-annotation', icon: 'fa-plus', name: '#{msg.add_annotation}' }, | ||
{ action: 'edit-annotation', icon: 'fa-pencil-alt', name: '#{msg.edit_annotation}' }, | ||
{ action: 'delete-annotation', icon: 'fa-minus', name: '#{msg.delete_annotation}' }, | ||
{ action: 'add-wordnet-definition', icon: 'fa-language', name: '#{msg.add_wordnet_definition}' }, | ||
{ action: 'delete-selection', icon: 'fa-trash', name: '#{msg.delete_selection}' }, | ||
{ action: 'colorpicker', icon: 'fa-folder', name: '#{msg.color}' } | ||
], | ||
locale: { | ||
deleteSelection: '#{msg.delete_selection}' | ||
} | ||
}); | ||
</h:outputScript> | ||
<h:outputScript target="body"> | ||
const annotator = new Annotator('#annotated_text', { | ||
readOnly: false, | ||
lastNoteId: 0, | ||
editNoteFormSelector: '#update_note_form', | ||
noteContextMenu: [ | ||
{ action: 'add-annotation', icon: 'fa-plus', name: '#{msg.add_annotation}' }, | ||
{ action: 'edit-annotation', icon: 'fa-pencil-alt', name: '#{msg.edit_annotation}' }, | ||
{ action: 'delete-annotation', icon: 'fa-minus', name: '#{msg.delete_annotation}' }, | ||
{ action: 'add-wordnet-definition', icon: 'fa-language', name: '#{msg.add_wordnet_definition}' }, | ||
{ action: 'delete-selection', icon: 'fa-trash', name: '#{msg.delete_selection}' }, | ||
{ action: 'colorpicker', icon: 'fa-folder', name: '#{msg.color}' } | ||
], | ||
annotations: [ | ||
#{resourceAnnotationBean.getAnnotationsAsJson()} | ||
], | ||
locale: { | ||
deleteSelection: '#{msg.delete_selection}' | ||
} | ||
}); | ||
</h:outputScript> | ||
</ui:fragment> | ||
</div> | ||
|
||
</ui:composition> |
Oops, something went wrong.