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

[ENGAGE-1649] Feature/ai and reviews #154

Merged
merged 67 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
acc9115
feat: Added Firebase and created request to add new ai review
Aldemylla Sep 18, 2024
2f9da6b
feat: Created generate insight button
Aldemylla Sep 18, 2024
9d64473
feat: Styled the generate insight button and started the generated in…
Aldemylla Sep 19, 2024
acd02d8
Merge branch 'main' of https://github.com/weni-ai/insights-webapp int…
Aldemylla Sep 19, 2024
b3af7f3
adding initial gradient logic
MarcusviniciusLsantos Sep 26, 2024
5a8740a
adding mitt package
MarcusviniciusLsantos Sep 26, 2024
9606a6e
adding logic to render gradient in big texts
MarcusviniciusLsantos Sep 26, 2024
0c1322e
adding translations
MarcusviniciusLsantos Sep 26, 2024
8a390dd
adding new translations
MarcusviniciusLsantos Sep 27, 2024
be70174
adding feedback logic
MarcusviniciusLsantos Sep 27, 2024
abe8bab
adding user store
MarcusviniciusLsantos Sep 27, 2024
07e539c
adding setEmail in App.vue
MarcusviniciusLsantos Sep 27, 2024
f977554
Adjusting InsightBtn logic
MarcusviniciusLsantos Sep 27, 2024
678fd5d
adjusting service to match new logic
MarcusviniciusLsantos Sep 27, 2024
206566a
adding integration AI and feedback in firebase
MarcusviniciusLsantos Sep 27, 2024
3823de2
feat: Added Firebase and created request to add new ai review
Aldemylla Sep 18, 2024
ce53c50
feat: Created generate insight button
Aldemylla Sep 18, 2024
7a51d1e
feat: Styled the generate insight button and started the generated in…
Aldemylla Sep 19, 2024
518e791
adding initial gradient logic
MarcusviniciusLsantos Sep 26, 2024
765cf30
adding mitt package
MarcusviniciusLsantos Sep 26, 2024
8dc5d53
adding logic to render gradient in big texts
MarcusviniciusLsantos Sep 26, 2024
151f0c7
adding translations
MarcusviniciusLsantos Sep 26, 2024
1b31933
adding new translations
MarcusviniciusLsantos Sep 27, 2024
1e5c8d9
adding feedback logic
MarcusviniciusLsantos Sep 27, 2024
aa89351
adding user store
MarcusviniciusLsantos Sep 27, 2024
6dee025
adding setEmail in App.vue
MarcusviniciusLsantos Sep 27, 2024
41f1d4e
Adjusting InsightBtn logic
MarcusviniciusLsantos Sep 27, 2024
0e8e81d
adjusting service to match new logic
MarcusviniciusLsantos Sep 27, 2024
7d2b371
adding integration AI and feedback in firebase
MarcusviniciusLsantos Sep 27, 2024
7f9da28
adding prompt translations
MarcusviniciusLsantos Sep 27, 2024
9e2af91
adding isDisable btn to generate insight
MarcusviniciusLsantos Sep 27, 2024
4882c73
adding prompt dynamic logic
MarcusviniciusLsantos Sep 27, 2024
4ad409a
Merge branch 'feature/ai-and-reviews' of https://github.com/weni-ai/i…
MarcusviniciusLsantos Sep 30, 2024
c3a194e
fix break logic
MarcusviniciusLsantos Sep 30, 2024
a43039f
adjusting envs
MarcusviniciusLsantos Sep 30, 2024
41a08bb
adjusting docker-entrypoint to fix insights
MarcusviniciusLsantos Sep 30, 2024
f2e5a61
adjusting to jq
MarcusviniciusLsantos Sep 30, 2024
b4e6d81
adding console.log vars in docker-entrypoint
MarcusviniciusLsantos Sep 30, 2024
5d48dbe
adding jq
MarcusviniciusLsantos Sep 30, 2024
dd9d8e6
adding new logic do render json
MarcusviniciusLsantos Sep 30, 2024
0fdc4bd
test scaped logic
MarcusviniciusLsantos Sep 30, 2024
f68a16c
adjusting utils .env logic
MarcusviniciusLsantos Sep 30, 2024
1aa9f98
rm echo's
MarcusviniciusLsantos Sep 30, 2024
d403e53
adjusting env logic
MarcusviniciusLsantos Oct 1, 2024
a29f781
adding new packages: dompurify and marked
MarcusviniciusLsantos Oct 1, 2024
70858c9
creating Markdown component
MarcusviniciusLsantos Oct 1, 2024
e99fea6
adding markdown logic to headerGenerateInsightText
MarcusviniciusLsantos Oct 1, 2024
c47a528
adjusting generated fonts
MarcusviniciusLsantos Oct 2, 2024
582dfe5
adjusting height modal
MarcusviniciusLsantos Oct 2, 2024
bb1b602
adding logic to scroll after feedback response
MarcusviniciusLsantos Oct 2, 2024
b2680a8
adding logic to typingComplete
MarcusviniciusLsantos Oct 2, 2024
2d02ef1
adding emit event to typingComplete
MarcusviniciusLsantos Oct 2, 2024
b37b2f8
addding insightModalFooter
MarcusviniciusLsantos Oct 3, 2024
d4bf205
adjusting HeaderGenerateInsightModal
MarcusviniciusLsantos Oct 3, 2024
4f86c5d
Merge branch 'main' of https://github.com/weni-ai/insights-webapp int…
MarcusviniciusLsantos Oct 3, 2024
2286057
adding firebase mocks
MarcusviniciusLsantos Oct 3, 2024
d2a68e6
adding modalFooter tests
MarcusviniciusLsantos Oct 3, 2024
7c1e869
adding GenerateInsightButton tests
MarcusviniciusLsantos Oct 3, 2024
63fed09
adding GenerateInsightText tests
MarcusviniciusLsantos Oct 3, 2024
4e93633
adjusting firebase mock logic
MarcusviniciusLsantos Oct 3, 2024
f5803b9
adjusting btns css
MarcusviniciusLsantos Oct 4, 2024
4f35701
adjusting by ai translation
MarcusviniciusLsantos Oct 4, 2024
e9fce47
adding HeaderGenerateInsightModal tests
MarcusviniciusLsantos Oct 4, 2024
505abc5
adjusting insightModalFooter tests
MarcusviniciusLsantos Oct 4, 2024
c3f62c9
adjusting HeaderGenerateInsightModal
MarcusviniciusLsantos Oct 4, 2024
1f6b86e
rm console
MarcusviniciusLsantos Oct 4, 2024
2c7b01a
adding new prompt and new styles
MarcusviniciusLsantos Oct 4, 2024
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
3 changes: 1 addition & 2 deletions .env.local.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
VITE_GPT_URL=""
VITE_GPT_AUTH=""
VITE_FIREBASE_CONFIG=""
14 changes: 14 additions & 0 deletions __tests__/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { config } from '@vue/test-utils';
import i18n from '@/utils/plugins/i18n.js';
import UnnnicSystemPlugin from '@/utils/plugins/UnnnicSystem.js';
import { vi } from 'vitest';

