Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

805 feature request ability to export schedule to google calendar #825

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"devDependencies": {
"cross-env": "^7.0.2",
"npm-run-all": "^4.1.5"
},
"dependencies": {
"date-fns": "^2.30.0",
"googleapis": "^127.0.0"
}
}
4 changes: 4 additions & 0 deletions src/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="favicon.ico">
<script src="./ics.min.js" type="application/javascript"></script>
<script src="https://apis.google.com/js/api.js" type="text/javascript"></script>
<script src="https://accounts.google.com/gsi/client" type="text/javascript"></script>
<title>YACS</title>
<link rel="apple-touch-icon" href="img/apple-icon-180.png">

Expand Down Expand Up @@ -36,6 +38,8 @@
<link rel="apple-touch-startup-image" href="img/apple-splash-640-1136.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="img/apple-splash-1136-640.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">



</head>
<body>
<noscript>
Expand Down
2 changes: 1 addition & 1 deletion src/web/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@ export default {
.drop-down-item {
background: hsl(211, 100%, 60%) !important;
}
</style>
</style>
39 changes: 36 additions & 3 deletions src/web/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
></b-form-input>
</b-form-group>
<b-button type="submit" variant="primary">Submit</b-button>
<b-button @click="initiateGoogleOneTap" variant="primary" style="margin-left: 10px;">Login with Google</b-button>
<div>
<b-button-group size="md">
<button
Expand Down Expand Up @@ -67,8 +68,9 @@ export default {
},
methods: {
async onSubmit(evt) {
evt.preventDefault();

if (evt) {
evt.preventDefault();
}
try {
await this.$store.dispatch(userTypes.actions.LOGIN, this.form);

Expand All @@ -88,6 +90,37 @@ export default {
onSignUp() {
this.$refs["signup-modal"].hide();
},
initiateGoogleOneTap() {
window.google.accounts.id.initialize({
client_id: "833663758121-ff8hq6a8ibujhv969laf6h9edc000ad2.apps.googleusercontent.com",
callback: this.handleGoogleResponse
});

window.google.accounts.id.prompt(); // This triggers the One Tap UI
},

async handleGoogleResponse(response) {
// Extract user information from the ID token
const idToken = response.credential;
const decodedData = this.decodeIdToken(idToken);

// Set the required form field values

this.form.email = decodedData.email;
this.form.password = decodedData.name+decodedData.email;

// Automatically create the account
await this.onSubmit();
},

decodeIdToken(token) {
const base64Url = token.split('.')[1];
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
const jsonData = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonData);
},
onReset(evt) {
evt.preventDefault();
// Reset our form values
Expand All @@ -109,4 +142,4 @@ export default {
};
</script>

<style></style>
<style></style>
39 changes: 39 additions & 0 deletions src/web/src/components/SignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@
<button type="submit" class="btn-primary btn w-100">
Finish Sign Up!
</button>
<button @click="initiateGoogleOneTap" class="btn-primary btn w-100 mt-2">
Sign Up with Google
</button>
</b-form>
</div>
</template>

<script>
import { signup } from "@/services/UserService";
import { userTypes } from "../store/modules/user";

export default {
name: "SignUp",
data() {
Expand Down Expand Up @@ -115,6 +119,41 @@ export default {

this.$emit("submit");
},
initiateGoogleOneTap() {
window.google.accounts.id.initialize({
client_id: "833663758121-ff8hq6a8ibujhv969laf6h9edc000ad2.apps.googleusercontent.com",
callback: this.handleGoogleResponse
});

window.google.accounts.id.prompt(); // This triggers the One Tap UI
},

async handleGoogleResponse(response) {
// Extract user information from the ID token
const idToken = response.credential;
const decodedData = this.decodeIdToken(idToken);

// Set the required form field values
this.form.name = decodedData.name;
this.form.email = decodedData.email;
// Note: Ideally, you shouldn't set a password for users signing in with Google.
// For this demonstration, I'm using the ID token, but consider changing this approach.
this.form.password = (decodedData.name+decodedData.email).replace(/\s+/g, '');
this.form.degree = "Undergraduate";
this.form.major = "CSCI";

// Automatically create the account
await this.onSubmit();
},

decodeIdToken(token) {
const base64Url = token.split('.')[1];
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
const jsonData = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonData);
}
},
};
</script>
3 changes: 3 additions & 0 deletions src/web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import router from "./routes";
import VueCookies from "vue-cookies";
import Meta from "vue-meta";


Vue.config.productionTip = false;

Vue.use(VueRouter);
Expand All @@ -20,6 +21,8 @@ Vue.use(Meta);

Vue.$cookies.config("7d");



new Vue({
render: (h) => h(App),
router,
Expand Down
Loading
Loading