~pistos/remoteku

568e9e9c7ddb8ec8a765d1e1a62b1b5dea874b27 — Pistos 1 year, 5 months ago b81343a
Add app icons
2 files changed, 44 insertions(+), 0 deletions(-)

M frontend/src/views/Home.vue
M sample.py
M frontend/src/views/Home.vue => frontend/src/views/Home.vue +27 -0
@@ 19,6 19,7 @@
      </div>
    </div>
  </div>

  <div v-if="rokuHost">
    <div>
      <img src="/roku-remote.png" alt="Roku remote" usemap="#rokumap"/>


@@ 40,6 41,7 @@
        <area shape="rect" coords="284,409,306,457" title="Mute" @click="apiPress('mute')"/>
      </map>
    </div>

    <div class="text-entry">
      <label>
        Type text:


@@ 54,6 56,16 @@
      <button @click="sendLiteral"><b>&#x23ce;</b></button>
      <button @click="apiPress('backspace')"><b>&#x232b;</b></button>
    </div>

    <div class="apps">
      <img
        :alt="name"
        @click="launch(appId)"
        :src="`app-icons/${appId}.jpg`"
        v-for="(name, appId) in apps"
        :key="appId"
      />
    </div>
  </div>
</div>
</template>


@@ 73,6 85,9 @@ export default {
    this.rokuHosts = res.data
    this.discoveringRokus = false

    const res2 = await axios.get('/api/apps')
    this.apps = res2.data

    const self = this
    window.addEventListener('keydown', function (e) {
      if (! self.textFieldFocused) {


@@ 88,6 103,7 @@ export default {
  },
  data: function () {
    return {
      apps: {},
      discoveringRokus: false,
      literalText: '',
      rokuHost: null,


@@ 99,6 115,9 @@ export default {
    async apiPress (button) {
      await axios.get(`/api/press/${button}`)
    },
    launch(appId) {
      axios.get(`/api/launch/${appId}`)
    },
    async sendLiteral () {
      await axios.post(
        '/api/literal',


@@ 139,4 158,12 @@ map {
    max-width: 20vw;
  }
}

.apps {
  img {
    cursor: pointer;
    margin: 1em;
    max-width: 30vw;
  }
}
</style>

M sample.py => sample.py +17 -0
@@ 21,6 21,23 @@ def choose_roku():

    return "OK", 200

@app.route('/api/apps')
def apps():
    apps = dict()
    for a in current_roku.apps:
        apps[a.id] = a.name

    return make_response(
        jsonify(apps),
        200
    )

@app.route('/api/launch/<app_id>')
def launch(app_id):
    current_roku[app_id].launch()

    return "OK", 200

@app.route('/api/discover')
def discover():
    rokus = Roku.discover()