Skip to content

Commit

Permalink
Merge pull request #121 from NERDDISCO/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
TimPietrusky authored Oct 11, 2019
2 parents e579b50 + a74da21 commit e458360
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/git",
"@semantic-release/github",
["@semantic-release/npm", {
"npmPublish": false
}],
"@semantic-release/git",
"@semantic-release/github",
],
"verifyConditions": [
"@semantic-release/changelog",
Expand Down
16 changes: 14 additions & 2 deletions src/actions/animation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as constants from '../constants/index.js'
import { getScenesWithAnimation } from '../selectors/index.js'
import { removeAnimationFromScene } from './index.js'
import { getScenesWithAnimation, getVenuesWithAnimation } from '../selectors/index.js'
import { removeAnimationFromScene, setVenueSlot } from './index.js'

/*
* Add a animation
Expand Down Expand Up @@ -47,6 +47,18 @@ export const removeAnimationFromEverywhere = animationId => {
dispatch(removeAnimationFromScene(scene.id, animationId))
})

// Remove animation from all venues
getVenuesWithAnimation(getState(), { animationId }).map(venue => {
venue.slots
// Find all slots that contain the fixture
.filter(slot => slot.animations.includes(animationId))
.map(slot => {
// Remove the fixture from the list of animations of this slot
const animations = slot.animations.filter(_animationId => _animationId !== animationId)
dispatch(setVenueSlot(venue.id, { id: slot.id, animations }))
})
})

dispatch(removeAnimation(animationId))
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as utils from '../utils/index.js'

export * from './timeline.js'
export * from './animation.js'
export * from './venue.js'

import { setVenueSlot } from './venue.js'

/*
*
Expand Down Expand Up @@ -289,10 +292,20 @@ export const removeFixtureFromEverywhere = fixtureId => {
utils.clearFixtureInBatch(fixtureId)

// Remove fixture from all scenes
selectors.getScenes(getState()).map(scene => {
if (scene.fixtures.indexOf(fixtureId) > -1) {
dispatch(removeFixtureFromScene(scene.id, scene.fixtures.indexOf(fixtureId)))
}
selectors.getScenesWithFixture(getState(), { fixtureId }).map(scene => {
dispatch(removeFixtureFromScene(scene.id, fixtureId))
})

// Remove fixture from all venues
selectors.getVenuesWithFixture(getState(), { fixtureId }).map(venue => {
venue.slots
// Find all slots that contain the fixture
.filter(slot => slot.fixtures.includes(fixtureId))
.map(slot => {
// Remove the fixture from the list of fixtures of this slot
const fixtures = slot.fixtures.filter(_fixtureId => _fixtureId !== fixtureId)
dispatch(setVenueSlot(venue.id, { id: slot.id, fixtures }))
})
})

dispatch(removeFixture(fixtureId))
Expand Down
4 changes: 2 additions & 2 deletions src/components/dmx-fixture-property/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class DmxFixtureProperty extends LitElement {
<xy-pad
width="180"
height="120"
currentX="${defaultValue(value.realX, 0)}"
currentY="${defaultValue(value.realY, 0)}"
currentX="${defaultValue(value === undefined ? undefined : value.realX, 0)}"
currentY="${defaultValue(value === undefined ? undefined : value.realY, 0)}"
maxX="180"
maxY="120"
labelX="pan"
Expand Down
4 changes: 4 additions & 0 deletions src/components/fixture-list-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class FixtureListItem extends LitElement {
render() {
const { fixture } = this

if (fixture === undefined) {
return html``
}

return html`
${links}
Expand Down
4 changes: 2 additions & 2 deletions src/components/scene-bee/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { LitElement, html } from 'lit-element'
import { store } from '../../reduxStore.js'
import { setSceneName, addAnimationToScene, addFixturesToScene, removeFixtureFromScene, removeAnimationFromScene, addSceneToTimeline, removeScene, resetUniverseAndFixtures, removeFixtureFromSceneAndUniverse } from '../../actions/index.js'
import { setSceneName, addAnimationToScene, addFixturesToScene, removeSceneFromTimelineAndResetFixtures, removeAnimationFromScene, addSceneToTimeline, removeScene, resetUniverseAndFixtures, removeFixtureFromSceneAndUniverse } from '../../actions/index.js'
import '../fixture-list/index.js'
import '../animation-list/index.js'
import { SCENE_TYPE_STATIC } from '../../constants/timeline.js'
import uuidv1 from 'uuid/v1.js'



/*
* Handle a list of scenes
*/
Expand Down Expand Up @@ -43,6 +42,7 @@ class SceneBee extends LitElement {

removeScene(e) {
const { sceneId } = e.target
store.dispatch(removeSceneFromTimelineAndResetFixtures(sceneId))
store.dispatch(removeScene(sceneId))
}

Expand Down
28 changes: 28 additions & 0 deletions src/components/timeline/sketch_timeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"timeline": {
"scenes": [{
"sceneId": "1acee3e0-e02c-11e9-aa5a-053c07f0fa34",
"timelineSceneId": "2d3f80f0-eb23-11e9-a506-1d4f9a09fff9",
"adapt": true,
"type": "static",
"added": 1570687192703,
"started": 1570688810596,
"priority": 0,
"animations": [{
"animationId": "asd-asdf-asdf-asdf-asdf-asdf",
"type": "repeat",
"started": 1570688810596
}]
}, {
"sceneId": "6878c220-e02f-11e9-b1ac-b1b9c8742475",
"timelineSceneId": "ec3e6ef0-eb26-11e9-af75-e516d6b192d7",
"adapt": true,
"type": "static",
"added": 1570688801631,
"started": 1570688806691,
"priority": 0
}],
"playing": false,
"progress": 0
}
}
13 changes: 9 additions & 4 deletions src/components/timeline/timeline-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ class TimelineAnimation extends LitElement {
}

ended() {
// Animation is done
this.dispatchEvent(new CustomEvent('animation-ended', {
detail: {}
}))
// This is a quick fix to restart the animation when it's done
this.started = new Date().getTime()

// The real fix would be to still let the scene know that the animation ended
// but only restart the animation and not the whole scene
// // Animation is done
// this.dispatchEvent(new CustomEvent('animation-ended', {
// detail: {}
// }))
}

shouldUpdate(changedProperties) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/timeline/timeline-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class TimelineScene extends connect(store)(LitElement) {
}

animationEnded(e) {
// @TODO: Do not reset the scene if one of it's animations is done
// every anmation has to have it's own progress and type
if (this.timelineScene.type === SCENE_TYPE_STATIC) {
const scene = {
sceneId: this.timelineScene.sceneId,
Expand Down
27 changes: 10 additions & 17 deletions src/selectors/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createSelector } from 'reselect/src/index.js'
import { collator } from '../utils/index.js'

export * from './venue.js'

/*
* Selectors help you to retrieve data from the state so you don't have to write the
* same code to access the state over and over again. It also helps to have a central position
Expand Down Expand Up @@ -30,7 +32,6 @@ export const getDekk = state => state.dekkManager
export const getDekkConnected = state => state.dekkManager.connected
export const getDekkData = state => state.dekkManager.data
export const getUsbDmxControllerConnected = state => state.connectionManager.usb.connected
export const getVenues = state => state.venueManager

export const getAnimation = (state, properties) => {
return getAnimations(state)
Expand Down Expand Up @@ -77,6 +78,14 @@ export const getScenesWithAnimation = (state, properties) => {
.filter(scene => scene.animations.includes(properties.animationId))
}

/*
* Get scenes that contain a certain fixtureId
*/
export const getScenesWithFixture = (state, properties) => {
return getScenes(state)
.filter(scene => scene.fixtures.includes(properties.fixtureId))
}

/*
* Get a specific fixture by using the fixtureId
*/
Expand All @@ -93,22 +102,6 @@ export const getFixtureByName = (state, properties) => {
.filter(fixture => fixture.name === properties.name)[0]
}

/*
* Get a specific fixture by using the fixtureId
*/
export const getVenue = (state, properties) => {
return getVenues(state)
.filter(venue => venue.id === properties.venueId)[0]
}

/*
* Sort venues by venue.name
*/
export const getVenuesSorted = createSelector(
getVenues,
venues => venues.sort((a, b) => collator.compare(a.name, b.name))
)

/*
* Sort fixtures by fixture.name
*/
Expand Down
40 changes: 40 additions & 0 deletions src/selectors/venue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSelector } from 'reselect/src/index.js'

export const getVenues = state => state.venueManager

/*
* Get a specific fixture by using the fixtureId
*/
export const getVenue = (state, properties) => {
return getVenues(state)
.filter(venue => venue.id === properties.venueId)[0]
}

/*
* Sort venues by venue.name
*/
export const getVenuesSorted = createSelector(
getVenues,
venues => venues.sort((a, b) => collator.compare(a.name, b.name))
)

/*
* Get venues that contain a specific fixture
*/
export const getVenuesWithFixture = (state, properties) => {
return getVenues(state)
.filter(venue => {
return venue.slots.filter(slot => slot.fixtures.includes(properties.fixtureId))
})
}

/*
* Get venues that contain a specific animation
*/
export const getVenuesWithAnimation = (state, properties) => {
return getVenues(state)
.filter(venue => {
return venue.slots.filter(slot => slot.animations.includes(properties.animationId))
})
}

0 comments on commit e458360

Please sign in to comment.