Skip to content

Commit

Permalink
Better Widget selector
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Mar 13, 2024
1 parent 0b91c2f commit 7becee3
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
24 changes: 21 additions & 3 deletions src/src/Toolbar/MultiSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const styles = theme => ({
display: 'inline-block',
height: 24,
},
menuToolbar: {
paddingLeft: 8,
paddingRight: 8,
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.secondary.dark : theme.palette.secondary.light,
},
});

class MultiSelect extends Component {
Expand Down Expand Up @@ -154,9 +159,22 @@ class MultiSelect extends Component {
anchorEl={this.state.elAnchor}
onClose={() => this.setState({ elAnchor: null })}
>
<div>
<Button onClick={() => this.props.setSelectedWidgets(props.options.map(item => item.value))}>{I18n.t('Select all')}</Button>
<Button onClick={() => this.props.setSelectedWidgets([])}>{I18n.t('Unselect all')}</Button>
<div className={this.props.classes.menuToolbar}>
{I18n.t('All')}
<Button
disabled={value.length === props.options.length}
onClick={() => this.props.setSelectedWidgets(props.options.map(item => item.value))}
startIcon={<Checkbox style={{ opacity: value.length === props.options.length ? 0.5 : 1 }} checked />}
>
{I18n.t('Select')}
</Button>
<Button
disabled={!value.length}
onClick={() => this.props.setSelectedWidgets([])}
startIcon={<Checkbox style={{ opacity: !value.length ? 0.5 : 1 }} />}
>
{I18n.t('Unselect')}
</Button>
</div>
{props.options.map(item => <MenuItem
value={item.value}
Expand Down
5 changes: 2 additions & 3 deletions src/src/Vis/visLoadWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function getRemoteWidgets(socket: Connection, onlyWidgetSets?: false | string[])
}
const lang = I18n.getLanguage();

const i18nPromise = fetch(`${i18nURL}/i18n/${lang}.json`)
i18nPromiseWait = fetch(`${i18nURL}/i18n/${lang}.json`)
.then(data => data.json())
.then(json => {
countRef.count++;
Expand All @@ -244,10 +244,9 @@ function getRemoteWidgets(socket: Connection, onlyWidgetSets?: false | string[])
console.log(`Cannot load i18n "${i18nURL}/i18n/${lang}.json": ${error}`);
return null;
});
promises.push(i18nPromise);
promises.push(i18nPromiseWait);
} else if (collection.url && collection.i18n === 'component') {
// instance.common.visWidgets.i18n is deprecated

i18nPromiseWait = loadComponent(collection.name, 'default', './translations', collection.url)()
.then((translations: any) => {
countRef.count++;
Expand Down
5 changes: 3 additions & 2 deletions src/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Deinstallieren",
"Unknown widget type \"%s\"": "Unbekannter Widget-Typ „%s“",
"Unlock": "Freischalten",
"Unselect all": "Alles deselektieren",
"Update": "Aktualisieren",
"Usage of widget %s": "Verwendung des Widgets %s",
"Use background": "Hintergrund verwenden",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Alle verbleibenden",
"Only for desktop": "Nur für Desktop",
"Include widget?": "Widget einbinden?",
"Do you want to include \"%s\" widget into \"%s\"?": "Möchten Sie das Widget „%s“ in „%s“ einbinden?"
"Do you want to include \"%s\" widget into \"%s\"?": "Möchten Sie das Widget „%s“ in „%s“ einbinden?",
"Unselect": "Aufheben",
"All": "Alle"
}
5 changes: 3 additions & 2 deletions src/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Uninstall",
"Unknown widget type \"%s\"": "Unknown widget type \"%s\"",
"Unlock": "Unlock",
"Unselect all": "Unselect all",
"Update": "Update",
"Usage of widget %s": "Usage of widget %s",
"Use background": "Use background",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Add all left",
"Only for desktop": "Only for desktop",
"Include widget?": "Include widget?",
"Do you want to include \"%s\" widget into \"%s\"?": "Do you want to include \"%s\" widget into \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "Do you want to include \"%s\" widget into \"%s\"?",
"Unselect": "Unselect",
"All": "All"
}
5 changes: 3 additions & 2 deletions src/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Desinstalar",
"Unknown widget type \"%s\"": "Tipo de widget desconocido \"%s\"",
"Unlock": "desbloquear",
"Unselect all": "Deselecciona todo",
"Update": "Actualizar",
"Usage of widget %s": "Uso del widget %s",
"Use background": "Usar fondo",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Añadir todo lo que queda",
"Only for desktop": "Sólo para escritorio",
"Include widget?": "¿Incluir widget?",
"Do you want to include \"%s\" widget into \"%s\"?": "¿Quieres incluir el widget \"%s\" en \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "¿Quieres incluir el widget \"%s\" en \"%s\"?",
"Unselect": "Deseleccionar",
"All": "Todo"
}
5 changes: 3 additions & 2 deletions src/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Désinstaller",
"Unknown widget type \"%s\"": "Type de widget inconnu \"%s\"",
"Unlock": "Ouvrir",
"Unselect all": "Tout déselectionner",
"Update": "Mettre à jour",
"Usage of widget %s": "Utilisation du widget %s",
"Use background": "Utiliser l'arrière-plan",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Ajouter tout ce qui reste",
"Only for desktop": "Uniquement pour ordinateur de bureau",
"Include widget?": "Inclure le widget ?",
"Do you want to include \"%s\" widget into \"%s\"?": "Voulez-vous inclure le widget « %s » dans « %s » ?"
"Do you want to include \"%s\" widget into \"%s\"?": "Voulez-vous inclure le widget « %s » dans « %s » ?",
"Unselect": "Désélectionner",
"All": "Tous"
}
5 changes: 3 additions & 2 deletions src/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Disinstalla",
"Unknown widget type \"%s\"": "Tipo di widget sconosciuto \"%s\"",
"Unlock": "Sbloccare",
"Unselect all": "Deseleziona tutto",
"Update": "Aggiornare",
"Usage of widget %s": "Utilizzo del widget %s",
"Use background": "Usa lo sfondo",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Aggiungi tutto quello che resta",
"Only for desktop": "Solo per desktop",
"Include widget?": "Includere il widget?",
"Do you want to include \"%s\" widget into \"%s\"?": "Vuoi includere il widget \"%s\" in \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "Vuoi includere il widget \"%s\" in \"%s\"?",
"Unselect": "Deseleziona",
"All": "Tutto"
}
5 changes: 3 additions & 2 deletions src/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Verwijderen",
"Unknown widget type \"%s\"": "Onbekend widgettype \"%s\"",
"Unlock": "Ontgrendelen",
"Unselect all": "Deselecteer alles",
"Update": "Update",
"Usage of widget %s": "Gebruik van widget %s",
"Use background": "Achtergrond gebruiken",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Voeg alles links toe",
"Only for desktop": "Alleen voor desktop",
"Include widget?": "Widget toevoegen?",
"Do you want to include \"%s\" widget into \"%s\"?": "Wilt u de widget \"%s\" opnemen in \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "Wilt u de widget \"%s\" opnemen in \"%s\"?",
"Unselect": "Deselecteer",
"All": "Alle"
}
5 changes: 3 additions & 2 deletions src/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Odinstaluj",
"Unknown widget type \"%s\"": "Nieznany typ widżetu „%s”",
"Unlock": "Odblokować",
"Unselect all": "Odznacz wszystko",
"Update": "Aktualizacja",
"Usage of widget %s": "Użycie widżetu %s",
"Use background": "Użyj tła",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Dodaj wszystko, co zostało",
"Only for desktop": "Tylko na komputery stacjonarne",
"Include widget?": "Dołącz widżet?",
"Do you want to include \"%s\" widget into \"%s\"?": "Czy chcesz dołączyć widżet „%s” do „%s”?"
"Do you want to include \"%s\" widget into \"%s\"?": "Czy chcesz dołączyć widżet „%s” do „%s”?",
"Unselect": "Odznacz",
"All": "Wszystko"
}
5 changes: 3 additions & 2 deletions src/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Desinstalar",
"Unknown widget type \"%s\"": "Tipo de widget desconhecido \"%s\"",
"Unlock": "Desbloquear",
"Unselect all": "Desmarque todos",
"Update": "Atualizar",
"Usage of widget %s": "Uso do widget %s",
"Use background": "Usar plano de fundo",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Adicione tudo o que resta",
"Only for desktop": "Somente para desktop",
"Include widget?": "Incluir widget?",
"Do you want to include \"%s\" widget into \"%s\"?": "Deseja incluir o widget \"%s\" em \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "Deseja incluir o widget \"%s\" em \"%s\"?",
"Unselect": "Desmarcar",
"All": "Todos"
}
5 changes: 3 additions & 2 deletions src/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Удалить",
"Unknown widget type \"%s\"": "Неизвестный тип виджета \"%s\"",
"Unlock": "Разблокировать",
"Unselect all": "Снять все",
"Update": "Обновить",
"Usage of widget %s": "Использование виджета %s",
"Use background": "Использовать фон",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Добавить все, что осталось",
"Only for desktop": "Только для рабочего стола",
"Include widget?": "Включить виджет?",
"Do you want to include \"%s\" widget into \"%s\"?": "Вы хотите включить виджет «%s» в «%s»?"
"Do you want to include \"%s\" widget into \"%s\"?": "Вы хотите включить виджет «%s» в «%s»?",
"Unselect": "Отменить выбор",
"All": "Все"
}
5 changes: 3 additions & 2 deletions src/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "Видалити",
"Unknown widget type \"%s\"": "Невідомий тип віджета \"%s\"",
"Unlock": "Розблокувати",
"Unselect all": "Скасувати вибір усіх",
"Update": "оновлення",
"Usage of widget %s": "Використання віджета %s",
"Use background": "Використовуйте фон",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "Додайте всі ліві",
"Only for desktop": "Тільки для робочого столу",
"Include widget?": "Включити віджет?",
"Do you want to include \"%s\" widget into \"%s\"?": "Бажаєте включити віджет \"%s\" до \"%s\"?"
"Do you want to include \"%s\" widget into \"%s\"?": "Бажаєте включити віджет \"%s\" до \"%s\"?",
"Unselect": "Скасувати вибір",
"All": "все"
}
5 changes: 3 additions & 2 deletions src/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"Uninstall": "卸载",
"Unknown widget type \"%s\"": "未知的小部件类型“%s”",
"Unlock": "开锁",
"Unselect all": "全部取消选择",
"Update": "更新",
"Usage of widget %s": "小部件 %s 的使用",
"Use background": "使用背景",
Expand Down Expand Up @@ -733,5 +732,7 @@
"basic_all_filters": "添加所有剩余的",
"Only for desktop": "仅适用于桌面",
"Include widget?": "包括小部件吗?",
"Do you want to include \"%s\" widget into \"%s\"?": "您想将“%s”小部件包含到“%s”中吗?"
"Do you want to include \"%s\" widget into \"%s\"?": "您想将“%s”小部件包含到“%s”中吗?",
"Unselect": "取消选择",
"All": "全部"
}

0 comments on commit 7becee3

Please sign in to comment.