vi.mock('firebase/app', () => ({
initializeApp: vi.fn(() => ({
name: 'mockApp',
})),
}));

vi.mock('firebase/firestore', () => ({
getFirestore: vi.fn(() => ({
collection: vi.fn(),
doc: vi.fn(),
})),
}));

config.global.plugins = [i18n, UnnnicSystemPlugin];
config.global.mocks = {
Expand Down
11 changes: 7 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh

ESCAPED_FIREBASE_CONFIG=$(echo "${VITE_FIREBASE_CONFIG}" | sed 's/\//\\\//g')

export JSON_STRING='window.configs = { \
"VITE_GPT_URL":"'${VITE_GPT_URL}'", \
"VITE_GPT_AUTH":"'${VITE_GPT_AUTH}'", \
"VITE_INSIGHTS_API_URL":"'${VITE_INSIGHTS_API_URL}'", \
"VITE_HOTJAR_ID":"'${VITE_HOTJAR_ID}'", \
"VITE_INSIGHTS_API_URL": "'${VITE_INSIGHTS_API_URL}'", \
"VITE_FIREBASE_CONFIG": '${ESCAPED_FIREBASE_CONFIG}', \
"VITE_HOTJAR_ID": "'${VITE_HOTJAR_ID}'" \
}'

sed "s|//CONFIGURATIONS_PLACEHOLDER|${JSON_STRING}|" /usr/share/nginx/html/insights/index.html.tmpl > /tmp/index.html

exec "$@"
7 changes: 2 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ FROM node:${NODE_VERSION}-${BASE_VERSION} as builder

WORKDIR /app

ARG VITE_GPT_URL
ARG VITE_GPT_AUTH
ARG VITE_HOTJAR_ID
ARG VITE_FIREBASE_CONFIG

ENV VITE_GPT_URL $VITE_GPT_URL
ENV VITE_GPT_AUTH $VITE_GPT_AUTH
ENV VITE_FIREBASE_CONFIG $VITE_FIREBASE_CONFIG
ENV VITE_HOTJAR_ID $VITE_HOTJAR_ID

RUN apk --no-cache add git
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"axios": "^1.7.2",
"chart.js": "^4.4.2",
"chartjs-plugin-datalabels": "^2.2.0",
"dompurify": "^3.1.7",
"emoji-mart": "^5.6.0",
"firebase": "^10.13.1",
"marked": "^14.1.2",
"mitt": "^3.0.1",
"moment": "^2.30.1",
"vue": "^3.3.11",
"vue-i18n": "9",
Expand Down Expand Up @@ -56,4 +60,4 @@
"resolutions": {
"strip-ansi": "6.0.1"
}
}
}
5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
setProject: 'config/setProject',
checkEnableCreateCustomDashboards:
'config/checkEnableCreateCustomDashboards',
setEmail: 'user/setEmail',
}),

