Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evercam UI timeline #293

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/ex_nvr/lib/ex_nvr/recordings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ defmodule ExNVR.Recordings do
|> Multi.insert(:run, run, on_conflict: {:replace_all_except, [:start_date]})
|> Repo.transaction()
|> case do
{:ok, %{recording: recording, run: run}} -> {:ok, recording, run}
{:ok, %{recording: recording, run: run}} ->
Phoenix.PubSub.broadcast(
ExNVR.PubSub,
"new_runs",
:runs
)
{:ok, recording, run}
{:error, _, changeset, _} -> {:error, changeset}
end
end
Expand Down Expand Up @@ -108,6 +114,11 @@ defmodule ExNVR.Recordings do
|> Repo.transaction()
|> case do
{:ok, _params} ->
Phoenix.PubSub.broadcast(
ExNVR.PubSub,
"new_runs",
:runs
)
:telemetry.execute([:ex_nvr, :recording, :delete], %{count: length(recordings)}, %{
device_id: device.id
})
Expand Down
45 changes: 45 additions & 0 deletions apps/ex_nvr_web/assets/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const esbuild = require('esbuild')
const vuePlugin = require("esbuild-vue")

const args = process.argv.slice(2)
const watch = args.includes('--watch')
const deploy = args.includes('--deploy')

const loader = {
// Add loaders for images/fonts/etc, e.g. { '.svg': 'file' }
}

const plugins = [
vuePlugin()
]

let opts = {
entryPoints: ['js/app.js'],
bundle: true,
target: 'es2017',
outdir: '../priv/static/assets',
logLevel: 'info',
loader,
plugins
}

if (deploy) {
opts = {
...opts,
minify: true
}
}

if (watch) {
async function watchFunc() {
let ctx = await esbuild.context({
...opts,
sourcemap: 'inline'
});
await ctx.watch();
console.log('Watching...');
}
watchFunc()
} else {
esbuild.build(opts)
}
2 changes: 2 additions & 0 deletions apps/ex_nvr_web/assets/css/app.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import "@evercam/ui/dist/style.css";
@import "@evercam/ui/dist/styles.css";

/* This file is for your main application CSS */
#timeline .x-axis g {
Expand Down
18 changes: 10 additions & 8 deletions apps/ex_nvr_web/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import "phoenix_html"
import { Socket } from "phoenix"
import { LiveSocket } from "phoenix_live_view"
import topbar from "../vendor/topbar"
import createTimeline, { updateTimelineSegments } from "./timeline"
import "flowbite/dist/flowbite.phoenix"
import Hls from "hls.js"

import Timeline from "../vue/Timeline.vue"
import vueWrapper from "./vueWrapper"

const MANIFEST_LOAD_TIMEOUT = 60_000

let Hooks = {
Expand Down Expand Up @@ -71,15 +73,15 @@ let Hooks = {
videoElement.play();
},
},
Timeline: {
vueTimeLine: {
mounted() {
createTimeline(this.el)
window.TimelineHook = this
},
updated() {
updateTimelineSegments(this.el)
},
},
vueWrapper({
el: this.el,
component: Timeline,
})
}
}
}

let csrfToken = document
Expand Down
8 changes: 8 additions & 0 deletions apps/ex_nvr_web/assets/js/vueWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Vue from "vue"

export default function vueWrapper({ el, component, data = {} }) {
return new Vue({
el: el,
render: (h) => h(component, data)
})
}
Loading