From 80193603c6ab37cad98661bcf19f60ce3a145b05 Mon Sep 17 00:00:00 2001 From: f43nd1r Date: Wed, 4 Dec 2019 03:55:12 +0100 Subject: [PATCH] cleaner looking danger zone for app AdminTab --- acrarium/frontend/elements/card.js | 1 + .../acra/ui/component/Translatable.java | 4 +- .../acra/ui/view/app/tabs/AdminTab.java | 73 +++++++++++-------- .../com/faendir/acra/messages_de.properties | 10 ++- .../com/faendir/acra/messages_en.properties | 10 ++- 5 files changed, 62 insertions(+), 36 deletions(-) diff --git a/acrarium/frontend/elements/card.js b/acrarium/frontend/elements/card.js index 0f5801c..9d5ed25 100644 --- a/acrarium/frontend/elements/card.js +++ b/acrarium/frontend/elements/card.js @@ -37,6 +37,7 @@ class AcrariumCard extends PolymerElement { slot[class~="divider"]::slotted(:not(:first-child)) { border-top: 1px solid var(--lumo-contrast-20pct); + margin-top: 0.5em; } diff --git a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java index 4e25c3a..db0bf09 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java @@ -117,8 +117,8 @@ public class Translatable extends Composite implements L return new Translatable<>(new TextArea("", initialValue, ""), textField -> textField.setLabel(textField.getTranslation(captionId, params))); } - public static Translatable> createComboBox(@NonNull Collection items, @NonNull String captionId, @NonNull Object... params) { - return new Translatable<>(new ComboBox<>("", items), tComboBox -> tComboBox.setLabel(tComboBox.getTranslation(captionId, params))); + public static Translatable.Value, T> createComboBox(@NonNull Collection items, @NonNull String captionId, @NonNull Object... params) { + return new Translatable.Value<>(new ComboBox<>("", items), tComboBox -> tComboBox.setLabel(tComboBox.getTranslation(captionId, params))); } public static Translatable> createSelect(@NonNull Collection items, @NonNull String captionId, @NonNull Object... params) { diff --git a/acrarium/src/main/java/com/faendir/acra/ui/view/app/tabs/AdminTab.java b/acrarium/src/main/java/com/faendir/acra/ui/view/app/tabs/AdminTab.java index 524491a..874f441 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/view/app/tabs/AdminTab.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/view/app/tabs/AdminTab.java @@ -170,37 +170,50 @@ public class AdminTab extends AppTab
{ Box configBox = new Box(Translatable.createLabel(Messages.NEW_ACRA_CONFIG), Translatable.createLabel(Messages.NEW_ACRA_CONFIG_DETAILS), Translatable.createButton(e -> new Popup().setTitle(Messages.NEW_ACRA_CONFIG_CONFIRM) - .addYesNoButtons(popup -> popup.clear().addComponent(new ConfigurationLabel(getDataService().recreateReporterUser(app))).addCloseButton().show()) - .show(), Messages.CREATE)); + .addYesNoButtons(popup -> popup.clear().addComponent(new ConfigurationLabel(getDataService().recreateReporterUser(app))).addCloseButton().show()) + .show(), Messages.CREATE)); Box matchingBox = new Box(Translatable.createLabel(Messages.NEW_BUG_CONFIG), Translatable.createLabel(Messages.NEW_BUG_CONFIG_DETAILS), Translatable.createButton(e -> { - App.Configuration configuration = app.getConfiguration(); - Translatable.Value score = Translatable.createRangeField(Messages.SCORE).with(it -> { - it.setMin(0); - it.setMax(100); - it.setValue((double) configuration.getMinScore()); - }); - new Popup().addComponent(score) - .setTitle(Messages.NEW_BUG_CONFIG_CONFIRM) - .addYesNoButtons(p -> getDataService().changeConfiguration(app, new App.Configuration(score.getValue().intValue())), true) - .show(); - }, Messages.CONFIGURE)); - NumberField age = new NumberField(); - age.setStep(1d); - age.setMin(1d); - age.setValue(30d); - age.setPreventInvalidInput(true); - age.setHasControls(true); - age.setWidthFull(); - age.setSuffixComponent(Translatable.createLabel(Messages.REPORTS_OLDER_THAN2)); - FlexLayout purgeAge = new FlexLayout(); - purgeAge.setWidthFull(); - purgeAge.preventWhiteSpaceBreaking(); - purgeAge.setAlignItems(FlexComponent.Alignment.CENTER); - purgeAge.add(Translatable.createButton(e -> getDataService().deleteReportsOlderThanDays(app, age.getValue().intValue()), Messages.PURGE), - Translatable.createLabel(Messages.REPORTS_OLDER_THAN1), - age); - purgeAge.expand(age); + App.Configuration configuration = app.getConfiguration(); + Translatable.Value score = Translatable.createRangeField(Messages.SCORE).with(it -> { + it.setMin(0); + it.setMax(100); + it.setValue((double) configuration.getMinScore()); + }); + new Popup().addComponent(score) + .setTitle(Messages.NEW_BUG_CONFIG_CONFIRM) + .addYesNoButtons(p -> getDataService().changeConfiguration(app, new App.Configuration(score.getValue().intValue())), true) + .show(); + }, Messages.CONFIGURE)); + Box purgeAgeBox = new Box(Translatable.createLabel(Messages.PURGE_OLD), Translatable.createLabel(Messages.PURGE_OLD_DETAILS), Translatable.createButton(e -> { + Translatable.Value age = Translatable.createNumberField(30d, Messages.REPORTS_OLDER_THAN1).with(it -> { + it.setStep(1d); + it.setMin(1d); + it.setPreventInvalidInput(true); + it.setHasControls(true); + it.setWidthFull(); + it.setSuffixComponent(Translatable.createLabel(Messages.REPORTS_OLDER_THAN2)); + } + ); + new Popup().addComponent(age) + .addYesNoButtons(popup -> { + getDataService().deleteReportsOlderThanDays(app, age.getValue().intValue()); + }, true).show(); + }, Messages.PURGE)); + Box purgeVersionBox = new Box(Translatable.createLabel(Messages.PURGE_VERSION), Translatable.createLabel(Messages.PURGE_VERSION_DETAILS), Translatable.createButton(e -> { + Translatable.Value, Integer> versionBox = Translatable.createComboBox(getDataService().getFromReports(app, null, report.stacktrace.version.code), Messages.REPORTS_BEFORE_VERSION); + new Popup().addComponent(versionBox) + .addYesNoButtons(popup -> { + if (versionBox.getValue() != null) { + getDataService().deleteReportsBeforeVersion(app, versionBox.getValue()); + } + }, true).show(); + }, Messages.PURGE)); + Box deleteBox = new Box(Translatable.createLabel(Messages.DELETE_APP), Translatable.createLabel(Messages.DELETE_APP_DETAILS), Translatable.createButton(e -> + new Popup().setTitle(Messages.DELETE_APP_CONFIRM).addYesNoButtons(popup -> { + getDataService().delete(app); + UI.getCurrent().navigate(Overview.class); + }, true).show(), Messages.DELETE)); ComboBox versionBox = new ComboBox<>(null, getDataService().getFromReports(app, null, QReport.report.stacktrace.version.code)); versionBox.setWidth("100%"); FlexLayout purgeVersion = new FlexLayout(); @@ -218,7 +231,7 @@ public class AdminTab extends AppTab
{ UI.getCurrent().navigate(Overview.class); }, true).show(), Messages.DELETE_APP); deleteButton.setWidthFull(); - Card dangerCard = createCard(configBox, matchingBox, purgeAge, purgeVersion, deleteButton); + Card dangerCard = createCard(configBox, matchingBox, purgeAgeBox, purgeVersionBox, deleteBox); dangerCard.setHeader(Translatable.createLabel(Messages.DANGER_ZONE)); dangerCard.enableDivider(); dangerCard.setHeaderColor("var(----lumo-error-text-color)", "var(--lumo-error-color)"); diff --git a/acrarium/src/main/resources/i18n/com/faendir/acra/messages_de.properties b/acrarium/src/main/resources/i18n/com/faendir/acra/messages_de.properties index d0a3a25..9315d36 100644 --- a/acrarium/src/main/resources/i18n/com/faendir/acra/messages_de.properties +++ b/acrarium/src/main/resources/i18n/com/faendir/acra/messages_de.properties @@ -50,7 +50,7 @@ solved=Gelöst statistics=Statistiken newAcraConfig=Erzeuge neue ACRA Konfiguration confirm=Bestätigen -newAcraConfigConfirm=Sind Sie sicher dass Sie eine neue ACRA Konfiguration erzeugen wollen?
Die existierende Konfiguration wird dadurch ungültig +newAcraConfigConfirm=Sind Sie sicher dass Sie eine neue ACRA Konfiguration erzeugen wollen? Die existierende Konfiguration wird dadurch ungültig newBugConfig=Bugzusammenfassung konfigurieren minScore=Minimaler Score newBugConfigConfirm=Sind Sie sicher dass sie diese Konfiguration speichern wollen? Alle Bugs werden überprüft, was eine Weile dauern kann. Beachten Sie außerdem, dass ein höherer Wert keine bereits gebildeten Zusammenfassungen auflöst. @@ -169,4 +169,10 @@ settings=Einstellungen other=Weitere newAcraConfigDetails=Nützlich wenn Sie die Konfiguration vergessen haben oder invalidieren wollen configure=Konfigurieren -newBugConfigDetails=Anpassen wie ähnlich Bugs sein müssen um automatisch zusammgeführt zu werden \ No newline at end of file +newBugConfigDetails=Anpassen wie ähnlich Bugs sein müssen um automatisch zusammgeführt zu werden +purgeOld=Lösche alte Berichte +purgeOldDetails=Lösche Berichte, die älter als das gegebene Datum sind +purgeVersion=Lösche Berichte aus alten Versionen +purgeVersionDetails=Lösche Berichte, die älter als die gegebene Version sind +deleteAppDetails=Lösche diese App und alle zugehörigen Daten +delete=Lösche \ No newline at end of file diff --git a/acrarium/src/main/resources/i18n/com/faendir/acra/messages_en.properties b/acrarium/src/main/resources/i18n/com/faendir/acra/messages_en.properties index cae7eff..e82af18 100644 --- a/acrarium/src/main/resources/i18n/com/faendir/acra/messages_en.properties +++ b/acrarium/src/main/resources/i18n/com/faendir/acra/messages_en.properties @@ -50,7 +50,7 @@ solved=Solved statistics=Statistics newAcraConfig=Create new ACRA Configuration confirm=Confirm -newAcraConfigConfirm=Are you sure you want to create a new ACRA configuration?
The existing configuration will be invalidated +newAcraConfigConfirm=Are you sure you want to create a new ACRA configuration? The existing configuration will be invalidated newBugConfig=Configure Bug matching minScore=Minimum Score newBugConfigConfirm=Are you sure you want to save this configuration?\ @@ -171,4 +171,10 @@ settings=Settings other=Other newAcraConfigDetails=Useful if you forgot or want to invalidate the old configuration configure=Configure -newBugConfigDetails=Change how similar bugs have to be to be merged automatically \ No newline at end of file +newBugConfigDetails=Change how similar bugs have to be to be merged automatically +purgeOld=Purge old reports +purgeOldDetails=Delete reports older than a certain date +purgeVersion=Purge reports from previous versions +purgeVersionDetails=Delete reports older than a certain version +deleteAppDetails=Delete this app and all data associated with it +delete=Delete \ No newline at end of file