Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1188)

Issue 6503111: Add a read-only view to display unit details.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 7 months ago by benji
Modified:
11 years, 7 months ago
Reviewers:
mp+124051, hazmat, gary.poster, benjamin.saller
Visibility:
Public.

Description

Add a read-only view to display unit details. This branch adds a read-only view that displays unit details including charm, machine info, and a listing of relations. https://code.launchpad.net/~benji/juju-ui/unit-view/+merge/124051 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : Add a read-only view to display unit details. #

Total comments: 34
Unified diffs Side-by-side diffs Delta from patch set Stats (+638 lines, -352 lines) Patch
M .bzrignore View 1 chunk +2 lines, -0 lines 0 comments Download
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M app/app.js View 1 1 chunk +4 lines, -0 lines 3 comments Download
M app/assets/stylesheets/juju-gui.css View 1 1 chunk +1 line, -0 lines 1 comment Download
M app/templates.js View 1 4 chunks +336 lines, -276 lines 1 comment Download
M app/templates/service-config.handlebars View 1 chunk +1 line, -1 line 0 comments Download
M app/templates/unit.handlebars View 1 1 chunk +70 lines, -58 lines 14 comments Download
M app/views/unit.js View 1 2 chunks +54 lines, -17 lines 5 comments Download
M jshint.config View 1 1 chunk +2 lines, -0 lines 1 comment Download
M lib/views/stylesheet.less View 1 1 chunk +4 lines, -0 lines 0 comments Download
M test/index.html View 1 chunk +1 line, -0 lines 0 comments Download
A test/test_unit_view.js View 1 1 chunk +161 lines, -0 lines 9 comments Download

Messages

Total messages: 8
benji
Please take a look.
11 years, 7 months ago (2012-09-12 20:30:18 UTC) #1
benji
Please take a look.
11 years, 7 months ago (2012-09-13 12:15:43 UTC) #2
gary.poster
Hi Benji. Thank you for the changes. This looks very good to me. The only ...
11 years, 7 months ago (2012-09-13 15:03:44 UTC) #3
benji
On 2012/09/13 15:03:44, gary.poster wrote: > Hi Benji. Thank you for the changes. This looks ...
11 years, 7 months ago (2012-09-13 15:49:10 UTC) #4
hazmat
lgtm with these minors, and gary's point regarding reusing socketstub from test-utils. https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebars File app/templates/unit.handlebars ...
11 years, 7 months ago (2012-09-13 18:00:32 UTC) #5
benjamin.saller
Thanks for this, I think the view template and render method need some work, some ...
11 years, 7 months ago (2012-09-13 18:13:51 UTC) #6
hazmat
https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebars File app/templates/unit.handlebars (right): https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebars#newcode13 app/templates/unit.handlebars:13: <span style="color: red">&#x2b1b;</span> the boolean distinction here is a ...
11 years, 7 months ago (2012-09-14 11:51:50 UTC) #7
benji
11 years, 7 months ago (2012-09-14 19:06:23 UTC) #8
I've fixed or otherwise responded to all the comments thus far.  As discussed in
the standup, I'll be merging this branch now.

https://codereview.appspot.com/6503111/diff/2001/app/app.js
File app/app.js (right):

https://codereview.appspot.com/6503111/diff/2001/app/app.js#newcode155
app/app.js:155: this._prefetch_service(service);
On 2012/09/13 15:03:44, gary.poster wrote:
> It *might* be nice to say why prefetching the service is important.  Then
again,
> maybe it's obvious to everyone else. :-)

Done.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebars
File app/templates/unit.handlebars (right):

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:4: <b id="charm-uri">{{service.charm}}</b>
On 2012/09/13 18:13:52, benjamin.saller wrote:
> The charm object should be in the template name space and this should be a
link
> ala services view.

