Skip to content

Commit

Permalink
Limited download count to one per session + added automated "request …
Browse files Browse the repository at this point in the history
…my data""
  • Loading branch information
elrumo committed Jun 3, 2021
1 parent 9aa1761 commit b003214
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 32 deletions.
76 changes: 64 additions & 12 deletions website/macos-big-sur-icons/src/components/AccountDialog.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<template>
<coral-dialog id="accountDialog" v-if="getUser.isAuth" focusOnShow="off">


<coral-dialog-header>
Your Account
</coral-dialog-header>

<coral-dialog-content>

<div v-if="isLoading.requestUserData" class="loading-overlay">
<div class="loading-popup">
<coral-progress indeterminate> Fetching your data</coral-progress>
</div>
</div>

<coral-alert style="max-width: 360px; min-width: 260px !important;">
<coral-alert-header>Info</coral-alert-header>
<coral-alert-content>
Expand Down Expand Up @@ -115,30 +122,30 @@
</form>

<p class="coral-Body--XS p-l-5 p-t-5 p-r-5 m-0 opacity-60">
<!-- :href="'mailto:elias.ruiz.monserrat@gmail.com?subject=Request macOSicons data: '+getUserData('objectId')" -->
<a
@click="requestUserData"
rel="noopener"
:href="'mailto:elias.ruiz.monserrat@gmail.com?subject=Right to be forgotten: '+getUserData('objectId')"
target="_blank"
class="coral-Link">
Exercise
Request
</a>
right to be forgotten and delete account.
all the data macOSicons has about me.
</p>

<p class="coral-Body--XS p-l-5 p-t-5 p-r-5 m-0 opacity-60">
<a
rel="noopener"
:href="'mailto:elias.ruiz.monserrat@gmail.com?subject=Request macOSicons data: '+getUserData('objectId')"
:href="'mailto:elias.ruiz.monserrat@gmail.com?subject=Right to be forgotten: '+getUserData('objectId')"
target="_blank"
class="coral-Link">
Request
Exercise
</a>
all the data macOSicons has about me.
right to be forgotten and delete account.
</p>

<div v-if="isLoading" class="loading-overlay">
<div v-if="isLoading.updatingUser" class="loading-overlay">
<div class="loading-popup">
<coral-progress indeterminate>{{ uploadProgress }}/{{ totalNumFiles }} icons uploaded</coral-progress>
<coral-progress indeterminate>Saving changes...</coral-progress>
</div>
</div>

