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

TsDynamicTable now has links pointing back to searches in sketch. #1831

Merged
merged 3 commits into from
Jun 28, 2021
Merged
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
2 changes: 1 addition & 1 deletion timesketch/frontend/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ strong {

a,
a:hover {
color: var(--link-color);
color: var(--default-link-color);
}

.button {
Expand Down
58 changes: 55 additions & 3 deletions timesketch/frontend/src/components/Common/TsDynamicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
<p class="card-header-title">{{ section.label }}</p>
</header>

<div class="card-content">
<div class="card-content ts-dynamic-table">
<b-table :data="data">
<b-table-column
v-for="column in section.columns"
Expand All @@ -33,11 +33,44 @@ limitations under the License.
:numeric="typeof data[0][column.field] === 'number' ? true : false"
sortable
>
<!-- column is an text -->
<div v-if="column.type === 'text'">
<router-link
v-if="column.searchable"
:to="{ name: 'Explore', query: generateQuery(props.row[column.field], column) }"
>
{{ props.row[column.field] }}
<i class="fas fa-search" aria-hidden="true"></i>
</router-link>
<span v-else>{{ props.row[column.field] }}</span>
</div>

<!-- column is a timestamp -->
<div v-else-if="column.type === 'timestamp'">
{{ props.row[column.field] }}
</div>

<!-- column is a list of tags -->
<div v-else-if="column.type === 'list'">
<b-taglist v-if="column.searchable">
<router-link
v-bind:key="tag"
v-for="tag in props.row[column.field]"
:to="{ name: 'Explore', query: generateQuery(tag, column) }"
>
<b-tag type="is-link is-light">{{ tag }} <i class="fas fa-search" aria-hidden="true"></i></b-tag>
</router-link>
</b-taglist>
<b-taglist v-else>
<b-tag v-bind:key="tag" v-for="tag in props.row[column.field]" type="is-light">{{ tag }}</b-tag>
</b-taglist>
</div>

<!-- column is an object -->
<pre v-if="typeof props.row[column.field] === 'object'">{{ props.row[column.field] }}</pre>
<pre v-else-if="column.type === 'object'">{{ props.row[column.field] }}</pre>

<!-- deal with all other cases -->
<span v-else>{{ props.row[column.field] }}</span>
<div v-else>{{ props.row[column.field] }}</div>
</b-table-column>
</b-table>
</div>
Expand All @@ -60,5 +93,24 @@ export default {
return this.$store.state.meta
},
},
methods: {
generateQuery(value, column) {
let query = `"${value}"`
if (column.searchKey) {
query = `${column.searchKey}:${query}`
}
return { q: query }
},
},
}
</script>

<style scoped lang="scss">
.tags a:not(:last-child) {
margin-right: 0.5rem;
}

.ts-dynamic-table a {
color: var(--default-link-color);
}
</style>