Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show custom column labels in tables #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/looker_api_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface IQuery {
type?: string;
hidden_fields?: string[];
show_view_names: boolean;
series_labels: { [key: string]: string };
[key: string]: any;
}
client_id?: string | null // deprecated
Expand Down
9 changes: 9 additions & 0 deletions src/repliers/slack_table_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class SlackTableFormatter {
private fields: any[]
private query: IQuery
private result: IQueryResponse
private customLabels: { [key: string]: string }

constructor(
private options: {query: IQuery, result: IQueryResponse, baseUrl: string, shareUrl: string},
Expand All @@ -28,6 +29,9 @@ export class SlackTableFormatter {
}
}

// get custom labels
this.customLabels = this.query.vis_config.series_labels

const calcs = this.result.fields.table_calculations || []
const dimensions = this.result.fields.dimensions || []
const measures = this.result.fields.measures || []
Expand Down Expand Up @@ -110,6 +114,11 @@ export class SlackTableFormatter {
}

private renderFieldLabel(field: IQueryResponseField): string {

if (this.customLabels[field.name]) {
return this.customLabels[field.name]
}

let showViewNames: boolean
if (!this.query.vis_config || typeof this.query.vis_config.show_view_names === "undefined") {
showViewNames = true
Expand Down