Initial Vite Commit
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import Vue from 'vue';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import VueRouter from 'vue-router';
|
||||
import axios from 'axios';
|
||||
// Global Components
|
||||
import hljs from 'highlight.js';
|
||||
import Multiselect from 'vue-multiselect';
|
||||
import VueFormulate from '@braid/vue-formulate';
|
||||
import WootSwitch from 'components/ui/Switch.vue';
|
||||
import WootWizard from 'components/ui/Wizard.vue';
|
||||
import { sync } from 'vuex-router-sync';
|
||||
import Vuelidate from 'vuelidate';
|
||||
import VTooltip from 'v-tooltip';
|
||||
import WootUiKit from '../dashboard/components';
|
||||
import App from '../dashboard/App.vue';
|
||||
import i18n from '../dashboard/i18n';
|
||||
import createAxios from '../dashboard/helper/APIHelper';
|
||||
import commonHelpers, { isJSONValid } from '../dashboard/helper/commons';
|
||||
import router, { initalizeRouter } from '../dashboard/routes';
|
||||
import store from '../dashboard/store';
|
||||
import constants from 'dashboard/constants/globals';
|
||||
import * as Sentry from '@sentry/vue';
|
||||
import 'vue-easytable/libs/theme-default/index.css';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import {
|
||||
initializeAnalyticsEvents,
|
||||
initializeChatwootEvents,
|
||||
} from '../dashboard/helper/scriptHelpers';
|
||||
import FluentIcon from 'shared/components/FluentIcon/DashboardIcon.vue';
|
||||
import VueDOMPurifyHTML from 'vue-dompurify-html';
|
||||
import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
|
||||
import AnalyticsPlugin from '../dashboard/helper/AnalyticsHelper/plugin';
|
||||
|
||||
Vue.config.env = process.env;
|
||||
|
||||
if (window.errorLoggingConfig) {
|
||||
Sentry.init({
|
||||
Vue,
|
||||
dsn: window.errorLoggingConfig,
|
||||
denyUrls: [
|
||||
// Chrome extensions
|
||||
/^chrome:\/\//i,
|
||||
/chrome-extension:/i,
|
||||
/extensions\//i,
|
||||
|
||||
// Locally saved copies
|
||||
/file:\/\//i,
|
||||
|
||||
// Safari extensions.
|
||||
/safari-web-extension:/i,
|
||||
/safari-extension:/i,
|
||||
],
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
ignoreErrors: [
|
||||
'ResizeObserver loop completed with undelivered notifications',
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
Vue.use(VueRouter);
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(WootUiKit);
|
||||
Vue.use(Vuelidate);
|
||||
Vue.use(VueFormulate, {
|
||||
rules: {
|
||||
JSON: ({ value }) => isJSONValid(value),
|
||||
},
|
||||
});
|
||||
Vue.use(VTooltip, {
|
||||
defaultHtml: false,
|
||||
});
|
||||
Vue.use(hljs.vuePlugin);
|
||||
Vue.use(AnalyticsPlugin);
|
||||
|
||||
Vue.component('multiselect', Multiselect);
|
||||
Vue.component('woot-switch', WootSwitch);
|
||||
Vue.component('woot-wizard', WootWizard);
|
||||
Vue.component('fluent-icon', FluentIcon);
|
||||
|
||||
const i18nConfig = new VueI18n({
|
||||
locale: 'en',
|
||||
messages: i18n,
|
||||
});
|
||||
|
||||
sync(store, router);
|
||||
// load common helpers into js
|
||||
commonHelpers();
|
||||
|
||||
window.WootConstants = constants;
|
||||
window.axios = createAxios(axios);
|
||||
window.bus = new Vue();
|
||||
initializeChatwootEvents();
|
||||
initializeAnalyticsEvents();
|
||||
initalizeRouter();
|
||||
|
||||
window.onload = () => {
|
||||
window.WOOT = new Vue({
|
||||
router,
|
||||
store,
|
||||
i18n: i18nConfig,
|
||||
components: { App },
|
||||
template: '<App/>',
|
||||
}).$mount('#app');
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
window.playAudioAlert = () => {};
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import Rails from '@rails/ujs';
|
||||
import Turbolinks from 'turbolinks';
|
||||
import '../portal/application.scss';
|
||||
import Vue from 'vue';
|
||||
import { InitializationHelpers } from '../portal/portalHelpers';
|
||||
import VueDOMPurifyHTML from 'vue-dompurify-html';
|
||||
import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
|
||||
|
||||
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
|
||||
Rails.start();
|
||||
Turbolinks.start();
|
||||
|
||||
document.addEventListener('turbolinks:load', InitializationHelpers.onLoad);
|
||||
Executable
+184
@@ -0,0 +1,184 @@
|
||||
import Cookies from 'js-cookie';
|
||||
import { IFrameHelper } from '../sdk/IFrameHelper';
|
||||
import {
|
||||
getBubbleView,
|
||||
getDarkMode,
|
||||
getWidgetStyle,
|
||||
} from '../sdk/settingsHelper';
|
||||
import {
|
||||
computeHashForUserData,
|
||||
getUserCookieName,
|
||||
hasUserKeys,
|
||||
} from '../sdk/cookieHelpers';
|
||||
import { addClasses, removeClasses } from '../sdk/DOMHelpers';
|
||||
import { setCookieWithDomain } from '../sdk/cookieHelpers';
|
||||
import { SDK_SET_BUBBLE_VISIBILITY } from 'shared/constants/sharedFrameEvents';
|
||||
const runSDK = ({ baseUrl, websiteToken }) => {
|
||||
if (window.$chatwoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
const chatwootSettings = window.chatwootSettings || {};
|
||||
let locale = chatwootSettings.locale;
|
||||
let baseDomain = chatwootSettings.baseDomain;
|
||||
|
||||
if (chatwootSettings.useBrowserLanguage) {
|
||||
locale = window.navigator.language.replace('-', '_');
|
||||
}
|
||||
|
||||
window.$chatwoot = {
|
||||
baseUrl,
|
||||
baseDomain,
|
||||
hasLoaded: false,
|
||||
hideMessageBubble: chatwootSettings.hideMessageBubble || false,
|
||||
isOpen: false,
|
||||
position: chatwootSettings.position === 'left' ? 'left' : 'right',
|
||||
websiteToken,
|
||||
locale,
|
||||
useBrowserLanguage: chatwootSettings.useBrowserLanguage || false,
|
||||
type: getBubbleView(chatwootSettings.type),
|
||||
launcherTitle: chatwootSettings.launcherTitle || '',
|
||||
showPopoutButton: chatwootSettings.showPopoutButton || false,
|
||||
widgetStyle: getWidgetStyle(chatwootSettings.widgetStyle) || 'standard',
|
||||
resetTriggered: false,
|
||||
darkMode: getDarkMode(chatwootSettings.darkMode),
|
||||
|
||||
toggle(state) {
|
||||
IFrameHelper.events.toggleBubble(state);
|
||||
},
|
||||
|
||||
toggleBubbleVisibility(visibility) {
|
||||
let widgetElm = document.querySelector('.woot--bubble-holder');
|
||||
let widgetHolder = document.querySelector('.woot-widget-holder');
|
||||
if (visibility === 'hide') {
|
||||
addClasses(widgetHolder, 'woot-widget--without-bubble');
|
||||
addClasses(widgetElm, 'woot-hidden');
|
||||
window.$chatwoot.hideMessageBubble = true;
|
||||
} else if (visibility === 'show') {
|
||||
removeClasses(widgetElm, 'woot-hidden');
|
||||
removeClasses(widgetHolder, 'woot-widget--without-bubble');
|
||||
window.$chatwoot.hideMessageBubble = false;
|
||||
}
|
||||
IFrameHelper.sendMessage(SDK_SET_BUBBLE_VISIBILITY, {
|
||||
hideMessageBubble: window.$chatwoot.hideMessageBubble,
|
||||
});
|
||||
},
|
||||
|
||||
popoutChatWindow() {
|
||||
IFrameHelper.events.popoutChatWindow({
|
||||
baseUrl: window.$chatwoot.baseUrl,
|
||||
websiteToken: window.$chatwoot.websiteToken,
|
||||
locale,
|
||||
});
|
||||
},
|
||||
|
||||
setUser(identifier, user) {
|
||||
if (typeof identifier !== 'string' && typeof identifier !== 'number') {
|
||||
throw new Error('Identifier should be a string or a number');
|
||||
}
|
||||
|
||||
if (!hasUserKeys(user)) {
|
||||
throw new Error(
|
||||
'User object should have one of the keys [avatar_url, email, name]'
|
||||
);
|
||||
}
|
||||
|
||||
const userCookieName = getUserCookieName();
|
||||
const existingCookieValue = Cookies.get(userCookieName);
|
||||
const hashToBeStored = computeHashForUserData({ identifier, user });
|
||||
if (hashToBeStored === existingCookieValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.$chatwoot.identifier = identifier;
|
||||
window.$chatwoot.user = user;
|
||||
IFrameHelper.sendMessage('set-user', { identifier, user });
|
||||
|
||||
setCookieWithDomain(userCookieName, hashToBeStored, {
|
||||
baseDomain,
|
||||
});
|
||||
},
|
||||
|
||||
setCustomAttributes(customAttributes = {}) {
|
||||
if (!customAttributes || !Object.keys(customAttributes).length) {
|
||||
throw new Error('Custom attributes should have atleast one key');
|
||||
} else {
|
||||
IFrameHelper.sendMessage('set-custom-attributes', { customAttributes });
|
||||
}
|
||||
},
|
||||
|
||||
deleteCustomAttribute(customAttribute = '') {
|
||||
if (!customAttribute) {
|
||||
throw new Error('Custom attribute is required');
|
||||
} else {
|
||||
IFrameHelper.sendMessage('delete-custom-attribute', {
|
||||
customAttribute,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setConversationCustomAttributes(customAttributes = {}) {
|
||||
if (!customAttributes || !Object.keys(customAttributes).length) {
|
||||
throw new Error('Custom attributes should have atleast one key');
|
||||
} else {
|
||||
IFrameHelper.sendMessage('set-conversation-custom-attributes', {
|
||||
customAttributes,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
deleteConversationCustomAttribute(customAttribute = '') {
|
||||
if (!customAttribute) {
|
||||
throw new Error('Custom attribute is required');
|
||||
} else {
|
||||
IFrameHelper.sendMessage('delete-conversation-custom-attribute', {
|
||||
customAttribute,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setLabel(label = '') {
|
||||
IFrameHelper.sendMessage('set-label', { label });
|
||||
},
|
||||
|
||||
removeLabel(label = '') {
|
||||
IFrameHelper.sendMessage('remove-label', { label });
|
||||
},
|
||||
|
||||
setLocale(localeToBeUsed = 'en') {
|
||||
IFrameHelper.sendMessage('set-locale', { locale: localeToBeUsed });
|
||||
},
|
||||
|
||||
setColorScheme(darkMode = 'light') {
|
||||
IFrameHelper.sendMessage('set-color-scheme', {
|
||||
darkMode: getDarkMode(darkMode),
|
||||
});
|
||||
},
|
||||
|
||||
reset() {
|
||||
if (window.$chatwoot.isOpen) {
|
||||
IFrameHelper.events.toggleBubble();
|
||||
}
|
||||
|
||||
Cookies.remove('cw_conversation');
|
||||
Cookies.remove(getUserCookieName());
|
||||
|
||||
const iframe = IFrameHelper.getAppFrame();
|
||||
iframe.src = IFrameHelper.getUrl({
|
||||
baseUrl: window.$chatwoot.baseUrl,
|
||||
websiteToken: window.$chatwoot.websiteToken,
|
||||
});
|
||||
|
||||
window.$chatwoot.resetTriggered = true;
|
||||
},
|
||||
};
|
||||
|
||||
IFrameHelper.createFrame({
|
||||
baseUrl,
|
||||
websiteToken,
|
||||
});
|
||||
};
|
||||
|
||||
window.chatwootSDK = {
|
||||
run: runSDK,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
import '../dashboard/assets/scss/super_admin/index.scss';
|
||||
@@ -0,0 +1 @@
|
||||
import 'chart.js';
|
||||
@@ -0,0 +1,27 @@
|
||||
import Vue from 'vue';
|
||||
import Vuelidate from 'vuelidate';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import App from '../survey/App.vue';
|
||||
import i18n from '../survey/i18n';
|
||||
import store from '../survey/store';
|
||||
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(Vuelidate);
|
||||
|
||||
const i18nConfig = new VueI18n({
|
||||
locale: 'en',
|
||||
messages: i18n,
|
||||
});
|
||||
|
||||
// Event Bus
|
||||
window.bus = new Vue();
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
window.onload = () => {
|
||||
window.WOOT_SURVEY = new Vue({
|
||||
i18n: i18nConfig,
|
||||
store,
|
||||
render: h => h(App),
|
||||
}).$mount('#app');
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
import Vue from 'vue';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import VueRouter from 'vue-router';
|
||||
import Vuelidate from 'vuelidate';
|
||||
import i18n from 'dashboard/i18n';
|
||||
import * as Sentry from '@sentry/vue';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import {
|
||||
initializeAnalyticsEvents,
|
||||
initializeChatwootEvents,
|
||||
} from 'dashboard/helper/scriptHelpers';
|
||||
import AnalyticsPlugin from 'dashboard/helper/AnalyticsHelper/plugin';
|
||||
import App from '../v3/App.vue';
|
||||
import router, { initalizeRouter } from '../v3/views/index';
|
||||
import store from '../v3/store';
|
||||
import FluentIcon from 'shared/components/FluentIcon/DashboardIcon.vue';
|
||||
|
||||
Vue.config.env = process.env;
|
||||
|
||||
if (window.errorLoggingConfig) {
|
||||
Sentry.init({
|
||||
Vue,
|
||||
dsn: window.errorLoggingConfig,
|
||||
denyUrls: [
|
||||
// Chrome extensions
|
||||
/^chrome:\/\//i,
|
||||
/chrome-extension:/i,
|
||||
/extensions\//i,
|
||||
|
||||
// Locally saved copies
|
||||
/file:\/\//i,
|
||||
|
||||
// Safari extensions.
|
||||
/safari-web-extension:/i,
|
||||
/safari-extension:/i,
|
||||
],
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
ignoreErrors: [
|
||||
'ResizeObserver loop completed with undelivered notifications',
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
Vue.use(VueRouter);
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(Vuelidate);
|
||||
Vue.use(AnalyticsPlugin);
|
||||
Vue.component('fluent-icon', FluentIcon);
|
||||
|
||||
const i18nConfig = new VueI18n({ locale: 'en', messages: i18n });
|
||||
|
||||
window.bus = new Vue();
|
||||
initializeChatwootEvents();
|
||||
initializeAnalyticsEvents();
|
||||
initalizeRouter();
|
||||
window.onload = () => {
|
||||
new Vue({
|
||||
router,
|
||||
store,
|
||||
i18n: i18nConfig,
|
||||
components: { App },
|
||||
template: '<App/>',
|
||||
}).$mount('#app');
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
import Vue from 'vue';
|
||||
import Vuelidate from 'vuelidate';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import VueDOMPurifyHTML from 'vue-dompurify-html';
|
||||
import VueFormulate from '@braid/vue-formulate';
|
||||
import store from '../widget/store';
|
||||
import App from '../widget/App.vue';
|
||||
import ActionCableConnector from '../widget/helpers/actionCable';
|
||||
import i18n from '../widget/i18n';
|
||||
import {
|
||||
startsWithPlus,
|
||||
isPhoneNumberValidWithDialCode,
|
||||
} from 'shared/helpers/Validators';
|
||||
import router from '../widget/router';
|
||||
import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
|
||||
const PhoneInput = () => import('../widget/components/Form/PhoneInput');
|
||||
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(Vuelidate);
|
||||
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
|
||||
const i18nConfig = new VueI18n({
|
||||
locale: 'en',
|
||||
messages: i18n,
|
||||
});
|
||||
Vue.use(VueFormulate, {
|
||||
library: {
|
||||
phoneInput: {
|
||||
classification: 'number',
|
||||
component: PhoneInput,
|
||||
slotProps: {
|
||||
component: ['placeholder', 'hasErrorInPhoneInput'],
|
||||
},
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
startsWithPlus: ({ value }) => startsWithPlus(value),
|
||||
isValidPhoneNumber: ({ value }) => isPhoneNumberValidWithDialCode(value),
|
||||
},
|
||||
classes: {
|
||||
outer: 'mb-2 wrapper',
|
||||
error: 'text-red-400 mt-2 text-xs leading-3 font-medium',
|
||||
},
|
||||
});
|
||||
// Event Bus
|
||||
window.bus = new Vue();
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
window.onload = () => {
|
||||
window.WOOT_WIDGET = new Vue({
|
||||
router,
|
||||
store,
|
||||
i18n: i18nConfig,
|
||||
render: h => h(App),
|
||||
}).$mount('#app');
|
||||
|
||||
window.actionCable = new ActionCableConnector(
|
||||
window.WOOT_WIDGET,
|
||||
window.chatwootPubsubToken
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user