Skip to content

Commit

Permalink
Backbone (part 2)
Browse files Browse the repository at this point in the history
- Remove some Rails-isms in JS files
- Backbone-ify index querying

Author: @franklinhu
Fixes #122
URL: #122
  • Loading branch information
Franklin Hu committed Aug 23, 2012
1 parent 59999c7 commit b758814
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 215 deletions.
359 changes: 183 additions & 176 deletions zipkin-finatra/src/main/resources/public/js/application-index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,82 @@ Zipkin.Application.Models = (function() {
}
});

/*
* @param serviceName: string
* @param endTime: string
* @param limit: int
*/
var Query = Backbone.Model.extend({
execute: function() {
var params = this.params();
var results = new (QueryResults.extend({
url: function() {
return "/api/query?" + $.param(params)
}
}));
results.fetch();
return results;
},

params: function() {
return {
serviceName: this.get("serviceName"),
endDatetime: this.get("endDatetime"),
limit: this.get("limit")
};
}
});

/*
* @param spanName: string
*/
var SpanQuery = Query.extend({
params: function() {
return $.extend({}, SpanQuery.__super__.params.apply(this), {
spanName: this.get("spanName")
});
}
});

/*
* @param timeAnnotation: string
*/
var AnnotationQuery = Query.extend({
params: function() {
return $.extend({}, AnnotationQuery.__super__.params.apply(this), {
timeAnnotation: this.get("timeAnnotation")
});
}
});

/*
* @param annotationKey: string
* @param annotationValue: string
*/
var KeyValueQuery = Query.extend({
params: function() {
return $.extend({}, KeyValueQuery.__super__.params.apply(this), {
annotationKey: this.get("annotationKey"),
annotationValue: this.get("annotationValue")
});
}
});

var TraceSummary = Backbone.Model.extend();
var QueryResults = Backbone.Collection.extend({
model: TraceSummary
});

return {
Service: Service,
ServiceList: ServiceList,

Span: Span,
SpanList: SpanList
SpanList: SpanList,

Query: Query,
SpanQuery: SpanQuery,
AnnotationQuery: AnnotationQuery,
KeyValueQuery: KeyValueQuery
}
})();
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
/*global root_url:false */
//= require zipkin
var Zipkin = Zipkin || {};
Zipkin.Application = Zipkin.Application || {};
Zipkin.Application.Show = (function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
/*global root_url:false */
//= require zipkin
var Zipkin = Zipkin || {};
Zipkin.Application = Zipkin.Application || {};
Zipkin.Application.Static = (function() {
Expand Down
8 changes: 0 additions & 8 deletions zipkin-finatra/src/main/resources/public/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
// This file is automatically included by javascript_include_tag :defaults

/*global root_url:false Trace:false */

//= require bootstrap
//= require hogan-2.0.0

//= require datepicker

//= require_tree .

var Zipkin = Zipkin || {};

Zipkin.Base = (function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//= require zipkin-span

var Zipkin = Zipkin || {};
Zipkin.FilterSpan = (function(superClass) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//= require zipkin-tree

var Zipkin = Zipkin || {};
Zipkin.LazyTree = (function() {

Expand Down
2 changes: 0 additions & 2 deletions zipkin-finatra/src/main/resources/public/js/zipkin-onebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//= require zipkin-config

var Zipkin = Zipkin || {};

/*
Expand Down
2 changes: 0 additions & 2 deletions zipkin-finatra/src/main/resources/public/js/zipkin-span.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//= require zipkin-node

var Zipkin = Zipkin || {};

Zipkin.Span = (function(superClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/

/*global d3:false */

//= require d3-2.9.1

var Zipkin = Zipkin || {};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
*/

/*global d3:false */

//= require d3-2.9.1

//= require zipkin
//= require zipkin-node

var Zipkin = Zipkin || {};
Zipkin.TraceSummary = (function(Zipkin) {

Expand Down
2 changes: 0 additions & 2 deletions zipkin-finatra/src/main/resources/public/js/zipkin-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//= require zipkin-node

var Zipkin = Zipkin || {};
Zipkin.Tree = (function() {

Expand Down
6 changes: 3 additions & 3 deletions zipkin-finatra/src/main/resources/templates/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<div class="sidebar-block filter-options">
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active">
<a href="#filter-span" data-toggle="tab">Span</a>
<a id="filter-span-tab" class="filter-tab" href="#filter-span" data-toggle="tab">Span</a>
</li>
<li>
<a href="#filter-annotation" data-toggle="tab">Annotation</a>
<a id="filter-annotation-tab" class="filter-tab" href="#filter-annotation" data-toggle="tab">Annotation</a>
</li>
<li>
<a href="#filter-key-value" data-toggle="tab">Key / value</a>
<a id="filter-key-value-tab" class="filter-tab" href="#filter-key-value" data-toggle="tab">Key / value</a>
</li>
</ul>
<div class="tab-content filter-block-contents">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ object QueryRequest {
* () => None
*/
def apply(request: Request): Option[QueryRequest] = {
val serviceName = request.params.get("service_name")
val spanName = request.params.get("span_name")
val timeAnnotation = request.params.get("time_annotation")
val annotationKey = request.params.get("annotation_key")
val annotationValue = request.params.get("annotation_value")
val serviceName = request.params.get("serviceName")
val spanName = request.params.get("spanName")
val timeAnnotation = request.params.get("timeAnnotation")
val annotationKey = request.params.get("annotationKey")
val annotationValue = request.params.get("annotationValue")

val endTimestamp = request.params.get("end_datetime") match {
val endTimestamp = request.params.get("endDatetime") match {
case Some(str) => {
fmt.parse(str).getTime * 1000
}
Expand Down

0 comments on commit b758814

Please sign in to comment.