Skip to content

Commit

Permalink
established the frontend for search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupeshiya committed Dec 25, 2019
1 parent 3205228 commit c114e06
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stackle-app/src/app/secure/secure.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ <h5 class="mat-h5">By Opensource, For Opensource</h5>
<div class="example-container">
<form>
<mat-form-field>
<input matInput placeholder="Stack Name">
<input matInput placeholder="Stack Name" [(ngModel)]="stackNameToSearch" name="stackNameText">
</mat-form-field>
<button mat-button color="primary" type="submit">
<button mat-button color="primary" type="submit" (click)="onSearchSubmit()">
<mat-icon matListIcon>search</mat-icon>
Search
</button>
Expand Down
17 changes: 17 additions & 0 deletions stackle-app/src/app/secure/secure.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class SecureComponent implements OnInit {

private subscribedStacks = [];
private userAvatarUrl;
public stackNameToSearch: String;
public stackInfo: any;

constructor(
private auth: AuthService,
Expand Down Expand Up @@ -59,4 +61,19 @@ export class SecureComponent implements OnInit {
this.router.navigate(['app/stack'], { queryParams: { name: stackName }});
}

public onSearchSubmit(){
let stackToSearch = {
stackName: this.stackNameToSearch
};
console.log(stackToSearch);
this.stackService.getStack(stackToSearch.stackName).subscribe((res)=>{
console.log(res);
if(res.success){
this.stackInfo = res.result;
}
}, (err)=>{
console.log(err);
});
}

}
5 changes: 5 additions & 0 deletions stackle-app/src/app/services/stack.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ export class StackService {

}

public getStack(stackName){
return this.http.get(`${this.apiUrl}/api/org/name/${stackName}`)
.map((res: Response) => res.json())
.catch((error: any) => Observable.throw(error.json().error) || 'Server error');
}
}

0 comments on commit c114e06

Please sign in to comment.