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

Allow user to pass multiple filters to custom slash commands / Show all filters in help menu #208

Open
wants to merge 2 commits 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
11 changes: 8 additions & 3 deletions src/commands/custom_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ export class CustomCommand extends Command {

const filters: {[key: string]: string} = {}
const dashboardFilters = dashboard.dashboard_filters || dashboard.filters
for (const filter of dashboardFilters) {
filters[filter.name] = query
}
const params = query.split(";")
const usedFilters = dashboardFilters.slice(0, params.length)
var iterator = params.values()

usedFilters.forEach(function (value: any) {
filters[value.name] = iterator.next().value
})

const runner = new DashboardQueryRunner(context, matchedCommand.dashboard, filters)
runner.start()

Expand Down
7 changes: 6 additions & 1 deletion src/looker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export class Looker {

const dashboardFilters = dashboard.dashboard_filters || dashboard.filters
if (dashboardFilters && dashboardFilters.length > 0) {
command.helptext = `<${dashboardFilters[0].title.toLowerCase()}>`
let descText = ""
dashboardFilters.forEach(function (value: any) {
descText += `<${value.title.toLowerCase()}>`
descText += ";"
})
command.helptext = descText.substring(0, descText.length - 1)
}

Looker.customCommands[command.name] = command
Expand Down