mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
keyboard keymap also
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
i18nPipe,
|
||||
i18nService,
|
||||
Keyboard,
|
||||
KeyboardCode,
|
||||
KeyboardLayout,
|
||||
Language,
|
||||
LANGUAGES,
|
||||
LANGUAGE_TO_CODE,
|
||||
@@ -317,29 +317,30 @@ export default class SystemGeneralComponent {
|
||||
if (!server) return
|
||||
|
||||
const keyboards = getAllKeyboardsSorted(LANGUAGE_TO_CODE[server.language])
|
||||
const currentKeyboard = (server.keyboard?.layout as KeyboardCode) || null
|
||||
const currentLayout = (server.keyboard?.layout as KeyboardLayout) || null
|
||||
|
||||
this.dialog
|
||||
.openComponent<KeyboardCode | null>(
|
||||
.openComponent<Keyboard | null>(
|
||||
new PolymorpheusComponent(KeyboardSelectComponent, this.injector),
|
||||
{
|
||||
label: 'Select Keyboard Layout',
|
||||
size: 's',
|
||||
data: { keyboards, currentKeyboard },
|
||||
data: { keyboards, currentLayout },
|
||||
},
|
||||
)
|
||||
.pipe(filter((code): code is KeyboardCode => code !== null))
|
||||
.subscribe(keyboardCode => {
|
||||
this.saveKeyboard(keyboardCode)
|
||||
.pipe(filter((keyboard): keyboard is Keyboard => keyboard !== null))
|
||||
.subscribe(keyboard => {
|
||||
this.saveKeyboard(keyboard)
|
||||
})
|
||||
}
|
||||
|
||||
private async saveKeyboard(keyboardCode: KeyboardCode) {
|
||||
private async saveKeyboard(keyboard: Keyboard) {
|
||||
const loader = this.loader.open('Saving').subscribe()
|
||||
|
||||
try {
|
||||
await this.api.setKeyboard({
|
||||
layout: keyboardCode,
|
||||
layout: keyboard.layout,
|
||||
keymap: keyboard.keymap,
|
||||
model: null,
|
||||
variant: null,
|
||||
options: [],
|
||||
@@ -457,17 +458,17 @@ export default class SystemGeneralComponent {
|
||||
|
||||
private promptKeyboardSelection(keyboards: Keyboard[]) {
|
||||
this.dialog
|
||||
.openComponent<KeyboardCode | null>(
|
||||
.openComponent<Keyboard | null>(
|
||||
new PolymorpheusComponent(KeyboardSelectComponent, this.injector),
|
||||
{
|
||||
label: 'Select Keyboard Layout',
|
||||
size: 's',
|
||||
data: { keyboards, currentKeyboard: null },
|
||||
data: { keyboards, currentLayout: null },
|
||||
},
|
||||
)
|
||||
.pipe(filter((code): code is KeyboardCode => code !== null))
|
||||
.subscribe(keyboardCode => {
|
||||
this.enableKioskWithKeyboard(keyboardCode)
|
||||
.pipe(filter((keyboard): keyboard is Keyboard => keyboard !== null))
|
||||
.subscribe(keyboard => {
|
||||
this.enableKioskWithKeyboard(keyboard)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -484,12 +485,13 @@ export default class SystemGeneralComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private async enableKioskWithKeyboard(keyboardCode: KeyboardCode) {
|
||||
private async enableKioskWithKeyboard(keyboard: Keyboard) {
|
||||
const loader = this.loader.open('Enabling').subscribe()
|
||||
|
||||
try {
|
||||
await this.api.setKeyboard({
|
||||
layout: keyboardCode,
|
||||
layout: keyboard.layout,
|
||||
keymap: keyboard.keymap,
|
||||
model: null,
|
||||
variant: null,
|
||||
options: [],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, inject } from '@angular/core'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { i18nPipe, Keyboard, KeyboardCode } from '@start9labs/shared'
|
||||
import { i18nPipe, Keyboard, KeyboardLayout } from '@start9labs/shared'
|
||||
import { TUI_IS_MOBILE } from '@taiga-ui/cdk'
|
||||
import { TuiButton, TuiDialogContext, TuiTextfield } from '@taiga-ui/core'
|
||||
import { TuiChevron, TuiDataListWrapper, TuiSelect } from '@taiga-ui/kit'
|
||||
@@ -29,7 +29,7 @@ import { injectContext } from '@taiga-ui/polymorpheus'
|
||||
</button>
|
||||
<button
|
||||
tuiButton
|
||||
[disabled]="!selected || selected.code === initialCode"
|
||||
[disabled]="!selected || selected.layout === initialLayout"
|
||||
(click)="confirm()"
|
||||
>
|
||||
{{ 'Confirm' | i18n }}
|
||||
@@ -61,16 +61,16 @@ export class KeyboardSelectComponent {
|
||||
private readonly context =
|
||||
injectContext<
|
||||
TuiDialogContext<
|
||||
KeyboardCode | null,
|
||||
{ keyboards: Keyboard[]; currentKeyboard: KeyboardCode | null }
|
||||
Keyboard | null,
|
||||
{ keyboards: Keyboard[]; currentLayout: KeyboardLayout | null }
|
||||
>
|
||||
>()
|
||||
|
||||
protected readonly mobile = inject(TUI_IS_MOBILE)
|
||||
readonly keyboards = this.context.data.keyboards
|
||||
readonly initialCode = this.context.data.currentKeyboard
|
||||
readonly initialLayout = this.context.data.currentLayout
|
||||
selected =
|
||||
this.keyboards.find(kb => kb.code === this.initialCode) ||
|
||||
this.keyboards.find(kb => kb.layout === this.initialLayout) ||
|
||||
this.keyboards[0]!
|
||||
|
||||
readonly stringify = (kb: Keyboard) => kb.name
|
||||
@@ -80,6 +80,6 @@ export class KeyboardSelectComponent {
|
||||
}
|
||||
|
||||
confirm() {
|
||||
this.context.completeWith(this.selected.code)
|
||||
this.context.completeWith(this.selected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,12 +460,7 @@ export class MockApiService extends ApiService {
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/serverInfo/keyboard',
|
||||
value: {
|
||||
layout: params.layout,
|
||||
model: params.model,
|
||||
variant: params.variant,
|
||||
options: params.options,
|
||||
},
|
||||
value: params,
|
||||
},
|
||||
]
|
||||
this.mockRevision(patch)
|
||||
|
||||
@@ -222,6 +222,7 @@ export const mockPatchData: DataModel = {
|
||||
language: 'en_US',
|
||||
keyboard: {
|
||||
layout: 'us',
|
||||
keymap: 'us',
|
||||
model: null,
|
||||
variant: null,
|
||||
options: [],
|
||||
|
||||
Reference in New Issue
Block a user