diff --git a/bin/effectListing b/bin/effectListing new file mode 100755 --- /dev/null +++ b/bin/effectListing @@ -0,0 +1,4 @@ +#!/bin/sh +pnpx vite -c light9/effect/listing/web/vite.config.ts & +wait + diff --git a/light9/web/effects/effects.coffee b/light9/effect/listing/web/Light9EffectListing.ts rename from light9/web/effects/effects.coffee rename to light9/effect/listing/web/Light9EffectListing.ts --- a/light9/web/effects/effects.coffee +++ b/light9/effect/listing/web/Light9EffectListing.ts @@ -1,36 +1,106 @@ -Polymer - is: "light9-effects" - properties: - graph: {type: Object} - effectClasses: { type: Array } - ready: -> - @graph.runHandler(@getClasses.bind(@), 'getClasses') +import debug from "debug"; +import { css, html, LitElement } from "lit"; +import { customElement, property } from "lit/decorators.js"; +import { NamedNode } from "n3"; +import { sortBy } from "underscore"; +import { getTopGraph } from "../../../web/RdfdbSyncedGraph"; +import { SyncedGraph } from "../../../web/SyncedGraph"; +export {ResourceDisplay} from "../../../web/ResourceDisplay" +debug.enable("*"); +const log = debug("listing"); + +@customElement("light9-effect-listing") +export class Light9EffectListing extends LitElement { + render() { + return html` +

Effects

+ - getClasses: -> - U = (x) => @graph.Uri(x) - @effectClasses = @graph.subjects(U('rdf:type'), U(':Effect')) - @effectClasses = _.sortBy(@effectClasses, (ec) => @graph.stringValue(ec, U('rdfs:label'))) + ${this.effectClasses.map((e: NamedNode) => html``)} + `; + } + graph!: SyncedGraph; + effectClasses: NamedNode[] = []; + constructor() { + super(); + getTopGraph().then((g) => { + this.graph = g; + this.graph.runHandler(this.getClasses.bind(this), "getClasses"); + }); + } + + getClasses() { + const U = this.graph.U(); + this.effectClasses = this.graph.subjects(U("rdf:type"), U(":Effect")) as NamedNode[]; + this.effectClasses = sortBy(this.effectClasses, (ec: any) => this.graph.stringValue(ec, U("rdfs:label"))); + this.requestUpdate(); + } +} -Polymer - is: "light9-effect-class" - properties: - graph: {type: Object} - uri: {type: Object} - - onAdd: -> - @$.songEffects.body = {drop: @uri.value} - @$.songEffects.generateRequest() - - onMomentaryPress: -> - @$.songEffects.body = {drop: @uri.value, event: 'start'} - @lastPress = @$.songEffects.generateRequest() - @lastPress.completes.then (request) => - @lastMomentaryNote = request.response.note - - onMomentaryRelease: -> - return unless @lastMomentaryNote - @$.songEffects.body = {drop: @uri.value, note: @lastMomentaryNote} - @lastMomentaryNote = null - @$.songEffects.generateRequest() - \ No newline at end of file +@customElement("light9-effect-class") +export class Light9EffectClass extends LitElement { + static styles = [ + css` + :host { + display: block; + padding: 5px; + border: 1px solid green; + background: #1e271e; + margin-bottom: 3px; + } + a { + color: #7992d0; + background: #00000859; + min-width: 4em; + min-height: 2em; + display: inline-block; + text-align: center; + vertical-align: middle; + } + resource-display { + min-width: 12em; + font-size: 180%; + } + `, + ]; + render() { + if (!this.uri) { + return html`loading...`; + } + return html` + Effect + + Edit + + + + + + `; + } + graph!: SyncedGraph; + uri?: NamedNode; + + onAdd() { + // this.$.songEffects.body = { drop: this.uri.value }; + // this.$.songEffects.generateRequest(); + } + + onMomentaryPress() { + // this.$.songEffects.body = { drop: this.uri.value, event: "start" }; + // this.lastPress = this.$.songEffects.generateRequest(); + // return this.lastPress.completes.then((request: { response: { note: any } }) => { + // return (this.lastMomentaryNote = request.response.note); + // }); + } + + onMomentaryRelease() { + // if (!this.lastMomentaryNote) { + // return; + // } + // this.$.songEffects.body = { drop: this.uri.value, note: this.lastMomentaryNote }; + // this.lastMomentaryNote = null; + // return this.$.songEffects.generateRequest(); + } +} diff --git a/light9/web/effects/index.html b/light9/effect/listing/web/index.html rename from light9/web/effects/index.html rename to light9/effect/listing/web/index.html --- a/light9/web/effects/index.html +++ b/light9/effect/listing/web/index.html @@ -1,82 +1,12 @@ - subserver effects2 + effect listing - - - - - - - - - - - + + - - - - - - - - - - - - - + diff --git a/light9/effect/listing/web/vite.config.ts b/light9/effect/listing/web/vite.config.ts new file mode 100644 --- /dev/null +++ b/light9/effect/listing/web/vite.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from "vite"; + +const servicePort = 8218; +export default defineConfig({ + base: "/effectListing/", + root: "./light9/effect/listing/web", + publicDir: "../web", + server: { + host: "0.0.0.0", + strictPort: true, + port: servicePort + 100, + hmr: { + port: servicePort + 200, + }, + }, + clearScreen: false, + define: { + global: {}, + }, +}); diff --git a/show/dance2019/networking.n3 b/show/dance2019/networking.n3 --- a/show/dance2019/networking.n3 +++ b/show/dance2019/networking.n3 @@ -20,6 +20,7 @@ sh:netHome :webServer ; :timeline ; :live ; + :effectListing ; :collector ; :collectorZmq . @@ -37,3 +38,4 @@ sh:netHome :vidref :urlPath "vidref" . :timeline :urlPath "timeline" . :live :urlPath "live" . +:effectListing :urlPath "effectListing" . \ No newline at end of file