mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Angular application :first draft
This commit is contained in:
parent
bd324a6692
commit
dc8bc31be5
34 changed files with 509 additions and 192 deletions
63
client/angular/app/app.component.ts
Normal file
63
client/angular/app/app.component.ts
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { Component, ElementRef } from 'angular2/core';
|
||||
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
|
||||
import {HTTP_PROVIDERS} from 'angular2/http';
|
||||
|
||||
import { VideosAddComponent } from '../videos/components/add/videos-add.component';
|
||||
import { VideosListComponent } from '../videos/components/list/videos-list.component';
|
||||
import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
|
||||
import { VideosService } from '../videos/services/videos.service';
|
||||
import { FriendsService } from '../friends/services/friends.service';
|
||||
|
||||
@RouteConfig([
|
||||
{
|
||||
path: '/videos/list',
|
||||
name: 'VideosList',
|
||||
component: VideosListComponent,
|
||||
useAsDefault: true
|
||||
},
|
||||
{
|
||||
path: '/videos/watch/:id',
|
||||
name: 'VideosWatch',
|
||||
component: VideosWatchComponent
|
||||
},
|
||||
{
|
||||
path: '/videos/add',
|
||||
name: 'VideosAdd',
|
||||
component: VideosAddComponent
|
||||
}
|
||||
])
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
templateUrl: 'app/angular/app/app.component.html',
|
||||
styleUrls: [ 'app/angular/app/app.component.css' ],
|
||||
directives: [ ROUTER_DIRECTIVES ],
|
||||
providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ]
|
||||
})
|
||||
|
||||
export class AppComponent {
|
||||
constructor(private _friendsService: FriendsService) {}
|
||||
|
||||
makeFriends() {
|
||||
this._friendsService.makeFriends().subscribe(
|
||||
status => {
|
||||
if (status === 409) {
|
||||
alert('Already made friends!');
|
||||
}
|
||||
else {
|
||||
alert('Made friends!');
|
||||
}
|
||||
},
|
||||
error => alert(error)
|
||||
)
|
||||
}
|
||||
|
||||
quitFriends() {
|
||||
this._friendsService.quitFriends().subscribe(
|
||||
status => {
|
||||
alert('Quit friends!');
|
||||
},
|
||||
error => alert(error)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue