Permalink
Browse files

Upgrade to ember-1.0.0 and latest ember-data beta

* Swapped out all the ember related vendored javascript files for the
  new most stable versions
* Rewrote the router to use the new DSL
* Namespaced controller and view
* Removed a lot of code that is now unnecessary due to better defaults
  • Loading branch information...
1 parent d449797 commit 2ff7904633e2dd45a70f0f30f8395a9af8effe15 @vanstee vanstee committed Sep 4, 2013
View
@@ -3,47 +3,31 @@ minispade.register('app', function() {
/**
* RiakControl Ember application.
*/
- RiakControl = Ember.Application.create({
- ready: Ember.alias('initialize')
- });
+ RiakControl = Ember.Application.create();
/**
* How often to refresh/poll the server for changes in cluster
* and partition status
*/
RiakControl.refreshInterval = 1000;
- RiakControl.ApplicationController = Ember.Controller.extend();
-
- RiakControl.ApplicationView = Ember.View.extend({
- templateName: 'application'
- });
-
/**
- * Provide reload functionality for objects and recordarrays.
+ * Provide reload functionality for recordarrays.
*/
- DS.Model.reopen({
- reload: function() {
- var store = this.get('store');
- store.get('adapter').find(store, this.constructor, this.get('id'));
- }
- });
-
DS.RecordArray.reopen({
reload: function() {
Ember.assert("Can only reload base RecordArrays",
this.constructor === DS.RecordArray);
var store = this.get('store');
- store.get('adapter').findAll(store, this.get('type'));
+ store.findAll(this.get('type'));
}
});
/**
* Data store configuration.
*/
RiakControl.Store = DS.Store.extend({
- revision: 4,
- adapter: DS.RESTAdapter.create({ namespace: 'admin' })
+ adapter: DS.RESTAdapter.reopen({ namespace: 'admin' })
});
RiakControl.store = RiakControl.Store.create();
View
@@ -255,63 +255,59 @@ minispade.register('cluster', function() {
return this.get('content.stagedCluster').filterProperty('isDestroyed', false);
}.property('content.stagedCluster', 'content.stagedCluster.@each'),
- commitPlan: function(ev) {
- ev.preventDefault();
+ actions: {
+ commitPlan: function() {
+ var self = this;
+ var confirmed = $(document).find("[name='confirmed']:checked").val();
+
+ if(confirmed) {
+ $.ajax({
+ type: 'POST',
+ url: '/admin/cluster',
+ dataType: 'json',
+ success: function(d) { self.reload(); },
+ error: function (jqXHR, textStatus, errorThrown) {
+ self.get('displayError').call(self, jqXHR, textStatus, errorThrown);
+ }
+ });
+ } else {
+ self.get('displayError').call(self, undefined, undefined, "Please confirm the plan.");
+ }
+ },
- var self = this;
- var confirmed = $(document).find("[name='confirmed']:checked").val();
+ /**
+ * Clear the currently staged cluster plan.
+ *
+ * @returns {void}
+ */
+ clearPlan: function() {
+ var self = this;
- if(confirmed) {
$.ajax({
- type: 'POST',
+ type: 'DELETE',
url: '/admin/cluster',
dataType: 'json',
success: function(d) { self.reload(); },
error: function (jqXHR, textStatus, errorThrown) {
self.get('displayError').call(self, jqXHR, textStatus, errorThrown);
}
});
- } else {
- self.get('displayError').call(self, undefined, undefined, "Please confirm the plan.");
- }
- },
-
- /**
- * Clear the currently staged cluster plan.
- *
- * @returns {void}
- */
- clearPlan: function(ev) {
- ev.preventDefault();
-
- var self = this;
-
- $.ajax({
- type: 'DELETE',
- url: '/admin/cluster',
- dataType: 'json',
- success: function(d) { self.reload(); },
- error: function (jqXHR, textStatus, errorThrown) {
- self.get('displayError').call(self, jqXHR, textStatus, errorThrown);
- }
- });
- },
+ },
- /**
- * Join a node.
- *
- * @returns {void}
- */
- joinNode: function(ev) {
- ev.preventDefault();
-
- var self = this;
- var node = this.get('joinNodeField');
- var success = function() {
- self.set('joinNodeField', undefined);
- };
-
- this.stageChange(node, "join", "", success, undefined);
+ /**
+ * Join a node.
+ *
+ * @returns {void}
+ */
+ joinNode: function() {
+ var self = this;
+ var node = this.get('joinNodeField');
+ var success = function() {
+ self.set('joinNodeField', undefined);
+ };
+
+ this.send('stageChange', node, "join", "", success, undefined);
+ }
},
/**
@@ -336,8 +332,8 @@ minispade.register('cluster', function() {
*/
RiakControl.JoinNodeView = Ember.TextField.extend(
/** @scope RiakControl.JoinNodeView.prototype */ {
- valueBinding: 'controller.joinNodeField',
classNames: ['gui-input', 'gui-text'],
+ joinNode: 'joinNode',
/**
* When the user presses the enter/return key in the
@@ -349,9 +345,8 @@ minispade.register('cluster', function() {
* @returns {void}
*/
keyUp: function (ev) {
- var controller = this.get('controller');
if(ev.keyCode === 13){
- controller.get('joinNode').call(controller, ev);
+ this.sendAction('joinNode');
}
}
});
@@ -419,38 +414,38 @@ minispade.register('cluster', function() {
classNameBindings: ['expanded:open'],
- /**
- * Stage a change for a given node.
- *
- * @returns {void}
- */
- stageChange: function(ev) {
- ev.preventDefault();
-
- var self = this;
- var controller = this.get('controller');
-
- var name = this.get('name');
-
- var action = this.$().
- find("input[type='radio']:checked").val();
- var forced = this.$().
- find("input[type='checkbox']:checked").val();
- var replacement = this.$().
- find("input[type='select']:selected").val();
+ actions: {
+ /**
+ * Stage a change for a given node.
+ *
+ * @returns {void}
+ */
+ stageChange: function() {
+ var self = this;
+ var controller = this.get('controller');
+
+ var name = this.get('name');
+
+ var action = this.$().
+ find("input[type='radio']:checked").val();
+ var forced = this.$().
+ find("input[type='checkbox']:checked").val();
+ var replacement = this.$().
+ find("input[type='select']:selected").val();
+
+ // Make sure we handle the force replace correctly.
+ //
+ if(action === 'replace' && forced === 'true') {
+ action = 'force_replace';
+ }
- // Make sure we handle the force replace correctly.
- //
- if(action === 'replace' && forced === 'true') {
- action = 'force_replace';
- }
+ // Empty string instead of undefined for null.
+ if(replacement === undefined) {
+ replacement = '';
+ }
- // Empty string instead of undefined for null.
- if(replacement === undefined) {
- replacement = '';
+ controller.send('stageChange', name, action, replacement);
}
-
- controller.stageChange(name, action, replacement);
},
/**
View
@@ -1,15 +1,19 @@
minispade.register('core', function() {
/** Handle an array type. */
- DS.attr.transforms.array = {
- from: function(serialized) {
- return Em.none(serialized) ? [] : serialized;
+ var none = Ember.isNone;
+
+ DS.ArrayTransform = DS.Transform.extend({
+ deserialize: function(serialized) {
+ return none(serialized) ? [] : serialized;
+ },
+
+ serialize: function(deserialized) {
+ return none(deserialized) ? [] : deserialized;
},
+ });
- to: function(deserialized) {
- return Em.none(deserialized) ? [] : deserialized;
- }
- };
+ RiakControl.register('transform:array', DS.ArrayTransform);
/**
* @class
@@ -25,7 +29,8 @@ minispade.register('core', function() {
*/
primaryKey: 'name',
- name: DS.attr("string"),
+ /** The id attribute contains the name after deserializing */
+ name: Ember.computed.alias('id'),
status: DS.attr("string"),
@@ -56,4 +61,8 @@ minispade.register('core', function() {
claimant: DS.attr("boolean")
});
+ /** Register serializer that respects custom primary key */
+ RiakControl.register('serializer:node', DS.RESTSerializer.extend({
+ primaryKey: 'name'
+ }));
});
View
@@ -3,17 +3,6 @@ minispade.register('nodes', function() {
/**
* @class
*
- * Node_managementView is responsible for allowing you to stop
- * or down a node.
- */
- RiakControl.NodesView = Ember.View.extend(
- /** @scope RiakControl.NodesView.prototype */ {
- templateName: 'nodes'
- });
-
- /**
- * @class
- *
* NodesController is responsible for displaying the list of nodes
* in the cluster.
*/
@@ -33,46 +22,40 @@ minispade.register('nodes', function() {
this.get('content').reload();
},
- /**
- * Removes all checks from radio buttons.
- *
- * @returns {void}
- */
- clearChecked: function(ev) {
- if(ev) {
- ev.preventDefault();
+ actions: {
+ /**
+ * Removes all checks from radio buttons.
+ *
+ * @returns {void}
+ */
+ clearChecked: function() {
+ $('#node-list input[type=radio]').each(function(index, item) {
+ item.checked = false;
+ $(item).parent().css('background-position', 'left top');
+ });
+ },
+
+ /**
+ * Submits requests to stop and/or down nodes to the app.
+ */
+ applyChanges: function() {
+ var self = this;
+
+ $("#node-list input[type='radio']:checked").each(function(index, item) {
+ var name = item.name,
+ action = item.value,
+ replacement;
+
+ // Empty string instead of undefined for null.
+ if(replacement === undefined) {
+ replacement = '';
+ }
+
+ self.send('stageChange', name, action, replacement);
+ });
+
+ self.send('clearChecked');
}
-
- $('#node-list input[type=radio]').each(function(index, item) {
- item.checked = false;
- $(item).parent().css('background-position', 'left top');
- });
- },
-
- /**
- * Submits requests to stop and/or down nodes to the app.
- */
- applyChanges: function(ev) {
- if(ev) {
- ev.preventDefault();
- }
-
- var self = this;
-
- $("#node-list input[type='radio']:checked").each(function(index, item) {
- var name = item.name,
- action = item.value,
- replacement;
-
- // Empty string instead of undefined for null.
- if(replacement === undefined) {
- replacement = '';
- }
-
- self.stageChange(name, action, replacement);
- });
-
- self.clearChecked();
}
});
Oops, something went wrong.

0 comments on commit 2ff7904

Please sign in to comment.