| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <style>
- .red {
- color: #f00;
- }
- </style>
- <template>
- <md-layout md-align="center" md-gutter="16">
- <md-card>
- <md-card-header>
- <div class="md-title">{{ light.name }}</div>
- <div class="md-subhead">{{ light.type }}</div>
- </md-card-header>
- <md-card-content>
- <md-switch v-model="stateOn" class="md-warn" @change="toggleOnOff()">State</md-switch>
- </md-card-content>
- <md-card-actions>
- <md-button @click.native="reset()">Reset</md-button>
- <md-button @click.native="setColor('purple')">Purple</md-button>
- <md-button @click.native="colorLoop()">Color Loop</md-button>
- </md-card-actions>
- </md-card>
- </md-layout>
- </template>
- <script>
- module.exports = {
- props: ['light'],
- data: function () {
- return {
- stateOn: false
- };
- },
- http: {
- root: '/api',
- },
- methods: {
- setProps: function (data) {
- this.$http.put('lights/' + this.$props.light.id, data).then(function (result) {
- console.log('result', result);
- }, function (error) {
- console.log('error', error);
- });
- },
- toggleOnOff: function () {
- this.stateOn = !this.stateOn;
- this.setProps({ state: this.stateOn });
- },
- reset: function () {
- this.setProps({ reset: true });
- },
- colorLoop: function () {
- this.setProps({ effect: 'colorloop' });
- },
- setColor: function (color) {
- this.setProps({ color: color });
- }
- }
- }
- </script>
|