From fc297fdde75f913335284265a3ff4046e8015ddb Mon Sep 17 00:00:00 2001 From: uhensler <none@none> Date: Wed, 12 Jul 2017 10:23:29 +0200 Subject: [PATCH] OO-2834: Format the quota bytes in the admin environment --- .../olat/admin/quota/QuotaByteRenderer.java | 50 +++++++++++++++++++ .../org/olat/admin/quota/QuotaController.java | 8 ++- .../quota/_i18n/LocalStrings_cs.properties | 4 +- .../quota/_i18n/LocalStrings_da.properties | 4 +- .../quota/_i18n/LocalStrings_de.properties | 4 +- .../quota/_i18n/LocalStrings_el.properties | 4 +- .../quota/_i18n/LocalStrings_en.properties | 4 +- .../quota/_i18n/LocalStrings_es.properties | 4 +- .../quota/_i18n/LocalStrings_fa.properties | 4 +- .../quota/_i18n/LocalStrings_it.properties | 4 +- .../quota/_i18n/LocalStrings_jp.properties | 4 +- .../quota/_i18n/LocalStrings_lt.properties | 4 +- .../quota/_i18n/LocalStrings_nl_NL.properties | 4 +- .../quota/_i18n/LocalStrings_sq.properties | 4 +- 14 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 src/main/java/org/olat/admin/quota/QuotaByteRenderer.java diff --git a/src/main/java/org/olat/admin/quota/QuotaByteRenderer.java b/src/main/java/org/olat/admin/quota/QuotaByteRenderer.java new file mode 100644 index 00000000000..3c951c516c6 --- /dev/null +++ b/src/main/java/org/olat/admin/quota/QuotaByteRenderer.java @@ -0,0 +1,50 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.admin.quota; + +import java.util.Locale; + +import org.olat.core.gui.components.table.CustomCellRenderer; +import org.olat.core.gui.render.Renderer; +import org.olat.core.gui.render.StringOutput; +import org.olat.core.util.Formatter; + +/** + * Render the bytes of the quota in a human readable format. + * + * Initial date: 12.07.2017<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class QuotaByteRenderer implements CustomCellRenderer { + + @Override + public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) { + if (val instanceof Long) { + Long kBytes = (Long) val; + Long bytes = kBytes * 1000L; + sb.append(Formatter.formatBytes(bytes)) + .append(" (") + .append(kBytes) + .append(")"); + } + } + +} diff --git a/src/main/java/org/olat/admin/quota/QuotaController.java b/src/main/java/org/olat/admin/quota/QuotaController.java index 221eb33a6dd..046a65fa8df 100644 --- a/src/main/java/org/olat/admin/quota/QuotaController.java +++ b/src/main/java/org/olat/admin/quota/QuotaController.java @@ -30,6 +30,8 @@ import org.olat.core.gui.components.Component; import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.link.LinkFactory; import org.olat.core.gui.components.panel.Panel; +import org.olat.core.gui.components.table.ColumnDescriptor; +import org.olat.core.gui.components.table.CustomRenderColumnDescriptor; import org.olat.core.gui.components.table.DefaultColumnDescriptor; import org.olat.core.gui.components.table.StaticColumnDescriptor; import org.olat.core.gui.components.table.Table; @@ -83,8 +85,10 @@ public class QuotaController extends BasicController { quotaTableModel = new QuotaTableModel(); tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.path", 0, null, getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.quota", 1, null, getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.limit", 2, null, getLocale())); + tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.quota", 1, null, getLocale(), + ColumnDescriptor.ALIGNMENT_LEFT, new QuotaByteRenderer())); + tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.limit", 2, null, getLocale(), + ColumnDescriptor.ALIGNMENT_LEFT, new QuotaByteRenderer())); tableCtr.addColumnDescriptor(new StaticColumnDescriptor("qf.edit", "table.action", translate("edit"))); tableCtr.addColumnDescriptor(new StaticColumnDescriptor("qf.del", "table.action", translate("delete"))); tableCtr.setTableDataModel(quotaTableModel); diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_cs.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_cs.properties index 0e217a14c35..eeaa465e02a 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_cs.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_cs.properties @@ -19,6 +19,6 @@ qf.noquota=Tento adres\u00E1\u0159 nem\u00E1 specifikovanou kv\u00F3tu. Jsou u\u qf.path=Cesta qf.quota=Kv\u00F3ta (KB) qf.title=Administrace kv\u00F3t -table.header.limit=Upload limit KB +table.header.limit=Upload limit (KB) table.header.path=Cesta -table.header.quota=Kv\u00F3ta KB +table.header.quota=Kv\u00F3ta (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_da.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_da.properties index bb532461134..17b5e0394b3 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_da.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_da.properties @@ -19,6 +19,6 @@ qf.noquota=Denne mappe har ingen specifik kvota. Den f\u00F8lgende standardkvota qf.path=Stinavn qf.quota=Kvota (KB) qf.title=Kvota administration -table.header.limit=Upload begr\u00E6nsning i KB +table.header.limit=Upload begr\u00E6nsning (KB) table.header.path=Stinavn -table.header.quota=Kvota KB +table.header.quota=Kvota (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_de.properties index f369dc40ade..5fc186b1efe 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_de.properties @@ -22,7 +22,7 @@ qf.noquota=Dieser Ordner hat keine spezifische Quota. Die untenstehenden Default qf.path=Pfad qf.quota=Quota (KB) qf.title=Quotaverwaltung -table.header.limit=Upload Limite KB +table.header.limit=Upload Limite (KB) table.header.path=Pfad -table.header.quota=Quota KB +table.header.quota=Quota (KB) warning.qd.not.enough.privilege=Sie haben nicht die Berechtigungen Quota zu editieren. diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_el.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_el.properties index a711a682871..06109780621 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_el.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_el.properties @@ -21,6 +21,6 @@ qf.noquota=\u039F \u03C6\u03AC\u03BA\u03B5\u03BB\u03BF\u03C2 \u03B4\u03B5\u03BD qf.path=\u0394\u03B9\u03B1\u03B4\u03C1\u03BF\u03BC\u03AE qf.quota=\u038C\u03C1\u03B9\u03B1 (KB) qf.title=\u0394\u03B9\u03B1\u03C7\u03B5\u03AF\u03C1\u03B9\u03C3\u03B7 \u039F\u03C1\u03AF\u03C9\u03BD -table.header.limit=\u038C\u03C1\u03B9\u03BF Upload [KB] +table.header.limit=\u038C\u03C1\u03B9\u03BF Upload (KB) table.header.path=\u0394\u03B9\u03B1\u03B4\u03C1\u03BF\u03BC\u03AE -table.header.quota=\u038C\u03C1\u03B9\u03BF [KB] +table.header.quota=\u038C\u03C1\u03B9\u03BF (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_en.properties index a701d4ec531..0d3e8d67072 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_en.properties @@ -22,7 +22,7 @@ qf.noquota=This folder has no specific quota. The following default quotas will qf.path=Path qf.quota=Quota (KB) qf.title=Quota management -table.header.limit=Upload limit KB +table.header.limit=Upload limit (KB) table.header.path=Path -table.header.quota=Quota KB +table.header.quota=Quota (KB) warning.qd.not.enough.privilege=You don't have the privileges to edit quotas. diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_es.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_es.properties index 6c5ee528420..9bf50c31717 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_es.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_es.properties @@ -19,6 +19,6 @@ qf.noquota=Esta carpeta no tiene cuota espec\u00EDfica. Se est\u00E1n utilizando qf.path=Ruta qf.quota=Cuota (KB) qf.title=Gesti\u00F3n de cuota -table.header.limit=L\u00EDmite de subida en KB +table.header.limit=L\u00EDmite de subida en (KB) table.header.path=Ruta -table.header.quota=Cuota KB +table.header.quota=Cuota (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_fa.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_fa.properties index 38617c141c7..eb6c3e0670b 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_fa.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_fa.properties @@ -19,6 +19,6 @@ qf.noquota=This folder has no specific quota. The following default quotas are u qf.path=Path qf.quota=Quota (KB) qf.title=Quota management -table.header.limit=Upload limit KB +table.header.limit=Upload limit (KB) table.header.path=Path -table.header.quota=Quota KB +table.header.quota=Quota (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_it.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_it.properties index 8208dde9ef9..843c68f8d2b 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_it.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_it.properties @@ -22,7 +22,7 @@ qf.noquota=Questa cartella non ha una quota specifica. Vengono utilizzate le quo qf.path=Percorso qf.quota=Quota (KB) qf.title=Gestione delle quote -table.header.limit=Limite di caricamento KB +table.header.limit=Limite di caricamento (KB) table.header.path=Percorso -table.header.quota=Quota KB +table.header.quota=Quota (KB) warning.qd.not.enough.privilege=Privilegi insufficienti per modificare le quote. diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_jp.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_jp.properties index da8b913d94c..fe364a77fae 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_jp.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_jp.properties @@ -21,6 +21,6 @@ qf.noquota=\u3053\u306E\u30D5\u30A9\u30EB\u30C0\u306B\u306F\u3001\u30AF\u30AA\u3 qf.path=\u30D1\u30B9 qf.quota=\u30AF\u30AA\u30FC\u30BF (KB) qf.title=\u30AF\u30AA\u30FC\u30BF\u7BA1\u7406 -table.header.limit=\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5236\u9650 KB +table.header.limit=\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5236\u9650 (KB) table.header.path=\u30D1\u30B9 -table.header.quota=\u30AF\u30AA\u30FC\u30BF KB +table.header.quota=\u30AF\u30AA\u30FC\u30BF (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_lt.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_lt.properties index 83282cbcce8..d2d73dffec4 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_lt.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_lt.properties @@ -19,6 +19,6 @@ qf.noquota=Aplankas neturi nustatytos kvotos. Bus naudojamos kvotos pagal nutyl\ qf.path=Kelias qf.quota=Kvota KB qf.title=Kvot\u0173 valdymas -table.header.limit=Nusiuntimo limitas KB +table.header.limit=Nusiuntimo limitas (KB) table.header.path=Kelias -table.header.quota=Kvota KB +table.header.quota=Kvota (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_nl_NL.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_nl_NL.properties index 5ce951a3396..1c95b744509 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_nl_NL.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_nl_NL.properties @@ -21,6 +21,6 @@ qf.noquota=Deze map heeft geen specifieke quota. De volgende default quota's zul qf.path=Pad qf.quota=Quota (KB) qf.title=Quota beheer -table.header.limit=Upload limiet KB +table.header.limit=Upload limiet (KB) table.header.path=Pad -table.header.quota=Quota KB +table.header.quota=Quota (KB) diff --git a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_sq.properties b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_sq.properties index 235a3a1af0a..5491fd1283e 100644 --- a/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_sq.properties +++ b/src/main/java/org/olat/admin/quota/_i18n/LocalStrings_sq.properties @@ -19,6 +19,6 @@ qf.noquota=Kjo dosje nuk ka ndonj\u00EB kuot\u00EB t\u00EB ve\u00E7ant\u00EB. N\ qf.path=Dosje qf.quota=Kuota (KB) qf.title=Menaxhimi i kuot\u00EBs -table.header.limit=Kufiri i ngarkimi n\u00EB KB +table.header.limit=Kufiri i ngarkimi n\u00EB (KB) table.header.path=Dosje -table.header.quota=Q\=Kuota KB +table.header.quota=Q\=Kuota (KB) -- GitLab