diff --git a/Jenkinsfile b/Jenkinsfile index 45ac21a..2d013b9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,9 @@ pipeline { } stage('Deploy') { steps { - sh '/usr/bin/rsync ./public /var/www/public/html/drums' + sh '''#!/bin/bash -l + /usr/bin/rsync ./public /var/www/public/html/drums' + ''' } } } diff --git a/src/Beat.ts b/src/Beat.ts index ba9f79e..d0e21a5 100644 --- a/src/Beat.ts +++ b/src/Beat.ts @@ -40,15 +40,15 @@ export default class Beat implements IPublisher{ return this.publisher.addSubscriber(subscriber, eventType); } - setTimeSignature(up: number, down: number): void { - if (Beat.isValidTimeSigRange(up)) { - if (Beat.isValidTimeSigRange(down)) { - this.timeSigUp = up | 0; - this.timeSigDown = down | 0; - this.updateBeatUnitLength(); - this.publisher.notifySubs(BeatEvents.NewTimeSig); - } + setTimeSignature(timeSig: {up?: number, down?: number}): void { + if (timeSig.up && Beat.isValidTimeSigRange(timeSig.up)) { + this.timeSigUp = timeSig.up | 0; } + if (timeSig.down && Beat.isValidTimeSigRange(timeSig.down)) { + this.timeSigDown = timeSig.down | 0; + } + this.updateBeatUnitLength(); + this.publisher.notifySubs(BeatEvents.NewTimeSig); } setBars(barCount: number): void { diff --git a/src/ui/BeatGroup/Beat/BeatSettings/BeatSettingsView.ts b/src/ui/BeatGroup/Beat/BeatSettings/BeatSettingsView.ts index d75bab5..9fd8b19 100644 --- a/src/ui/BeatGroup/Beat/BeatSettings/BeatSettingsView.ts +++ b/src/ui/BeatGroup/Beat/BeatSettings/BeatSettingsView.ts @@ -11,8 +11,9 @@ export type BeatSettingsViewUINodeOptions = UINodeOptions & { export default class BeatSettingsView extends UINode implements ISubscriber { private beat: Beat; private visible = false; - private timeSigUp: HTMLInputElement | null = null; - private timeSigDown: HTMLInputElement | null = null; + private timeSigUp: HTMLInputElement; + private timeSigDown: HTMLInputElement; + private barCountInput: HTMLInputElement; constructor(options: BeatSettingsViewUINodeOptions) { super(options); @@ -26,10 +27,10 @@ export default class BeatSettingsView extends UINode implements ISubscriber { notify(publisher: IPublisher, event: "all" | T[] | T) { if (event === BeatEvents.NewTimeSig) { - if (this.timeSigUp && this.timeSigDown) { - this.timeSigUp.value = this.beat.getTimeSigUp().toString(); - this.timeSigDown.value = this.beat.getTimeSigDown().toString(); - } + this.timeSigUp.value = this.beat.getTimeSigUp().toString(); + this.timeSigDown.value = this.beat.getTimeSigDown().toString(); + } else if (event === BeatEvents.NewBarCount) { + this.barCountInput.value = this.beat.getBarCount(); } } @@ -47,9 +48,19 @@ export default class BeatSettingsView extends UINode implements ISubscriber { } rebuild(): HTMLElement { + this.timeSigUp = UINode.make("input", {}); + this.timeSigUp.addEventListener("input", + (event) => this.beat.setTimeSignature({ + up: Number((event.target as HTMLInputElement).value) })); + this.timeSigDown = UINode.make("input", {}); + this.timeSigDown.addEventListener("input", + (event) => this.beat.setTimeSignature({ + down: Number((event.target as HTMLInputElement).value) })); this.node = UINode.make("div", { subs: [ UINode.make("p", {innerText: `Settings for ${this.beat.getName()}`}), + this.timeSigUp, + this.timeSigDown, ], classes: ["beatSettingsView"] });