-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Social page developed and fetch details
- Loading branch information
Showing
8 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<app-side-bar></app-side-bar> | ||
|
||
<section> | ||
<div class="w-100 my-4 flex justify-center items-center"> | ||
<input | ||
type="text" | ||
placeholder="Search friends..." | ||
class="my-2 w-[500px] pl-4 pr-4 py-2 px-4 text-center text-sm text-slate-900 bg-white border border-slate-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 shadow-sm" | ||
(input)="searchFriends($event)" | ||
/> | ||
</div> | ||
|
||
<div> | ||
<div *ngFor="let friend of friendsList"> | ||
<span>{{friend.name}}</span> | ||
</div> | ||
</div> | ||
</section> |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { User } from 'src/app/models/User'; | ||
import { ApiService } from 'src/app/services/api.service'; | ||
import { CommonService } from 'src/app/services/common.service'; | ||
|
||
@Component({ | ||
selector: 'app-social', | ||
templateUrl: './social.component.html', | ||
styleUrls: ['./social.component.scss'] | ||
}) | ||
export class SocialComponent implements OnInit{ | ||
|
||
friendsList: User[] = []; | ||
allUsers: any; | ||
constructor(public apiServ: ApiService, private cs: CommonService){} | ||
|
||
ngOnInit(){ | ||
if(!this.cs.socialLoaded){ | ||
this.getAllUsers().then((val: any) => { | ||
this.friendsList = this.allUsers; | ||
this.cs.socialLoaded = true; | ||
}) | ||
} | ||
} | ||
|
||
searchFriends(ev: any){ | ||
let name = ev.target.value; | ||
if(!name){ | ||
this.friendsList = this.allUsers; | ||
} | ||
|
||
this.friendsList = []; | ||
for(let user of this.allUsers){ | ||
let case_sensitive_user_name = user.name.toLowerCase(); | ||
if(case_sensitive_user_name.includes(name.toLowerCase())){ | ||
if(!this.friendsList.some(friend => friend.name == user.name)){ | ||
this.friendsList.push(user); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
getAllUsers() : Promise<any>{ | ||
return this.apiServ.get("admin/getAllUsers").then((res: any) => { | ||
this.allUsers = res; | ||
}, (error: any) => console.error(error) | ||
)} | ||
} |
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