diff --git a/src/app/app.component.html b/src/app/app.component.html index 3740bc9..892ec69 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,8 +1,12 @@ - {{title}} + + Switch Campaign + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 47e44fc..a8ee07b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { TwitterClientService } from './services/twitter-client.service'; @Component({ selector: 'app-root', @@ -7,4 +8,32 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'Twitter Campaigns'; + + statusCampaign = false; + + constructor(private twitterClientService: TwitterClientService) { + this.twitterClientService.statusCampaign().subscribe((data: any) => { + this.statusCampaign = !data; + }); + } + + switchCampaign(event) { + if (event.checked) { + this.startCampaign(); + } else { + this.stopCampaign(); + } + } + + startCampaign() { + this.twitterClientService.startCampaign().subscribe((data: any) => { + console.log(data); + }); + } + + stopCampaign() { + this.twitterClientService.stopCampaign().subscribe((data: any) => { + console.log(data); + }); + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 14a3da5..d24a51f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,7 +16,8 @@ import { MatToolbarModule, MatCardModule, MatIconModule, - MatGridListModule + MatGridListModule, + MatSlideToggleModule } from '@angular/material'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -40,7 +41,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; MatTableModule, MatSortModule, MatGridListModule, - BrowserAnimationsModule + BrowserAnimationsModule, + MatSlideToggleModule ], providers: [ TwitterClientService diff --git a/src/app/services/twitter-client.service.ts b/src/app/services/twitter-client.service.ts index 9046a2d..38f87cf 100644 --- a/src/app/services/twitter-client.service.ts +++ b/src/app/services/twitter-client.service.ts @@ -34,4 +34,16 @@ export class TwitterClientService { getRewardsTweets(id: String): Observable { return this.http.get(this.BASE_URL + '/ttc-connectors-reward/rewards/' + id); } + + startCampaign(): Observable { + return this.http.post(this.BASE_URL + '/ttc-connectors-dummytwitter/feed/stop', null); + } + + stopCampaign(): Observable { + return this.http.post(this.BASE_URL + '/ttc-connectors-dummytwitter/feed/start', null); + } + + statusCampaign(): Observable { + return this.http.get(this.BASE_URL + '/ttc-connectors-dummytwitter/feed'); + } } diff --git a/src/app/twitter-campaign-details/twitter-campaign-details.component.html b/src/app/twitter-campaign-details/twitter-campaign-details.component.html index dd51523..8ce96f0 100644 --- a/src/app/twitter-campaign-details/twitter-campaign-details.component.html +++ b/src/app/twitter-campaign-details/twitter-campaign-details.component.html @@ -1,3 +1,80 @@ + + + + + Processed Feeds + repeat + + + + + + + + +
+
+ error_outline +
+
+ Service Unavailable +
+
+ +
+
+ format_align_justify +
+
+ Empty Feed +
+
+ +
+
+ +
+
+ Loading +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Text {{element.entry.text}} Author {{element.entry.author}} Lang {{element.entry.lang}} Attitude {{element.entry.attitude}} Timestamp {{element.entry.timestamp}}
+ +
+
+ +

+ @@ -170,80 +247,6 @@

- - - - Processed Feeds - repeat - - - - - - - - -
-
- error_outline -
-
- Service Unavailable -
-
- -
-
- format_align_justify -
-
- Empty Feed -
-
- -
-
- -
-
- Loading -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Text {{element.entry.text}} Author {{element.entry.author}} Lang {{element.entry.lang}} Attitude {{element.entry.attitude}} Timestamp {{element.entry.timestamp}}
- -
-
@@ -256,7 +259,7 @@
- +
@@ -286,7 +289,6 @@
- @@ -319,3 +321,4 @@
+
diff --git a/src/app/twitter-campaign-details/twitter-campaign-details.component.ts b/src/app/twitter-campaign-details/twitter-campaign-details.component.ts index 8840a21..99e352d 100644 --- a/src/app/twitter-campaign-details/twitter-campaign-details.component.ts +++ b/src/app/twitter-campaign-details/twitter-campaign-details.component.ts @@ -14,7 +14,7 @@ export class TwitterCampaignDetailsComponent implements OnInit { displayedColumns = ['nroOfTweets', 'userName']; displayedColumnsProcessed = ['text', 'author', 'lang', 'attitude', 'timestamp']; - displayedColumnsReward: ['campaignName', 'nroOfTweets', 'userName', 'rewardsText', 'rewardDate']; + displayedColumnsReward = ['campaignName', 'nroOfTweets', 'userName', 'rewardsText', 'rewardDate']; negativeFeeds: any; positiveFeeds: any; diff --git a/src/app/twitter-campaigns/twitter-campaigns.component.css b/src/app/twitter-campaigns/twitter-campaigns.component.css index 943bdd1..8f25d57 100644 --- a/src/app/twitter-campaigns/twitter-campaigns.component.css +++ b/src/app/twitter-campaigns/twitter-campaigns.component.css @@ -6,3 +6,26 @@ background-image: url('https://material.angular.io/assets/img/examples/shiba1.jpg'); background-size: cover; } + +.status-icon mat-icon { + height: 150px !important; + width: 150px !important; + font-size: 106px !important; +} + +.status-icon fa { + height: 150px !important; + width: 150px !important; + font-size: 106px !important; +} + +.status { + text-align: center; + font-size: 27px; + font-family: sans-serif; + padding: 50px 50px 50px 50px; +} + +.status-message { + +} diff --git a/src/app/twitter-campaigns/twitter-campaigns.component.html b/src/app/twitter-campaigns/twitter-campaigns.component.html index 2ac63fa..83726b7 100644 --- a/src/app/twitter-campaigns/twitter-campaigns.component.html +++ b/src/app/twitter-campaigns/twitter-campaigns.component.html @@ -1,14 +1,42 @@ - + {{campaign.name}}

- {{campaign.serviceId}} - {{campaign.name}} - {{campaign.lang}} - Twitter Campaign + {{campaign.serviceId}} - {{campaign.name}} - {{campaign.lang}} + Twitter Campaign

+ + +
+
+ error_outline +
+
+ Service Unavailable +
+
+ +
+
+ +
+
+ Loading +
+
+ +
+
+ format_align_justify +
+
+ No Campaign Available +
+
diff --git a/src/app/twitter-campaigns/twitter-campaigns.component.ts b/src/app/twitter-campaigns/twitter-campaigns.component.ts index d8ac2f3..fb52a31 100644 --- a/src/app/twitter-campaigns/twitter-campaigns.component.ts +++ b/src/app/twitter-campaigns/twitter-campaigns.component.ts @@ -11,10 +11,14 @@ export class TwitterCampaignsComponent implements OnInit { campaigns: any[]; + isCampaignsLoading = true; + constructor(private twitterClientService: TwitterClientService, private router: Router) { twitterClientService.getCampaigns().subscribe((data: any[]) => { this.campaigns = data; + this.isCampaignsLoading = false; }, error => { + this.isCampaignsLoading = false; console.log(error); } ); @@ -27,4 +31,11 @@ export class TwitterCampaignsComponent implements OnInit { this.router.navigate(['/campaigns', campaign.name]); } + isCampaignEmpty() { + if (this.campaigns && this.campaigns.length === 0 && !this.isCampaignsLoading) { + return true; + } else { + return false; + } + } }