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

Side by Side Diff: app/app.js

Issue 7095058: Support read-only mode in the GUI
Patch Set: Created 12 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 'use strict'; 1 'use strict';
2 /** 2 /**
3 * Provides the main app class. 3 * Provides the main app class.
4 * 4 *
5 * @module app 5 * @module app
6 */ 6 */
7 7
8 // Create a global for debug console access to YUI context. 8 // Create a global for debug console access to YUI context.
9 var yui; 9 var yui;
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 environment_node.set('text', environment_name); 212 environment_node.set('text', environment_name);
213 } 213 }
214 // Create an environment facade to interact with. 214 // Create an environment facade to interact with.
215 // allow env as an attr/option to ease testing 215 // allow env as an attr/option to ease testing
216 if (this.get('env')) { 216 if (this.get('env')) {
217 this.env = this.get('env'); 217 this.env = this.get('env');
218 } else { 218 } else {
219 this.env = new juju.Environment( 219 this.env = new juju.Environment(
220 { socket_url: this.get('socket_url'), 220 { socket_url: this.get('socket_url'),
221 user: this.get('user'), 221 user: this.get('user'),
222 password: this.get('password')}); 222 password: this.get('password'),
223 readOnly: this.get('readOnly')});
teknico 2013/01/15 16:45:43 No need for camel case here, "readonly" is an esta
223 } 224 }
224 // Create a charm store. 225 // Create a charm store.
225 if (this.get('charm_store')) { 226 if (this.get('charm_store')) {
226 // This path is for tests. 227 // This path is for tests.
227 this.charm_store = this.get('charm_store'); 228 this.charm_store = this.get('charm_store');
228 } else { 229 } else {
229 this.charm_store = new juju.CharmStore({ 230 this.charm_store = new juju.CharmStore({
230 datasource: this.get('charm_store_url')}); 231 datasource: this.get('charm_store_url')});
231 } 232 }
232 // Create notifications controller 233 // Create notifications controller
233 this.notifications = new juju.NotificationController({ 234 this.notifications = new juju.NotificationController({
234 app: this, 235 app: this,
235 env: this.env, 236 env: this.env,
236 notifications: this.db.notifications}); 237 notifications: this.db.notifications});
237 238
238 // Event subscriptions 239 // Event subscriptions
239 240
240 this.on('*:navigateTo', function(e) { 241 this.on('*:navigateTo', function(e) {
241 console.log('navigateTo', e); 242 console.log('navigateTo', e);
242 this.navigate(e.url); 243 this.navigate(e.url);
243 }, this); 244 }, this);
244 245
246 // Notify user attempts to modify the environment without permission.
247 this.env.on('permissionDenied', this.onEnvPermissionDenied, this);
248
245 // When the provider type becomes available, display it. 249 // When the provider type becomes available, display it.
246 this.env.after('providerTypeChange', this.onProviderTypeChange); 250 this.env.after('providerTypeChange', this.onProviderTypeChange);
247 251
248 // Once the user logs in we need to redraw. 252 // Once the user logs in we need to redraw.
249 this.env.after('login', this.onLogin, this); 253 this.env.after('login', this.onLogin, this);
250 254
251 // Feed environment changes directly into the database. 255 // Feed environment changes directly into the database.
252 this.env.on('delta', this.db.on_delta, this.db); 256 this.env.on('delta', this.db.on_delta, this.db);
253 257
254 // Feed delta changes to the notifications system 258 // Feed delta changes to the notifications system
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 564 }
561 // If there has not been a successful login attempt, 565 // If there has not been a successful login attempt,
562 // do not let the route dispatch proceed. 566 // do not let the route dispatch proceed.
563 if (!this.env.userIsAuthenticated) { 567 if (!this.env.userIsAuthenticated) {
564 return; 568 return;
565 } 569 }
566 next(); 570 next();
567 }, 571 },
568 572
569 /** 573 /**
574 * Notify with an error when the user tries to change the environment
575 * without permission.
576 *
577 * @method onEnvPermissionDenied
578 * @private
579 * @param {Object} evt An event object (with "title" and "message"
580 attributes).
581 * @return {undefined} Mutates only.
582 */
583 onEnvPermissionDenied: function(evt) {
584 this.db.notifications.add(
585 new models.Notification({
586 title: evt.title,
587 message: evt.message,
588 level: 'error'
589 })
590 );
591 },
592
593 /**
570 * Hide the login mask and redispatch the router. 594 * Hide the login mask and redispatch the router.
571 * 595 *
572 * When the environment gets a response from a login attempt, 596 * When the environment gets a response from a login attempt,
573 * it fires a login event, to which this responds. 597 * it fires a login event, to which this responds.
574 * 598 *
575 * @method onLogin 599 * @method onLogin
576 * @private 600 * @private
577 */ 601 */
578 onLogin: function() { 602 onLogin: function() {
579 Y.one('body > #login-mask').hide(); 603 Y.one('body > #login-mask').hide();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 'juju-views', 844 'juju-views',
821 'juju-view-login', 845 'juju-view-login',
822 'io', 846 'io',
823 'json-parse', 847 'json-parse',
824 'app-base', 848 'app-base',
825 'app-transitions', 849 'app-transitions',
826 'base', 850 'base',
827 'node', 851 'node',
828 'model'] 852 'model']
829 }); 853 });
OLDNEW
« no previous file with comments | « [revision details] ('k') | app/config-debug.js » ('j') | app/config-debug.js » ('J')

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