diff --git a/Kitodo-DataManagement/src/main/resources/db/migration/V2_104__Add_authority_to_broadcast_messages.sql b/Kitodo-DataManagement/src/main/resources/db/migration/V2_104__Add_authority_to_broadcast_messages.sql new file mode 100644 index 00000000000..bedb3be9e38 --- /dev/null +++ b/Kitodo-DataManagement/src/main/resources/db/migration/V2_104__Add_authority_to_broadcast_messages.sql @@ -0,0 +1,17 @@ +-- +-- (c) Kitodo. Key to digital objects e. V. +-- +-- This file is part of the Kitodo project. +-- +-- It is licensed under GNU General Public License version 3 or later. +-- +-- For the full copyright and license information, please read the +-- GPL3-License.txt file that was distributed with this source code. +-- + +-- Insert authority to broadcast messages + +INSERT IGNORE INTO authority (title) VALUES ('broadcastMessage_globalAssignable'); + +INSERT IGNORE INTO role_x_authority (role_id, authority_id) +SELECT (SELECT id FROM role WHERE title = 'Administration'), id FROM authority WHERE title = 'broadcastMessage_globalAssignable'; diff --git a/Kitodo/src/main/java/org/kitodo/production/channel/SystemMessageChannel.java b/Kitodo/src/main/java/org/kitodo/production/channel/SystemMessageChannel.java new file mode 100644 index 00000000000..eff669ab637 --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/channel/SystemMessageChannel.java @@ -0,0 +1,185 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.production.channel; + +import java.util.HashMap; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; +import javax.faces.push.Push; +import javax.faces.push.PushContext; +import javax.inject.Inject; +import javax.inject.Named; + +import org.kitodo.data.database.beans.User; +import org.kitodo.production.security.SecuritySession; +import org.kitodo.production.services.ServiceManager; + +@Named("SystemMessageChannel") +@ApplicationScoped +public class SystemMessageChannel { + + @Inject + @Push + PushContext messageChannel; + + private static final String SHOW_MESSAGE = "showMessage"; + private static final String UPDATE_USER_TABLE = "updateUserTable"; + + private String userName = ""; + private String message = ""; + private HashMap currentUsers; + + private String staticSystemMessage = ""; + private Boolean showSystemMessage = false; + + /** + * Inform connected websocket clients to show message. + */ + public void showMessage() { + messageChannel.send(SHOW_MESSAGE); + } + + /** + * Inform connected websocket clients to update user table. + */ + public void updateUserTable() { + messageChannel.send(UPDATE_USER_TABLE); + } + + /** + * Set message String. + * + * @param messageText message String + */ + public void setMessage(String messageText) { + this.message = messageText; + } + + /** + * Get message String. + * + * @return message String + */ + public String getMessage() { + return this.message; + } + + /** + * Acknowledge system message. + * + * @param user User that acknowledges system message + */ + public void acknowledge(User user) { + this.currentUsers.put(user.getLogin(), true); + this.updateUserTable(); + } + + /** + * Load list of current users. + */ + public void loadCurrentUsers() { + this.currentUsers = new HashMap<>(); + for (SecuritySession session : ServiceManager.getSessionService().getActiveSessions()) { + this.currentUsers.put(session.getUserName(), null); + } + } + + /** + * Reset status of current users. + */ + public void resetCurrentUsersStatus() { + this.currentUsers.replaceAll((n, v) -> false); + } + + /** + * Get list of current users. + * + * @return list of current users + */ + public Set getCurrentUsers() { + return this.currentUsers.keySet(); + } + + /** + * Return whether User with user name 'userName' acknowledged system message or not. + * + * @param userName user name of user to check + * @return whether user acknowledged system message or not + */ + public Boolean acknowledged(String userName) { + return this.currentUsers.get(userName); + } + + /** + * Get user name of broadcaster. + * + * @return user name + */ + public String getUserName() { + return this.userName; + } + + /** + * Set user name of broadcaster. + * + * @param name user name + */ + public void setUserName(String name) { + this.userName = name; + } + + /** + * Send message String to connected clients. + */ + public void sendMessage() { + this.resetCurrentUsersStatus(); + this.showMessage(); + } + + /** + * Get staticSystemMessage. + * + * @return value of staticSystemMessage + */ + public String getStaticSystemMessage() { + return staticSystemMessage; + } + + /** + * Set staticSystemMessage. + * + * @param staticSystemMessage as java.lang.String + */ + public void setStaticSystemMessage(String staticSystemMessage) { + this.staticSystemMessage = staticSystemMessage; + } + + /** + * Get showSystemMessage. + * + * @return value of showSystemMessage + */ + public boolean isShowSystemMessage() { + return showSystemMessage; + } + + /** + * Set showSystemMessage. + * + * @param showSystemMessage as boolean + */ + public void setShowSystemMessage(boolean showSystemMessage) { + this.showSystemMessage = showSystemMessage; + } + +} diff --git a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java index e2539fa5e24..06eea117633 100644 --- a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java +++ b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java @@ -631,7 +631,8 @@ public boolean hasAuthorityToViewSystemPage() { return securityAccessService.hasAuthorityToViewIndexPage() || securityAccessService.hasAuthorityToViewTaskManagerPage() || securityAccessService.hasAuthorityToViewTermsPage() - || securityAccessService.hasAuthorityToViewMigrationPage(); + || securityAccessService.hasAuthorityToViewMigrationPage() + || securityAccessService.hasAuthorityToViewMessagePage(); } /** @@ -670,6 +671,15 @@ public boolean hasAuthorityToViewMigrationPage() { return securityAccessService.hasAuthorityToViewMigrationPage(); } + /** + * Check if current user has authority to view message tab of system page. + * + * @return true if user has authority to view message tab of system page + */ + public boolean hasAuthorityToViewMessagePage() { + return securityAccessService.hasAuthorityToViewMessagePage(); + } + /** * Check if current user has authority to view task page. It returns true if * user has "viewAllTasks" authority for client. diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/SystemWarningForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/SystemWarningForm.java new file mode 100644 index 00000000000..5c8a7b0e4f5 --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/forms/SystemWarningForm.java @@ -0,0 +1,46 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.production.forms; + +import java.io.Serializable; + +import javax.enterprise.context.SessionScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import org.kitodo.production.channel.SystemMessageChannel; + +@Named("SystemWarningForm") +@SessionScoped +public class SystemWarningForm implements Serializable { + + @Inject + private SystemMessageChannel systemMessageChannel; + + /** + * Set warning String. + * + * @param warningText warning String + */ + public void setWarning(String warningText) { + this.systemMessageChannel.setMessage(warningText); + } + + /** + * Get warning String. + * + * @return warning String + */ + public String getWarning() { + return ""; + } +} diff --git a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java index 2d60ddddbba..ca38650776e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java @@ -913,6 +913,15 @@ public boolean hasAuthorityToViewMigrationPage() { return hasAnyAuthorityGlobal("viewMigration"); } + /** + * Check if the current user has the authority to view the message tab of the system page. + * + * @return true if the current user has the authority to view the message tab of the system page + */ + public boolean hasAuthorityToViewMessagePage() { + return hasAnyAuthorityGlobal("broadcastMessage"); + } + private boolean hasAuthorityForTask(int taskId) throws DataException { Integer processId = ServiceManager.getTaskService().findById(taskId).getProcess().getId(); diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index d43917e0484..fd6190e1537 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -18,6 +18,7 @@ mapping=ElasticSearch Mapping NOT=Enth\u00E4lt nicht NoCataloguePluginForCatalogue=Keines der verf\u00fcgbaren OPAC-Plugins unterst\u00fctzt diesen Katalog. abDerErstenMarkiertenSeite=Ab der ersten markierten Seite +acknowledged=Best\u00E4tigt active=Aktiv ACTIVE=Aktiv activeUsers=Aktive Benutzer @@ -567,6 +568,7 @@ locked=Gesperrt location=Standort loggedIn=Angemeldet logical=Logische +loggedInUsers=Angemeldete Benutzer login=Login loginNoteText=Kitodo.Production ist das Workflowmanagementmodul der Kitodo-Suite. Es unterst\u00FCtzt den Digitalisierungsprozess verschiedener Materialarten wie z.B. Drucken, Periodika, Handschriften, Noten und Musikalien, Einblattmedien und Dokumentennachl\u00E4ssen. logout=Logout @@ -859,6 +861,7 @@ selectProcess=Vorgang ausw\u00E4hlen selectProject=Bitte Projekt ausw\u00E4hlen selectTemplate=Bitte Produktionsvorlage ausw\u00E4hlen selectWorkflow=Bitte Workflow ausw\u00E4hlen +send=Absenden sendSolutionMessageNextTask=Meldung \u00FCber Probleml\u00F6sung an nachfolgende Station senden sendSolutionMessage=Meldung \u00FCber Probleml\u00F6sung senden sendSolutionMessageForAll=Meldung \u00FCber Probleml\u00F6sung f\u00FCr alle Schritte senden @@ -932,6 +935,9 @@ systemErrorInformAdminMessage=Bitte informieren Sie einen Administrator! systemErrorMessage=Es ist ein Fehler im System aufgetreten. systemMaintenanceHeader=Systemwartung systemMaintenanceMessage=Das System wird derzeit gewartet. +systemMessage=Systemnachricht +systemMessage.broadcast=Broadcast +systemMessage.static=Statische Systemnachricht table=Tabelle tableSize=Tabellengr\u00F6\u00DFe task=Aufgabe diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 5c360ac7a7e..b8e4ff0a105 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -18,6 +18,7 @@ mapping=ElasticSearch mapping NOT=does not contain NoCataloguePluginForCatalogue=None of the OPAC plugins available is capable of reading this catalogue. abDerErstenMarkiertenSeite=From first selected page +acknowledged=Acknowledged active=Active ACTIVE=Active activeUsers=Current users @@ -579,6 +580,7 @@ locked=Locked location=Location loggedIn=Logged in logical=Logical +loggedInUsers=Logged in users login=Login loginNoteText=Kitodo.Production is the workflow management module in the Kitodo suite. It supports the process of digitising a range of material types, such as books, periodicals, manuscripts, printed music, single-sheet media, and document collections. logout=Log out @@ -874,6 +876,7 @@ selectProcess=Select process selectProject=Please select a project selectTemplate=Please select a template selectWorkflow=Please select a workflow +send=Send sendSolutionMessageNextTask=Send message about problem solution to following task sendSolutionMessage=Send message about problem solution sendSolutionMessageForAll=send troubleshooting message to all steps @@ -948,6 +951,9 @@ systemErrorInformAdminMessage=Please inform an administrator! systemErrorMessage=A system error occurred. systemMaintenanceHeader=System maintenance systemMaintenanceMessage=The system is currently under maintenance. +systemMessage=System message +systemMessage.broadcast=Broadcast +systemMessage.static=Static system message table=Table tableSize=Table size task=Task diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 3bb26907e7c..44097f1f3fb 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -2652,6 +2652,59 @@ kbd { padding: 0 var(--default-half-size); } +/*---------------------------------------------------------------------- +System page +----------------------------------------------------------------------*/ + +#systemTabView .messageWrapper { + border: 1px solid var(--carbon-blue); + border-radius: var(--default-border-radius); + margin: auto; + padding: var(--default-double-size); + width: 50%; +} + +#systemTabView\:systemWarningForm\:warningText { + height: 100px; +} + +#systemTabView\:systemWarningForm\:sendWarningButton { + margin-top: var(--default-half-size); +} + +#acknowledgeSystemWarningForm\:okButton { + margin-right: var(--default-double-size); +} + +#acknowledgeSystemWarningForm\:systemMessageLabel { + font-style: italic; + font-weight: bold; +} + +#acknowledgeSystemWarningForm\:messageWrapper { + padding: 0 var(--default-double-size); +} + +#systemMessagePanel { + background-color: white; + border: 3px solid red; + color: red; + height: 70px; + left: calc(50% - 320px); + opacity: 80%; + padding: var(--default-full-size); + pointer-events: none; + position: absolute; + text-align: center; + top: 10px; + width: 640px; + z-index: 9999; +} + +#systemTabView\:messagePanel.ui-accordion .ui-accordion-content { + padding: 0; +} + /*---------------------------------------------------------------------- Workflow Editor ----------------------------------------------------------------------*/ diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/pattern-library.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/pattern-library.css index 2aac0690522..40367463851 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/pattern-library.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/pattern-library.css @@ -1589,6 +1589,15 @@ Popup dialogs padding: 0; } +/* Helper classes for colors */ +.red { + color: var(--focused-orange); +} + +.green { + color: var(--focused-green); +} + /* Messages */ .ui-messages-error.ui-corner-all, .ui-messages-warn.ui-corner-all, diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/defaultScript.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/defaultScript.js index 42a5680572f..f52b24ca3e7 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/defaultScript.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/defaultScript.js @@ -8,7 +8,20 @@ * For the full copyright and license information, please read the * GPL3-License.txt file that was distributed with this source code. */ +/* globals updateSystemMessageDialog, updateUserTable */ $(document).ready(function() { $('#loadingScreen').hide(); }); + +function onMessage(message) { + if (message === "showMessage") { + updateSystemMessageDialog(); + } else if (message === "updateUserTable" && typeof updateUserTable === "function") { + updateUserTable(); + } +} + +function onChannelClose(code, channel) { + channel = null; +} diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/base.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/base.xhtml index d7fc149ddb7..499c2726b1f 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/base.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/base.xhtml @@ -25,7 +25,15 @@ - + + +

#{SystemMessageChannel.staticSystemMessage}

+
+ + + + @@ -80,6 +89,10 @@ target="body" /> +
diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/base/systemMessageDialog.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/base/systemMessageDialog.xhtml new file mode 100644 index 00000000000..2f3b2b5dbb3 --- /dev/null +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/base/systemMessageDialog.xhtml @@ -0,0 +1,48 @@ + + + + + +

#{msgs['systemMessage.broadcast']}

+ + + + + + +
+
+
diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/system/message.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/system/message.xhtml new file mode 100644 index 00000000000..13bc15e612a --- /dev/null +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/system/message.xhtml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + diff --git a/Kitodo/src/main/webapp/pages/login.xhtml b/Kitodo/src/main/webapp/pages/login.xhtml index a7e94c230e6..f5e1031cb04 100644 --- a/Kitodo/src/main/webapp/pages/login.xhtml +++ b/Kitodo/src/main/webapp/pages/login.xhtml @@ -11,76 +11,86 @@ * --> - - - - + - -

- -
- + + + + + + + + + + + + + - +
+ +
- +
+
+ + + + + + +
+ + +
+
+
+
- -
-
- - - - - - -
- - -
-
-
-
+ +

#{msgs.pleaseSignIn}

+
+ + + +
+ + +
+
+ + +
+ + +
- -

#{msgs.pleaseSignIn}

-
- - - -
- - + -
- - -
- - - - + + +
+
+ +
+
- - -
-
- -
-
-
+ -
+ +
+ + diff --git a/Kitodo/src/main/webapp/pages/system.xhtml b/Kitodo/src/main/webapp/pages/system.xhtml index 92f57e41bb8..c2dd8b090a9 100644 --- a/Kitodo/src/main/webapp/pages/system.xhtml +++ b/Kitodo/src/main/webapp/pages/system.xhtml @@ -25,6 +25,7 @@ + @@ -50,6 +51,10 @@ rendered="#{SecurityAccessController.hasAuthorityToViewMigrationPage()}"> + + +