forked from fossasia/loklak_search
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes fossasia#46: Implement news sub tab with results from news orga…
…nizations
- Loading branch information
1 parent
7eaf03f
commit 6d49715
Showing
14 changed files
with
172 additions
and
8 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
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,7 @@ | ||
<div class="feed-wrapper"> | ||
<div class="wrapper feed-results"> | ||
<div *ngFor="let item of (apiResponseResults$ | async); let i = index "> | ||
<app-feed-card [feedItem]="item" [feedIndex]="i"></app-feed-card> | ||
</div> | ||
</div> | ||
</div> |
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 @@ | ||
@import "../feed.component.scss"; |
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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FeedNewsComponent } from './feed-news.component'; | ||
|
||
describe('FeedNewsComponent', () => { | ||
let component: FeedNewsComponent; | ||
let fixture: ComponentFixture<FeedNewsComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ FeedNewsComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FeedNewsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,65 @@ | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { Subscription } from 'rxjs/Subscription'; | ||
import { Store } from '@ngrx/store'; | ||
import { ActivatedRoute, Params } from '@angular/router'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import * as fromRoot from '../../reducers'; | ||
import { Query, parseStringToQuery } from '../../models/query'; | ||
import * as queryAction from '../../actions/query'; | ||
import { ApiResponseResult } from '../../models/api-response'; | ||
|
||
@Component({ | ||
selector: 'app-feed-news', | ||
templateUrl: './feed-news.component.html', | ||
styleUrls: ['./feed-news.component.scss'] | ||
}) | ||
export class FeedNewsComponent implements OnInit, OnDestroy { | ||
|
||
private __subscriptions__: Subscription[] = new Array<Subscription>(); | ||
public query$: Observable<Query>; | ||
public isSearching$: Observable<boolean>; | ||
public areResultsAvailable$: Observable<boolean>; | ||
public apiResponseResults$: Observable<ApiResponseResult[]>; | ||
searchQuery: Query = { | ||
displayString: 'from:CNN', | ||
queryString: 'from:CNN', | ||
routerString: 'from:CNN', | ||
filter: { video: false, image: false }, | ||
location: null, | ||
timeBound: { since: null, until: null }, | ||
from: true | ||
} | ||
constructor( | ||
private route: ActivatedRoute, | ||
private store: Store<fromRoot.State>, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.queryFromURL(); | ||
this.getDataFromStore(); | ||
} | ||
|
||
private queryFromURL(): void { | ||
this.__subscriptions__.push( | ||
this.route.queryParams | ||
.subscribe((params: Params) => { | ||
const queryParam = params['query'] || ''; | ||
const query: Query = parseStringToQuery(queryParam); | ||
this.store.dispatch(new queryAction.RelocationAfterQuerySetAction()); | ||
this.store.dispatch(new queryAction.QueryChangeAction(this.searchQuery)); | ||
}) | ||
); | ||
} | ||
|
||
private getDataFromStore(): void { | ||
this.query$ = this.store.select(fromRoot.getQuery); | ||
this.query$.subscribe(value => console.log(value.queryString)); | ||
this.isSearching$ = this.store.select(fromRoot.getSearchLoading); | ||
this.areResultsAvailable$ = this.store.select(fromRoot.getAreResultsAvailable); | ||
this.apiResponseResults$ = this.store.select(fromRoot.getApiResponseEntities); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.__subscriptions__.forEach(subscription => subscription.unsubscribe()); | ||
} | ||
} |
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,15 @@ | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
|
||
import { ShareNewsStatusService } from './share-news-status.service'; | ||
|
||
describe('ShareNewsStatusService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ShareNewsStatusService] | ||
}); | ||
}); | ||
|
||
it('should be created', inject([ShareNewsStatusService], (service: ShareNewsStatusService) => { | ||
expect(service).toBeTruthy(); | ||
})); | ||
}); |
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,17 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable() | ||
export class ShareNewsStatusService { | ||
|
||
public sharedNewsStatus = false; | ||
|
||
constructor() { } | ||
|
||
changeStatus(currentStatus: boolean) { | ||
this.sharedNewsStatus = currentStatus; | ||
} | ||
|
||
getSharedNewsStatus() { | ||
return this.sharedNewsStatus; | ||
} | ||
} |