@christianriedl/utils 1.0.63 → 1.0.65

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/utils",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "Interfaces, local storage, service worker, configuration, application state",
5
5
 
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { reactive } from 'vue';
3
- import { IConfigItem } from '@christianriedl/utils';
3
+ import { IConfigItem, EScope } from '@christianriedl/utils';
4
4
 
5
- const props = defineProps<{item: IConfigItem; }>();
5
+ const props = defineProps<{item: IConfigItem; scopes: EScope }>();
6
6
  const emits = defineEmits<{ (e: 'change', value: any): void }>();
7
7
 
8
8
  const item = reactive(props.item);
@@ -11,6 +11,7 @@
11
11
  const isNumber = typeof item.default === 'number';
12
12
  const isBoolean = typeof item.default === 'boolean';
13
13
  const isDisabled = item.doNotChange;
14
+ const isVisible = (item.scopes & props.scopes) != 0;
14
15
 
15
16
  function onChange(ev: Event) {
16
17
  emits('change', true);
@@ -18,7 +19,7 @@
18
19
  </script>
19
20
 
20
21
  <template>
21
- <tr class="settingsline">
22
+ <tr v-if="isVisible" class="settingsline">
22
23
  <td style="width:50%">{{item.description}}</td>
23
24
  <td style="width:50%">
24
25
  <v-switch v-if="isBoolean" v-model="item.value" :disabled="isDisabled" density="compact" hide-details marg color="primary" @change="onChange"></v-switch>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { inject, computed, onBeforeUnmount } from 'vue';
2
+ import { inject, computed, ref, nextTick, onBeforeUnmount } from 'vue';
3
3
  import { onBeforeRouteLeave } from 'vue-router'
4
4
  import { IAppConfig, IConfigItem, IAppState } from '@christianriedl/utils'
5
5
  import SettingsLine from '../components/SettingsLine.vue';
@@ -7,9 +7,8 @@
7
7
  const emits = defineEmits<{ (e: 'configchange', item: IConfigItem): void }>();
8
8
  const appState = inject<IAppState>('appstate')!;
9
9
  const appConfig = inject<IAppConfig>('appconfig')!;
10
- const appItems = appConfig.items.filter((i) => (i.scopes & appState.scopes) != 0);
11
-
12
10
  const heightStyle = computed(() => { return { height: appState.bodyHeight.value + 'px', overflowY: 'auto' } });
11
+ const scopes = ref(appState.scopes);
13
12
 
14
13
  let changed = false;
15
14
  const subscribePushNotifications = appConfig.subscribePush ? appConfig.items["subscribePushNotifications"] : null;
@@ -29,6 +28,7 @@
29
28
 
30
29
  async function saveConfiguration(): Promise<boolean> {
31
30
  if (changed) {
31
+ const useServerWait = appConfig.items['smartHomeUseServerWait'].value;
32
32
  appConfig.save();
33
33
  if (subscribePushNotifications && subscribePushNotifications.value != wasSubscribed) {
34
34
  console.log(`Subscribe changed to ${subscribePushNotifications.value}`)
@@ -46,6 +46,13 @@
46
46
  }
47
47
 
48
48
  function onChange(item: IConfigItem) {
49
+ if (item.name === 'smartHomeUseServerWait') {
50
+ const acqCycleItem = appConfig.items['smartHomeAcqCycle'];
51
+ if (acqCycleItem)
52
+ acqCycleItem.value = item.value ? 30000 : 1000;
53
+ scopes.value = 0;
54
+ nextTick(() => scopes.value = appState.scopes);
55
+ }
49
56
  emits('configchange', item);
50
57
  changed = true;
51
58
  }
@@ -62,7 +69,7 @@
62
69
  </tr>
63
70
  </thead>
64
71
  <tbody>
65
- <settings-line v-for="config in appItems" :item="config" :key="config.name" @change="onChange(config)"></settings-line>
72
+ <settings-line v-for="config in appConfig.items" :key="config.name" :item="config" :scopes="scopes" @change="onChange(config)"></settings-line>
66
73
  </tbody>
67
74
  </v-table>
68
75
  </v-container>