{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla-iot/gateway/issues/229","repository_url":"https://api.github.com/repos/mozilla-iot/gateway","labels_url":"https://api.github.com/repos/mozilla-iot/gateway/issues/229/labels{/name}","comments_url":"https://api.github.com/repos/mozilla-iot/gateway/issues/229/comments","events_url":"https://api.github.com/repos/mozilla-iot/gateway/issues/229/events","html_url":"https://github.com/mozilla-iot/gateway/pull/229","id":245780727,"number":229,"title":"Thing Detail View","user":{"login":"benfrancis","id":552417,"avatar_url":"https://avatars3.githubusercontent.com/u/552417?v=4","gravatar_id":"","url":"https://api.github.com/users/benfrancis","html_url":"https://github.com/benfrancis","followers_url":"https://api.github.com/users/benfrancis/followers","following_url":"https://api.github.com/users/benfrancis/following{/other_user}","gists_url":"https://api.github.com/users/benfrancis/gists{/gist_id}","starred_url":"https://api.github.com/users/benfrancis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benfrancis/subscriptions","organizations_url":"https://api.github.com/users/benfrancis/orgs","repos_url":"https://api.github.com/users/benfrancis/repos","events_url":"https://api.github.com/users/benfrancis/events{/privacy}","received_events_url":"https://api.github.com/users/benfrancis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-07-26T16:28:57Z","updated_at":"2017-08-02T10:18:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla-iot/gateway/pulls/229","html_url":"https://github.com/mozilla-iot/gateway/pull/229","diff_url":"https://github.com/mozilla-iot/gateway/pull/229.diff","patch_url":"https://github.com/mozilla-iot/gateway/pull/229.patch"},"body":"This pull request includes two commits, the first splits routing between a server side Express router (for API requests) and a client side Page.js router (for app requests). The second introduces a basic Thing detail view which currently you can only access by typing in the URL of a Thing directly (until we have more complex Thing types and a UI that makes more sense).\r\n\r\nIn order to give things URLs in the web app like /things/{thingId} in a nice RESTful way, we need to be able to differentiate between API requests (JSON & WebSockets) and web app requests (HTML etc.).\r\n\r\nThe first commit splits the API and app routing so that app routing is handled mostly by a client side URL router so we can have a single page app with real URLs which can eventually also work offline using Service Workers.\r\n\r\nIt turns out this is something Express isn't actually very good at. The best approach I've found so far is to write our own content negotiation middleware which splits routing between API requests and app requests by adding a pseudo path prefix (which the end consumer never sees) based on the contents of the HTTP Accept header. It felt kind of hacky at first, but it actually works quite well.\r\n\r\nOne issue with the client side router is how to properly handle 404s when a resource doesn't exist, but this seems to be an issue with client side routing in general.\r\n\r\nThe client side router uses the very lightweight [page.js](https://visionmedia.github.io/page.js/) library which I've manually added to a /static/lib folder. Maybe not the best way of managing dependencies going forward but I didn't want to get into client side dependency management just yet."},"comment":{"url":"https://api.github.com/repos/mozilla-iot/gateway/issues/comments/319631660","html_url":"https://github.com/mozilla-iot/gateway/pull/229#issuecomment-319631660","issue_url":"https://api.github.com/repos/mozilla-iot/gateway/issues/229","id":319631660,"user":{"login":"igilham","id":541775,"avatar_url":"https://avatars3.githubusercontent.com/u/541775?v=4","gravatar_id":"","url":"https://api.github.com/users/igilham","html_url":"https://github.com/igilham","followers_url":"https://api.github.com/users/igilham/followers","following_url":"https://api.github.com/users/igilham/following{/other_user}","gists_url":"https://api.github.com/users/igilham/gists{/gist_id}","starred_url":"https://api.github.com/users/igilham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igilham/subscriptions","organizations_url":"https://api.github.com/users/igilham/orgs","repos_url":"https://api.github.com/users/igilham/repos","events_url":"https://api.github.com/users/igilham/events{/privacy}","received_events_url":"https://api.github.com/users/igilham/received_events","type":"User","site_admin":false},"created_at":"2017-08-02T10:18:41Z","updated_at":"2017-08-02T10:18:41Z","body":"I like the proposed detail view UI but it might be useful to retain a button on the Thing list view for simple toggle devices like switches, sirens etc. Just a thought. That's essentially the approach taken by the SmartThings mobile app and it works quite well."}}
{"actor":{"display_login":"igilham"}}