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 1 commit
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
4 changes: 2 additions & 2 deletions timesketch/frontend/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[data-theme='light'] {
--background-color: linear-gradient(90deg, rgba(249, 249, 249, 1) 11%, rgba(241, 241, 241, 1) 100%);
--default-font-color: var(--font-color-dark);
--default-link-color: var(--font-color-dark);
--default-link-color: #3273dc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this color come from? :) It is not consistent with the rest of the UI and this will change all links which is a substantial change. If you really want blue links here, could you scope them to this component only for now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @tomchop - PTAL

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I've removed it for now and moved to the local colors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 The new link color is till in the PR though :) (line 33)

--default-title-font-color: var(--font-color-dark);
--navbar-background: #ffffff;
--navbar-font-color: var(--font-color-dark);
Expand Down Expand Up @@ -283,7 +283,7 @@ ul.content-list > li:last-child {

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>