-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
131 lines (128 loc) · 3.17 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import vuetify from './plugins/vuetify';
import retryTimes = jest.retryTimes;
//import 'roboto-fontface/css/roboto/roboto-fontface.css'
//import '@mdi/font/css/materialdesignicons.css'
Vue.config.productionTip = false
Vue.filter('prettyTimeDate', (str: string) => {
function withZero(num: number): string {
if (num < 10) {
return '0' + num;
}
return String(num);
}
const t = new Date(str);
// this date looks wrong, show dash
if (isNaN(t.getTime())) {
return "-"
}
// event not finished yet / unknown, show dash
if (t.getFullYear() == 1) {
return "-"
}
// show proper date
return withZero(t.getHours()) + ':' + withZero(t.getMinutes()) +
' ' + withZero(t.getDate()) + '/' + withZero(t.getMonth() + 1) + '/' + t.getFullYear();
});
const mixin = {
computed: {
apiUrl(): string {
if (process.env.NODE_ENV === 'production') {
return '';
} else {
return 'http://127.0.0.1:3000';
}
},
lsToken(): string {
return 'authToken';
},
// color templates
// button colors
btnPrimary(): string {
return 'deep-purple darken-3';
},
btnSecondary(): string {
return 'deep-orange darken-4';
},
//checkbox colors
checkPrimary(): string {
return 'deep-purple lighten-3';
},
// chip colors
chipPrimary(): string {
return 'deep-purple lighten-3';
},
// is this element dark?
componentDark(): boolean {
return true
},
// input colors
inputPrimary(): string {
return 'deep-purple lighten-3';
},
// navbar colors
navbarPrimary(): string {
return 'deep-purple';
},
// TODO pagination colors - tables
// https://stackoverflow.com/questions/58936262/how-to-change-default-styling-of-v-data-table-footer
// pagination colors
pagePrimary(): string {
return 'deep-purple darken-3';
},
// picker colors
pickerPrimary(): string {
return 'deep-purple darken-3';
},
// progress bar colors
progressPrimary(): string {
return 'orange';
},
// tab colors
tabPrimary(): string {
return 'deep-purple';
},
// tags color
tagPrimary(): string {
return 'deep-purple';
},
// toolbar colors
toolbarPrimary(): string {
return 'deep-purple';
},
// snackbar colors
snackbarPrimary(): string {
return 'deep-purple darken-3';
},
// switch colors
switchPrimary(): string {
return 'deep-purple darken-3';
},
},
methods: {
urlToThumb(file: string, width: string): string {
// @ts-ignore
if (file.mime === 'image/gif') {
// @ts-ignore
return this.apiUrl + '/img/full/' + file.sha256
}
// @ts-ignore
return this.apiUrl + '/img/thumbs/' + width + '/' + width + '/' + file.sha256
},
isVideo(mime: string) {
return mime === 'video/webm' || mime === 'video/mp4';
},
}
}
Vue.mixin(mixin);
new Vue({
router,
store,
//@ts-ignore
vuetify,
render: h => h(App)
}).$mount('#app')