| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <link rel="import" href="../bower_components/polymer/polymer.html"> | 7 <link rel="import" href="logdog-error.html"> |
| 8 | 8 |
| 9 <script> | 9 <script> |
| 10 /** | 10 /** |
| 11 * Patches a JSONPB LogStreamDescriptor object. | 11 * Patches a JSONPB LogStreamDescriptor object. |
| 12 * | 12 * |
| 13 * @param state {Object} The LogStreamDescriptor object to patch. | 13 * @param state {Object} The LogStreamDescriptor object to patch. |
| 14 */ | 14 */ |
| 15 function patchDescriptor(desc) { | 15 function patchDescriptor(desc) { |
| 16 desc.timestamp = new Date(desc.timestamp); | 16 desc.timestamp = new Date(desc.timestamp); |
| 17 }; | 17 }; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return d; | 90 return d; |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Defines a LogDog stream, which is specified by its project and path. | 94 * Defines a LogDog stream, which is specified by its project and path. |
| 95 */ | 95 */ |
| 96 function LogDogStream(project, path) { | 96 function LogDogStream(project, path) { |
| 97 this.project = project; | 97 this.project = project; |
| 98 this.path = path; | 98 this.path = path; |
| 99 } | 99 } |
| 100 LogDogStream.prototype.fullName = function() { |
| 101 return this.project + "/" + this.path; |
| 102 }; |
| 103 LogDogStream.prototype.prefix = function() { |
| 104 var sepIdx = this.path.indexOf("/+"); |
| 105 if (sepIdx > 0) { |
| 106 return this.path.substring(0, sepIdx); |
| 107 } |
| 108 return this.path; |
| 109 }; |
| 110 LogDogStream.prototype.name = function() { |
| 111 var sep = "/+/"; |
| 112 var sepIdx = this.path.indexOf(sep); |
| 113 if (sepIdx < 0) { |
| 114 return undefined; |
| 115 } |
| 116 return this.path.substring(sepIdx + sep.length); |
| 117 }; |
| 118 LogDogStream.prototype.samePrefixAs = function(other) { |
| 119 return ( |
| 120 (this.project === other.project) && |
| 121 (this.prefix() === other.prefix())); |
| 122 }; |
| 100 LogDogStream.splitProject = function(v) { | 123 LogDogStream.splitProject = function(v) { |
| 101 var parts = LogDogStream.split(v, 2); | 124 var parts = LogDogStream.split(v, 2); |
| 102 if (parts.length === 1) { | 125 if (parts.length === 1) { |
| 103 return new LogDogStream(v, ""); | 126 return new LogDogStream(v, ""); |
| 104 } | 127 } |
| 105 | 128 |
| 106 // TODO: Remove this exception when project-less paths are no longer | 129 // TODO: Remove this exception when project-less paths are no longer |
| 107 // supported. | 130 // supported. |
| 108 if (parts[0] === "_") { | 131 if (parts[0] === "_") { |
| 109 parts[0] = ""; | 132 parts[0] = ""; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 124 LogDogStream.cmp = function(a, b) { | 147 LogDogStream.cmp = function(a, b) { |
| 125 if (a.project < b.project) { | 148 if (a.project < b.project) { |
| 126 return -1; | 149 return -1; |
| 127 } | 150 } |
| 128 if (a.project > b.project) { | 151 if (a.project > b.project) { |
| 129 return 1; | 152 return 1; |
| 130 } | 153 } |
| 131 return (a.path < b.path) ? -1 : ((a.path > b.path) ? 1 : 0); | 154 return (a.path < b.path) ? -1 : ((a.path > b.path) ? 1 : 0); |
| 132 }; | 155 }; |
| 133 </script> | 156 </script> |
| OLD | NEW |