Merge lp:~stephen-stewart/snapweb/link-to-external-ui into lp:~snappy-dev/snapweb/trunk

Proposed by Stephen Stewart
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 155
Merged at revision: 155
Proposed branch: lp:~stephen-stewart/snapweb/link-to-external-ui
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 184 lines (+69/-16)
7 files modified
www/src/css/snap.css (+10/-0)
www/src/images/external-link.svg (+1/-0)
www/src/js/models/snap.js (+17/-0)
www/src/js/templates/snap-menu.hbs (+5/-0)
www/src/js/views/snap-layout.js (+16/-13)
www/src/js/views/snap-menu.js (+6/-3)
www/tests/modelSpec.js (+14/-0)
To merge this branch: bzr merge lp:~stephen-stewart/snapweb/link-to-external-ui
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+260833@code.launchpad.net

Commit message

add a link to the service ui

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Added a question inline.

One of the original requirements was to open directly if possible, this seems a bit better except for the text.

review: Needs Information
Revision history for this message
Stephen Stewart (stephen-stewart) wrote :

> Added a question inline.
>
> One of the original requirements was to open directly if possible, this seems
> a bit better except for the text.

I honestly don't know what to call this.

I have 2 pieces of information to work on:

1) What a user will find at the end of this link could literally be anything.
2) Claire reports that following discussion with dkirkland and sadfl this link shouldn't be promoted; that the user should not be using webdm to find this link, and that it should not be exposed at a higher level (say, in lists) and should not be given prominence.

So I came up with the weak and non descript 'service ui' :)

Revision history for this message
Stephen Stewart (stephen-stewart) wrote :

The unique way in which lp works means i have to type something in here and hit save.

155. By Stephen Stewart

new name, same great taste

Revision history for this message
Stephen Stewart (stephen-stewart) wrote :

