-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Gaya/setup-block-types
Connect to store and display block types
- Loading branch information
Showing
25 changed files
with
288 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/dist | ||
*.ts |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/components/blocks/OneWireTempSensor/OneWireTempSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Vue from 'vue'; | ||
import Component from 'vue-class-component'; | ||
|
||
import { getById } from '../../../store/blocks/OneWireTempSensor/getters'; | ||
|
||
@Component({ | ||
props: { | ||
id: { | ||
default: '', | ||
type: String, | ||
}, | ||
}, | ||
}) | ||
export default class OneWireTempSensor extends Vue { | ||
get blockData() { | ||
return getById(this.$props.id); | ||
} | ||
|
||
get settings() { | ||
return this.blockData.settings; | ||
} | ||
|
||
get state() { | ||
return this.blockData.state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Vue from 'vue'; | ||
import Component from 'vue-class-component'; | ||
|
||
import { getById } from '../../../store/blocks/SetPointSimple/getters'; | ||
|
||
@Component({ | ||
props: { | ||
id: { | ||
default: '', | ||
type: String, | ||
}, | ||
}, | ||
}) | ||
export default class SetPointSimple extends Vue { | ||
get blockData() { | ||
return getById(this.$props.id); | ||
} | ||
|
||
get settings() { | ||
return this.blockData.settings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<component | ||
:is="type" | ||
:id="blockId" | ||
/> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import { blockById } from '../../store/blocks/getters'; | ||
const blockTypes = { | ||
OneWireTempSensor: () => import('./OneWireTempSensor/default.vue'), | ||
SetPointSimple: () => import('./SetPointSimple/default.vue'), | ||
}; | ||
export default Vue.extend({ | ||
name: 'block', | ||
components: { ...blockTypes }, | ||
props: { | ||
blockId: { | ||
default: '', | ||
type: String, | ||
}, | ||
}, | ||
computed: { | ||
type(): string { | ||
const type = blockById(this.$props.blockId).type; | ||
if (Object.keys(blockTypes).indexOf(type) === -1) { | ||
throw new Error(`'${type}' is not a valid block type`); | ||
} | ||
return type; | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.