Commit b286746d authored by Zéfling's avatar Zéfling 🎨
Browse files

Simple search without formatting

parent d9615a52
<div *ngIf="tweets"
class="tweets-total">
<span>
Total : {{tweets.total | numFormat}} tweet{{tweets.total > 0 ? 's' : ''}}
Total: {{tweets.total | numFormat}} tweet{{tweets.total > 0 ? 's' : ''}}
</span>
</div>
......@@ -36,12 +36,12 @@
<ng-container *ngIf="search.active">
<div class="tweets-search">
<span>
Search: {{active.label}}
Search: {{search.label}} - {{search.total | numFormat}} tweet{{search.total > 0 ? 's' : ''}}
</span>
</div>
</ng-container>
<div *ngIf="month && !search.active"
<div *ngIf="month || search.active"
class="tweets">
<section *ngFor="let tweet of (!search.active ? month.tweets : search.tweets)"
class="tweet"
......
......@@ -162,9 +162,10 @@
}
}
.mounth-calendar {
.month-calendar {
grid-area: f;
background-color: var(--panel-bg-color);
border: 1px solid var(--panel-bd-color);
margin: 5px;
display: none;
}
\ No newline at end of file
......@@ -25,9 +25,10 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
listener: Subscription[] = [];
calandar: { [week: string]: string[] } = {};
search: { active: boolean, label: string, tweets: Tweet[] } = {
search: { active: boolean, label: string, total: number, tweets: Tweet[] } = {
active: false,
label: '',
total: 0,
tweets: []
};
......@@ -79,6 +80,10 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
this.month = month;
this.month.selected = true;
// construct mount calandar
// lightbox album
this.album = [];
for (const tweet of month.tweets) {
......@@ -129,10 +134,12 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
onSubmit() {
if (this.tweetsForm.valid) {
const value = this.tweetsForm.get('search').value;
const tweets = this.tweetsService.search(value);
this.search = {
active: true,
label: value,
tweets: this.tweetsService.search(value)
tweets: tweets,
total: tweets.length
};
}
}
......
......@@ -191,6 +191,17 @@ export class TweetsService {
}
search(value: string): Tweet[] {
return [];
const tweets = this.tweetsData.tweets;
const result: Tweet[] = [];
tweets.forEach(tweet => {
console.log(tweet.id)
if (tweet.full_text.match(new RegExp(value, 'gi'))) {
result.push(tweet);
}
});
return result;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment