From 645fae23f744b21b6ac9b2b44cd5bd4e68734163 Mon Sep 17 00:00:00 2001 From: Curtis Delicata Date: Sat, 30 Jul 2022 15:11:25 +0000 Subject: [PATCH] Add the old plugins for reference --- plugins.old/bookmarksSettingRegister.js | 7 +++ plugins.old/bootEnums.js | 13 ++++++ plugins.old/date-fns/format.js | 9 ++++ plugins.old/date-fns/formatDistance.js | 5 +++ plugins.old/date-fns/i18n.js | 16 +++++++ plugins.old/date-fns/unicode2php.js | 37 ++++++++++++++++ plugins.old/echo.js | 11 +++++ plugins.old/filters.js | 31 +++++++++++++ plugins.old/fontawesome.js | 58 +++++++++++++++++++++++++ plugins.old/i18n.js | 39 +++++++++++++++++ plugins.old/ioRegister.js | 8 ++++ plugins.old/localisationRegister.js | 13 ++++++ plugins.old/notificationsRegister.js | 10 +++++ plugins.old/numberFormat.js | 9 ++++ plugins.old/pRoute.js | 9 ++++ plugins.old/shortNumber.js | 22 ++++++++++ plugins.old/tasksNavbarRegister.js | 7 +++ plugins.old/themesSettingRegister.js | 7 +++ plugins.old/toastr.js | 3 ++ plugins.old/tutorialSettingRegister.js | 8 ++++ plugins.old/usersRegister.js | 7 +++ plugins.old/vue-fb-customer-chat.js | 7 +++ plugins.old/vue-gtag.client.js | 14 ++++++ plugins.old/vue-select.js | 3 ++ plugins.old/vue-stripe.js | 5 +++ plugins.old/vuetify.js | 10 +++++ 26 files changed, 368 insertions(+) create mode 100644 plugins.old/bookmarksSettingRegister.js create mode 100644 plugins.old/bootEnums.js create mode 100644 plugins.old/date-fns/format.js create mode 100644 plugins.old/date-fns/formatDistance.js create mode 100644 plugins.old/date-fns/i18n.js create mode 100644 plugins.old/date-fns/unicode2php.js create mode 100644 plugins.old/echo.js create mode 100644 plugins.old/filters.js create mode 100644 plugins.old/fontawesome.js create mode 100644 plugins.old/i18n.js create mode 100644 plugins.old/ioRegister.js create mode 100644 plugins.old/localisationRegister.js create mode 100644 plugins.old/notificationsRegister.js create mode 100644 plugins.old/numberFormat.js create mode 100644 plugins.old/pRoute.js create mode 100644 plugins.old/shortNumber.js create mode 100644 plugins.old/tasksNavbarRegister.js create mode 100644 plugins.old/themesSettingRegister.js create mode 100644 plugins.old/toastr.js create mode 100644 plugins.old/tutorialSettingRegister.js create mode 100644 plugins.old/usersRegister.js create mode 100644 plugins.old/vue-fb-customer-chat.js create mode 100644 plugins.old/vue-gtag.client.js create mode 100644 plugins.old/vue-select.js create mode 100644 plugins.old/vue-stripe.js create mode 100644 plugins.old/vuetify.js diff --git a/plugins.old/bookmarksSettingRegister.js b/plugins.old/bookmarksSettingRegister.js new file mode 100644 index 00000000..3bbd1d8e --- /dev/null +++ b/plugins.old/bookmarksSettingRegister.js @@ -0,0 +1,7 @@ +import BookmarksState from '~/components/bookmarks/bulma/components/settings/BookmarksState.vue'; + +Vue.component('setting-bookmarks-state', BookmarksState); + +export default ({ store }, inject) => { + store.commit('layout/settings/registerItem', {component: 'setting-bookmarks-state', order: 500}) +} diff --git a/plugins.old/bootEnums.js b/plugins.old/bootEnums.js new file mode 100644 index 00000000..ca10bdba --- /dev/null +++ b/plugins.old/bootEnums.js @@ -0,0 +1,13 @@ +import Enum from '@enso-ui/enums' + +export default (context, inject) => { + inject('bootEnums', (enums, i18n) => { + const obj = {} + + Object.keys(enums).forEach( + (enumName) => (obj[enumName] = new Enum(enums[enumName], i18n)) + ) + + return obj + }) +} diff --git a/plugins.old/date-fns/format.js b/plugins.old/date-fns/format.js new file mode 100644 index 00000000..1687bc89 --- /dev/null +++ b/plugins.old/date-fns/format.js @@ -0,0 +1,9 @@ +import format from '@enso-ui/date/src/format.js'; + +export default ({ store }, inject) => { + inject('format', (date, formatStr = null) => format( + date, + formatStr || store.state.meta.dateFormat, + store.state.preferences.global.lang, + )) +} diff --git a/plugins.old/date-fns/formatDistance.js b/plugins.old/date-fns/formatDistance.js new file mode 100644 index 00000000..8fd4d839 --- /dev/null +++ b/plugins.old/date-fns/formatDistance.js @@ -0,0 +1,5 @@ +import formatDistance from '@enso-ui/date/src/formatDistance.js'; + +export default ({ store }, inject) => { + inject('formatDistance', date => formatDistance(date, store.state.preferences.global.lang)) +} \ No newline at end of file diff --git a/plugins.old/date-fns/i18n.js b/plugins.old/date-fns/i18n.js new file mode 100644 index 00000000..117b2092 --- /dev/null +++ b/plugins.old/date-fns/i18n.js @@ -0,0 +1,16 @@ +import ro from 'date-fns/esm/locale/ro'; +import en from 'date-fns/esm/locale/en-US/'; +import de from 'date-fns/esm/locale/de'; +import nl from 'date-fns/esm/locale/nl'; +import fr from 'date-fns/esm/locale/fr'; +import pt from 'date-fns/esm/locale/pt'; +// import ar from 'date-fns/esm/locale/ar'; +// import mn from 'date-fns/esm/locale/mn'; +import hu from 'date-fns/esm/locale/hu'; +import es from 'date-fns/esm/locale/es'; + +const i18n = { + ro, en, de, nl, fr, br: pt, ar: en, mn: en, hu, es +}; + +export default i18n; diff --git a/plugins.old/date-fns/unicode2php.js b/plugins.old/date-fns/unicode2php.js new file mode 100644 index 00000000..45f9c239 --- /dev/null +++ b/plugins.old/date-fns/unicode2php.js @@ -0,0 +1,37 @@ +const map = [ + { replace: 'Y', with: 'yyyy' }, // 1999 + { replace: 'y', with: 'yy' }, // 99 + { replace: 'Y', with: 'y' }, // 1999 + { replace: 'F', with: 'MMMM' }, // January + { replace: 'M', with: 'MMM' }, // Jan + { replace: 'm', with: 'MM' }, // 01 + { replace: 'd', with: 'dd' }, // 19 + { replace: 'j', with: 'd' }, // + { replace: 'l', with: 'EEEE' }, // Tuesday + { replace: 'D', with: 'EEE' }, // Tue + { replace: 'D', with: 'EE' }, // Tue + { replace: 'a', with: 'a' }, // Am/PM + { replace: 'p', with: 'p' }, // Am/PM + { replace: 'H', with: 'HH' }, // 24-hour with leading zeros + { replace: 'G', with: 'H' }, // 24-hour without leading zeros + { replace: 'h', with: 'h' }, // 12-hour with leading zeros + { replace: 'g', with: 'K' }, // 12-hour without leading zero + { replace: 'i', with: 'mm' }, // Minutes with leading zeros + { replace: 's', with: 'ss' }, // Seconds, with leading zeros + { replace: 'T', with: 'zz' }, // Timezone abbreviation + { replace: 'e', with: 'zzzz' }, // Timezone +]; + + +const segments = formatStr => formatStr + .split(new RegExp([' ', '-', '/', ':', ',', '[.]'].join('|'), '')) + .sort((a, b) => b.length - a.length); // ASC -> a - b; DESC -> b - a + +const mapping = segment => map + .find(({ replace }) => replace === segment).with; + +const unicode2PHP = formatStr => segments(formatStr) + .reduce((string, segment) => string + .replace(segment, mapping(segment)) || '', formatStr); + +export default unicode2PHP; diff --git a/plugins.old/echo.js b/plugins.old/echo.js new file mode 100644 index 00000000..126a77f2 --- /dev/null +++ b/plugins.old/echo.js @@ -0,0 +1,11 @@ +window.io = require('socket.io-client') +import Echo from 'laravel-echo' + +export default ({ app, env }, inject) => { + const echo = new Echo({ + broadcaster: 'socket.io', + host: `http://localhost:3000`, + }) + + inject('echo', echo) +} diff --git a/plugins.old/filters.js b/plugins.old/filters.js new file mode 100644 index 00000000..2e338367 --- /dev/null +++ b/plugins.old/filters.js @@ -0,0 +1,31 @@ +const SI = ['', 'k', 'M', 'G', 'T', 'P', 'E']; +export default ({ store }, inject) => { + Vue.filter('numberFormat', (value, decimals = 3) => new Intl.NumberFormat( + store.state.preferences.global.lang, { + style: 'decimal', + minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + }, + ).format(value)); + + Vue.filter('shortNumber', (number, precision = 2) => { + number = Number.parseFloat(number); + + if (number < 1) { + return number; + } + + const tier = Math.floor(Math.log10(number) / 3); + + if (tier === 0) { + return number; + } + + const suffix = SI[tier]; + const scale = 10 ** (tier * 3); + const scaled = number / scale; + const formatted = Number(scaled.toFixed(precision)) + suffix; + + return formatted; + }); +} diff --git a/plugins.old/fontawesome.js b/plugins.old/fontawesome.js new file mode 100644 index 00000000..35035ceb --- /dev/null +++ b/plugins.old/fontawesome.js @@ -0,0 +1,58 @@ +import { library } from '@fortawesome/fontawesome-svg-core'; +import { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText } from '@fortawesome/vue-fontawesome'; +import { + faListAlt, + faUpload, + faShoePrints, + faPuzzlePiece, + faCalendarAlt, + faFolderOpen, + faVideo, + faUsersCog, + faBook, + faUsers, + faUniversalAccess, + faExclamationTriangle, + faUserTie, + faTerminal, + faLanguage, + faUser, + faBuilding, + faCloudUploadAlt, + faTasks, + faTachometerAlt, + faSlidersH, + faList +} from '@fortawesome/free-solid-svg-icons'; +import { faGithub, faGoogle } from '@fortawesome/free-brands-svg-icons'; + +library.add( + faListAlt, + faGithub, + faUpload, + faShoePrints, + faGoogle, + faPuzzlePiece, + faCalendarAlt, + faFolderOpen, + faVideo, + faUsersCog, + faBook, + faUsers, + faUniversalAccess, + faExclamationTriangle, + faUserTie, + faTerminal, + faLanguage, + faUser, + faBuilding, + faCloudUploadAlt, + faTasks, + faTachometerAlt, + faSlidersH, + faList +); + +Vue.component('fa', FontAwesomeIcon); +Vue.component('fal', FontAwesomeLayers); +Vue.component('falt', FontAwesomeLayersText); diff --git a/plugins.old/i18n.js b/plugins.old/i18n.js new file mode 100644 index 00000000..c265fd6b --- /dev/null +++ b/plugins.old/i18n.js @@ -0,0 +1,39 @@ +export default ({ store }, inject) => { + inject('i18n', (key, params = null) => { + if (key === null || key === '' || typeof key === 'undefined') { + return null + } + + if (!store.getters['localisation/ready']) { + return key + } + + let translation = store.getters['localisation/i18n'](key) + + if (typeof translation === 'undefined' || translation === null) { + translation = key + + if (store.state.localisation.keyCollector) { + store.commit('localisation/addMissingKey', key) + } + } + + return !!params && typeof params === 'object' + ? translation.replace(/:(\w*)/g, (e, key) => { + if (typeof params[key.toLowerCase()] === 'undefined') { + return key + } + + const param = params[key.toLowerCase()] + + if (key === key.toUpperCase()) { + return param.toUpperCase() + } + + return key[0] === key[0].toUpperCase() + ? param.charAt(0).toUpperCase() + param.slice(1) + : param + }) + : translation || key + }) +} diff --git a/plugins.old/ioRegister.js b/plugins.old/ioRegister.js new file mode 100644 index 00000000..b88fd518 --- /dev/null +++ b/plugins.old/ioRegister.js @@ -0,0 +1,8 @@ +import IO from '~/components/io/bulma/components/navbar/IO.vue'; + + +Vue.component('navbar-io', IO); + +export default ({ store }, inject) => { + store.commit('layout/navbar/registerItem', { component: 'navbar-io', order: 200, permission: undefined }); +} diff --git a/plugins.old/localisationRegister.js b/plugins.old/localisationRegister.js new file mode 100644 index 00000000..bc27f188 --- /dev/null +++ b/plugins.old/localisationRegister.js @@ -0,0 +1,13 @@ +import MissingKey from '~/components/localisation/bulma/components/navbar/MissingKeys.vue'; +import KeyCollector from '~/components/localisation/bulma/components/settings/KeyCollector.vue'; +import LanguageSelector from '~/components/localisation/bulma/components/settings/LanguageSelector.vue'; + +Vue.component('navbar-missing-key', MissingKey); +Vue.component('setting-key-collector', KeyCollector); +Vue.component('setting-language-selector', LanguageSelector); + +export default ({ store }, inject) => { + store.commit('layout/settings/registerItem', { component: 'setting-language-selector', order: 100 }) + store.commit('layout/settings/registerItem', { component: 'setting-key-collector', order: 600 }) + store.commit('layout/navbar/registerItem', { component: 'navbar-missing-key', order: 100, permission: undefined }); +} diff --git a/plugins.old/notificationsRegister.js b/plugins.old/notificationsRegister.js new file mode 100644 index 00000000..bfc0c6db --- /dev/null +++ b/plugins.old/notificationsRegister.js @@ -0,0 +1,10 @@ +import Notification from '~/components/notifications/bulma/components/navbar/Notifications.vue'; +import ToastPosition from '~/components/notifications/bulma/components/settings/ToastrPosition.vue'; + +Vue.component('navbar-notification', Notification); +Vue.component('setting-toaster-position', ToastPosition); + +export default ({ store }, inject) => { + store.commit('layout/settings/registerItem', { component: 'setting-toaster-position', order: 300 }) + store.commit('layout/navbar/registerItem', { component: 'navbar-notification', order: 300, permission: 'core.notifications.count' }); +} diff --git a/plugins.old/numberFormat.js b/plugins.old/numberFormat.js new file mode 100644 index 00000000..e012f3d5 --- /dev/null +++ b/plugins.old/numberFormat.js @@ -0,0 +1,9 @@ +export default ({ store }, inject) => { + inject('numberFormat', (value, decimals = 3) => new Intl.NumberFormat( + store.state.preferences.global.lang, { + style: 'decimal', + minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + }, + ).format(value)) +} \ No newline at end of file diff --git a/plugins.old/pRoute.js b/plugins.old/pRoute.js new file mode 100644 index 00000000..b9c1f127 --- /dev/null +++ b/plugins.old/pRoute.js @@ -0,0 +1,9 @@ +import RouteMapper from '@enso-ui/route-mapper' + +export default ({ store }, inject) => { + inject('pRoute', (name, params, absolute) => { + const { meta, routes } = store.state + + return new RouteMapper(meta.appUrl, routes).get(name, params, absolute) + }) +} diff --git a/plugins.old/shortNumber.js b/plugins.old/shortNumber.js new file mode 100644 index 00000000..d73648ef --- /dev/null +++ b/plugins.old/shortNumber.js @@ -0,0 +1,22 @@ +export default (context, inject) => { + inject('shortNumber', (number, precision = 2) => { + number = Number.parseFloat(number); + + if (number < 1) { + return number; + } + + const tier = Math.floor(Math.log10(number) / 3); + + if (tier === 0) { + return number; + } + + const suffix = SI[tier]; + const scale = 10 ** (tier * 3); + const scaled = number / scale; + const formatted = Number(scaled.toFixed(precision)) + suffix; + + return formatted; + }); +} \ No newline at end of file diff --git a/plugins.old/tasksNavbarRegister.js b/plugins.old/tasksNavbarRegister.js new file mode 100644 index 00000000..c9dbe145 --- /dev/null +++ b/plugins.old/tasksNavbarRegister.js @@ -0,0 +1,7 @@ +import Tasks from '~/components/tasks/bulma/components/navbar/Tasks.vue'; + +Vue.component('navbar-tasks', Tasks); + +export default ({ store }, inject) => { + store.commit('layout/navbar/registerItem', { component: 'navbar-tasks', order: 150, permission: 'tasks.count' }); +} diff --git a/plugins.old/themesSettingRegister.js b/plugins.old/themesSettingRegister.js new file mode 100644 index 00000000..125fa28d --- /dev/null +++ b/plugins.old/themesSettingRegister.js @@ -0,0 +1,7 @@ +import ThemeSelector from '~/components/themes/bulma/components/settings/ThemeSelector.vue'; + +Vue.component('setting-theme-selector', ThemeSelector); + +export default ({ store }, inject) => { + store.commit('layout/settings/registerItem', {component: 'setting-theme-selector', order: 200}) +} diff --git a/plugins.old/toastr.js b/plugins.old/toastr.js new file mode 100644 index 00000000..d492b59d --- /dev/null +++ b/plugins.old/toastr.js @@ -0,0 +1,3 @@ +import toastr from '@enso-ui/toastr'; + +Vue.prototype.$toastr = toastr; diff --git a/plugins.old/tutorialSettingRegister.js b/plugins.old/tutorialSettingRegister.js new file mode 100644 index 00000000..c18438a3 --- /dev/null +++ b/plugins.old/tutorialSettingRegister.js @@ -0,0 +1,8 @@ +//import Vue from 'vue'; +//import Tutorial from '~/components/tutorials/bulma/components/settings/Tutorial.vue'; + +//Vue.component('setting-tutorials', Tutorial); +// +//export default ({ store }, inject) => { +// store.commit('layout/settings/registerItem', { component: 'setting-tutorials', order: 350 }) +//} \ No newline at end of file diff --git a/plugins.old/usersRegister.js b/plugins.old/usersRegister.js new file mode 100644 index 00000000..daebbe77 --- /dev/null +++ b/plugins.old/usersRegister.js @@ -0,0 +1,7 @@ +import ProfileController from '~/components/users/bulma/components/navbar/ProfileControl.vue'; + +Vue.component('navbar-profile-controller', ProfileController); + +export default ({ store }, inject) => { + store.commit('layout/navbar/registerItem', { component: 'navbar-profile-controller', order: 400, permission: undefined }); +} diff --git a/plugins.old/vue-fb-customer-chat.js b/plugins.old/vue-fb-customer-chat.js new file mode 100644 index 00000000..34003770 --- /dev/null +++ b/plugins.old/vue-fb-customer-chat.js @@ -0,0 +1,7 @@ +import VueFbCustomerChat from 'vue-fb-customer-chat' + +Vue.use(VueFbCustomerChat, { + page_id: 2089062604669120, // change 'null' to your Facebook Page ID, + theme_color: '#333333', // theme color in HEX + locale: 'en_US', // default 'en_US' +}) diff --git a/plugins.old/vue-gtag.client.js b/plugins.old/vue-gtag.client.js new file mode 100644 index 00000000..b7938234 --- /dev/null +++ b/plugins.old/vue-gtag.client.js @@ -0,0 +1,14 @@ +import { defineNuxtPlugin } from '#app' +import VueGtag from 'vue-gtag-next' + +export default defineNuxtPlugin((nuxtApp) => { + const getGDPR = localStorage.getItem('GDPR:accepted'); + nuxtApp.vueApp.use(VueGtag, { + property: { + id: 'UA-208194369-1' + }, + appName: 'Family Tree 365', + enabled: getGDPR === 'true', + pageTrackerScreenviewEnabled: true + }, nuxtApp.vueApp.router); +}); diff --git a/plugins.old/vue-select.js b/plugins.old/vue-select.js new file mode 100644 index 00000000..52586280 --- /dev/null +++ b/plugins.old/vue-select.js @@ -0,0 +1,3 @@ +import vSelect from 'vue-select' +import 'vue-select/dist/vue-select.css' +Vue.component('vue-select', vSelect) diff --git a/plugins.old/vue-stripe.js b/plugins.old/vue-stripe.js new file mode 100644 index 00000000..cb5cf87c --- /dev/null +++ b/plugins.old/vue-stripe.js @@ -0,0 +1,5 @@ +import { StripeCheckout } from '@vue-stripe/vue-stripe'; + +export default () => { + Vue.component('StripeCheckout', StripeCheckout); +}; diff --git a/plugins.old/vuetify.js b/plugins.old/vuetify.js new file mode 100644 index 00000000..74f5c479 --- /dev/null +++ b/plugins.old/vuetify.js @@ -0,0 +1,10 @@ +// src/plugins/vuetify.js + +import Vuetify from 'vuetify' +import 'vuetify/dist/vuetify.min.css' + +Vue.use(Vuetify) + +const opts = {} + +export default new Vuetify(opts)