From 44828da822dc52e58527eb27d32284c7e9e54419 Mon Sep 17 00:00:00 2001 From: samuelmenkus Date: Sun, 1 Mar 2020 17:49:41 -0500 Subject: [PATCH 1/4] firebase contact/ socialAccount deletions --- src/app/backendClasses.ts | 14 ++++++++++ src/app/firebase-backend.service.ts | 43 ++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/app/backendClasses.ts b/src/app/backendClasses.ts index 8bca9b0f..c56d939f 100644 --- a/src/app/backendClasses.ts +++ b/src/app/backendClasses.ts @@ -110,6 +110,12 @@ export class socialAccount { this.setUrl = tempUrl; this.setUser = tempUser; } + public isEqual(sAcot: socialAccount): boolean { + if(this.id == sAcot.id && this.user == sAcot.user && this.url == sAcot.url){ + return true; + } + return false; + } public get getId(): string { return this.id; } @@ -164,6 +170,14 @@ export class contact { this.setPhoto = tempPhoto; this.setAccessSocials = tempAccessSocial; } + public isEqual(cont: contact): boolean { + if(this.id == cont.id && this.name == cont.name && this.username == this.username && this.email == cont.email + && this.phoneNumber == cont.phoneNumber && this.DOB == cont.DOB && this.photo == cont.photo + && this.accessSocials == cont.accessSocials){ + return true; + } + return false; + } public get getId(): string { return this.id; } diff --git a/src/app/firebase-backend.service.ts b/src/app/firebase-backend.service.ts index 6e1ebb2a..61cbc818 100644 --- a/src/app/firebase-backend.service.ts +++ b/src/app/firebase-backend.service.ts @@ -45,7 +45,22 @@ export class FirebaseBackendService { await this.getUserData().then(usr => { userContacts = usr.getContacts; userContacts.push(cont); - // TODO Update the contact on firebase + var updates = {}; + updates['Users/'+this.uid+'/contacts'] = userContacts; + firebase.database().ref().update(updates); + }); + } + // deletion from user contact list + async deleteFromUserContacts(cont: backend.contact) { + var userContacts: backend.contact []; + await this.getUserData().then(usr => { + userContacts = usr.getContacts; + for(let i: number = 0; i < userContacts.length; i++){ + if(userContacts[i].isEqual(cont)){ + userContacts.splice(i,1); + break; + } + } var updates = {}; updates['Users/'+this.uid+'/contacts'] = userContacts; firebase.database().ref().update(updates); @@ -72,6 +87,32 @@ export class FirebaseBackendService { firebase.database().ref().update(updates); }); } + // delete social account + async deleteSocialAccount(typ: string, sAcot: backend.socialAccount) { + var userSocialAccounts: backend.socialAccount []; + var userSocials: {} [] = []; + await this.getUserData().then(usr => { + userSocials = usr.getSocials; + this.getSocialAccountsType(typ).then(dat => { + userSocialAccounts = dat; + for(let i:number = 0; i < userSocialAccounts.length; i++){ + if(userSocialAccounts[i].isEqual(sAcot)){ + userSocialAccounts.splice(i,1); + break; + } + } + }); + let i:number = 0; + for(; i < userSocials.length; i++){ + if(userSocials[i]['type'] == typ){ + break; + } + } + var updates = {}; + updates['Users/'+this.uid+'/socials/'+i+'/socialAccount'] = userSocialAccounts; + firebase.database().ref().update(updates); + }); + } // Getting social accounts of a given type async getSocialAccountsType(type: string) : Promise { console.log(type) From 79eff0b804f0a48d152d90bee731fcb60ff1ffd0 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 1 Mar 2020 19:21:06 -0500 Subject: [PATCH 2/4] updated home --- src/app/home/home.page.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/home/home.page.scss b/src/app/home/home.page.scss index dec49347..fb01bafa 100644 --- a/src/app/home/home.page.scss +++ b/src/app/home/home.page.scss @@ -60,4 +60,4 @@ ion-icon { border-radius: 30pt; -} +} \ No newline at end of file From b127c00eb57a9815974873a3c62858abb4c4987e Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 1 Mar 2020 19:26:30 -0500 Subject: [PATCH 3/4] updated --- package-lock.json | 91 ++++++++++++------------------- package.json | 3 +- src/app/home/home.page.html | 20 +++++-- src/app/home/home.page.scss | 12 +++- src/app/profile/profile.page.html | 1 - 5 files changed, 62 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index c409751b..0be516a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -506,8 +506,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -528,14 +527,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -550,20 +547,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -680,8 +674,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -693,7 +686,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -708,7 +700,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -716,14 +707,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -742,7 +731,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -823,8 +811,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -836,7 +823,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -922,8 +908,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -959,7 +944,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -979,7 +963,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1023,14 +1006,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -3781,6 +3762,21 @@ "protobufjs": "^6.8.6" } }, + "@ionic-native/call-number": { + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@ionic-native/call-number/-/call-number-5.22.0.tgz", + "integrity": "sha512-17KhhY1aA5GR/9ClckPUSxqj34/DTF2AhPt7TC5bVp3x8QejOre/JaEyGstepBW8WNXSikuWMuMbg843MambEQ==", + "requires": { + "@types/cordova": "^0.0.34" + }, + "dependencies": { + "@types/cordova": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz", + "integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ=" + } + } + }, "@ionic-native/core": { "version": "5.15.1", "resolved": "https://registry.npmjs.org/@ionic-native/core/-/core-5.15.1.tgz", @@ -11305,7 +11301,6 @@ "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -11324,7 +11319,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -11504,8 +11498,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -11611,8 +11604,7 @@ "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -17854,8 +17846,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -17898,8 +17889,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", @@ -17910,8 +17900,7 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -18028,8 +18017,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -18041,7 +18029,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -18071,7 +18058,6 @@ "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -18090,7 +18076,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -18193,7 +18178,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -18279,8 +18263,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -18316,7 +18299,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -18336,7 +18318,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -18380,14 +18361,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/package.json b/package.json index ebc40e18..7df73dcf 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@angular/platform-browser": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2", "@angular/router": "~8.1.2", + "@ionic-native/call-number": "^5.22.0", "@ionic-native/core": "^5.0.0", "@ionic-native/facebook": "^5.20.0", "@ionic-native/qr-scanner": "^5.17.1", @@ -104,4 +105,4 @@ "browser" ] } -} \ No newline at end of file +} diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index 3bc11f7b..93202ddf 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -12,7 +12,7 @@ - + @@ -38,10 +38,20 @@
- - - - {{contact.name}} + + + + + + + + + + {{contact.name}} + + + +
diff --git a/src/app/home/home.page.scss b/src/app/home/home.page.scss index fb01bafa..6e5386df 100644 --- a/src/app/home/home.page.scss +++ b/src/app/home/home.page.scss @@ -58,6 +58,14 @@ ion-icon { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } border-radius: 30pt; - - +} +#user-info{ + width: 70%; + left: 25%; + padding-left: 3%; + position: absolute; +} +#avatar-width{ + width: 25%; + position: absolute; } \ No newline at end of file diff --git a/src/app/profile/profile.page.html b/src/app/profile/profile.page.html index 0daadd68..863d8558 100644 --- a/src/app/profile/profile.page.html +++ b/src/app/profile/profile.page.html @@ -4,7 +4,6 @@ - {{profile.name}} From dd2ff820c7466634827383a66437fed6a4768c98 Mon Sep 17 00:00:00 2001 From: samuelmenkus Date: Sun, 1 Mar 2020 19:28:47 -0500 Subject: [PATCH 4/4] fix to remove an error so that i can test something --- src/app/user-contact/user-contact.module.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/user-contact/user-contact.module.ts b/src/app/user-contact/user-contact.module.ts index 9286aaf5..0981e816 100644 --- a/src/app/user-contact/user-contact.module.ts +++ b/src/app/user-contact/user-contact.module.ts @@ -6,7 +6,7 @@ import { Routes, RouterModule } from '@angular/router'; import { IonicModule } from '@ionic/angular'; import { UserContactPage } from './user-contact.page'; -import { Contacts2PageModule } from '../contacts/contacts2.module'; +// import { Contacts2PageModule } from '../contacts/contacts2.module'; const routes: Routes = [ { @@ -24,8 +24,9 @@ const routes: Routes = [ ], declarations: [ UserContactPage, - Contacts2PageModule + // Contacts2PageModule ], - entryComponents: [Contacts2PageModule] + entryComponents: [//Contacts2PageModule + ] }) export class UserContactPageModule {}