Done.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:5: {{#unit.is_subordinate}}
(subordinate){{/unit.is_subordinate}}
On 2012/09/13 18:13:52, benjamin.saller wrote:
> You using the block style for iteration rather than single element 'if's. 
> 
> This is done a number of places.
> 
> Following the style on the services page this could be
> {{#if unit.public_address}
> <b>Public Address:</b> {{unit.public_address}}
> {{/if}

Ah!  Very nice.  I was looking at the Moustache docs and they flat-out say that
there are no ifs.  Warning to future generations: Moustache and Handlebars are
only superficially similar.  Fixed.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:7: {{unit_ip_description}}
On 2012/09/13 18:13:52, benjamin.saller wrote:
> This object doesn't need to be built in the render method. The above 'if's
> should handle it just fine.

I would like to move the formatting to the template, but I don't see a (sane)
way to do this with just ifs.  Note the pipes separating the parts.  We could
use CSS and add an :after to each one to add the pipes or we could drop the
pipes and make a table like the rest of the data on the page.  I was trying to
be faithful to the mockup at
https://docs.google.com/a/canonical.com/file/d/0BwQq-CeM0YioeWxuMmRnQUdLNzA/edit.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:10: <span style="color: green">&#x25B6;</span>
On 2012/09/13 18:13:52, benjamin.saller wrote:
> We shouldn't include inline style information like this. 
> 
> This should be in the stylesheet (using LESS)
> 
> #unit-status {
>    .runnng {...}
> }
> 
> or style="success" || style="error" which are standards in the Bootstrap CSS

Bootstrap's "alert-error" was the closest I could find and it didn't produce
good results.  I added styles to our LESS stylesheet.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:13: <span style="color: red">&#x2b1b;</span>
On 2012/09/14 11:51:50, hazmat wrote:
> the boolean distinction here is a bit overly gestalt, we have multiple states
of
> interest, running/started, pending action, and error, so perhaps green,
yellow,
> red?

Sounds good.  I thought I heard someone say that we wanted to do it this way,
but I like yellow just fine. ;)

I've added a yellow circle for non-running, non-error states.  It looks good.

https://codereview.appspot.com/6503111/diff/2001/app/templates/unit.handlebar...
app/templates/unit.handlebars:61: <td
class="relation-endpoint">{{endpoint}}</td>
On 2012/09/13 18:00:32, hazmat wrote:
> this should link to the endpoint, see service relations details as an example.

Done.

Potential bug: can service names contain characters that need to be escaped?

https://codereview.appspot.com/6503111/diff/2001/app/views/unit.js
File app/views/unit.js (right):

https://codereview.appspot.com/6503111/diff/2001/app/views/unit.js#newcode30
app/views/unit.js:30: container.setHTML('<div class="alert">Loading...</div>');
On 2012/09/13 15:03:44, gary.poster wrote:
> Ah, we should do something like that for our view too.

Well, now that the top of every page isn't covered up by the banner, you'll
actually be able to see the loading message.

https://codereview.appspot.com/6503111/diff/2001/app/views/unit.js#newcode47
app/views/unit.js:47: unit_ip_description = ip_description_chunks.join(' | ');
On 2012/09/13 18:00:32, hazmat wrote:
> this sort of formatting in the view rather then the template seems odd, why
not
> push these named fields to the template and do presentation logic there?

I would like to, but I can't find a non-insane way to do so.  The interstitial
pipes are the issue.  Ben made a similar comment in the template if you want to
read the discussion there.

https://codereview.appspot.com/6503111/diff/2001/test/test_unit_view.js
File test/test_unit_view.js (right):

https://codereview.appspot.com/6503111/diff/2001/test/test_unit_view.js#newcode7
test/test_unit_view.js:7: var SocketStub = function () {
On 2012/09/13 15:03:44, gary.poster wrote:
> You can get the socket from juju-tests-utils now.  See our "before" function
in
> https://codereview.appspot.com/6496112/patch/1/17 .

Done.

https://codereview.appspot.com/6503111/diff/2001/test/test_unit_view.js#newcode7
test/test_unit_view.js:7: var SocketStub = function () {
On 2012/09/13 18:13:52, benjamin.saller wrote:
> On 2012/09/13 15:03:44, gary.poster wrote:
> > You can get the socket from juju-tests-utils now.  See our "before" function
> in
> > https://codereview.appspot.com/6496112/patch/1/17 .
> 
> agreed, however I can't see that its actually used, it looks like you build
the
> models by hand.

The connection is used to build an instance of juju.Environment which is in turn
used by the tests.

https://codereview.appspot.com/6503111/diff/2001/test/test_unit_view.js#newco...
test/test_unit_view.js:105: conn.messages = [];
On 2012/09/13 18:00:32, hazmat wrote:
> conn.close does this.

Ah, good to know.  I just cribbed this from another test.  I will fix all
instances of this. [later] Now the other test does not do this any more so this
test was the only one to fix.

https://codereview.appspot.com/6503111/diff/2001/test/test_unit_view.js#newco...
test/test_unit_view.js:134:
container.one('#machine-name').getHTML().should.contain(
On 2012/09/13 18:13:52, benjamin.saller wrote:
> If this pattern is repeated all over the test it might be worth adding a
> declarative handler in utils
> 
> this.validate_content(container, {
> "#machine-agent-state": {contain: "pending"},
> "#machine-instance-id": {contain: "instance-0"},
> ...
> }
> If you like the sound of that I could cut a small branch for a it as a slack
> task. 

Even though I'm a big proponent of DRY, the one less level of indirection makes
this approach is preferable.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b