Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Got the Graph to save and display from the db. Then got the Circles f…

…or the default graph to display
  • Loading branch information...
commit 5fcc3083e61966706370007d1f12667deec85d39 1 parent 9aaf9a2
@philfree authored
View
2  .meteor/packages
@@ -3,5 +3,5 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
-autopublish
d3
+backbone
View
9 client/gauge.html
@@ -7,19 +7,20 @@
<template name="graph_list">
<h1>Select a graph -</h1>
<div id="graphs">
-{{#each graphs}}
- ---- <div class="list {{selected}}">
+{{#each graph_all}}
+ <div class="list {{selected}}">
<div class="display">
<div class="list-name {{name_class}}">
{{name}}
+ {{#each circle_pos}}
+ -- cx={{cx}} , cy={{cy}}
+ {{/each}}
</div>
</div>
</div>
- {{name}}
{{/each}}
</div>
-
</template>
<template name="gauge">
View
67 client/gauge.js
@@ -1,5 +1,6 @@
// Define Minimongo collections to match server/publish.js.
-Graph = new Meteor.Collection("graphs");
+Graphs = new Meteor.Collection("graphs");
+Circles = new Meteor.Collection("circles");
console.log("Audrey test");
@@ -14,12 +15,19 @@ if (Meteor.is_client) {
Meteor.subscribe('graphs', function () {
if (!Session.get('graph_id')) {
console.log("no graph id value in session, doing nothing for now");
- // var graph = Graphs.findOne({}, {sort: {name: 1}});
- // if (graph)
- // Router.setGraph(graph._id);
+ var graph = Graphs.findOne({}, {sort: {name: 1}});
+ if (graph)
+ Router.setGraph(graph._id);
}
});
+// Always be subscribed to the todos for the selected list.
+ Meteor.autosubscribe(function () {
+ var graph_id = Session.get('graph_id');
+ if (graph_id)
+ Meteor.subscribe('circles', graph_id);
+ });
+
Template.gauge.events = {
'click input' : function () {
// template data, if any, is available in 'this'
@@ -38,24 +46,41 @@ if (Meteor.is_client) {
.attr("cy", event.layerY)
.on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
.on("mouseout", function(){d3.select(this).style("fill", "white");});
+ Circles.insert({
+ graph_id: Session.get('graph_id'),
+ cx: event.layerX,
+ cy: event.layerY }) ;
}
};
}
-//var GraphRouter = Backbone.Router.extend({
-// routes: {
-// ":graph_id": "main"
-// },
-// main: function (graph_id) {
-// Session.set("graph_id", graph_id);
-// },
-// setGraph: function (graph_id) {
-// this.navigate(graph_id, true);
-// }
-//});
-
-//Router = new GraphRouter;
-
-//Meteor.startup(function () {
-// Backbone.history.start({pushState: true});
-//});
+Template.graph_list.circle_pos = function () {
+ var graph_id = this._id;
+ return Circles.find({graph_id: graph_id}, {});
+ //return _.map(this.tags || [], function (tag) {
+ // return {todo_id: todo_id, tag: tag};
+ //});
+};
+
+ Template.graph_list.graph_all = function () {
+ console.log("template function: graph_all");
+ return Graphs.find({}, {});
+ };
+
+var GraphRouter = Backbone.Router.extend({
+ routes: {
+ ":graph_id": "main"
+ },
+ main: function (graph_id) {
+ Session.set("graph_id", graph_id);
+ },
+ setGraph: function (graph_id) {
+ this.navigate(graph_id, true);
+ }
+});
+
+Router = new GraphRouter;
+
+Meteor.startup(function () {
+ Backbone.history.start({pushState: true});
+});
View
3  meteordraw.html
@@ -14,6 +14,7 @@
</template>
<template name="svg_circles">
<h2> Testing templates </h2>
- <div id="mydrawboard">Hello</div>
+ <div id="mydrawboard">Hello, now this should be blue.</div>
{{drawsomething}}
+ <input type="button" value="Click this to turn in blue">
</template>
View
8 meteordraw.js
@@ -16,8 +16,8 @@ if (Meteor.is_client) {
};
}
-if (Meteor.is_server) {
- Meteor.startup(function () {
+//if (Meteor.is_server) {
+ // Meteor.startup(function () {
// code to run on server at startup
- });
-}
+ // });
+//}
View
12 server/publish.js
@@ -4,7 +4,17 @@ Graphs = new Meteor.Collection("graphs");
// Publish complete set of lists to all clients.
Meteor.publish('graphs', function () {
-
return Graphs.find();
});
+// Todos -- {text: String,
+// done: Boolean,
+// tags: [String, ...],
+// list_id: String,
+// timestamp: Number}
+Circles = new Meteor.Collection("circles");
+
+// Publish all items for requested list_id.
+Meteor.publish('circles', function (graph_id) {
+ return Circles.find({graph_id: graph_id});
+});
Please sign in to comment.
Something went wrong with that request. Please try again.