2020-12-17 17:11:01 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2021-01-21 17:07:09 +00:00
|
|
|
import Vue, { VNode } from 'vue';
|
2021-01-25 18:58:55 +00:00
|
|
|
import VueClipboard from 'vue-clipboard2';
|
2020-12-21 15:54:27 +00:00
|
|
|
import Router from 'vue-router';
|
2021-01-21 17:07:09 +00:00
|
|
|
import { DirectiveBinding } from 'vue/types/options';
|
2020-12-17 17:11:01 +00:00
|
|
|
|
|
|
|
import App from '@/app/App.vue';
|
2020-12-21 15:54:27 +00:00
|
|
|
import { router } from '@/app/router';
|
2020-12-23 17:21:23 +00:00
|
|
|
import { store } from '@/app/store';
|
2021-01-04 18:17:00 +00:00
|
|
|
import { Currency } from '@/app/utils/currency';
|
2021-01-21 17:07:09 +00:00
|
|
|
import { Percentage } from '@/app/utils/percentage';
|
|
|
|
import { Size } from '@/private/memory/size';
|
2020-12-17 17:11:01 +00:00
|
|
|
|
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
2021-01-25 18:58:55 +00:00
|
|
|
Vue.use(VueClipboard);
|
|
|
|
|
2020-12-21 15:54:27 +00:00
|
|
|
Vue.use(Router);
|
|
|
|
|
2021-01-21 17:07:09 +00:00
|
|
|
let clickOutsideEvent: EventListener;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Binds closing action to outside popups area.
|
|
|
|
*/
|
|
|
|
Vue.directive('click-outside', {
|
|
|
|
bind: function (el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
|
|
|
|
clickOutsideEvent = function(event: Event): void {
|
|
|
|
if (el === event.target || el.contains((event.target as Node))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vnode.context) {
|
|
|
|
vnode.context[binding.expression](event);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
document.body.addEventListener('click', clickOutsideEvent);
|
|
|
|
},
|
|
|
|
unbind: function(): void {
|
|
|
|
document.body.removeEventListener('click', clickOutsideEvent);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-01-04 18:17:00 +00:00
|
|
|
/**
|
|
|
|
* centsToDollars is a Vue filter that converts amount of cents in dollars string.
|
|
|
|
*/
|
|
|
|
Vue.filter('centsToDollars', (cents: number): string => {
|
|
|
|
return Currency.dollarsFromCents(cents);
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts bytes to base-10 size.
|
|
|
|
*/
|
|
|
|
Vue.filter('bytesToBase10String', (amountInBytes: number): string => {
|
|
|
|
return Size.toBase10String(amountInBytes);
|
|
|
|
});
|
|
|
|
|
2021-01-21 17:07:09 +00:00
|
|
|
/**
|
|
|
|
* Converts float number to percents.
|
|
|
|
*/
|
|
|
|
Vue.filter('floatToPercentage', (number: number): string => {
|
|
|
|
return Percentage.fromFloat(number);
|
|
|
|
});
|
|
|
|
|
2020-12-21 15:54:27 +00:00
|
|
|
const app = new Vue({
|
|
|
|
router,
|
2020-12-23 17:21:23 +00:00
|
|
|
store,
|
2020-12-17 17:11:01 +00:00
|
|
|
render: (h) => h(App),
|
2020-12-21 15:54:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.$mount('#app');
|