master: change repo

This commit is contained in:
Julien Calixte
2019-08-22 11:50:32 +02:00
commit dbd63d341c
263 changed files with 26153 additions and 0 deletions

7
src/utils/bus-event.ts Normal file
View File

@@ -0,0 +1,7 @@
import Vue from 'vue'
export default new Vue()
export const ONLINE: string = 'ONLINE'
export const OFFLINE: string = 'OFFLINE'
export const SYNC: string = 'SYNC'

2
src/utils/constants.ts Normal file
View File

@@ -0,0 +1,2 @@
export const COFFEE_LINK = 'https://ko-fi.com/juliencalixte'
export const BRAVE_LINK = 'https://brave.com/vaq785'

48
src/utils/filters.ts Normal file
View File

@@ -0,0 +1,48 @@
import ICurrency from '@/models/ICurrency'
export const money = (
value: number,
currency: ICurrency | null | undefined,
country: string = 'fr-FR'
): string => {
if (!currency) {
return value.toString()
}
return new Intl.NumberFormat(country, {
style: 'currency',
currency: currency.code,
minimumFractionDigits: 2
}).format(value)
}
export const moneypad = (
value: number,
currency: ICurrency | null | undefined
): string => {
const m = money(value, currency)
const s: string[] = m.split('\xa0')
const cur: string | undefined = s.pop()
return `${s.join('\xa0')}\xa0${(cur || '').padEnd(3, '\xa0')}`
}
export const date = (value: string, country: string = 'fr-FR') => {
return new Intl.DateTimeFormat(country).format(new Date(value))
}
export const fulldate = (value: string, country: string = 'fr-FR') => {
return new Intl.DateTimeFormat(country, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(new Date(value))
}
export default {
money,
moneypad,
date,
fulldate
} as { [key: string]: (...args: any[]) => any }

6
src/utils/format-date.ts Normal file
View File

@@ -0,0 +1,6 @@
export default (date: Date | string): string => {
if (date instanceof Date) {
return date.toISOString().split('T')[0]
}
return date.split('T')[0]
}

3
src/utils/hooks.ts Normal file
View File

@@ -0,0 +1,3 @@
import { Component } from 'vue-property-decorator'
Component.registerHooks(['beforeRouteEnter', 'beforeRouteUpdate'])

76
src/utils/icons.ts Normal file
View File

@@ -0,0 +1,76 @@
import Vue from 'vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faBalanceScale,
faCheck,
faChevronDown,
faChevronRight,
faCog,
faCircle,
faClock,
faToriiGate,
faUtensils,
faSubway,
faHome,
faGift,
faDollarSign,
faEuroSign,
faExchangeAlt,
faInbox,
faEquals,
faMinus,
faInfinity,
faHandHoldingUsd,
faShoppingBasket,
faMobile,
faMoneyBillWave,
faPenSquare,
faPlus,
faTag,
faSignal,
faSyncAlt,
faUser,
faUsers,
faUserLock,
faTimes,
faTheaterMasks
} from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(
faBalanceScale,
faCheck,
faChevronDown,
faChevronRight,
faCog,
faCircle,
faClock,
faToriiGate,
faUtensils,
faSubway,
faHome,
faGift,
faDollarSign,
faEuroSign,
faExchangeAlt,
faInbox,
faEquals,
faMinus,
faInfinity,
faHandHoldingUsd,
faShoppingBasket,
faMobile,
faMoneyBillWave,
faPenSquare,
faPlus,
faTag,
faSignal,
faSyncAlt,
faUser,
faUsers,
faUserLock,
faTimes,
faTheaterMasks
)
Vue.component('awe-icon', FontAwesomeIcon)

66
src/utils/index.ts Normal file
View File

@@ -0,0 +1,66 @@
import { debounce } from 'lodash-es'
import notif from '@/utils/notif'
import IColor from '@/models/IColor'
import colors from '@/data/colors'
export const confirmation = debounce(
(message: string) => {
notif.confirm(message)
},
3000,
{
leading: true
}
)
export const alertMessage = debounce(
(message: string) => {
notif.alert(message)
},
3000,
{
leading: true
}
)
export const primary: string = '#3f4fa6'
export const main: string = '#2c3e50'
export const slug = (text: string): string => {
if (!text) {
return ''
}
return text
.toString()
.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, '') // Trim - from end of text
}
export const findDarkValue = (value: string): string | null => {
if (!value) {
return null
}
const find: IColor | undefined = colors.find(
(color: IColor) => color.value === value
)
return find && find.darkValue ? find.darkValue : null
}
export const toHex = (text: string): string => {
return (
[...text]
// tslint:disable-next-line: variable-name
.map((_c: string, i: number) => Number(text.charCodeAt(i)).toString(16))
.join('')
)
}
export const getCurrentPosition = (options = {}): Promise<Position> => {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject, options)
})
}

21
src/utils/network.ts Normal file
View File

@@ -0,0 +1,21 @@
declare var navigator: any
export const hasGoodNetwork = (): boolean => {
const connection =
navigator.connection ||
navigator.mozConnection ||
navigator.webkitConnection
if (connection) {
if (connection.effectiveType) {
const goodNetworks: string[] = ['3g', '4g']
return goodNetworks.includes(connection.effectiveType)
} else {
const highBandwidth: boolean =
connection.metered && (connection.bandwidth || 0) > 2
return highBandwidth
}
}
return true
}

3
src/utils/notif.ts Normal file
View File

@@ -0,0 +1,3 @@
declare const Notyf: any
export default new Notyf()

125
src/utils/notyf.js Normal file
View File

@@ -0,0 +1,125 @@
(function () {
var $this = window
$this.Notyf = function () {
//List of notifications currently active
this.notifications = [];
var defaults = {
delay: 2000,
alertIcon: 'notyf__icon--alert',
confirmIcon: 'notyf__icon--confirm'
}
if (arguments[0] && typeof arguments[0] == "object") {
this.options = extendDefaults(defaults, arguments[0]);
} else {
this.options = defaults;
}
//Creates the main notifications container
var docFrag = document.createDocumentFragment();
var notyfContainer = document.createElement('div');
notyfContainer.className = 'notyf';
docFrag.appendChild(notyfContainer);
document.body.appendChild(docFrag);
this.container = notyfContainer;
//Stores which transitionEnd event this browser supports
this.animationEnd = animationEndSelect();
}
//---------- Public methods ---------------
/**
* Shows an alert card
*/
$this.Notyf.prototype.alert = function (alertMessage) {
var card = buildNotificationCard.call(this, alertMessage, this.options.alertIcon);
card.className += ' notyf--alert';
this.container.appendChild(card);
this.notifications.push(card);
}
/**
* Shows a confirm card
*/
$this.Notyf.prototype.confirm = function (alertMessage) {
var card = buildNotificationCard.call(this, alertMessage, this.options.confirmIcon);
card.className += ' notyf--confirm';
this.container.appendChild(card);
this.notifications.push(card);
}
//---------- Private methods ---------------
/**
* Populates the source object with the value from the same keys found in destination
*/
function extendDefaults(source, destination) {
for (const property in destination) {
//Avoid asigning inherited properties of destination, only asign to source the destination own properties
if (destination.hasOwnProperty(property)) {
source[property] = destination[property];
}
}
return source;
}
/**
* Creates a generic card with the param message. Returns a document fragment.
*/
function buildNotificationCard(messageText, iconClass) {
//Card wrapper
var notification = document.createElement('div');
notification.className = 'notyf__toast';
var wrapper = document.createElement('div');
wrapper.className = 'notyf__wrapper';
var iconContainer = document.createElement('div');
iconContainer.className = 'notyf__icon';
var icon = document.createElement('i');
icon.className = iconClass;
var message = document.createElement('div');
message.className = 'notyf__message';
message.innerHTML = messageText;
//Build the card
iconContainer.appendChild(icon);
wrapper.appendChild(iconContainer);
wrapper.appendChild(message);
notification.appendChild(wrapper);
var _this = this;
setTimeout(function () {
notification.className += " notyf--disappear";
notification.addEventListener(_this.animationEnd, function (event) {
event.target == notification && _this.container.removeChild(notification);
});
var index = _this.notifications.indexOf(notification);
_this.notifications.splice(index, 1);
}, _this.options.delay);
return notification;
}
// Determine which animationend event is supported
function animationEndSelect() {
var t;
var el = document.createElement('fake');
var transitions = {
'transition': 'animationend',
'OTransition': 'oAnimationEnd',
'MozTransition': 'animationend',
'WebkitTransition': 'webkitAnimationEnd'
}
for (t in transitions) {
if (el.style[t] !== undefined) {
return transitions[t];
}
}
}
})();

View File

@@ -0,0 +1,12 @@
const ROOT: string =
process.env.NODE_ENV === 'production'
? 'https://vaquant.azurewebsites.net/api'
: 'http://localhost:7071/api'
const setAccountKeyCode: string =
'fIisMFMT5v0bUKlpJloiv6NomppqEXE06rB9/c04anacRuqTCSFgWw=='
export const SET_KEY_URL: string = `${ROOT}/setaccountkey?code=${setAccountKeyCode}`
const getAccountKeyCode: string =
'k1x7Ct7EnShWttLoUHbsRM0T2lN23GDwzvsAsTSqBf5qMINQGxOeYQ=='
export const GET_KEY_URL: string = `${ROOT}/getaccountkey?code=${getAccountKeyCode}`

2
src/utils/smtp.js Normal file
View File

@@ -0,0 +1,2 @@
/* SmtpJS.com - v2.0.1 */
Email = { send: function (e, o, t, n, a, s, r, c) { var d = Math.floor(1e6 * Math.random() + 1), i = "From=" + e; i += "&to=" + o, i += "&Subject=" + encodeURIComponent(t), i += "&Body=" + encodeURIComponent(n), void 0 == a.token ? (i += "&Host=" + a, i += "&Username=" + s, i += "&Password=" + r, i += "&Action=Send") : (i += "&SecureToken=" + a.token, i += "&Action=SendFromStored", c = a.callback), i += "&cachebuster=" + d, Email.ajaxPost("https://smtpjs.com/v2/smtp.aspx?", i, c) }, sendWithAttachment: function (e, o, t, n, a, s, r, c, d) { var i = Math.floor(1e6 * Math.random() + 1), m = "From=" + e; m += "&to=" + o, m += "&Subject=" + encodeURIComponent(t), m += "&Body=" + encodeURIComponent(n), m += "&Attachment=" + encodeURIComponent(c), void 0 == a.token ? (m += "&Host=" + a, m += "&Username=" + s, m += "&Password=" + r, m += "&Action=Send") : (m += "&SecureToken=" + a.token, m += "&Action=SendFromStored"), m += "&cachebuster=" + i, Email.ajaxPost("https://smtpjs.com/v2/smtp.aspx?", m, d) }, ajaxPost: function (e, o, t) { var n = Email.createCORSRequest("POST", e); n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onload = function () { var e = n.responseText; void 0 != t && t(e) }, n.send(o) }, ajax: function (e, o) { var t = Email.createCORSRequest("GET", e); t.onload = function () { var e = t.responseText; void 0 != o && o(e) }, t.send() }, createCORSRequest: function (e, o) { var t = new XMLHttpRequest; return "withCredentials" in t ? t.open(e, o, !0) : "undefined" != typeof XDomainRequest ? (t = new XDomainRequest).open(e, o) : t = null, t } };