-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
437 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,18 @@ | |
<h1 class="heading">Hyphen-Hacks 2020</h1> | ||
</div> | ||
<router-link class="nav__link" :class="{active: $route.path == '/'}" to="/">Statistics</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/review'}" to="/review">Applications in review</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/review'}" to="/review">Applications in review | ||
<span class="notification" v-if="$store.getters.applications.length > 0"><i class="fas fa-bell"></i>{{$store.getters.applications.length}}</span></router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/mentors'}" to="/mentors">Mentors</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/attendees'}" to="/attendees">Attendees</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/volunteers'}" to="/volunteers">Volunteers</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/notifications'}" to="/notifications">Notifications</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/schedule'}" to="/schedule">Schedule</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/attendees'}" to="/attendees">Attendees | ||
</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/volunteers'}" to="/volunteers">Volunteers | ||
</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/notifications'}" to="/notifications"> | ||
Notifications | ||
</router-link> | ||
<router-link class="nav__link" :class="{active: $route.path == '/schedule'}" to="/schedule">Schedule | ||
</router-link> | ||
<div class="nav__user"> | ||
<p class="bold">{{user.displayName}}</p> | ||
<p>{{user.email}}</p> | ||
|
@@ -25,9 +31,12 @@ | |
<div class="card"> | ||
<h1 class="heading">Login</h1> | ||
<p>Please login to access the Hyphen-Hacks 2020 Admin Dashboard</p> | ||
<p>For security reasons, please use your Hyphen-Hacks email address. If you need help signing in please email Ronan | ||
<p>For security reasons, please use your Hyphen-Hacks email address. If you need help signing in please email | ||
Ronan | ||
<a href="mailto:[email protected]">[email protected]</a></p> | ||
<p>Non Hyphen-Hacks team members need to be authorized directly, please email <a href="mailto:[email protected]">Ronan</a> from the email you would like authorized. (this can take up to 24 hours)</p> | ||
<p>Non Hyphen-Hacks team members need to be authorized directly, please email <a | ||
href="mailto:[email protected]">Ronan</a> from the email you would like authorized. (this can | ||
take up to 24 hours)</p> | ||
<button @click="login" class="btn mt-1"><i class="fa fa-google"></i>Login With Google</button> | ||
</div> | ||
|
||
|
@@ -51,21 +60,22 @@ | |
</div> | ||
<div class="loader__row"> | ||
|
||
<p>Something not working right? Get tech support <a href="mailto:[email protected]">[email protected]</a></p> | ||
<p>Something not working right? Get tech support <a href="mailto:[email protected]">[email protected]</a> | ||
</p> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</template> | ||
<script> | ||
let focus, blur, tokenRefresh | ||
export default { | ||
name: "App Container", | ||
name: "AppContainer", | ||
data() { | ||
return { | ||
version: require("../package").version, | ||
firebaseLoaded: false, | ||
version: require("../package").version, | ||
firebaseLoaded: false, | ||
noAccess: false | ||
} | ||
}, | ||
|
@@ -75,6 +85,24 @@ firebaseLoaded: false, | |
} | ||
}, | ||
methods: { | ||
loadBasicData() { | ||
if (this.$route.path != "/review") { | ||
fetch(this.$store.getters.api + "/api/v1/admin/applications", { | ||
method: "get", | ||
headers: { | ||
"Authorization": this.$store.getters.token | ||
} | ||
}).then(async res => { | ||
let json = await res.json() | ||
console.log(json, res.status) | ||
if (json.applicants) { | ||
this.$store.commit("applications", json.applicants) | ||
} | ||
}) | ||
} | ||
}, | ||
login() { | ||
var provider = new this.$firebase.auth.GoogleAuthProvider(); | ||
provider.setCustomParameters({ | ||
|
@@ -87,16 +115,43 @@ firebaseLoaded: false, | |
} | ||
}, | ||
mounted() { | ||
this.$firebase.auth().onAuthStateChanged((user) =>{ | ||
this.firebaseLoaded = true | ||
let getToken = (trig) => { | ||
console.log('token trigger', trig) | ||
if (this.$firebase.currentUser) { | ||
this.$firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then((idToken) => { | ||
this.$store.commit("token", idToken) | ||
}) | ||
} | ||
} | ||
this.$firebase.auth().onAuthStateChanged((user) => { | ||
if (user) { | ||
// User is signed in. | ||
let email = user.email | ||
console.log(email.endsWith("hyphen-hacks.com")) | ||
if (email.endsWith("hyphen-hacks.com")) { | ||
this.$store.commit("user", user) | ||
this.$firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then((idToken) => { | ||
// Send token to your backend via HTTPS | ||
// ... | ||
this.$store.commit("user", user) | ||
this.$store.commit("token", idToken) | ||
this.firebaseLoaded = true | ||
tokenRefresh = window.setInterval(getToken("interval"), 900000) | ||
focus = window.addEventListener("focus", getToken("focus"), false); | ||
blur = window.addEventListener("blur", getToken("blur"), false); | ||
this.loadBasicData() | ||
}).catch(function (error) { | ||
// Handle error | ||
}); | ||
} else { | ||
this.$store.commit("user", false) | ||
this.firebaseLoaded = true | ||
this.noAccess = true | ||
console.log("no acess") | ||
this.$swal({ | ||
|
@@ -107,6 +162,7 @@ firebaseLoaded: false, | |
} | ||
} else { | ||
this.$store.commit("user", false) | ||
this.firebaseLoaded = true | ||
// No user is signed in. | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.