From: David ‘Bombe’ Roden Date: Tue, 12 Apr 2011 07:05:48 +0000 (+0200) Subject: Add image insert notifications. X-Git-Tag: beta-freefall-0.6.2-1~35 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=74619f4302ade0dd34c9b169e23c2f3314d4c0b3;p=Sone.git Add image insert notifications. --- diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index ddca4d1..560b3c3 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -37,6 +37,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.CoreListener; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; @@ -173,6 +174,15 @@ public class WebInterface implements CoreListener { /** The “new version” notification. */ private final TemplateNotification newVersionNotification; + /** The “inserting images” notification. */ + private final ListNotification insertingImagesNotification; + + /** The “inserted images” notification. */ + private final ListNotification insertedImagesNotification; + + /** The “image insert failed” notification. */ + private final ListNotification imageInsertFailedNotification; + /** * Creates a new web interface. * @@ -235,6 +245,15 @@ public class WebInterface implements CoreListener { Template newVersionTemplate = TemplateParser.parse(createReader("/templates/notify/newVersionNotification.html")); newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate); + + Template insertingImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserting-images-notification.html")); + insertingImagesNotification = new ListNotification("inserting-images-notification", "images", insertingImagesTemplate); + + Template insertedImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserted-images-notification.html")); + insertedImagesNotification = new ListNotification("inserted-images-notification", "images", insertedImagesTemplate); + + Template imageInsertFailedTemplate = TemplateParser.parse(createReader("/templates/notify/image-insert-failed-notification.html")); + imageInsertFailedNotification = new ListNotification("image-insert-failed-notification", "images", imageInsertFailedTemplate); } // @@ -797,6 +816,8 @@ public class WebInterface implements CoreListener { */ @Override public void imageInsertStarted(Image image) { + insertingImagesNotification.add(image); + notificationManager.addNotification(insertingImagesNotification); } /** @@ -804,6 +825,7 @@ public class WebInterface implements CoreListener { */ @Override public void imageInsertAborted(Image image) { + insertingImagesNotification.remove(image); } /** @@ -811,6 +833,9 @@ public class WebInterface implements CoreListener { */ @Override public void imageInsertFinished(Image image) { + insertingImagesNotification.remove(image); + insertedImagesNotification.add(image); + notificationManager.addNotification(insertedImagesNotification); } /** @@ -818,6 +843,9 @@ public class WebInterface implements CoreListener { */ @Override public void imageInsertFailed(Image image, Throwable cause) { + insertingImagesNotification.remove(image); + imageInsertFailedNotification.add(image); + notificationManager.addNotification(imageInsertFailedNotification); } /** diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index b146e68..aa90d0b 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -285,3 +285,6 @@ Notification.SoneRescued.Text=The following Sones have been rescued: Notification.SoneRescued.Text.RememberToUnlock=Please remember to control the posts and replies you have given and don’t forget to unlock your Sones! Notification.LockedSones.Text=The following Sones have been locked for more than 5 minutes. Please check if you really want to keep these Sones locked: Notification.NewVersion.Text=Version {version} of the Sone plugin was found. Download it from USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​! +Notification.InsertingImages.Text=The following images are being inserted: +Notification.InsertedImages.Text=The following images have been inserted: +Notification.ImageInsertFailed.Text=The following images could not be inserted: diff --git a/src/main/resources/templates/notify/image-insert-failed-notification.html b/src/main/resources/templates/notify/image-insert-failed-notification.html new file mode 100644 index 0000000..c4b3c67 --- /dev/null +++ b/src/main/resources/templates/notify/image-insert-failed-notification.html @@ -0,0 +1,6 @@ +
+ <%= Notification.ImageInsertFailed.Text|l10n|html> + <%foreach images image> + <%image.title|html><%notlast>,<%/notlast><%last>.<%/last> + <%/foreach> +
diff --git a/src/main/resources/templates/notify/inserted-images-notification.html b/src/main/resources/templates/notify/inserted-images-notification.html new file mode 100644 index 0000000..f388d59 --- /dev/null +++ b/src/main/resources/templates/notify/inserted-images-notification.html @@ -0,0 +1,6 @@ +
+ <%= Notification.InsertedImages.Text|l10n|html> + <%foreach images image> + <%image.title|html><%notlast>,<%/notlast><%last>.<%/last> + <%/foreach> +
diff --git a/src/main/resources/templates/notify/inserting-images-notification.html b/src/main/resources/templates/notify/inserting-images-notification.html new file mode 100644 index 0000000..efe930d --- /dev/null +++ b/src/main/resources/templates/notify/inserting-images-notification.html @@ -0,0 +1,6 @@ +
+ <%= Notification.InsertingImages.Text|l10n|html> + <%foreach images image> + <%image.title|html><%notlast>,<%/notlast><%last>.<%/last> + <%/foreach> +