-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…s-io/MIPs#162 (#1338) Add analytics extension to display snv title
- Loading branch information
Showing
13 changed files
with
325 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...rc/main/webapp/vue-app/notes-analytics-extension/componnets/NotesContentTypeAttribute.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!-- | ||
This file is part of the Meeds project (https://meeds.io/). | ||
|
||
Copyright (C) 2025 Meeds Association contact@meeds.io | ||
|
||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
--> | ||
|
||
<template> | ||
<span> | ||
{{ attributeValue }} | ||
</span> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
pageName: null, | ||
pageRefPattern: /^[a-z_]+::[a-z_]+::[a-z_]+$/ | ||
}; | ||
}, | ||
props: { | ||
attrValue: { | ||
type: String, | ||
default: null | ||
} | ||
}, | ||
computed: { | ||
attributeValue() { | ||
return this.pageName && this.$t('analytics.snv.title', {0: this.pageName}) || this.attrValue; | ||
} | ||
}, | ||
async created() { | ||
if (!this.pageRefPattern.test(this.attrValue)) { | ||
return; | ||
} | ||
const page = await this.getPage(); | ||
if (page?.key?.name) { | ||
this.pageName = page.key.name; | ||
} | ||
}, | ||
methods: { | ||
async getPage() { | ||
try { | ||
const response = await fetch(`/layout/rest/pages/byRef?pageRef=${this.attrValue}`, { | ||
method: 'GET', | ||
credentials: 'include', | ||
}); | ||
if (!response.ok) { | ||
console.error(`Error retrieving page: ${response.statusText}`); | ||
return null; | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error('Fetch error:', error); | ||
return null; | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
39 changes: 39 additions & 0 deletions
39
notes-webapp/src/main/webapp/vue-app/notes-analytics-extension/extensions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
extensionRegistry.registerExtension('AnalyticsSamples', 'SampleItem', { | ||
type: 'noteContentTitle', | ||
options: { | ||
rank: 80, | ||
vueComponent: Vue.options.components['note-content-type-attribute'], | ||
match: (fieldName) => { | ||
return fieldName === 'contentTitle'; | ||
} | ||
}, | ||
}); | ||
|
||
extensionRegistry.registerExtension('AnalyticsChart', 'FieldValueName', { | ||
type: 'noteContentTitle', | ||
match: (fieldName, fieldValue) => { | ||
return fieldName === 'contentTitle' && /^[a-z_]+::[a-z_]+::[a-z_]+$/.test(fieldValue); | ||
}, | ||
getLabel: (fieldName, fieldValue) => { | ||
return exoi18n.i18n.t('analytics.snv.title', {0: fieldValue.split('::')[2]}); | ||
} | ||
}); |
28 changes: 28 additions & 0 deletions
28
notes-webapp/src/main/webapp/vue-app/notes-analytics-extension/initComponents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
import NotesContentTypeAttribute from './componnets/NotesContentTypeAttribute.vue'; | ||
|
||
const components = { | ||
'note-content-type-attribute': NotesContentTypeAttribute, | ||
}; | ||
|
||
for (const key in components) { | ||
Vue.component(key, components[key]); | ||
} |
21 changes: 21 additions & 0 deletions
21
notes-webapp/src/main/webapp/vue-app/notes-analytics-extension/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
import './initComponents.js'; | ||
import './extensions.js'; |
35 changes: 35 additions & 0 deletions
35
.../webapp/vue-app/notes-analytics-table-extension/components/NotesContentTitleCellValue.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!-- | ||
This file is part of the Meeds project (https://meeds.io/). | ||
|
||
Copyright (C) 2025 Meeds Association contact@meeds.io | ||
|
||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
--> | ||
|
||
<template> | ||
<note-content-type-attribute | ||
:attr-value="value" /> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
value: { | ||
type: Object, | ||
default: null | ||
} | ||
}, | ||
}; | ||
</script> | ||
|
27 changes: 27 additions & 0 deletions
27
notes-webapp/src/main/webapp/vue-app/notes-analytics-table-extension/extensions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
extensionRegistry.registerExtension('AnalyticsTable', 'CellValue', { | ||
type: 'noteContentTitle', | ||
options: { | ||
rank: 300, | ||
vueComponent: Vue.options.components['note-content-title-cell-value'], | ||
match: (fieldName, aggregationType) => aggregationType === 'TERMS' && fieldName === 'contentTitle.keyword' | ||
}, | ||
}); |
30 changes: 30 additions & 0 deletions
30
notes-webapp/src/main/webapp/vue-app/notes-analytics-table-extension/initComponents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
import NotesContentTypeAttribute from '../notes-analytics-extension/componnets/NotesContentTypeAttribute.vue'; | ||
import NotesContentTitleCellValue from './components/NotesContentTitleCellValue.vue'; | ||
|
||
const components = { | ||
'note-content-type-attribute': NotesContentTypeAttribute, | ||
'note-content-title-cell-value': NotesContentTitleCellValue | ||
}; | ||
|
||
for (const key in components) { | ||
Vue.component(key, components[key]); | ||
} |
21 changes: 21 additions & 0 deletions
21
notes-webapp/src/main/webapp/vue-app/notes-analytics-table-extension/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2025 Meeds Association [email protected] | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
import './initComponents.js'; | ||
import './extensions.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters