HTRACE-246. HTrace WebApp not properly defined and therefore not packaged into .war (Lewis John McGibbney via iwasakims)
Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/6b3d2d82 Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/6b3d2d82 Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/6b3d2d82 Branch: refs/heads/4.0 Commit: 6b3d2d82309c43183490cb13cb5fad2cb72e843c Parents: c0ab0b9 Author: Masatake Iwasaki <[email protected]> Authored: Sun Sep 13 18:39:53 2015 +0900 Committer: stack <[email protected]> Committed: Fri Sep 18 13:00:12 2015 -0700 ---------------------------------------------------------------------- htrace-htraced/go/gobuild.sh | 2 +- htrace-webapp/pom.xml | 2 +- htrace-webapp/src/main/web/WEB-INF/web.xml | 20 - htrace-webapp/src/main/web/app/about_view.js | 33 - htrace-webapp/src/main/web/app/modal.js | 42 - .../src/main/web/app/partition_widget.js | 72 - htrace-webapp/src/main/web/app/predicate.js | 126 - .../src/main/web/app/predicate_view.js | 68 - htrace-webapp/src/main/web/app/query_results.js | 45 - htrace-webapp/src/main/web/app/router.js | 74 - htrace-webapp/src/main/web/app/search_result.js | 55 - .../src/main/web/app/search_results.js | 25 - .../src/main/web/app/search_results_view.js | 478 - htrace-webapp/src/main/web/app/search_view.js | 196 - htrace-webapp/src/main/web/app/server_info.js | 31 - htrace-webapp/src/main/web/app/span.js | 282 - .../src/main/web/app/span_details_view.js | 39 - .../src/main/web/app/span_group_widget.js | 103 - htrace-webapp/src/main/web/app/span_widget.js | 309 - htrace-webapp/src/main/web/app/string.js | 62 - htrace-webapp/src/main/web/app/time_cursor.js | 81 - htrace-webapp/src/main/web/app/tree.js | 74 - .../src/main/web/app/triangle_button.js | 108 - .../src/main/web/app/widget_manager.js | 67 - htrace-webapp/src/main/web/custom.css | 101 - htrace-webapp/src/main/web/image/owl.png | Bin 435334 -> 0 bytes htrace-webapp/src/main/web/index.html | 246 - .../src/main/web/lib/backbone-1.1.2.js | 1608 --- .../lib/bootstrap-3.3.1/css/bootstrap-theme.css | 470 - .../bootstrap-3.3.1/css/bootstrap-theme.css.map | 1 - .../bootstrap-3.3.1/css/bootstrap-theme.min.css | 5 - .../web/lib/bootstrap-3.3.1/css/bootstrap.css | 6332 ------------ .../lib/bootstrap-3.3.1/css/bootstrap.css.map | 1 - .../lib/bootstrap-3.3.1/css/bootstrap.min.css | 5 - .../web/lib/bootstrap-3.3.1/js/bootstrap.js | 2320 ----- .../web/lib/bootstrap-3.3.1/js/bootstrap.min.js | 7 - .../src/main/web/lib/bootstrap-3.3.1/js/npm.js | 13 - htrace-webapp/src/main/web/lib/jquery-2.1.4.js | 9210 ------------------ htrace-webapp/src/main/web/lib/moment-2.10.3.js | 3111 ------ .../src/main/web/lib/underscore-1.7.0.js | 1416 --- htrace-webapp/src/main/webapp/WEB-INF/web.xml | 20 + htrace-webapp/src/main/webapp/app/about_view.js | 33 + htrace-webapp/src/main/webapp/app/modal.js | 42 + .../src/main/webapp/app/partition_widget.js | 72 + htrace-webapp/src/main/webapp/app/predicate.js | 126 + .../src/main/webapp/app/predicate_view.js | 68 + .../src/main/webapp/app/query_results.js | 45 + htrace-webapp/src/main/webapp/app/router.js | 74 + .../src/main/webapp/app/search_result.js | 55 + .../src/main/webapp/app/search_results.js | 25 + .../src/main/webapp/app/search_results_view.js | 478 + .../src/main/webapp/app/search_view.js | 196 + .../src/main/webapp/app/server_info.js | 31 + htrace-webapp/src/main/webapp/app/span.js | 282 + .../src/main/webapp/app/span_details_view.js | 39 + .../src/main/webapp/app/span_group_widget.js | 103 + .../src/main/webapp/app/span_widget.js | 309 + htrace-webapp/src/main/webapp/app/string.js | 62 + .../src/main/webapp/app/time_cursor.js | 81 + htrace-webapp/src/main/webapp/app/tree.js | 74 + .../src/main/webapp/app/triangle_button.js | 108 + .../src/main/webapp/app/widget_manager.js | 67 + htrace-webapp/src/main/webapp/custom.css | 101 + htrace-webapp/src/main/webapp/image/owl.png | Bin 0 -> 435334 bytes htrace-webapp/src/main/webapp/index.html | 246 + .../src/main/webapp/lib/backbone-1.1.2.js | 1608 +++ .../lib/bootstrap-3.3.1/css/bootstrap-theme.css | 470 + .../bootstrap-3.3.1/css/bootstrap-theme.css.map | 1 + .../bootstrap-3.3.1/css/bootstrap-theme.min.css | 5 + .../lib/bootstrap-3.3.1/css/bootstrap.css | 6332 ++++++++++++ .../lib/bootstrap-3.3.1/css/bootstrap.css.map | 1 + .../lib/bootstrap-3.3.1/css/bootstrap.min.css | 5 + .../webapp/lib/bootstrap-3.3.1/js/bootstrap.js | 2320 +++++ .../lib/bootstrap-3.3.1/js/bootstrap.min.js | 7 + .../main/webapp/lib/bootstrap-3.3.1/js/npm.js | 13 + .../src/main/webapp/lib/jquery-2.1.4.js | 9210 ++++++++++++++++++ .../src/main/webapp/lib/moment-2.10.3.js | 3111 ++++++ .../src/main/webapp/lib/underscore-1.7.0.js | 1416 +++ 78 files changed, 27238 insertions(+), 27238 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-htraced/go/gobuild.sh ---------------------------------------------------------------------- diff --git a/htrace-htraced/go/gobuild.sh b/htrace-htraced/go/gobuild.sh index eb10e9e..f23c639 100755 --- a/htrace-htraced/go/gobuild.sh +++ b/htrace-htraced/go/gobuild.sh @@ -129,7 +129,7 @@ install) || die "go install failed." # Make a symlink to web src dir so can do development in-situ out # of build dir. This is ugly but blame go build. - ln -fs "../../htrace-webapp/src/main/web" "${GOBIN}/../" + ln -fs "../../htrace-webapp/src/main/webapp" "${GOBIN}/../web" # Set the RPATH to make bundling leveldb and snappy easier. set_rpath "${GOBIN}/htraced" ;; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/pom.xml ---------------------------------------------------------------------- diff --git a/htrace-webapp/pom.xml b/htrace-webapp/pom.xml index 74dd3d7..1963710 100644 --- a/htrace-webapp/pom.xml +++ b/htrace-webapp/pom.xml @@ -33,7 +33,7 @@ language governing permissions and limitations under the License. --> <artifactId>maven-war-plugin</artifactId> <version>${maven-war-plugin.version}</version> <configuration> - <webXml>src/main/web/WEB-INF/web.xml</webXml> + <webXml>src/main/webapp/WEB-INF/web.xml</webXml> </configuration> </plugin> <plugin> http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/WEB-INF/web.xml b/htrace-webapp/src/main/web/WEB-INF/web.xml deleted file mode 100644 index 38c7a98..0000000 --- a/htrace-webapp/src/main/web/WEB-INF/web.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE file distributed with this work for additional -information regarding copyright ownership. The ASF licenses this file to -You under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required -by applicable law or agreed to in writing, software distributed under the -License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS -OF ANY KIND, either express or implied. See the License for the specific -language governing permissions and limitations under the License. --> - -<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - - <display-name>HTrace</display-name> -<description>WebApp that goes against an htrace server. -</description> -</web-app> http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/about_view.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/about_view.js b/htrace-webapp/src/main/web/app/about_view.js deleted file mode 100644 index 7dfe868..0000000 --- a/htrace-webapp/src/main/web/app/about_view.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; -htrace.AboutView = Backbone.View.extend({ - render: function() { - this.$el.html(_.template($("#about-view-template").html()) - ({ model : this.model })); - console.log("AboutView#render"); - return this; - }, - - close: function() { - console.log("AboutView#close") - this.undelegateEvents(); - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/modal.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/modal.js b/htrace-webapp/src/main/web/app/modal.js deleted file mode 100644 index aed3fdc..0000000 --- a/htrace-webapp/src/main/web/app/modal.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// Show a modal dialog box with a warning message. -htrace.showModalWarning = function(title, body) { - var html = _.template($("#modal-warning-template").html()) - ({ title: title, body: body }); - htrace.showModal(html); -} - -// Show a modal dialog box. -htrace.showModal = function(html) { - var el = $("#modal"); - el.html(html); - // Dismiss the modal dialog box when enter is pressed. - $(document).on("keypress", function(e) { - if (e.which === 13) { - $(document).off('keypress'); - $('#modal button:first', $(this)).click(); - return false; - } - }); - el.modal(); -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/partition_widget.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/partition_widget.js b/htrace-webapp/src/main/web/app/partition_widget.js deleted file mode 100644 index a68c8ce..0000000 --- a/htrace-webapp/src/main/web/app/partition_widget.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// Widget containing draggable horizontal partition -htrace.PartitionWidget = function(params) { - this.draw = function() { - this.ctx.save(); - this.ctx.fillStyle = this.selected ? "#6600ff" : "#aaaaaa"; - this.ctx.fillRect(this.x0, this.y0, this.xF - this.x0, this.yF - this.y0); - this.ctx.restore(); - }; - - this.handle = function(e) { - switch (e.type) { - case "mouseDown": - if (!htrace.inBoundingBox(e.x, e.y, - this.x0, this.xF, this.y0, this.yF)) { - return true; - } - this.manager.registerHighPriority("mouseUp", this); - this.manager.registerHighPriority("mouseMove", this); - this.selected = true; - $(this.el).css('cursor', 'ew-resize'); - return false; - case "mouseMove": - // Move the partition to the mouse pointer area - var x = Math.min(Math.max(e.x, this.xMin), this.xMax); - var width = this.xF - this.x0; - this.x0 = Math.floor(x - (width / 2)); - this.xF = this.x0 + width; - return false; - case "mouseUp": - this.manager.unregister("mouseUp", this); - this.manager.unregister("mouseMove", this); - $(this.el).css('cursor', 'pointer'); - this.selected = false; - this.releaseHandler(this.x0); - return false; - case "draw": - this.draw(); - return true; - default: - return true; - } - }; - - for (var k in params) { - this[k]=params[k]; - } - this.selected = false; - this.manager.register("mouseDown", this); - this.manager.register("draw", this); - return this; -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/predicate.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/predicate.js b/htrace-webapp/src/main/web/app/predicate.js deleted file mode 100644 index 6526719..0000000 --- a/htrace-webapp/src/main/web/app/predicate.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.checkStringIsPositiveWholeNumber = function(val) { - if (!val.match(/^[0-9]([0-9]*)$/)) { - if (!val.match(/[^\s]/)) { - throw "You entered an empty string into a numeric field."; - } - throw "Non-numeric characters found."; - } -}; - -htrace.checkStringIsNotEmpty = function(val) { - if (!val.match(/[^\s]/)) { - throw "You entered an empty string into a text field."; - } -}; - -// Predicate type -htrace.PType = Backbone.Model.extend({ - initialize: function(options) { - this.name = options.name; - this.field = options.field; - this.op = options.op; - }, - - // Try to normalize a value of this type into something htraced can accept. - // Returns a string containing the normalized value on success. Throws a - // string explaining the parse error otherwise. - // Dates are represented by milliseconds since the epoch; span ids don't start - // with 0x. - normalize: function(val) { - switch (this.field) { - case "begin": - return htrace.parseDate(val).valueOf().toString(); - case "end": - return htrace.parseDate(val).valueOf().toString(); - case "description": - htrace.checkStringIsNotEmpty(val); - return val; - case "duration": - htrace.checkStringIsPositiveWholeNumber(val); - return val; - case "spanid": - return htrace.normalizeSpanId(val); - case "tracerid": - htrace.checkStringIsNotEmpty(val); - return val; - default: - return "Normalization not implemented for field '" + this.field + "'"; - } - }, - - getDefaultValue: function() { - switch (this.field) { - case "begin": - return htrace.dateToString(moment()); - case "end": - return htrace.dateToString(moment()); - case "description": - return ""; - case "duration": - return "0"; - case "spanid": - return ""; - case "tracerid": - return ""; - default: - return "(unknown)"; - } - } -}); - -htrace.parsePType = function(name) { - switch (name) { - case "Began after": - return new htrace.PType({name: name, field:"begin", op:"gt"}); - case "Began at or before": - return new htrace.PType({name: name, field:"begin", op:"le"}); - case "Ended after": - return new htrace.PType({name: name, field:"end", op:"gt"}); - case "Ended at or before": - return new htrace.PType({name: name, field:"end", op:"le"}); - case "Description contains": - return new htrace.PType({name: name, field:"description", op:"cn"}); - case "Description is exactly": - return new htrace.PType({name: name, field:"description", op:"eq"}); - case "Duration is longer than": - return new htrace.PType({name: name, field:"duration", op:"gt"}); - case "Duration is at most": - return new htrace.PType({name: name, field:"duration", op:"le"}); - case "Span ID is": - return new htrace.PType({name: name, field:"spanid", op:"eq"}); - case "TracerId contains": - return new htrace.PType({name: name, field:"tracerid", op:"cn"}); - case "TracerId is exactly": - return new htrace.PType({name: name, field:"tracerid", op:"eq"}); - default: - return null - } -}; - -htrace.Predicate = function(options) { - this.op = options.ptype.op; - this.field = options.ptype.field; - this.val = options.val; - return this; -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/predicate_view.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/predicate_view.js b/htrace-webapp/src/main/web/app/predicate_view.js deleted file mode 100644 index aefe896..0000000 --- a/htrace-webapp/src/main/web/app/predicate_view.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.PredicateView = Backbone.View.extend({ - initialize: function(options) { - this.el = options.el; - this.index = options.index; - this.ptype = options.ptype; - this.searchView = options.searchView; - }, - - events: { - "click .closeButton": "remove", - }, - - render: function() { - this.$el.html(_.template($("#predicate-template").html()) - ({ desc: this.ptype.name, id: this.index })) - if (this.getText() === "") { - $(this.$el).find(".form-control").val(this.ptype.getDefaultValue()); - } - console.log(this.toString() + "#render"); - return this; - }, - - // Handle the user removing this predicate. - remove: function() { - this.searchView.removePredicateView(this); - Backbone.View.prototype.remove.apply(this, arguments); - }, - - // Get the text which the user has entered in. - getText: function() { - return $(this.$el).find(".form-control").val().trim(); - }, - - // Get the predicate expressed by this view. - // Throw an exception if the predicate can't be parsed. - getPredicate: function() { - return new htrace.Predicate({ - ptype: this.ptype, - val: this.ptype.normalize(this.getText()) - }); - }, - - toString: function() { - return "PredicateView(this.el=" + this.el + ", this.index=" + - this.index + ", this.ptype='" + this.ptype.name + "')"; - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/query_results.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/query_results.js b/htrace-webapp/src/main/web/app/query_results.js deleted file mode 100644 index 8beaf0e..0000000 --- a/htrace-webapp/src/main/web/app/query_results.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.QueryResults = Backbone.Collection.extend({ - // The query results are spans. - model: htrace.Span, - - initialize: function(options) { - this.queryJson = options.queryJson; - }, - - url: function() { - return "query?query=" + this.queryString(); - }, - - parse: function(response, xhr) { - return response; - }, - - prettyQueryString: function() { - return JSON.stringify(this.queryJson, null, 2); - }, - - queryString: function() { - return encodeURIComponent(JSON.stringify(this.queryJson)); - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/router.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/router.js b/htrace-webapp/src/main/web/app/router.js deleted file mode 100644 index 607da44..0000000 --- a/htrace-webapp/src/main/web/app/router.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.HTraceRouter = Backbone.Router.extend({ - "routes": { - "": "empty", - "about": "about", - "search": "search", - "*unknown": "unknown" - }, - - empty: function() { - console.log("Redirecting to #about."); - Backbone.history.navigate("about", {"trigger": true, "replace": true}); - }, - - about: function() { - console.log("Visiting #about."); - serverInfo = new htrace.ServerInfo(); - var router = this; - serverInfo.fetch({ - "success": function(model, response, options) { - router.switchView(new htrace.AboutView({model: serverInfo, el: "#app"})); - router.activateNavBarEntry("about") - }, - "error": function(model, response, options) { - window.alert("Failed to fetch htraced server info via GET " + - "/server/info: " + JSON.stringify(response)); - } - }); - }, - - search: function() { - console.log("Visiting #search."); - this.switchView(new htrace.SearchView({el : "#app"})); - htrace.router.activateNavBarEntry("search"); - }, - - unknown: function() { - console.log("Unknown route " + Backbone.history.getFragment() + ".") - }, - - "switchView": function(view) { - this.view && this.view.close(); - this.view = view; - this.view.render(); - }, - - "activateNavBarEntry": function(id) { - $(".nav").find(".active").removeClass("active"); - $(".nav").find("#" + id).addClass("active"); - } -}); - -htrace.router = new htrace.HTraceRouter(); -Backbone.history.start(); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/search_result.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/search_result.js b/htrace-webapp/src/main/web/app/search_result.js deleted file mode 100644 index 9798ad7..0000000 --- a/htrace-webapp/src/main/web/app/search_result.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// A pair of span trees: one going up, and the other going down. -// This represents a single search result. -htrace.SearchResult = Backbone.Model.extend({ - initialize: function(options) { - this.set("childrenRoot", { - root: options.span, - contents: null, - }); - this.set("childrenRoot", { - root: options.span, - contents: null, - }); - - this.set("parentsRoot", options.span); - }, - - getBegin: function() { - var begin = this.get("span").get("begin"); - var children = this.get("children"); - for (var childIdx = 0; childIdx < children.length; childIdx++) { - begin = Math.min(begin, children[childIdx].getBegin()); - } - return begin; - }, - - getEnd: function() { - var end = this.get("span").get("end"); - var children = this.get("children"); - for (var childIdx = 0; childIdx < children.length; childIdx++) { - end = Math.max(end, children[childIdx].getEnd()); - } - return end; - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/search_results.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/search_results.js b/htrace-webapp/src/main/web/app/search_results.js deleted file mode 100644 index 25b18ae..0000000 --- a/htrace-webapp/src/main/web/app/search_results.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.SearchResults = Backbone.Collection.extend({ - // The search results are span trees. - model: htrace.SpanTreeNode -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/search_results_view.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/search_results_view.js b/htrace-webapp/src/main/web/app/search_results_view.js deleted file mode 100644 index b2fffbd..0000000 --- a/htrace-webapp/src/main/web/app/search_results_view.js +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.SearchResultsView = Backbone.View.extend({ - // The minimum time span we will allow between begin and end. - MINIMUM_TIME_SPAN: 100, - - begin: 0, - - end: this.MINIMUM_TIME_SPAN, - - processNameFraction: 0.2, - - initialize: function(options) { - this.searchResults = options.searchResults; - this.el = options.el; - var view = this; - - // Re-render the canvas when the window size changes. - // Add a debouncer delay to avoid spamming render requests. - $(window).on("resize", _.debounce(function() { - view.render(); - }, 250)); - }, - - // Get the canvas X coordinate of a mouse click from the absolute event - // coordinate. - getCanvasX: function(e) { - return e.pageX - $("#resultsCanvas").offset().left; - }, - - // Get the canvas Y coordinate of a mouse click from the absolute event - // coordinate. - getCanvasY: function(e) { - return e.pageY - $("#resultsCanvas").offset().top; - }, - - handleMouseDown: function(e) { - e.preventDefault(); - this.widgetManager.handle({ - type: "mouseDown", - x: this.getCanvasX(e), - y: this.getCanvasY(e), - raw: e - }); - this.draw(); - }, - - handleMouseUp: function(e) { - e.preventDefault(); - this.widgetManager.handle({ - type: "mouseUp", - x: this.getCanvasX(e), - y: this.getCanvasY(e), - raw: e - }); - this.draw(); - }, - - handleMouseOut: function(e) { - e.preventDefault(); - this.widgetManager.handle({ - type: "mouseOut" - }); - this.draw(); - }, - - handleMouseMove: function(e) { - e.preventDefault(); - this.widgetManager.handle({ - type: "mouseMove", - x: this.getCanvasX(e), - y: this.getCanvasY(e), - raw: e - }); - this.draw(); - }, - - handleDblclick: function(e) { - e.preventDefault(); - this.widgetManager.handle({ - type: "dblclick", - x: this.getCanvasX(e), - y: this.getCanvasY(e), - raw: e - }); - this.draw(); - }, - - render: function() { - console.log("SearchResultsView#render."); - $(this.el).html(_.template($("#search-results-view-template").html())); - $('#selectedTime').attr('readonly', 'readonly'); - this.canvas = $("#resultsCanvas"); - this.ctx = this.canvas.get(0).getContext("2d"); - this.setupCoordinates(); - this.setupWidgets(); - this.scaleCanvas(); - this.draw(); - this.attachEvents(); - return this; - }, - - /* - * Compute the ratio to use between the size of the canvas (i.e. - * canvas.ctx.width, canvas.ctx.height) and the size in "HTML5 pixels." Note - * that 'HTML5 pixels" don't actually correspond to screen pixels. A line 1 - * "HTML5 pixel" wide actually takes up multiple scren pixels, etc. - * - * TODO: fix this to be sharper - */ - computeScaleFactor: function() { - var backingStoreRatio = this.ctx.backingStorePixelRatio || - this.ctx.mozBackingStorePixelRatio || - this.ctx.msBackingStorePixelRatio || - this.ctx.webkitBackingStorePixelRatio || - this.ctx.oBackingStorePixelRatio || - this.ctx.backingStorePixelRatio || 1; - return (window.devicePixelRatio || 1) / backingStoreRatio; - }, - - // Sets up the canvas size and scaling. - scaleCanvas: function() { - var ratio = this.computeScaleFactor(); - //console.log("scaleCanvas: cssX=" + cssX + ", cssY=" + cssY + ", ratio=" + ratio); - $('#searchView').css('height', this.canvasY + "px"); - $('#resultsView').css('height', this.canvasY + "px"); - $('#resultsCanvas').css('height', this.canvasY + "px"); - this.ctx.canvas.width = this.viewX * ratio; - this.ctx.canvas.height = this.canvasY * ratio; - this.ctx.scale(ratio, ratio); - }, - - // - // Set up the screen coordinates. - // - // 0 xB xD xS viewX - // +--------------+----------+--------------------+-----------+ - // |TracerId | Buttons | Span Description | Scrollbar | - // +--------------+----------+--------------------+-----------+ - // - setupCoordinates: function() { - this.viewX = this.canvas.parent().innerWidth(); - this.viewY = $(window).innerHeight() - $("#header").innerHeight() - 50; - this.xB = Math.floor(this.viewX * this.processNameFraction); - this.xD = this.xB + Math.min(75, Math.floor(this.viewX / 20)); - var scrollBarWidth = Math.min(50, Math.floor(this.viewX / 10)); - this.xS = this.viewX - scrollBarWidth; - this.canvasY = this.viewY; - }, - - setupWidgets: function() { - var searchResultsView = this; - this.widgetManager = new htrace.WidgetManager({searchResultsView: this}); - - var partitionWidgetWidth = Math.max(5, Math.floor(this.viewX / 300)); - - // Create a SpanWidget for each span we know about - var spanWidgetHeight = Math.min(25, Math.floor(this.viewY / 32)); - var numResults = this.searchResults.size(); - var groupY = 0; - for (var i = 0; i < numResults; i++) { - var widget = new htrace.SpanGroupWidget({ - manager: this.widgetManager, - ctx: this.ctx, - span: this.searchResults.at(i), - x0: 0, - xB: this.xB + partitionWidgetWidth, - xD: this.xD, - xF: this.xS, - y0: groupY, - begin: this.begin, - end: this.end, - spanWidgetHeight: spanWidgetHeight - }); - groupY = widget.yF; - } - if (this.canvasY < groupY) { - this.canvasY = groupY; - } - - // Create the draggable horizontal parition between process names and span - // names. - new htrace.PartitionWidget({ - el: '#resultsCanvas', - manager: this.widgetManager, - ctx: this.ctx, - x0: this.xB, - xF: this.xB + partitionWidgetWidth, - xMin: Math.floor(this.viewX * 0.10), - xMax: Math.floor(this.viewX * 0.90), - y0: 0, - yF: groupY, - releaseHandler: function(x) { - searchResultsView.processNameFraction = (x / searchResultsView.viewX); - console.log("htrace#PartitionWidget setting processNameFraction to " + - searchResultsView.processNameFraction); - searchResultsView.render(); - } - }); - - // Create the time cursor widget. - var selectedTime = this.begin; - if (this.timeCursor != null) { - selectedTime = this.timeCursor.selectedTime; - } - this.timeCursor = new htrace.TimeCursor({ - manager: this.widgetManager, - selectedTime: selectedTime, - el: "#selectedTime" - }); - this.timeCursor.ctx = this.ctx; - this.timeCursor.x0 = this.xD; - this.timeCursor.xF = this.xS; - this.timeCursor.y0 = 0; - this.timeCursor.yF = this.canvasY; - this.timeCursor.begin = this.begin; - this.timeCursor.end = this.end; - }, - - draw: function() { - if (this.checkCanvasTooSmall()) { - return; - } - - // Set the background to white. - this.ctx.save(); - this.ctx.fillStyle="#ffffff"; - this.ctx.strokeStyle="#000000"; - this.ctx.fillRect(0, 0, this.viewX, this.canvasY); - this.ctx.restore(); - - // Draw all the widgets. - this.widgetManager.handle({type: "draw"}); - }, - - checkCanvasTooSmall: function() { - if ((this.viewX < 200) || (this.viewY < 200)) { - this.ctx.fillStyle="#cccccc"; - this.ctx.strokeStyle="#000000"; - this.ctx.fillRect(0, 0, this.viewX, this.viewY); - this.ctx.font = "24px serif"; - this.ctx.fillStyle="#000000"; - this.ctx.fillText("Canvas too small!", 0, 24); - return true; - } - return false; - }, - - attachEvents: function() { - // Use jquery to capture mouse events on the canvas. - // For some reason using backbone doesn't work for getting these events. - var view = this; - $("#resultsCanvas").off("mousedown"); - $("#resultsCanvas").on("mousedown", function(e) { - $("#resultsCanvas").focus(); - view.handleMouseDown(e); - }); - $("#resultsCanvas").off("mouseup"); - $("#resultsCanvas").on("mouseup", function(e) { - view.handleMouseUp(e); - }); - $("#resultsCanvas").off("mouseout"); - $("#resultsCanvas").on("mouseout", function(e) { - view.handleMouseOut(e); - }); - $("#resultsCanvas").off("mousemove"); - $("#resultsCanvas").on("mousemove", function(e) { - view.handleMouseMove(e); - }); - $("#resultsCanvas").off("dblclick"); - $("#resultsCanvas").on("dblclick", function(e) { - view.handleDblclick(e); - }); - // Keyboard events. These events only fire if the canvas has focus. So if - // you press delete when entering a time in the time dialog box, this will - // not fire. Etc. - $("#resultsCanvas").off("keyup"); - $("#resultsCanvas").on("keyup", function(e) { - if (e.keyCode == 46) { // delete key - view.clearHandler(false); - return false; - } else if (e.keyCode == 90) { // z key - view.zoomHandler(); - return false; - } else { - return true; - } - }); - $("#resultsCanvas").off("contextmenu"); - $("#resultsCanvas").on("contextmenu", function(e) { - return false; - }); - }, - - remove: function() { - $(window).off("resize"); - $("#resultsCanvas").off("mousedown"); - $("#resultsCanvas").off("mouseup"); - $("#resultsCanvas").off("mouseout"); - $("#resultsCanvas").off("mousemove"); - $("#resultsCanvas").off("dblclick"); - $("#resultsCanvas").off("keyup"); - $("#resultsCanvas").off("contextmenu"); - Backbone.View.prototype.remove.apply(this, arguments); - }, - - handleBeginOrEndChange: function(e, type) { - e.preventDefault(); - var text = $(e.target).val().trim(); - var d = null; - try { - d = htrace.parseDate(text); - } catch(err) { - $("#begin").val(htrace.dateToString(this.begin)); - $("#end").val(htrace.dateToString(this.end)); - htrace.showModalWarning("Timeline " + type + " Format Error", - "Please enter a valid time in the timeline " + type + " field.<p/>" + - err); - return null; - } - if (type === "begin") { - this.setTimes({begin: d.valueOf()}); - } else if (type === "end") { - this.setTimes({end: d.valueOf()}); - } else { - throw "invalid type for handleBeginOrEndChange: expected begin or end."; - } - this.render(); - }, - - setTimes: function(params) { - if (params["begin"]) { - this.begin = params["begin"]; - } - if (params["end"]) { - this.end = params["end"]; - } - if (this.end < this.begin) { - var b = this.begin; - this.begin = this.end; - this.end = b; - } - var delta = this.end - this.begin; - if (delta < this.MINIMUM_TIME_SPAN) { - var needed = this.MINIMUM_TIME_SPAN - delta; - this.begin -= (needed / 2); - this.end += (needed / 2); - } - $("#begin").val(htrace.dateToString(this.begin)); - $("#end").val(htrace.dateToString(this.end)); - // caller should invoke render() - }, - - clearHandler: function(clearAllIfNoneSelected) { - console.log("invoking clearHandler."); - var toDelete = [] - var noneSelected = true; - for (var i = 0; i < this.searchResults.length; i++) { - var resultSelected = false; - var model = this.searchResults.at(i); - htrace.treeTraverseDepthFirstPre(model, - htrace.getReifiedChildren, 0, - function(node, depth) { - if (noneSelected) { - if (node.get("selected")) { - resultSelected = true; - } - } - }); - htrace.treeTraverseDepthFirstPre(model, - htrace.getReifiedParents, 0, - function(node, depth) { - if (node.get("selected")) { - resultSelected = true; - } - }); - if (resultSelected) { - if (noneSelected) { - toDelete = []; - noneSelected = false; - } - toDelete.push(model); - } else if (noneSelected) { - toDelete.push(model); - } - } - if (noneSelected && (!clearAllIfNoneSelected)) { - return; - } - ids = []; - for (var i = 0; i < toDelete.length; i++) { - ids.push(toDelete[i].get("spanId")); - } - console.log("clearHandler: removing " + JSON.stringify(ids)); - this.searchResults.remove(toDelete); - this.render(); - }, - - getSelectedSpansOrAllSpans: function() { - // Get the list of selected spans. - // If there are no spans selected, we return all spans. - var ret = []; - var noneSelected = true; - this.applyToAllSpans(function(span) { - if (span.get("selected")) { - if (noneSelected) { - ret = []; - noneSelected = false; - } - ret.push(span); - } else if (noneSelected) { - ret.push(span); - } - }); - return ret; - }, - - zoomHandler: function() { - var zoomSpans = this.getSelectedSpansOrAllSpans(); - var numResults = zoomSpans.length; - if (numResults == 0) { - this.setTimes({begin:0, end:this.MINIMUM_TIME_SPAN}); - this.render(); - return; - } - var minStart = 4503599627370496; - var maxEnd = 0; - for (var i = 0; i < numResults; i++) { - var begin = zoomSpans[i].getEarliestBegin(); - if (begin < minStart) { - minStart = begin; - } - var end = zoomSpans[i].getLatestEnd(); - if (end > maxEnd) { - maxEnd = end; - } - } - this.setTimes({begin: minStart, end: maxEnd}); - this.render(); - }, - - // Apply a function to all spans - applyToAllSpans: function(cb) { - for (var i = 0; i < this.searchResults.length; i++) { - htrace.treeTraverseDepthFirstPre(this.searchResults.at(i), - htrace.getReifiedChildren, 0, - function(node, depth) { - cb(node); - }); - htrace.treeTraverseDepthFirstPre(this.searchResults.at(i), - htrace.getReifiedParents, 0, - function(node, depth) { - if (depth > 0) { - cb(node); - } - }); - } - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/search_view.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/search_view.js b/htrace-webapp/src/main/web/app/search_view.js deleted file mode 100644 index aeb4273..0000000 --- a/htrace-webapp/src/main/web/app/search_view.js +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; -htrace.SearchView = Backbone.View.extend({ - initialize : function() { - this.predicateViews = []; - this.highestPredicateIndex = 0; - this.searchInProgress = false; - this.searchResults = new htrace.SearchResults(); - this.resultsView = new htrace.SearchResultsView({ - searchResults: this.searchResults, - el: "#resultsView" - }); - }, - - events: { - "click #searchButton": "searchHandler", - "click #clearButton": "clearHandler", - "click .add-field": "dropdownHandler", - "blur #begin": "blurBeginHandler", - "blur #end": "blurEndHandler", - "click #zoomButton": "zoomHandler" - }, - - searchHandler: function(e){ - e.preventDefault(); - - this.doSearch(e.ctrlKey); - }, - - clearHandler: function(e){ - e.preventDefault(); - - this.resultsView.clearHandler(true); - }, - - doSearch: function(showDebug){ - if (this.searchInProgress) { - console.log("Can't start a new search while another one is in " + - "progress."); - return false; - } - - // Check if there are no search criteria. - if (this.predicateViews.length == 0) { - htrace.showModalWarning("No Search Criteria Specified", - "You have not specified any search criteria. " + - "Use the 'Add Predicate' button to specify what to search for."); - return false; - } - - // Build the predicate array. - predicates = [] - var predicateViewsLen = this.predicateViews.length; - for (var i = 0; i < predicateViewsLen; i++) { - var predicateView = this.predicateViews[i]; - try { - predicates.push(predicateView.getPredicate()); - } catch(err) { - htrace.showModalWarning("Search Field Validation Error", - "Invalid search string for the '" + predicateView.ptype.name + - "' field.<p/>" + err); - return false; - } - } - var queryJson = { - pred: predicates, - lim: 20 - }; - // If there are existing search results, we want results which "come after" - // those. So pass the last span we saw as a continuation token. - if (this.searchResults.size() > 0) { - queryJson.prev = - this.searchResults.at(this.searchResults.size() - 1).unparse(); - } - var searchView = this; - var queryResults = new htrace.QueryResults({queryJson: queryJson}); - console.log("Starting span query " + queryResults.url()); - this.searchInProgress = true; - queryResults.fetch({ - success: function(model, response, options){ - var firstResults = (searchView.searchResults.size() === 0); - console.log("Success on span query " + queryResults.url() + ": got " + - queryResults.size() + " result(s). firstResults=" + firstResults); - searchView.searchResults.add(queryResults.models); - if (firstResults) { - // After the initial search, zoom to fit everything. - // On subsequent searches, we leave the viewport alone. - searchView.resultsView.zoomHandler(); - } - searchView.searchInProgress = false; - if (showDebug) { - htrace.showModalWarning("Search Debug", - "This is the search debug box, accessible by holding down the " + - "control key while clicking the search button.<p/>" + - "<h3>Query JSON</h3><pre>" + queryResults.prettyQueryString() + - "</pre><p/><h3>Response JSON</h3><pre>" + - JSON.stringify(queryResults, null, 2) + "</pre><p/>"); - } else if (queryResults.size() == 0) { - if (firstResults) { - htrace.showModalWarning("No Results Found", - "No results were found for your query.<p/>"); - } else { - htrace.showModalWarning("No Additional Results Found", - "No additional results were found for your query.<p/>"); - } - } - searchView.resultsView.render(); - }, - error: function(model, response, options){ - searchView.searchResults.reset(); - var err = "Error " + JSON.stringify(response, null, 2) + - " on span query " + queryResults.url(); - console.log(err); - alert(err); - searchView.searchInProgress = false; - } - }); - return false; - }, - - dropdownHandler: function(e){ - e.preventDefault(); - var text = $(e.target).text(); - var ptype = htrace.parsePType(text); - if (!ptype) { - alert("Unable to parse predicate type '" + text + "'"); - return false; - } - var index = this.highestPredicateIndex; - this.highestPredicateIndex++; - var el = "pred" + index; - $("#predicates").append('<div id="' + el + '"/></div>'); - predicateView = new htrace.PredicateView({ - el: "#" + el, - index: index, - ptype: ptype, - searchView: this - }); - this.predicateViews.push(predicateView); - predicateView.render(); - return true; - }, - - blurBeginHandler: function(e) { - return this.resultsView.handleBeginOrEndChange(e, "begin"); - }, - - blurEndHandler: function(e) { - return this.resultsView.handleBeginOrEndChange(e, "end"); - }, - - zoomHandler: function(e) { - e.preventDefault(); - this.resultsView.zoomHandler(); - }, - - removePredicateView: function(predicateView) { - this.predicateViews = _.without(this.predicateViews, predicateView); - }, - - render: function() { - this.$el.html(_.template($("#search-view-template").html()) - ({ model : this.model })) - this.resultsView.render(); - console.log("SearchView#render"); - return this; - }, - - close: function() { - console.log("SearchView#close") - while (this.predicateViews.length > 0) { - this.predicateViews[0].remove(); - } - this.resultsView.remove(); - this.resultsView = null; - this.undelegateEvents(); - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/server_info.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/server_info.js b/htrace-webapp/src/main/web/app/server_info.js deleted file mode 100644 index b03f706..0000000 --- a/htrace-webapp/src/main/web/app/server_info.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// htraced ServerInfo sent back from /serverInfo. -// See rest.go. -htrace.ServerInfo = Backbone.Model.extend({ - defaults: { - "ReleaseVersion": "unknown", - "GitVersion": "unknown", - }, - - url: function() { - return "server/info"; - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/span.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/span.js b/htrace-webapp/src/main/web/app/span.js deleted file mode 100644 index cd87543..0000000 --- a/htrace-webapp/src/main/web/app/span.js +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// The invalid span ID, which is all zeroes. -htrace.INVALID_SPAN_ID = "00000000000000000000000000000000"; - -// Convert an array of htrace.Span models into a comma-separated string. -htrace.spanModelsToString = function(spans) { - var ret = ""; - var prefix = ""; - for (var i = 0; i < spans.length; i++) { - ret += prefix + JSON.stringify(spans[i].unparse()); - prefix = ", "; - } - return ret; -}; - -// Convert an array of return results from ajax calls into an array of -// htrace.Span models. -htrace.parseMultiSpanAjaxQueryResults = function(ajaxCalls) { - var parsedSpans = []; - for (var i = 0; i < ajaxCalls.length; i++) { - var text = ajaxCalls[i][0]; - var result = ajaxCalls[i][1]; - if (ajaxCalls[i]["status"] != "200") { - throw "ajax error: " + ajaxCalls[i].statusText; - } - var parsedSpan = new htrace.Span({}); - try { - parsedSpan.parse(ajaxCalls[i].responseJSON, {}); - } catch (e) { - throw "span parse error: " + e; - } - parsedSpans.push(parsedSpan); - } - return parsedSpans; -}; - -htrace.sortSpansByBeginTime = function(spans) { - return spans.sort(function(a, b) { - if (a.get("begin") < b.get("begin")) { - return -1; - } else if (a.get("begin") > b.get("begin")) { - return 1; - } else { - return 0; - } - }); -}; - -htrace.getReifiedParents = function(span) { - return span.get("reifiedParents") || []; -}; - -htrace.getReifiedChildren = function(span) { - return span.get("reifiedChildren") || []; -}; - -htrace.Span = Backbone.Model.extend({ - // Parse a span sent from htraced. - // We use more verbose names for some attributes. - // Missing attributes are treated as zero or empty. Numerical attributes are - // forced to be numbers. - parse: function(response, options) { - var span = {}; - this.set("spanId", response.a ? response.a : htrace.INVALID_SPAN_ID); - this.set("tracerId", response.r ? response.r : ""); - this.set("parents", response.p ? response.p : []); - this.set("description", response.d ? response.d : ""); - this.set("begin", response.b ? parseInt(response.b, 10) : 0); - this.set("end", response.e ? parseInt(response.e, 10) : 0); - if (response.t) { - var t = response.t.sort(function(a, b) { - if (a.t < b.t) { - return -1; - } else if (a.t > b.t) { - return 1; - } else { - return 0; - } - }); - this.set("timeAnnotations", t); - } else { - this.set("timeAnnotations", []); - } - this.set("infoAnnotations", response.n ? response.n : {}); - this.set("selected", false); - - // reifiedChildren starts off as null and will be filled in as needed. - this.set("reifiedChildren", null); - - // If there are parents, reifiedParents starts off as null. Otherwise, we - // know it is the empty array. - this.set("reifiedParents", (this.get("parents").length == 0) ? [] : null); - - return span; - }, - - // Transform a span model back into a JSON string suitable for sending over - // the wire. - unparse: function() { - var obj = { }; - if (!(this.get("spanId") === htrace.INVALID_SPAN_ID)) { - obj.a = this.get("spanId"); - } - if (!(this.get("tracerId") === "")) { - obj.r = this.get("tracerId"); - } - if (this.get("parents").length > 0) { - obj.p = this.get("parents"); - } - if (this.get("description").length > 0) { - obj.d = this.get("description"); - } - if (this.get("begin") > 0) { - obj.b = this.get("begin"); - } - if (this.get("end") > 0) { - obj.e = this.get("end"); - } - if (this.get("timeAnnotations").length > 0) { - obj.t = this.get("timeAnnotations"); - } - if (_.size(this.get("infoAnnotations")) > 0) { - obj.n = this.get("infoAnnotations"); - } - return obj; - }, - - // - // Although the parent IDs are always present in the 'parents' field of the - // span, sometimes we need the actual parent span models. In that case we - // must "reify" them (make them real). - // - // This functionReturns a jquery promise which reifies all the parents of this - // span and stores them into reifiedParents. The promise returns the empty - // string on success, or an error string on failure. - // - reifyParents: function() { - var span = this; - var numParents = span.get("parents").length; - var ajaxCalls = []; - // Set up AJAX queries to reify the parents. - for (var i = 0; i < numParents; i++) { - ajaxCalls.push($.ajax({ - url: "span/" + span.get("parents")[i], - data: {}, - contentType: "application/json; charset=utf-8", - dataType: "json" - })); - } - var rootDeferred = jQuery.Deferred(); - $.when.apply($, ajaxCalls).then(function() { - var reifiedParents = []; - try { - reifiedParents = htrace.parseMultiSpanAjaxQueryResults(ajaxCalls); - } catch (e) { - rootDeferred.resolve("Error reifying parents for " + - span.get("spanId") + ": " + e); - return; - } - reifiedParents = htrace.sortSpansByBeginTime(reifiedParents); - // The current span is a child of the reified parents. There may be other - // children of those parents, but we are ignoring that here. By making - // this non-null, the "expand children" button will not appear for these - // paren spans. - for (var j = 0; j < reifiedParents.length; j++) { - reifiedParents[j].set("reifiedChildren", [span]); - } - console.log("Setting reified parents for " + span.get("spanId") + - " to " + htrace.spanModelsToString (reifiedParents)); - span.set("reifiedParents", reifiedParents); - rootDeferred.resolve(""); - }); - return rootDeferred.promise(); - }, - - // - // The span itself does not contain its children. However, the server has an - // index which can be used to easily find the children of a particular span. - // - // This function returns a jquery promise which reifies all the children of - // this span and stores them into reifiedChildren. The promise returns the - // empty string on success, or an error string on failure. - // - reifyChildren: function() { - var rootDeferred = jQuery.Deferred(); - var span = this; - $.ajax({ - url: "span/" + span.get("spanId") + "/children?lim=50", - data: {}, - contentType: "application/json; charset=utf-8", - dataType: "json" - }).done(function(childIds) { - var ajaxCalls = []; - for (var i = 0; i < childIds.length; i++) { - ajaxCalls.push($.ajax({ - url: "span/" + childIds[i], - data: {}, - contentType: "application/json; charset=utf-8", - dataType: "json" - })); - }; - $.when.apply($, ajaxCalls).then(function() { - var reifiedChildren; - try { - reifiedChildren = htrace.parseMultiSpanAjaxQueryResults(ajaxCalls); - } catch (e) { - reifiedChildren = rootDeferred.resolve("Error reifying children " + - "for " + span.get("spanId") + ": " + e); - return; - } - reifiedChildren = htrace.sortSpansByBeginTime(reifiedChildren); - // The current span is a parent of the new child. - // There may be other parents, but we are ignoring that here. - // By making this non-null, the "expand parents" button will not - // appear for these child spans. - for (var j = 0; j < reifiedChildren.length; j++) { - reifiedChildren[j].set("reifiedParents", [span]); - } - console.log("Setting reified children for " + span.get("spanId") + - " to " + htrace.spanModelsToString (reifiedChildren)); - span.set("reifiedChildren", reifiedChildren); - rootDeferred.resolve(""); - }); - }).fail(function(statusData) { - // Check if the /children query failed. - rootDeferred.resolve("Error querying children of " + - span.get("spanId") + ": got " + statusData); - return; - }); - return rootDeferred.promise(); - }, - - // Get the earliest begin time of this span or any of its reified parents or - // children. - getEarliestBegin: function() { - var earliestBegin = this.get("begin"); - htrace.treeTraverseDepthFirstPre(this, htrace.getReifiedParents, 0, - function(span, depth) { - earliestBegin = Math.min(earliestBegin, span.get("begin")); - }); - htrace.treeTraverseDepthFirstPre(this, htrace.getReifiedChildren, 0, - function(span, depth) { - earliestBegin = Math.min(earliestBegin, span.get("begin")); - }); - return earliestBegin; - }, - - // Get the earliest begin time of this span or any of its reified parents or - // children. - getLatestEnd: function() { - var latestEnd = this.get("end"); - htrace.treeTraverseDepthFirstPre(this, htrace.getReifiedParents, 0, - function(span, depth) { - latestEnd = Math.max(latestEnd, span.get("end")); - }); - htrace.treeTraverseDepthFirstPre(this, htrace.getReifiedChildren, 0, - function(span, depth) { - latestEnd = Math.max(latestEnd, span.get("end")); - }); - return latestEnd; - }, -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/span_details_view.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/span_details_view.js b/htrace-webapp/src/main/web/app/span_details_view.js deleted file mode 100644 index 9a37055..0000000 --- a/htrace-webapp/src/main/web/app/span_details_view.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.SpanDetailsView = Backbone.View.extend({ - initialize: function(options) { - this.el = options.el; - this.model = options.model; - } - - render: function() { - this.$el.html(_.template($("#about-view-template").html()) - ({ model : this.model })); - console.log("AboutView#render"); - return this; - }, - - close: function() { - console.log("AboutView#close") - this.undelegateEvents(); - } -}); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/span_group_widget.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/span_group_widget.js b/htrace-webapp/src/main/web/app/span_group_widget.js deleted file mode 100644 index ad0b482..0000000 --- a/htrace-webapp/src/main/web/app/span_group_widget.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// Widget containing a group of trace spans displayed on the canvas. -htrace.SpanGroupWidget = function(params) { - this.draw = function() { - this.ctx.save(); - this.ctx.fillStyle="#ffffff"; - this.ctx.fillRect(this.x0, this.y0, this.xF - this.x0, this.yF - this.y0); - this.ctx.strokeStyle="#aaaaaa"; - this.ctx.beginPath(); - this.ctx.moveTo(this.x0, this.y0); - this.ctx.lineTo(this.xF, this.y0); - this.ctx.stroke(); - this.ctx.beginPath(); - this.ctx.moveTo(this.x0, this.yF); - this.ctx.lineTo(this.xF, this.yF); - this.ctx.stroke(); - this.ctx.restore(); - return true; - }; - - this.createSpanWidget = function(node, indentLevel, - allowUpButton, allowDownButton) { - new htrace.SpanWidget({ - manager: this.manager, - ctx: this.ctx, - span: node, - x0: this.x0, - xB: this.xB, - xD: this.xD, - xF: this.xF, - xT: this.childIndent * indentLevel, - y0: this.spanY, - yF: this.spanY + this.spanWidgetHeight, - allowUpButton: allowUpButton, - allowDownButton: allowDownButton, - begin: this.begin, - end: this.end - }); - this.spanY += this.spanWidgetHeight; - } - - this.handle = function(e) { - switch (e.type) { - case "draw": - this.draw(); - return true; - } - } - - for (var k in params) { - this[k]=params[k]; - } - this.manager.register("draw", this); - this.spanY = this.y0 + 4; - - // Figure out how much to indent each child's description text. - this.childIndent = Math.max(10, (this.xF - this.xD) / 50); - - // Get the maximum depth of the parents tree to find out how far to indent. - var parentTreeHeight = - htrace.treeHeight(this.span, htrace.getReifiedParents); - - // Traverse the parents tree upwards. - var thisWidget = this; - htrace.treeTraverseDepthFirstPost(this.span, htrace.getReifiedParents, 0, - function(node, depth) { - if (depth > 0) { - thisWidget.createSpanWidget(node, - parentTreeHeight - depth, true, false); - } - }); - thisWidget.createSpanWidget(this.span, parentTreeHeight, true, true); - // Traverse the children tree downwards. - htrace.treeTraverseDepthFirstPre(this.span, htrace.getReifiedChildren, 0, - function(node, depth) { - if (depth > 0) { - thisWidget.createSpanWidget(node, - parentTreeHeight + depth, false, true); - } - }); - this.yF = this.spanY + 4; - return this; -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/span_widget.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/span_widget.js b/htrace-webapp/src/main/web/app/span_widget.js deleted file mode 100644 index 50bea91..0000000 --- a/htrace-webapp/src/main/web/app/span_widget.js +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -htrace.showSpanDetails = function(span) { - var info = { - spanID: span.get("spanID"), - begin: htrace.dateToString(span.get("begin"), 10), - end: htrace.dateToString(span.get("end"), 10), - duration: ((span.get("end") - span.get("begin")) + " ms") - }; - var explicitOrder = { - spanId: 1, - begin: 2, - end: 3, - duration: 4 - }; - keys = ["duration"]; - for(k in span.attributes) { - if (k == "reifiedChildren") { - continue; - } - if (k == "reifiedParents") { - continue; - } - if (k == "selected") { - continue; - } - if (k == "timeAnnotations") { - // For timeline annotations, make the times into top-level keys. - var timeAnnotations = span.get("timeAnnotations"); - for (var i = 0; i < timeAnnotations.length; i++) { - var key = htrace.dateToString(timeAnnotations[i].t); - keys.push(key); - info[key] = timeAnnotations[i].m; - explicitOrder[key] = 200; - } - continue; - } - if (k == "infoAnnotations") { - // For info annotations, move the keys to the top level. - // Surround them in brackets to make it clear that they are - // user-defined. - var infoAnnotations = span.get("infoAnnotations"); - _.each(infoAnnotations, function(value, key) { - key = "[" + key + "]"; - keys.push(key); - info[key] = value; - explicitOrder[key] = 200; - }); - continue; - } - keys.push(k); - if (info[k] == null) { - info[k] = span.get(k); - } - } - // We sort the keys so that the stuff we want at the top appears at the top, - // and everything else is in alphabetical order. - keys = keys.sort(function(a, b) { - var oa = explicitOrder[a] || 100; - var ob = explicitOrder[b] || 100; - if (oa < ob) { - return -1; - } else if (oa > ob) { - return 1; - } else if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } - }); - var len = keys.length; - var h = '<table style="table-layout:fixed;width:100%;word-wrap:break-word">'; - for (i = 0; i < len; i++) { - // Make every other row grey to improve visibility. - var colorString = ((i%2) == 1) ? "#f1f1f1" : "#ffffff"; - h += _.template($("#table-row-template").html())( - {bgcolor: colorString, key: keys[i], val: info[keys[i]]}); - } - h += '</table>'; - htrace.showModal(_.template($("#modal-table-template").html())( - {title: "Span Details", body: h})); -}; - -// Widget containing the trace span displayed on the canvas. -htrace.SpanWidget = function(params) { - this.draw = function() { - this.drawBackground(); - this.drawTracerId(); - this.drawDescription(); - }; - - // Draw the background of this span widget. - this.drawBackground = function() { - this.ctx.save(); - if (this.span.get("selected")) { - this.ctx.fillStyle="#ffccff"; - } else { - this.ctx.fillStyle="#ffffff"; - } - this.ctx.fillRect(this.x0, this.y0, this.xSize, this.ySize); - this.ctx.restore(); - } - - // Draw process ID text. - this.drawTracerId = function() { - this.ctx.save(); - this.ctx.fillStyle="#000000"; - this.ctx.font = (this.ySize - 2) + "px sans-serif"; - this.ctx.beginPath(); - this.ctx.rect(this.x0, this.y0, this.xB - this.x0, this.ySize); - this.ctx.clip(); - this.ctx.fillText(this.span.get('tracerId'), this.x0, this.yF - 4); - this.ctx.restore(); - }; - - // Draw the span description - this.drawDescription = function() { - // Draw the light blue bar representing time. - this.ctx.save(); - this.ctx.beginPath(); - this.ctx.rect(this.xD, this.y0, this.xF - this.xD, this.ySize); - this.ctx.clip(); - this.ctx.strokeStyle="#000000"; - this.ctx.fillStyle="#a7b7ff"; - var beginX = this.timeToPosition(this.span.get('begin')); - var endX = this.timeToPosition(this.span.get('end')); - - // If the span is completely off the screen, draw a diamond at either the - // beginning or the end of the bar to indicate whether it's too early or too - // late to be seen. - if (endX < this.x0) { - beginX = this.xD; - endX = this.xD; - } - if (beginX > this.xF) { - beginX = this.xF; - endX = this.xF; - } - - var gapY = 2; - var epsilon = Math.max(2, Math.floor(this.xSize / 1000)); - if (endX - beginX < epsilon) { - // The time interval is too narrow to see. Draw a diamond on the point instead. - this.ctx.beginPath(); - this.ctx.moveTo(beginX, this.y0 + gapY); - this.ctx.lineTo(beginX + (Math.floor(this.ySize / 2) - gapY), - this.y0 + Math.floor(this.ySize / 2)); - this.ctx.lineTo(beginX, this.yF - gapY); - this.ctx.lineTo(beginX - (Math.floor(this.ySize / 2) - gapY), - this.y0 + Math.floor(this.ySize / 2)); - this.ctx.closePath(); - this.ctx.fill(); - } else { - // Draw a bar from the start time to the end time. -// console.log("beginX=" + beginX + ", endX=" + endX + -// ", begin=" + this.span.get('begin') + ", end=" + this.span.get('end')); - this.ctx.fillRect(beginX, this.y0 + gapY, endX - beginX, - this.ySize - (gapY * 2)); - - // Draw a dots showing time points where annotations are. - var annotations = this.span.get('timeAnnotations'); - var annotationY = this.y0 + gapY; - var annotationW = 4; - var annotationH = (this.ySize - (gapY * 2)) / 2; - this.ctx.fillStyle="#419641"; - for (var i = 0; i < annotations.length; i++) { - this.ctx.fillRect(this.timeToPosition(annotations[i].t), annotationY, - annotationW, annotationH); - } - } - - // Draw description text - this.ctx.fillStyle="#000000"; - this.ctx.font = (this.ySize - gapY) + "px sans-serif"; - this.ctx.fillText(this.span.get('description'), - this.xD + this.xT, - this.yF - gapY - 2); - - this.ctx.restore(); - }; - - // Convert a time in milliseconds since the epoch to an x position. - this.timeToPosition = function(time) { - return this.xD + - (((time - this.begin) * (this.xF - this.xD)) / - (this.end - this.begin)); - }; - - this.handle = function(e) { - switch (e.type) { - case "mouseDown": - if (!htrace.inBoundingBox(e.x, e.y, - this.x0, this.xF, this.y0, this.yF)) { - return true; - } - if (e.raw.ctrlKey) { - // If the control key is pressed, we toggle the current selection. - // The user can create multiple selections this way. - if (this.span.get("selected")) { - this.span.set("selected", false); - } else { - this.span.set("selected", true); - } - } else { - var that = this; - this.manager.searchResultsView.applyToAllSpans(function(span) { - // Note: we don't want to set the selection state unless we need - // to. Setting the state (even to the same thing it already is) - // triggers a full re-render, if the span is one in the results - // collection. A full re-render slows us down and disrupts events - // like double-clicking. - if (that.span === span) { - if (!span.get("selected")) { - span.set("selected", true); - } - } else if (span.get("selected")) { - span.set("selected", false); - } - }); - } - return true; - case "draw": - this.draw(); - return true; - case "dblclick": - if (htrace.inBoundingBox(e.x, e.y, - this.x0, this.xF, this.y0, this.yF)) { - htrace.showSpanDetails(this.span); - } - return true; - } - }; - - for (var k in params) { - this[k]=params[k]; - } - this.xSize = this.xF - this.x0; - this.ySize = this.yF - this.y0; - this.xDB = this.xD - this.xB; - this.manager.register("draw", this); - - var widget = this; - if ((this.span.get("reifiedParents") == null) && (this.allowUpButton)) { - new htrace.TriangleButton({ - ctx: this.ctx, - manager: this.manager, - direction: "up", - x0: this.xB + 2, - xF: this.xB + (this.xDB / 2) - 2, - y0: this.y0 + 2, - yF: this.yF - 2, - callback: function() { - $.when(widget.span.reifyParents()).done(function (result) { - console.log("reifyParents: result was '" + result + "'"); - if (result != "") { - alert(result); - } else { - widget.manager.searchResultsView.render(); - } - }); - }, - }); - } - if ((this.span.get("reifiedChildren") == null) && (this.allowDownButton)) { - new htrace.TriangleButton({ - ctx: this.ctx, - manager: this.manager, - direction: "down", - x0: this.xB + (this.xDB / 2) + 2, - xF: this.xD - 2, - y0: this.y0 + 2, - yF: this.yF - 2, - callback: function() { - $.when(widget.span.reifyChildren()).done(function (result) { - console.log("reifyChildren: result was '" + result + "'"); - if (result != "") { - alert(result); - } else { - widget.manager.searchResultsView.render(); - } - }); - }, - }); - } - this.manager.register("mouseDown", this); - this.manager.register("dblclick", this); - return this; -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/string.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/string.js b/htrace-webapp/src/main/web/app/string.js deleted file mode 100644 index c9c514b..0000000 --- a/htrace-webapp/src/main/web/app/string.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// Parse an ISO8601 date string into a moment.js object. -htrace.parseDate = function(val) { - if (val.match(/^[0-9]([0-9]*)$/)) { - // Treat an all-numeric field as UTC milliseconds since the epoch. - return moment.utc(parseInt(val, 10)); - } - // Look for approved date formats. - var toTry = [ - "YYYY-MM-DDTHH:mm:ss,SSS", - "YYYY-MM-DDTHH:mm:ss", - "YYYY-MM-DDTHH:mm", - "YYYY-MM-DD" - ]; - for (var i = 0; i < toTry.length; i++) { - var m = moment.utc(val, toTry[i], true); - if (m.isValid()) { - return m; - } - } - throw "Please enter the date either as YYYY-MM-DDTHH:mm:ss,SSS " + - "in UTC, or as the number of milliseconds since the epoch."; -}; - -// Convert a moment.js moment into an ISO8601-style date string. -htrace.dateToString = function(val) { - return moment.utc(val).format("YYYY-MM-DDTHH:mm:ss,SSS"); -}; - -// Normalize a span ID into the format the server expects to see-- -// i.e. something like 00000000000000000000000000000000. -htrace.normalizeSpanId = function(str) { - if (str.length != 36) { - throw "The length of '" + str + "' was " + str.length + - ", but span IDs must be 36 characters long."; - } - if (str.search(/[^0-9a-fA-F]/) != -1) { - throw "Span IDs must contain only hexadecimal digits, but '" + str + - "' contained invalid characters."; - } - return str; -}; http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6b3d2d82/htrace-webapp/src/main/web/app/time_cursor.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/time_cursor.js b/htrace-webapp/src/main/web/app/time_cursor.js deleted file mode 100644 index 1caaa9a..0000000 --- a/htrace-webapp/src/main/web/app/time_cursor.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var htrace = htrace || {}; - -// Draws a vertical bar selecting a time. -htrace.TimeCursor = function(params) { - this.positionToTime = function(x) { - if ((x < this.x0) || (x > this.xF)) { - return -1; - } - return this.begin + - (((x - this.x0) * (this.end - this.begin)) / (this.xF - this.x0)); - }; - - this.timeToPosition = function(time) { - return this.x0 + (((time - this.begin) * - (this.xF - this.x0)) / (this.end - this.begin)); - }; - - this.draw = function() { - if (this.selectedTime != -1) { - this.ctx.save(); - this.ctx.beginPath(); - this.ctx.rect(this.x0, this.y0, - this.xF - this.x0, this.yF - this.y0); - this.ctx.clip(); - this.ctx.strokeStyle="#ff0000"; - var x = this.timeToPosition(this.selectedTime); - this.ctx.beginPath(); - this.ctx.moveTo(x, this.y0); - this.ctx.lineTo(x, this.yF); - this.ctx.stroke(); - this.ctx.restore(); - } - }; - - this.handle = function(e) { - switch (e.type) { - case "mouseMove": - if (htrace.inBoundingBox(e.x, e.y, - this.x0, this.xF, this.y0, this.yF)) { - this.selectedTime = this.positionToTime(e.x); - if (this.selectedTime < 0) { - $(this.el).val(""); - } else { - $(this.el).val(htrace.dateToString(this.selectedTime)); - } - return true; - } - return true; - case "draw": - this.draw(); - return true; - } - }; - - this.selectedTime = -1; - for (var k in params) { - this[k]=params[k]; - } - this.manager.register("mouseMove", this); - this.manager.register("draw", this); - return this; -};
