1
1
<template >
2
- <v-container fluid >
2
+ <v-container fluid class = " h-100 mb-5 pb-5 " >
3
3
<v-row align =" center" justify =" center" >
4
4
<v-col cols =" 12" md =" 12" lg =" 12" class =" text-center h-100" >
5
5
<h1 >{{ mainData.LeaderBoardName || "" }}</h1 >
8
8
<v-row align =" center" class =" mt-5" justify =" center" >
9
9
<LeaderBoardFilters @searchData =" filterData" />
10
10
</v-row >
11
- {{ isLoading }}
12
- {{ leaderBoardData }}
13
- <v-row align =" center" class =" mt-5" justify =" center" >
11
+ <v-row
12
+ align =" center"
13
+ v-if =" !isLoading"
14
+ class =" mt-5 mb-5 pb-5"
15
+ justify =" center"
16
+ >
14
17
<LeaderBoardDataTable :searchTerm =" searchTerm" :data =" leaderBoardData" />
15
18
</v-row >
19
+ <v-row align =" center" v-else class =" mt-5" justify =" center" >
20
+ <v-progress-circular indeterminate color =" black" ></v-progress-circular >
21
+ </v-row >
16
22
</v-container >
17
23
</template >
18
24
@@ -36,56 +42,12 @@ export default {
36
42
leaderBoardData: [],
37
43
};
38
44
},
39
- mounted () {
40
- const ref = storage ().ref (` test_folder` );
41
-
42
- ref
43
- .child (" test_file.csv" )
44
- .getDownloadURL ()
45
- .then ((url ) => {
46
- // `url` is the download URL
47
- console .log (url);
48
- // This can be downloaded directly:
49
- const xhr = new XMLHttpRequest ();
50
- xhr .responseType = " blob" ;
51
- xhr .onload = function () {
52
- const blob = xhr .response ;
53
- const myReader = new FileReader ();
54
- myReader .onload = (e ) => {
55
- const csv = e .target .result ;
56
- const allTextLines = csv .split (/ \r\n | \n / );
57
- const lines = [];
58
- for (let i = 0 ; i < allTextLines .length ; i++ ) {
59
- const data = allTextLines[i].split (" ;" );
60
- const tarr = [];
61
- for (let j = 0 ; j < data .length ; j++ ) {
62
- tarr .push (data[j]);
63
- }
64
- lines .push (tarr);
65
- }
66
- const allData = lines .splice (1 , lines .length );
67
- const studentData = [];
68
- allData .forEach ((data ) => {
69
- const dt = data[0 ].split (" ," );
70
- const obj = {
71
- name: dt[0 ],
72
- badges: {
73
- track1: dt[1 ],
74
- track2: dt[2 ],
75
- },
76
- };
77
- studentData .push (obj);
78
- });
79
- this .leaderBoardData = studentData;
80
- this .leaderBoardFilteredData = studentData;
81
- this .isLoading = false ;
82
- };
83
-
84
- myReader .readAsText (blob);
85
- };
86
- xhr .open (" GET" , url);
87
- xhr .send ();
88
- });
45
+ async mounted () {
46
+ const Data = await this .getDataFromCSVFirebase ();
47
+ const sortedData = this .sortByRemainingTracks (Data);
48
+ this .leaderBoardData = sortedData .slice (1 , sortedData .length );
49
+ this .leaderBoardFilteredData = sortedData .slice (1 , sortedData .length );
50
+ this .isLoading = false ;
89
51
},
90
52
methods: {
91
53
filterData ($value ) {
@@ -100,6 +62,56 @@ export default {
100
62
});
101
63
return dta;
102
64
},
65
+ async getDataFromCSVFirebase () {
66
+ const ref = storage ().ref (` test_folder` );
67
+
68
+ const data = await new Promise ((resolve , reject ) => {
69
+ ref
70
+ .child (" test_file.csv" )
71
+ .getDownloadURL ()
72
+ .then ((url ) => {
73
+ // requesting to csv file and get data from that
74
+ const xhr = new XMLHttpRequest ();
75
+ xhr .responseType = " blob" ;
76
+ xhr .onload = function () {
77
+ const blob = xhr .response ;
78
+ const myReader = new FileReader ();
79
+ myReader .onload = (e ) => {
80
+ const csv = e .target .result ;
81
+ const allTextLines = csv .split (/ \r\n | \n / );
82
+ const lines = [];
83
+ for (let i = 0 ; i < allTextLines .length ; i++ ) {
84
+ const data = allTextLines[i].split (" ;" );
85
+ const tarr = [];
86
+ for (let j = 0 ; j < data .length ; j++ ) {
87
+ tarr .push (data[j]);
88
+ }
89
+ lines .push (tarr);
90
+ }
91
+ const allData = lines .splice (1 , lines .length );
92
+ const studentData = [];
93
+ allData .forEach ((data ) => {
94
+ const dt = data[0 ].split (" ," );
95
+ const obj = {
96
+ name: dt[0 ],
97
+ badges: {
98
+ track1: dt[1 ],
99
+ track2: dt[2 ],
100
+ },
101
+ };
102
+ studentData .push (obj);
103
+ });
104
+ resolve (studentData);
105
+ };
106
+
107
+ myReader .readAsText (blob);
108
+ };
109
+ xhr .open (" GET" , url);
110
+ xhr .send ();
111
+ });
112
+ });
113
+ return data;
114
+ },
103
115
},
104
116
};
105
117
</script >
0 commit comments