@christianriedl/utils 1.0.24 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { reactive } from 'vue';
|
|
3
|
+
import { IConfigItem } from '@christianriedl/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{item: IConfigItem; }>();
|
|
6
|
+
const emits = defineEmits<{ (e: 'change', value: any): void }>();
|
|
7
|
+
|
|
8
|
+
const item = reactive(props.item);
|
|
9
|
+
const isString = typeof item.default === 'string' && !item.values;
|
|
10
|
+
const isEnum = typeof item.default === 'string' && item.values;
|
|
11
|
+
const isNumber = typeof item.default === 'number';
|
|
12
|
+
const isBoolean = typeof item.default === 'boolean';
|
|
13
|
+
|
|
14
|
+
function onChange(ev: Event) {
|
|
15
|
+
emits('change', true);
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<tr class="settingsline">
|
|
21
|
+
<td style="width:50%">{{item.description}}</td>
|
|
22
|
+
<td style="width:50%">
|
|
23
|
+
<v-switch v-if="isBoolean" v-model="item.value" hide-details marg color="primary" @change="onChange"></v-switch>
|
|
24
|
+
<v-text-field v-if="isString" v-model="item.value" hide_details single_line type="string" @change="onChange"></v-text-field>
|
|
25
|
+
<v-text-field v-if="isNumber" v-model="item.value" hide_details single_line type="number" @change="onChange"></v-text-field>
|
|
26
|
+
<select v-if="isEnum" name="level" v-model="item.value" @change="onChange">
|
|
27
|
+
<option v-for="value in item.values" :key="value" :value="value">{{value}}</option>
|
|
28
|
+
</select>
|
|
29
|
+
</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SettingsLine from '../components/SettingsLine.vue';
|
|
3
|
+
import { IAppConfig, IConfigItem, IAppState } from '@christianriedl/utils'
|
|
4
|
+
import { inject, computed, onBeforeUnmount } from 'vue';
|
|
5
|
+
|
|
6
|
+
const appState = inject<IAppState>('appstate') as IAppState;
|
|
7
|
+
const appConfig = inject<IAppConfig>('appconfig') as IAppConfig;
|
|
8
|
+
|
|
9
|
+
const heightStyle = computed(() => { return { height: appState.bodyHeight.value + 'px' } });
|
|
10
|
+
|
|
11
|
+
let changed = false;
|
|
12
|
+
|
|
13
|
+
function onChange(item: IConfigItem) {
|
|
14
|
+
changed = true;
|
|
15
|
+
}
|
|
16
|
+
onBeforeUnmount(() => {
|
|
17
|
+
if (changed)
|
|
18
|
+
appConfig.save();
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<v-container fluid class="app-container app-scroll" :style="heightStyle">
|
|
24
|
+
<h2>Settings</h2>
|
|
25
|
+
<v-table>
|
|
26
|
+
<thead>
|
|
27
|
+
<tr>
|
|
28
|
+
<th style="width:50%">Topic</th>
|
|
29
|
+
<th style="width:50%">Parameter</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
<settings-line v-for="config in appConfig.items" :item="config" :key="config.name" @change="onChange(config)"></settings-line>
|
|
34
|
+
</tbody>
|
|
35
|
+
</v-table>
|
|
36
|
+
</v-container>
|
|
37
|
+
</template>
|