mirror of
https://github.com/koush/scrypted.git
synced 2026-03-16 23:22:07 +00:00
homekit/core/sdk: use global setting for server address and transcoding
This commit is contained in:
@@ -185,7 +185,7 @@
|
||||
<LogCard :rows="15" :logRoute="`/device/${id}/`"></LogCard>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12 v-if="!device.interfaces.includes(ScryptedInterface.Settings) && (availableMixins.length || !device.interfaces.includes(ScryptedInterface.ScryptedPlugin))">
|
||||
<v-flex xs12 v-if="!device.interfaces.includes(ScryptedInterface.Settings) && (availableMixins.length || deviceIsEditable(device))">
|
||||
<Settings :device="device"></Settings>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
@@ -206,6 +206,7 @@ import {
|
||||
getAlertIcon,
|
||||
hasFixedPhysicalLocation,
|
||||
getInterfaceFriendlyName,
|
||||
deviceIsEditable,
|
||||
} from "./helpers";
|
||||
import { ScryptedInterface } from "@scrypted/types";
|
||||
import RTCSignalingClient from "../interfaces/RTCSignalingClient.vue";
|
||||
@@ -410,6 +411,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
deviceIsEditable,
|
||||
getInterfaceFriendlyName,
|
||||
hasFixedPhysicalLocation,
|
||||
getComponentWebPath,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<v-layout>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 md6 lg4>
|
||||
<Settings :device="coreDevice" class="mb-2"></Settings>
|
||||
<v-card v-if="updateAvailable">
|
||||
<v-toolbar>
|
||||
<v-toolbar-title>Update Available </v-toolbar-title>
|
||||
@@ -101,10 +102,16 @@
|
||||
</template>
|
||||
<script>
|
||||
import { checkUpdate } from "../plugin/plugin";
|
||||
import Settings from "../../interfaces/Settings.vue"
|
||||
import {createSystemSettingsDevice} from './system-settings';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Settings,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
coreDevice: createSystemSettingsDevice(this.$scrypted.systemManager),
|
||||
currentVersion: null,
|
||||
updateAvailable: null,
|
||||
canUpdate: false,
|
||||
|
||||
64
plugins/core/ui/src/components/builtin/system-settings.ts
Normal file
64
plugins/core/ui/src/components/builtin/system-settings.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { ScryptedDevice, ScryptedDeviceType, ScryptedInterface, Settings, SystemManager } from "@scrypted/types";
|
||||
|
||||
export function createSystemSettingsDevice(systemManager: SystemManager): ScryptedDevice & Settings {
|
||||
const core = systemManager.getDeviceByName<Settings>('@scrypted/core');
|
||||
let transcode: ScryptedDevice & Settings;
|
||||
for (const id of Object.keys(systemManager.getSystemState())) {
|
||||
const device = systemManager.getDeviceById<Settings>(id);
|
||||
if (device.nativeId === 'transcode' && device.pluginId === '@scrypted/prebuffer-mixin') {
|
||||
transcode = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: 'Settings',
|
||||
type: ScryptedDeviceType.Builtin,
|
||||
interfaces: [
|
||||
ScryptedInterface.Settings,
|
||||
],
|
||||
async setName(name) {
|
||||
|
||||
},
|
||||
async setRoom() {
|
||||
|
||||
},
|
||||
async setType() {
|
||||
|
||||
},
|
||||
async probe() {
|
||||
return true;
|
||||
},
|
||||
listen(event, callback) {
|
||||
const cl = core.listen(event, callback);
|
||||
const tl = transcode?.listen(event, callback);
|
||||
return {
|
||||
removeListener() {
|
||||
cl.removeListener();
|
||||
tl?.removeListener();
|
||||
},
|
||||
}
|
||||
},
|
||||
async getSettings() {
|
||||
return [
|
||||
...(await core.getSettings()).map(s => ({
|
||||
...s,
|
||||
key: 'core:' + s.key,
|
||||
group: 'Network Settings',
|
||||
})),
|
||||
...(await transcode?.getSettings() || []).map(s => ({
|
||||
...s,
|
||||
key: 'transcode:' + s.key,
|
||||
group: 'Transcoding',
|
||||
})),
|
||||
];
|
||||
},
|
||||
async putSetting(key, value) {
|
||||
if (key.startsWith('core:')) {
|
||||
await core.putSetting(key.substring(5), value);
|
||||
}
|
||||
else if (key.startsWith('transcode:')) {
|
||||
await core.putSetting(key.substring(10), value);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,15 @@
|
||||
import { ScryptedDeviceType, ScryptedInterface } from "@scrypted/types";
|
||||
import { ScryptedDevice, ScryptedDeviceType, ScryptedInterface } from "@scrypted/types";
|
||||
|
||||
export function deviceIsEditable(device: ScryptedDevice) {
|
||||
if (!device)
|
||||
return;
|
||||
if (device.interfaces.includes(ScryptedInterface.ScryptedPlugin))
|
||||
return;
|
||||
if (device.type === ScryptedDeviceType.Builtin || device.type === ScryptedDeviceType.API)
|
||||
return;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function typeToIcon(type) {
|
||||
switch (type) {
|
||||
@@ -30,6 +41,7 @@ export function typeToIcon(type) {
|
||||
case ScryptedDeviceType.Irrigation: return "fa-faucet";
|
||||
case ScryptedDeviceType.Person: return "fa-user";
|
||||
case ScryptedDeviceType.SecuritySystem: return "fa-shield-alt";
|
||||
case ScryptedDeviceType.Builtin: return "fa-server";
|
||||
|
||||
}
|
||||
return "fa-toggle-on";
|
||||
|
||||
Reference in New Issue
Block a user