12:14 < sergiusens> beowulf: maybe ogra_ has better words for it
12:15 < ogra_> for what ? renaming webdm ?
12:15 < sergiusens> ogra_: no, let me get a screenshot ;-)
12:15 < ogra_> (if i can open a browser without my laptop sutting down :P )
12:16 < ogra_> *shutting
12:17 < sergiusens> ogra_: http://imgur.com/grZ72cS
12:17 < beowulf> ogra_: in your webrtc snap, you define a ui port, in webdm we create a button for this
12:17 < sergiusens> the mouse is over "Service UI"
12:17 < beowulf> ogra_: what should that button say?
12:18 < beowulf> (talking buttons, who knew)
12:18 < ogra_> just "Open" ?
12:19 < ogra_> service Ui sounds confusingly as if i would access a configuration option there
12:19 < beowulf> ogra_: you might, in some snaps
12:19 < ogra_> (somehow like "Management UI")
12:20 < ogra_> well, then call it "Manage/Open" or some such ...
12:21 < beowulf> "Open" is actually open ended enough to cover all options, or about "Open $name"
12:21 < ogra_> its a bit tricky to find a unique name for a multi purpose button :)
12:21 < ogra_> yeah, i guess Open is the best here unless you want to indicate management/configuration can be accessed through it
12:22 < ogra_> but i guess thats up to the app

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'www/src/css/snap.css'
2--- www/src/css/snap.css 2015-05-27 15:32:13 +0000
3+++ www/src/css/snap.css 2015-06-03 11:33:26 +0000
4@@ -52,6 +52,16 @@
5 padding:15px 0;
6 }
7
8+.b-snap__nav-item[target="_blank"]::after {
9+ content: '';
10+ width:10px;
11+ height:10px;
12+ display:inline-block;
13+ vertical-align:super;
14+ background:transparent url("/public/images/external-link.svg") 0 0 no-repeat;
15+ background-size:10px 10px;
16+}
17+
18 .b-snap__nav-item_active::before {
19 position:absolute;
20 content:'';
21
22=== added file 'www/src/images/external-link.svg'
23--- www/src/images/external-link.svg 1970-01-01 00:00:00 +0000
24+++ www/src/images/external-link.svg 2015-06-03 11:33:26 +0000
25@@ -0,0 +1,1 @@
26+<svg xmlns="http://www.w3.org/2000/svg" width="90" height="90"><path color="#000" fill="none" stroke-width="7.5" overflow="visible" enable-background="accumulate" d="M0 0h90v90H0z"/><path d="M33 13.012C8.994 13.042 6 13.747 6 31v36c0 18 3 18 30 18h12c27 0 30 0 30-18v-9h-9v6c0 12 0 12-24 12h-6c-24 0-24 0-24-12V34c0-10.864.192-11.885 18-11.982v-9.006z" fill="#808080"/><path color="#000" fill="none" stroke-width="6" overflow="visible" enable-background="accumulate" d="M0 0h90v90H0z"/><path d="M113.915 179.144c-.524.303-8.746-4.444-8.746-5.05 0-.605 8.22-5.352 8.744-5.05.525.304.525 9.797 0 10.1z" transform="matrix(-2.993 2.993 -3.111 -3.111 940.172 234.009)" xml:space="default" color="#000" fill="#808080" stroke-width="3" overflow="visible" enable-background="accumulate"/><path style="text-indent:0;text-align:start;line-height:normal;text-transform:none;block-progression:tb;-inkscape-font-specification:Sans" d="M56.426 24.633l-24.34 24.34 9.94 9.94 24.34-24.34z" xml:space="default" color="#000" fill="#808080" stroke-width="9" overflow="visible" enable-background="accumulate" font-family="Sans"/></svg>
27\ No newline at end of file
28
29=== modified file 'www/src/js/models/snap.js'
30--- www/src/js/models/snap.js 2015-06-01 16:27:13 +0000
31+++ www/src/js/models/snap.js 2015-06-03 11:33:26 +0000
32@@ -187,6 +187,7 @@
33 //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
34 'prettyDownloadSize',
35 this.prettifyBytes(Number(response.download_size))
36+ //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
37 );
38 }
39
40@@ -195,9 +196,25 @@
41 //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
42 'prettyInstalledSize',
43 this.prettifyBytes(Number(response.installed_size))
44+ //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
45 );
46 }
47
48+ if (response.hasOwnProperty('ui_port')) {
49+ //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
50+ var port = response.ui_port;
51+ //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
52+
53+ if (_.isFinite(port) && port > 0) {
54+
55+ this.set('vendorGuiHref', window.location.protocol + '//' +
56+ window.location.hostname + ':' + port + '/'
57+ );
58+ } else {
59+ this.unset('vendorGuiHref');
60+ }
61+ }
62+
63 return response;
64 },
65
66
67=== modified file 'www/src/js/templates/snap-menu.hbs'
68--- www/src/js/templates/snap-menu.hbs 2015-05-22 15:21:34 +0000
69+++ www/src/js/templates/snap-menu.hbs 2015-06-03 11:33:26 +0000
70@@ -8,4 +8,9 @@
71 <a class="b-snap__nav-item" href="settings">
72 Settings
73 </a>
74+ {{#if vendorGuiHref}}
75+ <a class="b-snap__nav-item" href="{{vendorGuiHref}}" target="_blank">
76+ Open / Manage
77+ </a>
78+ {{/if}}
79 </div>
80
81=== modified file 'www/src/js/views/snap-layout.js'
82--- www/src/js/views/snap-layout.js 2015-05-08 14:53:07 +0000
83+++ www/src/js/views/snap-layout.js 2015-06-03 11:33:26 +0000
84@@ -46,9 +46,10 @@
85 },
86
87 onBeforeShow: function() {
88- var tabView = this._getSectionView(this.options.section);
89+ var tabView = this.getSectionView(this.options.section);
90 this.showChildView('menuRegion',
91 new SnapMenuView({
92+ model: this.model,
93 section: this.options.section
94 })
95 );
96@@ -60,7 +61,7 @@
97 tabRegion: '.region-tab'
98 },
99
100- _getSectionView: function(section) {
101+ getSectionView: function(section) {
102 var view;
103 switch (section) {
104 case 'reviews':
105@@ -76,17 +77,19 @@
106 },
107
108 section: function(e) {
109- e.preventDefault();
110- var section = e.target.getAttribute('href');
111- var view = this._getSectionView(section);
112- var name = this.model.get('id');
113- // XXX url sane
114- var url = 'snap/' + name + '/' + section;
115- // if section is already in place, don't showChildView
116- var re = new RegExp('/' + section + '$', 'i');
117- if (!re.test(Backbone.history.fragment)) {
118- this.showChildView('tabRegion', view);
119- Backbone.history.navigate(url);
120+ if (!e.target.getAttribute('target')) {
121+ e.preventDefault();
122+ var section = e.target.getAttribute('href');
123+ var view = this.getSectionView(section);
124+ var name = this.model.get('id');
125+ // XXX url sane
126+ var url = 'snap/' + name + '/' + section;
127+ // if section is already in place, don't showChildView
128+ var re = new RegExp('/' + section + '$', 'i');
129+ if (!re.test(Backbone.history.fragment)) {
130+ this.showChildView('tabRegion', view);
131+ Backbone.history.navigate(url);
132+ }
133 }
134 }
135 });
136
137=== modified file 'www/src/js/views/snap-menu.js'
138--- www/src/js/views/snap-menu.js 2015-05-08 20:03:48 +0000
139+++ www/src/js/views/snap-menu.js 2015-06-03 11:33:26 +0000
140@@ -17,13 +17,16 @@
141 'click': 'onNavClick'
142 },
143
144- template: function() {
145- return template();
146+ template: function(model) {
147+ return template(model);
148 },
149
150 onNavClick: function(e) {
151 var link = e.target.getAttribute('href');
152- this.setActiveNav(link);
153+ if (!e.target.getAttribute('target')) {
154+ e.preventDefault();
155+ this.setActiveNav(link);
156+ }
157 },
158
159 setActiveNav: function(link) {
160
161=== modified file 'www/tests/modelSpec.js'
162--- www/tests/modelSpec.js 2015-06-01 22:09:08 +0000
163+++ www/tests/modelSpec.js 2015-06-03 11:33:26 +0000
164@@ -88,6 +88,20 @@
165 expect(this.model.get('prettyDownloadSize')).toBe('0 B');
166 });
167
168+ it('should parse response to create vendorGuiHref', function() {
169+ this.model.parse({'ui_port': 8080});
170+ expect(this.model.get('vendorGuiHref')).toBe('http://localhost:8080/');
171+ });
172+
173+ it('should not set vendorGuiHref if not a finite number', function() {
174+ this.model.parse({'ui_port': NaN});
175+ expect(this.model.get('vendorGuiHref')).not.toBeDefined();
176+ this.model.parse({'ui_port': ''});
177+ expect(this.model.get('vendorGuiHref')).not.toBeDefined();
178+ this.model.parse({'ui_port': -9});
179+ expect(this.model.get('vendorGuiHref')).not.toBeDefined();
180+ });
181+
182 });
183
184 describe('sync methods', function() {

Subscribers

People subscribed via source and target branches