...mapMutations({
Expand Down Expand Up @@ -141,6 +142,10 @@ export default {

const sessionUserEmail = parseJwt(newToken)?.email || null;

if (sessionUserEmail) {
this.setEmail(sessionUserEmail);
}

initHotjar(sessionUserEmail);

await this.checkEnableCreateCustomDashboards();
Expand Down
8 changes: 8 additions & 0 deletions src/assets/images/shine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/components/Markdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>

Check warning on line 1 in src/components/Markdown.vue

View workflow job for this annotation

GitHub Actions / lint-test-build

Component name "Markdown" should always be multi-word
<section
class="content-section"
v-html="html"

Check warning on line 4 in src/components/Markdown.vue

View workflow job for this annotation

GitHub Actions / lint-test-build

'v-html' directive can lead to XSS attack
/>
</template>

<script>
import DOMPurify from 'dompurify';
import { marked } from 'marked';

export default {
props: {
content: {
type: String,
default: '',
},
},

computed: {
html() {
return DOMPurify.sanitize(marked.parse(this.content));
},
},
};
</script>

<style scoped>
.content-section {
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
10 changes: 6 additions & 4 deletions src/components/insights/Layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
<InsightsLayoutHeaderFilters />
<HeaderDashboardSettings />
<!-- <UnnnicButton
class="clickable"
iconCenter="ios_share"
type="secondary"
class="clickable"
iconCenter="ios_share"
type="secondary"
/> -->
<HeaderGenerateInsightButton />
</section>
</section>
</header>
Expand All @@ -33,6 +34,7 @@ import HeaderSelectDashboard from './HeaderSelectDashboard/index.vue';
import HeaderTagLive from './HeaderTagLive.vue';
import InsightsLayoutHeaderFilters from './HeaderFilters/index.vue';
import HeaderDashboardSettings from './HeaderDashboardSettings.vue';
import HeaderGenerateInsightButton from './HeaderGenerateInsights/HeaderGenerateInsightButton.vue';

import moment from 'moment';

Expand All @@ -43,8 +45,8 @@ export default {
HeaderSelectDashboard,
HeaderTagLive,
InsightsLayoutHeaderFilters,

HeaderDashboardSettings,
HeaderGenerateInsightButton,
},
computed: {
...mapState({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<button
class="header-generate-insight-button"
:disabled="isDisableBtn"
@click="openModal"
>
<img src="@/assets/images/shine.svg" />
{{ $t('insights_header.generate_insight.title') }}

<HeaderGenerateInsightModal
:show="isGenerateInsightModalOpen"
@close="closeModal"
/>
</button>
</template>

<script>
import { mapState } from 'vuex';

import HeaderGenerateInsightModal from './HeaderGenerateInsightModal.vue';

export default {
name: 'HeaderGenerateInsightButton',

components: {
HeaderGenerateInsightModal,
},

data() {
return {
isGenerateInsightModalOpen: false,
};
},

computed: {
...mapState({
token: (state) => state.config.token,
}),
isDisableBtn() {
return this.$store.state.widgets.isLoadingCurrentDashboardWidgets;
},
},

methods: {
openModal() {
this.isGenerateInsightModalOpen = true;
},
closeModal() {
this.isGenerateInsightModalOpen = false;
},
},
};
</script>

<style scoped lang="scss">
.header-generate-insight-button {
position: relative;

border: none;

display: flex;
gap: $unnnic-spacing-nano;
justify-content: center;
align-items: center;

padding: $unnnic-spacing-ant $unnnic-spacing-sm;

border-radius: $unnnic-border-radius-sm;
background: $unnnic-color-neutral-darkest;

color: $unnnic-color-weni-300;

font-family: $unnnic-font-family-secondary;
font-size: $unnnic-font-size-body-gt;

cursor: pointer;
}
</style>
Loading
Loading