Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: web/inc/logdog-stream-view/viewer.ts

Issue 2860453003: LogDog Viewer: Link back to source build. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: web/inc/logdog-stream-view/viewer.ts
diff --git a/web/inc/logdog-stream-view/viewer.ts b/web/inc/logdog-stream-view/viewer.ts
index a1018a9655b5b16f8d7981b7cbbc5526b26eb8e5..d81e4948adbc80ecc6c3c9580ed70c18f5a05306 100644
--- a/web/inc/logdog-stream-view/viewer.ts
+++ b/web/inc/logdog-stream-view/viewer.ts
@@ -192,6 +192,8 @@ namespace LogDog {
/** Are we in the middle of rendering logs? */
private rendering = true;
+ private cachedLogStreamUrl: string|undefined = undefined;
+
private loadingStateValue: LoadingState = LoadingState.NONE;
private streamStatusValue: StreamStatusEntry[];
@@ -354,6 +356,7 @@ namespace LogDog {
split: this.isSplit,
bottom: !this.fetchedEndOfStream,
fullyLoaded: (this.fetchedFullStream && (!this.rendering)),
+ logStreamUrl: this.logStreamUrl,
loadingState: this.loadingState,
streamStatus: this.streamStatus,
});
@@ -632,12 +635,20 @@ namespace LogDog {
private get fetchedFullStream(): boolean {
return (this.fetchedEndOfStream && (!this.isSplit));
}
+
+ private get logStreamUrl(): string|undefined {
+ if (!this.cachedLogStreamUrl) {
+ this.cachedLogStreamUrl = this.provider.getLogStreamUrl();
+ }
+ return this.cachedLogStreamUrl;
+ }
}
/** Generic interface for a log provider. */
interface LogProvider {
setStreamStatusCallback(cb: StreamStatusCallback): void;
fetch(op: luci.Operation, l: Location): Promise<BufferedLogs>;
+ getLogStreamUrl(): string|undefined;
/** Will return null if this LogProvider doesn't support splitting. */
split(): SplitLogProvider|null;
@@ -748,6 +759,18 @@ namespace LogDog {
}
}
+ get descriptor() {
+ return this.fetcher.desc;
+ }
+
+ getLogStreamUrl(): string|undefined {
+ let desc = this.descriptor;
+ if (desc) {
+ return (desc.tags || {})['logdog.viewer_url'];
+ }
+ return undefined;
+ }
+
setStreamStatusCallback(cb: StreamStatusCallback) {
this.streamStatusCallback = cb;
}
@@ -1000,6 +1023,7 @@ namespace LogDog {
class AggregateLogStream implements LogProvider {
private streams: AggregateLogStream.Entry[];
private active: AggregateLogStream.Entry[];
+ private sharedPrefix: boolean;
private currentNextPromise: Promise<BufferedLogs[]>|null;
private compareLogs: (a: LogDog.LogEntry, b: LogDog.LogEntry) => number;
@@ -1028,7 +1052,7 @@ namespace LogDog {
// prefix, we will use the prefix index. Otherwise, we will use the
// timestamp.
let template: LogDog.StreamPath;
- let sharedPrefix = this.streams.every((entry) => {
+ this.sharedPrefix = this.streams.every((entry) => {
nodir 2017/05/03 15:36:52 I don't think this is used outside of this functio
dnj 2017/05/03 15:40:43 Correct, I originally wanted to only return links
if (!template) {
template = entry.ls.stream;
return true;
@@ -1036,7 +1060,7 @@ namespace LogDog {
return template.samePrefixAs(entry.ls.stream);
});
- this.compareLogs = ((sharedPrefix) ? (a, b) => {
+ this.compareLogs = ((this.sharedPrefix) ? (a, b) => {
return (a.prefixIndex - b.prefixIndex);
} : (a, b) => {
if (a.timestamp) {
@@ -1073,6 +1097,19 @@ namespace LogDog {
}
}
+ getLogStreamUrl(): string|undefined {
+ // Return the first log stream viewer URL. IF we have a shared prefix,
+ // this will always work. Otherwise, returning something is better than
+ // nothing, so if any of the base streams have a URL, we will return it.
+ for (let s of this.streams) {
+ let url = s.ls.getLogStreamUrl();
+ if (url) {
+ return url;
+ }
+ }
+ return undefined;
+ }
+
/**
* Implements LogProvider.next
*/

Powered by Google App Engine
This is Rietveld 408576698