Skip to content

Commit 106875e

Browse files
completed leaderboard
1 parent 14aa49c commit 106875e

File tree

2 files changed

+68
-57
lines changed

2 files changed

+68
-57
lines changed

src/components/core/Views.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<v-container
33
fluid
4-
class="pa-0 ma-0"
4+
class="pa-0 mb-5 pb-5"
55
:class="this.$vuetify.theme.dark == true ? 'black' : 'white'"
66
>
77
<v-slide-y-reverse-transition>
@@ -21,7 +21,6 @@ export default {
2121
created() {
2222
this.show = true;
2323
},
24-
methods: {
25-
},
24+
methods: {},
2625
};
2726
</script>

src/components/home/StartScreen.vue

+66-54
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<v-container fluid>
2+
<v-container fluid class="h-100 mb-5 pb-5">
33
<v-row align="center" justify="center">
44
<v-col cols="12" md="12" lg="12" class="text-center h-100">
55
<h1>{{ mainData.LeaderBoardName || "" }}</h1>
@@ -8,11 +8,17 @@
88
<v-row align="center" class="mt-5" justify="center">
99
<LeaderBoardFilters @searchData="filterData" />
1010
</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+
>
1417
<LeaderBoardDataTable :searchTerm="searchTerm" :data="leaderBoardData" />
1518
</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>
1622
</v-container>
1723
</template>
1824

@@ -36,56 +42,12 @@ export default {
3642
leaderBoardData: [],
3743
};
3844
},
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;
8951
},
9052
methods: {
9153
filterData($value) {
@@ -100,6 +62,56 @@ export default {
10062
});
10163
return dta;
10264
},
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+
},
103115
},
104116
};
105117
</script>

0 commit comments

Comments
 (0)