diff --git a/plugins/core/package-lock.json b/plugins/core/package-lock.json index 93d1eae5a..b85379171 100644 --- a/plugins/core/package-lock.json +++ b/plugins/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/core", - "version": "0.0.58", + "version": "0.0.59", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/core", - "version": "0.0.58", + "version": "0.0.59", "license": "Apache-2.0", "dependencies": { "@scrypted/sdk": "file:../../sdk", diff --git a/plugins/core/package.json b/plugins/core/package.json index 108a04eb1..9f5ee95fe 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/core", - "version": "0.0.58", + "version": "0.0.59", "description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/core/src/automation.ts b/plugins/core/src/automation.ts index f205a8405..b6f9167b7 100644 --- a/plugins/core/src/automation.ts +++ b/plugins/core/src/automation.ts @@ -49,7 +49,7 @@ export class Automation extends ScryptedDeviceBase implements OnOff { let device: any; if (id === 'javascript') { - device = new Javascript(systemManager, eventSource, eventDetails, eventData); + device = new Javascript(systemManager, eventSource, eventDetails, eventData, this.log); } else { device = systemManager.getDeviceById(id); diff --git a/plugins/core/src/builtins/javascript.ts b/plugins/core/src/builtins/javascript.ts index bd75d135f..577caf769 100644 --- a/plugins/core/src/builtins/javascript.ts +++ b/plugins/core/src/builtins/javascript.ts @@ -1,23 +1,25 @@ -import { EventDetails, ScryptedDevice, SystemManager } from "@scrypted/sdk"; +import { Logger, EventDetails, ScryptedDevice, SystemManager } from "@scrypted/sdk"; export class Javascript { systemManager: SystemManager; eventSource: ScryptedDevice; eventDetails: EventDetails; eventData: any; + log: Logger; - constructor(systemManager: SystemManager, eventSource: ScryptedDevice, eventDetails: EventDetails, eventData: any) { + constructor(systemManager: SystemManager, eventSource: ScryptedDevice, eventDetails: EventDetails, eventData: any, log: Logger) { this.systemManager = systemManager; this.eventSource = eventSource; this.eventDetails = eventDetails; this.eventData = eventData; + this.log = log; } run(script: string) { - const f = eval(`(function script(systemManager, eventSource, eventDetails, eventData) { + const f = eval(`(function script(systemManager, eventSource, eventDetails, eventData, log) { ${script} })`); - f(this.systemManager, this.eventSource, this.eventDetails, this.eventData); + f(this.systemManager, this.eventSource, this.eventDetails, this.eventData, this.log); } } diff --git a/plugins/core/ui/src/App.vue b/plugins/core/ui/src/App.vue index 552464ee8..7c75aaf0c 100644 --- a/plugins/core/ui/src/App.vue +++ b/plugins/core/ui/src/App.vue @@ -12,7 +12,7 @@ @@ -30,10 +30,16 @@ @@ -46,36 +52,50 @@ @click="doAlert(alert)" > - {{ getAlertIcon(alert) }} + {{ + getAlertIcon(alert) + }} - {{ alert.title }} - {{ alert.message }} - {{ friendlyTime(alert.timestamp) }} + {{ + alert.title + }} + {{ + alert.message + }} + {{ + friendlyTime(alert.timestamp) + }} - + - No notifications. + No notifications. - fa-trash + fa-trash - Clear All Alerts + Clear All Alerts - @@ -87,11 +107,17 @@ @click="menuItem.click" > - {{ menuItem.icon }} + {{ + menuItem.icon + }} - {{ menuItem.title }} - {{ menuItem.subtitle }} + {{ + menuItem.title + }} + {{ + menuItem.subtitle + }} @@ -121,39 +147,57 @@ persistent max-width="600px" > - - - Scrypted Management Console - - - - - - - - - - - -
{{ loginResult }}
-
-
- - - Log In - -
+ + + + Scrypted Management Console + + + + + + + + + + + + +
{{ loginResult }}
+
+
+ + + Log In + +
+
- + @@ -192,12 +243,12 @@ import { removeAlert, getAlertIcon } from "./components/helpers"; import router from "./router"; import Vue from "vue"; -import store from './store'; +import store from "./store"; import "./client"; const PushConnectionManager = window["pushconnect"].PushConnectionManager; var pushConnectionPromise; -Vue.prototype.$pushconnect = function() { +Vue.prototype.$pushconnect = function () { if (pushConnectionPromise) { return pushConnectionPromise; } @@ -208,11 +259,11 @@ Vue.prototype.$pushconnect = function() { { urls: ["turn:n0.clockworkmod.com", "turn:n1.clockworkmod.com"], username: "foo", - credential: "bar" - } - ] + credential: "bar", + }, + ], } - ).then(rtcManager => { + ).then((rtcManager) => { // console.log('persistent gcm connection created', rtcManager != null); // console.log(rtcManager.registrationId); return rtcManager; @@ -224,23 +275,23 @@ Vue.prototype.$pushconnect = function() { export default { name: "App", components: { - Drawer + Drawer, }, mounted() { this.$vuetify.theme.dark = true; this._timer = setInterval( - function() { + function () { this.$data.now = Date.now(); }.bind(this), 1000 ); }, - destroyed: function() { + destroyed: function () { clearInterval(this._timer); }, methods: { reconnect() { - this.$connectScrypted().catch(e => (this.loginResult = e.toString())); + this.$connectScrypted().catch((e) => (this.loginResult = e.toString())); }, reload() { window.location.reload(); @@ -250,7 +301,7 @@ export default { }, doCloudLogin() { var encode = qs.stringify({ - redirect_uri: "/endpoint/@scrypted/core/public/" + redirect_uri: "/endpoint/@scrypted/core/public/", }); window.location = `https://home.scrypted.app/_punch/login?${encode}`; @@ -258,36 +309,41 @@ export default { doLogin() { const body = { username: this.username, - password: this.password + password: this.password, }; if (this.changePassword || this.$store.state.hasLogin === false) { - if (this.password !== this.confirmPassword) { + if (this.$store.state.hasLogin === false && this.password !== this.confirmPassword) { + this.loginResult = 'Passwords do not match.'; return; } - body.confirm_password = this.confirmPassword; + else if (this.changePassword && this.newPassword !== this.confirmPassword) { + this.loginResult = 'Passwords do not match.'; + return; + } + body.change_password = this.confirmPassword; } this.loginResult = ""; axios .post("/login", qs.stringify(body), { headers: { - "Content-Type": "application/x-www-form-urlencoded" - } + "Content-Type": "application/x-www-form-urlencoded", + }, }) - .then(response => { + .then((response) => { if (response.data.error) { this.loginResult = response.data.error; return; } window.location.reload(); }) - .catch(e => { + .catch((e) => { this.loginResult = e.toString(); }); }, async clearAlerts() { - const alerts = await this.$scrypted.systemManager.getComponent('alerts') - await alerts.clearAlerts(); + const alerts = await this.$scrypted.systemManager.getComponent("alerts"); + await alerts.clearAlerts(); }, getAlertIcon, removeAlert, @@ -325,7 +381,7 @@ export default { }, alertConvert(alertPath) { return alertPath.replace("/web/", "/"); - } + }, }, created() { router.beforeEach((to, from, next) => { @@ -345,6 +401,7 @@ export default { username: null, password: null, confirmPassword: null, + newPassword: null, loginResult: undefined, passwordRules: [ () => { @@ -352,8 +409,8 @@ export default { return "Passwords do not match."; } return true; - } - ] + }, + ], }; }, }; diff --git a/plugins/core/ui/src/components/Device.vue b/plugins/core/ui/src/components/Device.vue index 007432c2d..1cbca0309 100644 --- a/plugins/core/ui/src/components/Device.vue +++ b/plugins/core/ui/src/components/Device.vue @@ -36,6 +36,7 @@ {{ name || "No Device Name" }} - + + + + + {{ iface }} + - - - - - {{ iface }} - - + @@ -386,6 +388,8 @@ import VideoCamera from "../interfaces/VideoCamera.vue"; import Thermometer from "../interfaces/sensors/Thermometer.vue"; import HumiditySensor from "../interfaces/sensors/HumiditySensor.vue"; import EntrySensor from "../interfaces/sensors/EntrySensor.vue"; +import MotionSensor from "../interfaces/sensors/MotionSensor.vue"; +import AudioSensor from "../interfaces/sensors/AudioSensor.vue"; import OccupancySensor from "../interfaces/sensors/OccupancySensor.vue"; import Settings from "../interfaces/Settings.vue"; import StartStop from "../interfaces/StartStop.vue"; @@ -408,6 +412,8 @@ import Vue from "vue"; const cardHeaderInterfaces = [ ScryptedInterface.OccupancySensor, ScryptedInterface.EntrySensor, + ScryptedInterface.MotionSensor, + ScryptedInterface.AudioSensor, ScryptedInterface.HumiditySensor, ScryptedInterface.Thermometer, ScryptedInterface.Battery, @@ -489,6 +495,8 @@ export default { Thermometer, HumiditySensor, EntrySensor, + MotionSensor, + AudioSensor, OccupancySensor, OauthClient, diff --git a/plugins/core/ui/src/components/script/Script.vue b/plugins/core/ui/src/components/script/Script.vue deleted file mode 100644 index 065d460bf..000000000 --- a/plugins/core/ui/src/components/script/Script.vue +++ /dev/null @@ -1,349 +0,0 @@ - - \ No newline at end of file diff --git a/plugins/core/ui/src/components/script/ScriptComponent.vue b/plugins/core/ui/src/components/script/ScriptComponent.vue index bb56453bf..8a2b5bf65 100644 --- a/plugins/core/ui/src/components/script/ScriptComponent.vue +++ b/plugins/core/ui/src/components/script/ScriptComponent.vue @@ -1,14 +1,10 @@ \ No newline at end of file diff --git a/plugins/core/ui/src/components/script/ScriptVariablePicker.vue b/plugins/core/ui/src/components/script/ScriptVariablePicker.vue deleted file mode 100644 index 0829b602b..000000000 --- a/plugins/core/ui/src/components/script/ScriptVariablePicker.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - diff --git a/plugins/core/ui/src/components/script/ScriptVariablesPicker.vue b/plugins/core/ui/src/components/script/ScriptVariablesPicker.vue deleted file mode 100644 index 90c4840e7..000000000 --- a/plugins/core/ui/src/components/script/ScriptVariablesPicker.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/plugins/core/ui/src/components/script/Stats.vue b/plugins/core/ui/src/components/script/Stats.vue deleted file mode 100644 index 3cab85798..000000000 --- a/plugins/core/ui/src/components/script/Stats.vue +++ /dev/null @@ -1,126 +0,0 @@ - - \ No newline at end of file diff --git a/plugins/core/ui/src/interfaces/Battery.vue b/plugins/core/ui/src/interfaces/Battery.vue index b4dd59057..a42dcc728 100644 --- a/plugins/core/ui/src/interfaces/Battery.vue +++ b/plugins/core/ui/src/interfaces/Battery.vue @@ -1,7 +1,7 @@ diff --git a/plugins/core/ui/src/interfaces/sensors/AudioSensor.vue b/plugins/core/ui/src/interfaces/sensors/AudioSensor.vue new file mode 100644 index 000000000..d80277f90 --- /dev/null +++ b/plugins/core/ui/src/interfaces/sensors/AudioSensor.vue @@ -0,0 +1,27 @@ + + + diff --git a/plugins/core/ui/src/interfaces/sensors/EntrySensor.vue b/plugins/core/ui/src/interfaces/sensors/EntrySensor.vue index 9de2ac61e..bbafaa31a 100644 --- a/plugins/core/ui/src/interfaces/sensors/EntrySensor.vue +++ b/plugins/core/ui/src/interfaces/sensors/EntrySensor.vue @@ -4,7 +4,7 @@ - - {{ Math.round(lazyValue.humidity) }}% + + {{ Math.round(lazyValue.humidity) }}% diff --git a/plugins/core/ui/src/interfaces/sensors/MotionSensor.vue b/plugins/core/ui/src/interfaces/sensors/MotionSensor.vue new file mode 100644 index 000000000..dd15b2537 --- /dev/null +++ b/plugins/core/ui/src/interfaces/sensors/MotionSensor.vue @@ -0,0 +1,27 @@ + + + diff --git a/plugins/core/ui/src/interfaces/sensors/OccupancySensor.vue b/plugins/core/ui/src/interfaces/sensors/OccupancySensor.vue index a1fbef319..b1a0c85d0 100644 --- a/plugins/core/ui/src/interfaces/sensors/OccupancySensor.vue +++ b/plugins/core/ui/src/interfaces/sensors/OccupancySensor.vue @@ -4,7 +4,7 @@ - - {{ Math.round(lazyValue.temperature) }}° + + {{ Math.round(lazyValue.temperature) }}°