Expand Down Expand Up @@ -171,7 +178,10 @@ export default {
},
email: "",
yourName: "",
isLoading: false,
isLoading: {
requestUserData: false,
updatingUser: false
},
isValidated: false,
hasChanged: false,
Expand All @@ -182,6 +192,47 @@ export default {
methods:{
...mapActions(['showToast', 'setUser']),
async requestUserData(){
let parent = this;
let user = Parse.User.current();
await user.fetch()
parent.isLoading.requestUserData = true;
function downloadFile(fileUrl, fileName) {
var a = document.createElement("a");
a.href = fileUrl;
a.setAttribute("download", fileName);
a.setAttribute("id", "fileName");
a.click();
a.remove();
}
let fileURL
if (user.get("userInfoFile")) {
fileURL = user.get("userInfoFile").url();
downloadFile(fileURL, user.get('username')+"_"+user.id+".json");
parent.isLoading.requestUserData = false
parent.showToast({
id: "toastMessage",
message: "Data downloaded successfully.",
variant: "success"
})
} else {
fileURL = await Parse.Cloud.run("requestUserData", {id: user.id})
downloadFile(fileURL, user.get('username')+"_"+user.id+".json");
parent.isLoading.requestUserData = false
parent.showToast({
id: "toastMessage",
message: "Data downloaded successfully.",
variant: "success"
})
}
},
setYourName(e){
console.log(e.target.value);
this.yourName = e.target.value
Expand Down Expand Up @@ -233,15 +284,17 @@ export default {
let parent = this
let toUpdate = parent.toUpdate
let ParseUser = Parse.User.current()
parent.isLoading.updatingUser = true;
for(let key in toUpdate){
ParseUser.set(key, toUpdate[key])
}
ParseUser.save().then((data) =>{
parent.isLoading.updatingUser = false;
parent.showToast({
id: "toastMessage",
message: "Updated settings successfully.",
message: "Updated settings successfully.",
variant: "success"
})
}).catch((error) => {
Expand All @@ -253,7 +306,6 @@ export default {
let parent = this
let ParseUser = Parse.User.current()
let userProps = JSON.parse(JSON.stringify(ParseUser))
// console.log(prop, " :", userProps[prop]);
return userProps[prop]
}
Expand Down
6 changes: 5 additions & 1 deletion website/macos-big-sur-icons/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ export default {
message: "",
today: "",
downloads:{},
iconListLen: 5_385,
lastVisible: {},
dataToShow: [],
Expand Down Expand Up @@ -491,8 +493,10 @@ export default {
},
async addClickCount(icon){
console.log(icon);
let parent = this
var id
if (icon.id) {
id = icon.id
} else{
Expand Down
15 changes: 2 additions & 13 deletions website/macos-big-sur-icons/src/components/UserIconCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
},
methods:{
...mapActions(['showEl', 'setSelectedIcon']),
...mapActions(['showEl', 'setSelectedIcon', 'addClickCount']),
prettifyName(name){
name = name.replaceAll("_", " ")
Expand All @@ -108,18 +108,7 @@ export default {
parent.setSelectedIcon(parent.icon)
parent.showEl(id)
},
async addClickCount(icon){
var id
if (icon.id) {
id = icon.id
} else{
id = icon.objectID
}
icon = { appName: icon.appName, id: id }
await Parse.Cloud.run("addClickCount", {icon: icon})
},
getDate(timeStamp){
let newDate = new Date(timeStamp)
Expand Down
4 changes: 2 additions & 2 deletions website/macos-big-sur-icons/src/components/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,8 @@ option[value=""][disabled] {
filter: brightness(0.7);
}

.coral-link{
cursor: pointer;
.coral-Link{
cursor: pointer !important;
}

.coral--light .coral-button .coral-Link{
Expand Down
23 changes: 22 additions & 1 deletion website/macos-big-sur-icons/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default new Vuex.Store({

loading: true,

downloads:[],

selectedIcon:{},

userIcons: {
Expand Down Expand Up @@ -108,6 +110,26 @@ export default new Vuex.Store({
document.getElementById(dialogId.id).show();
},

async addClickCount(store, icon){

if (store.state.downloads.indexOf(icon.id) == -1) {
store.commit('setDataToArr', {arr: 'downloads', data: icon.id})
// store.state.downloads.push(icon.id)
console.log(store.state.downloads.indexOf(icon.id));
var id

if (icon.id) {
id = icon.id
} else{
id = icon.objectID
}
icon = { appName: icon.appName, id: id }
await Parse.Cloud.run("addClickCount", {icon: icon})
} else{
return "No downlaod"
}
},

getPageData(store){
console.log(store.resourcesData);
return "Hi"
Expand Down Expand Up @@ -208,7 +230,6 @@ export default new Vuex.Store({
},

showEl(store, id){
console.log(id);
if(id.elId != undefined){
document.getElementById(id.elId).target = "#"+id.targetId
document.getElementById(id.elId).show()
Expand Down
12 changes: 9 additions & 3 deletions website/macos-big-sur-icons/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,25 @@ export default {
async deleteSubmission(icon){
let parent = this
console.log(icon);
let query = new Parse.Query(Icons)
let docToDelete = await query.get(icon.id);
console.log("appName: ", docToDelete.get("appName"));
// console.log("docToDelete: ", docToDelete.id);
let newIcon = {
id: icon.id
}
await Parse.Cloud.run("deleteIcon", newIcon);
docToDelete.destroy().then(() =>{
docToDelete.destroy().then((obj) =>{
console.log(obj);
Vue.delete(parent.icons[icon.usersName].icons, icon.appName) // Delete object locally
if (Object.keys(parent.icons[icon.usersName].icons).length == 0 ) { // Delete user from UI if no icons are left
Vue.delete(parent.icons, icon.usersName)
}
}).catch((e) =>{
console.log(e);
console.log("error deleting object: ", e);
})
},
Expand Down

0 comments on commit b003214

Please sign in to comment.