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

Drill Down Report - Clickable link to clickable links with a variable #5601

Open
noblemavely opened this Issue Jul 27, 2017 · 7 comments

Comments

Projects
None yet
7 participants
@noblemavely

noblemavely commented Jul 27, 2017

Is there a way where we can have hyperlink the data output to an external URL?

Example: If I have the following data in a table

id | name | dob | number | email

1 | noble | 1111 | 2222221 | nob@mavely.in

2 | darshit | 1111 | 2222221 | dar@mavely.in

3 | mialn | 1111 | 2222221 | mil@mavely.in

Can I hyperlink the values in the ID column to an external link like - google.com/{{id}}

@mazameli

This comment has been minimized.

Show comment
Hide comment
@mazameli

mazameli Jul 27, 2017

Contributor

One way we'd talked about doing this in the past is by adding additional functions to the custom field menu to allow things like string concatenation to enable a use case like this one. For example, strcat("google.com/", "ID") would create a new hyperlinked field.

Contributor

mazameli commented Jul 27, 2017

One way we'd talked about doing this in the past is by adding additional functions to the custom field menu to allow things like string concatenation to enable a use case like this one. For example, strcat("google.com/", "ID") would create a new hyperlinked field.

@tlrobinson

This comment has been minimized.

Show comment
Hide comment
@tlrobinson

tlrobinson Jul 27, 2017

Member

BTW there's an old PR that prototypes concat and some other expression functions #4047

We'd also need a way to set type of the extra column to be a URL to get it to include the link.

Or actually we'd probably want a special type of remapping that lets you specify the external URL.

Member

tlrobinson commented Jul 27, 2017

BTW there's an old PR that prototypes concat and some other expression functions #4047

We'd also need a way to set type of the extra column to be a URL to get it to include the link.

Or actually we'd probably want a special type of remapping that lets you specify the external URL.

@manjeshpv

This comment has been minimized.

Show comment
Hide comment
@manjeshpv

manjeshpv Jul 28, 2017

@milansync I suggest, it can be handled in ui, if any content have html then just don't html encode

I'm using google chrome extension for it which have below js code https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija/related?hl=en

select concat('<a class="drilldown" target="_blank" href="https://quezx.com/candidates/', id, '">',id, '</a>') as id, name from candidates limit 1
select drill(id, concat('https://quezx.com/candidates/', id),1) as id, name from candidates limit 1
-- or
CREATE DEFINER=`root`@`localhost` FUNCTION `drill`(`caption` VARCHAR(255), `link` VARCHAR(255), `target` INT) RETURNS varchar(255) CHARSET latin1
    NO SQL
BEGIN
    RETURN concat('<a class="drilldown" ',IF(target = 1, 'target="_blank"', ""),' href="', link, '">',caption, '</a>');
END

select drill(id, concat('https://quezx.com/candidates/', id),1) as id, name from candidates limit 1
document
.querySelectorAll('span')
.forEach(x => {
    if(x.textContent.includes('drilldown')) {
      x.outerHTML = x.textContent.replace(/&gt;/g, '>').replace(/&lt;/g, '<');
    }
})

manjeshpv commented Jul 28, 2017

@milansync I suggest, it can be handled in ui, if any content have html then just don't html encode

I'm using google chrome extension for it which have below js code https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija/related?hl=en

select concat('<a class="drilldown" target="_blank" href="https://quezx.com/candidates/', id, '">',id, '</a>') as id, name from candidates limit 1
select drill(id, concat('https://quezx.com/candidates/', id),1) as id, name from candidates limit 1
-- or
CREATE DEFINER=`root`@`localhost` FUNCTION `drill`(`caption` VARCHAR(255), `link` VARCHAR(255), `target` INT) RETURNS varchar(255) CHARSET latin1
    NO SQL
BEGIN
    RETURN concat('<a class="drilldown" ',IF(target = 1, 'target="_blank"', ""),' href="', link, '">',caption, '</a>');
END

select drill(id, concat('https://quezx.com/candidates/', id),1) as id, name from candidates limit 1
document
.querySelectorAll('span')
.forEach(x => {
    if(x.textContent.includes('drilldown')) {
      x.outerHTML = x.textContent.replace(/&gt;/g, '>').replace(/&lt;/g, '<');
    }
})

@noblemavely noblemavely changed the title from Clickable link to external webpages with a variable to Drill Down Report - Clickable link to external webpages with a variable Aug 4, 2017

@noblemavely noblemavely changed the title from Drill Down Report - Clickable link to external webpages with a variable to Drill Down Report - Clickable link to clickable links with a variable Aug 4, 2017

@manjeshpv

This comment has been minimized.

Show comment
Hide comment
@manjeshpv

manjeshpv commented Aug 8, 2017

duplicate #2791

@asusmsk

This comment has been minimized.

Show comment
Hide comment
@asusmsk

asusmsk Sep 20, 2018

put your vote in #8068

asusmsk commented Sep 20, 2018

put your vote in #8068

@jornh

This comment has been minimized.

Show comment
Hide comment
@jornh

jornh Sep 22, 2018

Contributor

I see 3 different approaches to solving this being discussed on various issues. Here I want to point out differences in UX for which role/where setup of the links happen in the hope it helps moving forward:

  • As mentioned in #5601 (comment) a few posts up to add the concatenation of id's through the custom field menu. This would make the feature available to any user who is able to use the Query Builder. The downside is it has to be built and maintained for each Question it’s used in. It’s not available on ad hoc drill downs similarly to next point

  • As proposed in PR #8068 “Add basic support for formatting markdown links in table cells“. This as far as I can see either requires ETL or a database view to build the Markdown formatted link as a database field OR native SQL queries to do the concatenation. This makes the feature available to “SQL literate” users. If it’s built through ETL or a database view it’s available for any querying user afterwards. Further cons regarding ETL/views are in OP of #8461

  • As proposed in #8461 “Associate URL templates with tables in data model”. This require involvement of an admin to configure once for each table. After that the navigation action would work with any query even drill downs/unsaved ad hoc queries for any user. If a link URL changes it would need to be maintained in one place only in Metabase.

Contributor

jornh commented Sep 22, 2018

I see 3 different approaches to solving this being discussed on various issues. Here I want to point out differences in UX for which role/where setup of the links happen in the hope it helps moving forward:

  • As mentioned in #5601 (comment) a few posts up to add the concatenation of id's through the custom field menu. This would make the feature available to any user who is able to use the Query Builder. The downside is it has to be built and maintained for each Question it’s used in. It’s not available on ad hoc drill downs similarly to next point

  • As proposed in PR #8068 “Add basic support for formatting markdown links in table cells“. This as far as I can see either requires ETL or a database view to build the Markdown formatted link as a database field OR native SQL queries to do the concatenation. This makes the feature available to “SQL literate” users. If it’s built through ETL or a database view it’s available for any querying user afterwards. Further cons regarding ETL/views are in OP of #8461

  • As proposed in #8461 “Associate URL templates with tables in data model”. This require involvement of an admin to configure once for each table. After that the navigation action would work with any query even drill downs/unsaved ad hoc queries for any user. If a link URL changes it would need to be maintained in one place only in Metabase.

@grncdr

This comment has been minimized.

Show comment
Hide comment
@grncdr

grncdr Sep 22, 2018

thanks for tracking and summarizing these issues @jornh!

grncdr commented Sep 22, 2018

thanks for tracking and summarizing these issues @jornh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment