2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2021-11-11 13:45:15 +00:00
|
|
|
import Vue from 'vue';
|
2020-02-06 11:46:59 +00:00
|
|
|
import VueClipboard from 'vue-clipboard2';
|
2022-09-08 15:11:09 +01:00
|
|
|
import VueSanitize from 'vue-sanitize';
|
2022-11-02 15:25:44 +00:00
|
|
|
import { createPinia, PiniaVuePlugin } from 'pinia';
|
2019-10-28 17:33:06 +00:00
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
import App from './App.vue';
|
2019-10-28 13:27:12 +00:00
|
|
|
import { router } from './router';
|
|
|
|
import { store } from './store';
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
import { Size } from '@/utils/bytesSize';
|
|
|
|
import { NotificatorPlugin } from '@/utils/plugins/notificator';
|
|
|
|
|
2021-09-22 10:20:03 +01:00
|
|
|
window['VueNextTick'] = function(callback) {
|
|
|
|
return Vue.nextTick(callback);
|
|
|
|
};
|
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
Vue.config.devtools = true;
|
|
|
|
Vue.config.performance = true;
|
2018-11-05 15:26:18 +00:00
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
2022-04-07 12:04:24 +01:00
|
|
|
Vue.use(new NotificatorPlugin(store));
|
2020-02-06 11:46:59 +00:00
|
|
|
Vue.use(VueClipboard);
|
2022-07-01 19:26:59 +01:00
|
|
|
Vue.use(VueSanitize);
|
2022-11-02 15:25:44 +00:00
|
|
|
Vue.use(PiniaVuePlugin);
|
|
|
|
const pinia = createPinia();
|
2019-10-28 17:33:06 +00:00
|
|
|
|
2021-11-11 13:45:15 +00:00
|
|
|
/**
|
|
|
|
* Click outside handlers.
|
|
|
|
*/
|
|
|
|
const handlers = new Map();
|
|
|
|
document.addEventListener('click', event => {
|
|
|
|
for (const handler of handlers.values()) {
|
|
|
|
handler(event);
|
|
|
|
}
|
|
|
|
});
|
2019-10-23 18:33:24 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Binds closing action to outside popups area.
|
|
|
|
*/
|
2019-10-23 18:33:24 +01:00
|
|
|
Vue.directive('click-outside', {
|
2021-11-11 13:45:15 +00:00
|
|
|
bind(el, binding) {
|
|
|
|
const handler = event => {
|
|
|
|
if (el !== event.target && !el.contains(event.target)) {
|
|
|
|
binding.value(event);
|
2019-10-23 18:33:24 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-11-11 13:45:15 +00:00
|
|
|
handlers.set(el, handler);
|
2019-10-23 18:33:24 +01:00
|
|
|
},
|
2021-11-11 13:45:15 +00:00
|
|
|
|
|
|
|
unbind(el) {
|
|
|
|
handlers.delete(el);
|
2019-10-23 18:33:24 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-11-25 12:59:41 +00:00
|
|
|
/**
|
2020-02-14 15:35:10 +00:00
|
|
|
* number directive allow user to type only numbers in input.
|
2019-11-25 12:59:41 +00:00
|
|
|
*/
|
|
|
|
Vue.directive('number', {
|
|
|
|
bind (el: HTMLElement) {
|
|
|
|
el.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
|
|
const keyCode = parseInt(e.key);
|
|
|
|
|
|
|
|
if (!isNaN(keyCode) || e.key === 'Delete' || e.key === 'Backspace') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-11-20 13:46:22 +00:00
|
|
|
/**
|
|
|
|
* centsToDollars is a Vue filter that converts amount of cents in dollars string.
|
|
|
|
*/
|
|
|
|
Vue.filter('centsToDollars', (cents: number): string => {
|
2020-05-12 18:16:04 +01:00
|
|
|
return `$${(cents / 100).toFixed(2)}`;
|
2019-11-20 13:46:22 +00:00
|
|
|
});
|
|
|
|
|
2022-06-20 17:53:39 +01:00
|
|
|
/**
|
|
|
|
* Converts bytes to base-10 types.
|
|
|
|
*/
|
|
|
|
Vue.filter('bytesToBase10String', (amountInBytes: number): string => {
|
|
|
|
return `${Size.toBase10String(amountInBytes)}`;
|
|
|
|
});
|
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
new Vue({
|
2019-02-20 13:33:56 +00:00
|
|
|
router,
|
|
|
|
store,
|
2022-11-02 15:25:44 +00:00
|
|
|
pinia,
|
2019-02-20 13:33:56 +00:00
|
|
|
render: (h) => h(App),
|
2018-11-05 15:26:18 +00:00
|
|
|
}).$mount('#app');
|