diff --git a/kibicara-frontend/src/app/dashboard/dashboard-routing.module.ts b/kibicara-frontend/src/app/dashboard/dashboard-routing.module.ts index a16a8c9..f21f0ab 100644 --- a/kibicara-frontend/src/app/dashboard/dashboard-routing.module.ts +++ b/kibicara-frontend/src/app/dashboard/dashboard-routing.module.ts @@ -4,6 +4,7 @@ import { DashboardComponent } from './dashboard.component'; import { HoodsComponent } from './hoods/hoods.component'; import { AuthGuard } from '../core/auth/auth.guard'; import { BoardComponent } from './board/board.component'; +import { TwitterCallbackComponent } from '../platforms/twitter/twitter-callback/twitter-callback.component'; const routes: Routes = [ { @@ -12,6 +13,8 @@ const routes: Routes = [ children: [ { path: '', component: HoodsComponent }, { path: 'hoods/:id', component: BoardComponent }, + // Platform-specific Routes + { path: 'twitter-callback', component: TwitterCallbackComponent }, ], canActivate: [AuthGuard], }, diff --git a/kibicara-frontend/src/app/platforms/platforms.module.ts b/kibicara-frontend/src/app/platforms/platforms.module.ts index d32b882..02f3817 100644 --- a/kibicara-frontend/src/app/platforms/platforms.module.ts +++ b/kibicara-frontend/src/app/platforms/platforms.module.ts @@ -8,8 +8,8 @@ import { EmailDialogComponent } from './email/email-dialog/email-dialog.componen import { EmailInfoDialogComponent } from './email/email-info-dialog/email-info-dialog.component'; import { TelegramInfoDialogComponent } from './telegram/telegram-info-dialog/telegram-info-dialog.component'; import { TelegramDialogComponent } from './telegram/telegram-dialog/telegram-dialog.component'; -import { TwitterDialogComponent } from './twitter/twitter-dialog/twitter-dialog.component'; import { TwitterInfoDialogComponent } from './twitter/twitter-info-dialog/twitter-info-dialog.component'; +import { TwitterCallbackComponent } from './twitter/twitter-callback/twitter-callback.component'; @NgModule({ declarations: [ @@ -20,8 +20,8 @@ import { TwitterInfoDialogComponent } from './twitter/twitter-info-dialog/twitte EmailInfoDialogComponent, TelegramInfoDialogComponent, TelegramDialogComponent, - TwitterDialogComponent, TwitterInfoDialogComponent, + TwitterCallbackComponent, ], imports: [CommonModule, SharedModule], exports: [ diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.html b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.html new file mode 100644 index 0000000..62ec712 --- /dev/null +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.scss b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.scss new file mode 100644 index 0000000..86c0c51 --- /dev/null +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.scss @@ -0,0 +1,4 @@ +.spinner { + display: block; + margin: auto; +} diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.spec.ts b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.spec.ts similarity index 51% rename from kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.spec.ts rename to kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.spec.ts index 97d5947..947d45a 100644 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.spec.ts +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.spec.ts @@ -1,19 +1,19 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { TwitterDialogComponent } from './twitter-dialog.component'; +import { TwitterCallbackComponent } from './twitter-callback.component'; -describe('TwitterDialogComponent', () => { - let component: TwitterDialogComponent; - let fixture: ComponentFixture; +describe('TwitterCallbackComponent', () => { + let component: TwitterCallbackComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [TwitterDialogComponent], + declarations: [TwitterCallbackComponent], }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(TwitterDialogComponent); + fixture = TestBed.createComponent(TwitterCallbackComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts new file mode 100644 index 0000000..ff4af55 --- /dev/null +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { TwitterService } from 'src/app/core/api'; + +@Component({ + selector: 'app-twitter-callback', + templateUrl: './twitter-callback.component.html', + styleUrls: ['./twitter-callback.component.scss'], +}) +export class TwitterCallbackComponent implements OnInit { + constructor( + private route: ActivatedRoute, + private router: Router, + private twitterService: TwitterService + ) {} + + ngOnInit(): void { + if ( + this.route.snapshot.queryParams['hood'] && + this.route.snapshot.queryParams['oauth_token'] && + this.route.snapshot.queryParams['oauth_verifier'] + ) { + this.twitterService + .callbackTwitter( + this.route.snapshot.queryParams['oauth_token'], + this.route.snapshot.queryParams['oauth_verifier'] + ) + .subscribe(() => { + this.router.navigate([ + '/dashboard/hoods', + this.route.snapshot.queryParams['hood'], + ]); + }); + } else { + this.router.navigate(['/404']); + } + } +} diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.html b/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.html deleted file mode 100644 index bc2fe2f..0000000 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.html +++ /dev/null @@ -1 +0,0 @@ -

twitter-dialog works!

diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.scss b/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.ts b/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.ts deleted file mode 100644 index 9e81a2f..0000000 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-dialog/twitter-dialog.component.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-twitter-dialog', - templateUrl: './twitter-dialog.component.html', - styleUrls: ['./twitter-dialog.component.scss'], -}) -export class TwitterDialogComponent implements OnInit { - constructor() {} - - ngOnInit(): void {} -} diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.html b/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.html index 5f695fd..794e5a2 100644 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.html +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.html @@ -17,7 +17,7 @@ - @@ -36,17 +36,17 @@ + + + + - - - - diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.ts b/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.ts index e440f35..af15bd4 100644 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.ts +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-settings/twitter-settings.component.ts @@ -19,10 +19,31 @@ export class TwitterSettingsComponent implements OnInit { ) {} ngOnInit(): void { + this.reload(); + } + + private reload() { this.twitters$ = this.twitterService.getTwitters(this.hoodId); } onInfoClick() { this.dialog.open(TwitterInfoDialogComponent); } + + onDelete(twitterId) { + this.twitterService.deleteTwitter(twitterId, this.hoodId).subscribe(() => { + this.reload(); + }); + } + + onCreate() { + this.twitterService.createTwitter(this.hoodId).subscribe((twitter) => { + if (twitter && twitter.access_token) { + const redirectUrl = + 'https://api.twitter.com/oauth/authorize?oauth_token=' + + twitter.access_token; + window.location.href = redirectUrl; + } + }); + } } diff --git a/kibicara-frontend/src/app/shared/material/material.module.ts b/kibicara-frontend/src/app/shared/material/material.module.ts index 0de107b..ce9e57d 100644 --- a/kibicara-frontend/src/app/shared/material/material.module.ts +++ b/kibicara-frontend/src/app/shared/material/material.module.ts @@ -12,6 +12,7 @@ import { MatDialogModule } from '@angular/material/dialog'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; @NgModule({ declarations: [], @@ -29,6 +30,7 @@ import { MatTooltipModule } from '@angular/material/tooltip'; MatSnackBarModule, MatSlideToggleModule, MatTooltipModule, + MatProgressSpinnerModule, ], exports: [ MatButtonModule, @@ -44,6 +46,7 @@ import { MatTooltipModule } from '@angular/material/tooltip'; MatSnackBarModule, MatSlideToggleModule, MatTooltipModule, + MatProgressSpinnerModule, ], }) export class MaterialModule {} diff --git a/kibicara-frontend/src/environments/environment.ts b/kibicara-frontend/src/environments/environment.ts index b820ee4..00d575e 100644 --- a/kibicara-frontend/src/environments/environment.ts +++ b/kibicara-frontend/src/environments/environment.ts @@ -4,8 +4,8 @@ export const environment = { production: false, - API_BASE_PATH: 'http://localhost:8000', - EMAIL_DOMAIN: 'localhost', + API_BASE_PATH: 'http://127.0.0.1:8000', + EMAIL_DOMAIN: '127.0.0.1', }; /*