Skip to content

Commit

Permalink
Merge pull request #43 from haystack/develop
Browse files Browse the repository at this point in the history
Add configuration to control what events to be logged
  • Loading branch information
JumanaFM authored Mar 31, 2022
2 parents 5fb42d9 + 684bef2 commit bdcfe8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion public/style/plugin.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
top: 0;
right: 0;
line-height: normal;
font-size: 16px;
font-size: 12px;
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
background: #fff;
z-index: 99999;
Expand Down
8 changes: 4 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ function embedNbApp() {
isSyncNotificationPopup: false,
isSyncSpotlightNewThread: false,
isNbLog: false,
nbLogEventsEnabled: [],
syncSpotlightNewThreadConfig: {},
isNbLogScroll: false,
nbLogScrollSpoConfig: 2000,
isShowQuickEditor: false,
sortByConfig: 'init',
Expand Down Expand Up @@ -554,8 +554,8 @@ function embedNbApp() {
this.currentConfigs.isSyncNotificationPopup = configs['SYNC_NOTIFICATION_POPUP'] === 'true' ? true : false
this.currentConfigs.isSyncSpotlightNewThread = configs['SYNC_SPOTLIGHT_NEW_THREAD'] === 'true' ? true : false
this.currentConfigs.isNbLog = configs['NB_LOG'] === 'true' ? true : false
this.currentConfigs.nbLogEventsEnabled = configs['CONFIG_NB_LOG_EVENTS_ENABLED'] ? JSON.parse(configs['CONFIG_NB_LOG_EVENTS_ENABLED']) : []
this.currentConfigs.syncSpotlightNewThreadConfig = configs['CONFIG_SYNC_SPOTLIGHT_NEW_THREAD'] ? JSON.parse(configs['CONFIG_SYNC_SPOTLIGHT_NEW_THREAD']) : {}
this.currentConfigs.isNbLogScroll = configs['NB_LOG_SCROLL'] === 'true' ? true : false
this.currentConfigs.nbLogScrollSpoConfig = configs['CONFIG_NB_LOG_SCROLL'] ? Number(configs['CONFIG_NB_LOG_SCROLL']) : 2000
this.currentConfigs.isShowQuickEditor = configs['SHOW_QUICK_EDITOR'] === 'true' ? true : false
this.currentConfigs.sortByConfig = configs['CONFIG_SORT_BY'] ? configs['CONFIG_SORT_BY'] : 'recent'
Expand Down Expand Up @@ -1277,7 +1277,7 @@ function embedNbApp() {
window.removeEventListener('scroll', this.handleScroll)
},
onLogNb: async function (event = 'NONE', initiator = 'NONE', spotlightType = 'NONE', isSyncAnnotation = false, hasSyncAnnotation = false, notificationTrigger = 'NONE', annotationId = null, countAnnotationReplies = 0) {
if (this.currentConfigs.isNbLog) {
if (this.currentConfigs.isNbLog && this.currentConfigs.nbLogEventsEnabled.includes(event)) {
// console.log(`onLogNb \nevent: ${event} \ninitiator: ${initiator} \nspotlightType: ${spotlightType} \nisSyncAnnotation: ${isSyncAnnotation} \nhasSyncAnnotation: ${hasSyncAnnotation} \nnotificationTrigger: ${notificationTrigger} \nannotationId: ${annotationId} \nannotation_replies_count: ${countAnnotationReplies}`)
const token = localStorage.getItem("nb.user");
const config = { headers: { Authorization: 'Bearer ' + token }, params: { url: this.sourceURL } }
Expand Down Expand Up @@ -1327,7 +1327,7 @@ function embedNbApp() {
return new Promise(resolve => setTimeout(resolve, ms))
},
handleScroll: function (e) {
if (this.currentConfigs.isNbLogScroll) {
if (this.currentConfigs.nbLogEventsEnabled.includes('SCROLL')) {
clearTimeout(this.scrollLogTimer)
this.scrollLogTimer = setTimeout(() => this.onLogNb('SCROLL'), this.currentConfigs.nbLogScrollSpoConfig)
}
Expand Down
13 changes: 12 additions & 1 deletion src/components/list/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div v-if="!isCollapsed">
<div class="list-header">
<span class="count">
{{ threads.length }} of {{ totalLabel }}
<span v-bind:class="{ 'filterdThreads': currentThreadsCount !== totalCount}">{{ currentThreadsCount }}</span> of {{ totalLabel }}
</span>
<span class="toggle-highlights" v-tooltip="showHighlights ? 'hide highlights' : 'show highlights'" @click="toggleHighlights">
<font-awesome-icon v-if="showHighlights" icon="eye" class="icon"></font-awesome-icon>
Expand Down Expand Up @@ -146,6 +146,9 @@ export default {
this.sortBy = this.currentConfigs.sortByConfig
},
computed: {
currentThreadsCount: function () {
return this.threads.length
},
totalLabel: function () {
if (this.totalCount === 1) {
return '1 thread'
Expand Down Expand Up @@ -216,3 +219,11 @@ export default {
}
}
</script>
<style>
.filterdThreads {
background: yellow;
font-weight: bold;
font-style: italic;
}
</style>

0 comments on commit bdcfe8a

Please sign in to comment.