Skip to content

Commit

Permalink
feat: allow using Search Chat per organization
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Nov 28, 2023
1 parent 1e1bd8c commit ebd5274
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 125 deletions.
256 changes: 136 additions & 120 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"video.js": "^8.6.1"
},
"devDependencies": {
"esbuild": "^0.19.2",
"esbuild": "^0.19.8",
"esbuild-sass-plugin": "^2.16.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<maven.dependency.jdbi3.version>3.41.3</maven.dependency.jdbi3.version>
<maven.dependency.flyway.version>10.0.1</maven.dependency.flyway.version>
<maven.dependency.log4j.version>2.21.1</maven.dependency.log4j.version>
<maven.dependency.sentry.version>6.33.1</maven.dependency.sentry.version>
<maven.dependency.sentry.version>6.34.0</maven.dependency.sentry.version>
<maven.dependency.junit.version>5.10.1</maven.dependency.junit.version>
<maven.dependency.mockito.version>5.7.0</maven.dependency.mockito.version>

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/de/l3s/learnweb/search/SearchChatBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class SearchChatBean extends ApplicationBean implements Serializable {

public void onLoad() throws InterwebException {
BeanAssert.authorized(isLoggedIn());
BeanAssert.hasPermission(getUser().isModerator() || getUserBean().isSearchChatEnabled());
interweb = getLearnweb().getInterweb();

newChat();
Expand All @@ -65,8 +66,8 @@ public void sendMessage() throws InterwebException {
message = null;

interweb.chatComplete(conversation);
if (!conversations.contains(conversation)) {
conversations.add(0, conversation);
if (!getConversations().contains(conversation)) {
getConversations().add(0, conversation);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/l3s/learnweb/user/Organisation.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public enum Option {
Search_Disable_alternative_sources,
Resource_Disallow_editing,
Resource_Disable_video_preview,
Search_Chat_enabled,
}

private int id;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/de/l3s/learnweb/user/UserBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ public boolean isLoggingEnabled() {
return !getActiveOrganisation().map(o -> o.getOption(Option.Privacy_Logging_disabled)).orElse(true);
}

public boolean isSearchChatEnabled() {
return getActiveOrganisation().map(o -> o.getOption(Option.Search_Chat_enabled)).orElse(false);
}

public boolean isTrackingEnabled() {
if (StringUtils.isEmpty(getTrackerApiKey())) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/de/l3s/learnweb/lang/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,8 @@ video_guide = Video guide

videos = Videos

chat = Chat

visualization = Visualization

votes = {0, choice, 0#Not rated yet|1#One vote|1<{0} Votes}
Expand Down
9 changes: 9 additions & 0 deletions src/main/webapp/lw/search.xhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ui:composition template="/WEB-INF/templates/layout/template.xhtml"
xmlns:h="jakarta.faces.html"
xmlns:f="jakarta.faces.core"
xmlns:faces="jakarta.faces"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="jakarta.faces.facelets">

Expand Down Expand Up @@ -62,6 +63,14 @@
<f:param name="query" value="#{searchBean.query}"/>
</h:link>
</li>
<li class="filter" faces:rendered="#{userBean.searchChatEnabled}">
<h:link outcome="search/chat">
<span class="filter-title">
<span class="text-truncate">#{msg.chat}</span>
</span>
<f:param name="query" value="#{searchBean.query}"/>
</h:link>
</li>
</ul>

<h:form id="search_source_carousel" styleClass="bg-medium p-2" rendered="#{searchBean.showAlternativeSources}">
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/lw/search/chat.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="filter active">
<h:link disabled="true">
<span class="filter-title">
<span class="text-truncate">#{msg.Chat}</span>
<span class="text-truncate">#{msg.chat}</span>
</span>
<f:param name="query" value="#{searchChatBean.query}"/>
</h:link>
Expand Down

0 comments on commit ebd5274

Please sign in to comment.