aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--client/angular/app/app.component.html14
-rw-r--r--client/angular/app/app.component.scss6
-rw-r--r--client/angular/app/app.component.ts17
-rw-r--r--client/angular/videos/components/add/videos-add.component.ts15
-rw-r--r--client/angular/videos/components/list/videos-list.component.ts27
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.ts12
-rw-r--r--client/angular/videos/services/videos.service.ts6
-rw-r--r--client/package.json1
-rw-r--r--client/stylesheets/application.scss1
-rw-r--r--client/stylesheets/index.scss5
-rw-r--r--package.json4
-rw-r--r--server/controllers/api/v1/videos.js4
13 files changed, 82 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml
index 2d3d94296..44d835d2c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,7 +21,6 @@ services:
21 21
22before_script: 22before_script:
23 - npm install electron-prebuilt -g 23 - npm install electron-prebuilt -g
24 - npm install grunt-cli -g
25 24
26after_failure: 25after_failure:
27 - cat test1/logs/all-logs.log 26 - cat test1/logs/all-logs.log
diff --git a/client/angular/app/app.component.html b/client/angular/app/app.component.html
index 590efa0d6..af41f8686 100644
--- a/client/angular/app/app.component.html
+++ b/client/angular/app/app.component.html
@@ -1,5 +1,19 @@
1<div class="container"> 1<div class="container">
2 2
3 <header class="row">
4 <div class="col-md-2">
5 <h4>PeerTube</h4>
6 </div>
7
8 <div class="col-md-8">
9 <input
10 type="text" id="search_video" name="search_video" class="form-control" placeholder="Search a video..."
11 #search (keyup.enter)="doSearch(search.value)"
12 >
13 </div>
14 </header>
15
16
3 <div class="row"> 17 <div class="row">
4 18
5 <menu class="col-md-2"> 19 <menu class="col-md-2">
diff --git a/client/angular/app/app.component.scss b/client/angular/app/app.component.scss
index 03ecba8f2..346460a31 100644
--- a/client/angular/app/app.component.scss
+++ b/client/angular/app/app.component.scss
@@ -1,3 +1,9 @@
1header div {
2 height: 50px;
3 line-height: 25px;
4 margin-bottom: 30px;
5}
6
1menu { 7menu {
2 min-height: 300px; 8 min-height: 300px;
3 height: 100%; 9 height: 100%;
diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts
index 3d41183f2..cb961a3c8 100644
--- a/client/angular/app/app.component.ts
+++ b/client/angular/app/app.component.ts
@@ -1,6 +1,6 @@
1import { Component, ElementRef } from 'angular2/core'; 1import { Component, ElementRef } from 'angular2/core';
2import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; 2import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from 'angular2/router';
3import {HTTP_PROVIDERS} from 'angular2/http'; 3import { HTTP_PROVIDERS } from 'angular2/http';
4 4
5import { VideosAddComponent } from '../videos/components/add/videos-add.component'; 5import { VideosAddComponent } from '../videos/components/add/videos-add.component';
6import { VideosListComponent } from '../videos/components/list/videos-list.component'; 6import { VideosListComponent } from '../videos/components/list/videos-list.component';
@@ -36,15 +36,22 @@ import { FriendsService } from '../friends/services/friends.service';
36}) 36})
37 37
38export class AppComponent { 38export class AppComponent {
39 constructor(private _friendsService: FriendsService) {} 39 constructor(private _friendsService: FriendsService, private _router: Router) {}
40
41 doSearch(search: string) {
42 if (search !== '') {
43 this._router.navigate(['VideosList', { search: search }]);
44 } else {
45 this._router.navigate(['VideosList']);
46 }
47 }
40 48
41 makeFriends() { 49 makeFriends() {
42 this._friendsService.makeFriends().subscribe( 50 this._friendsService.makeFriends().subscribe(
43 status => { 51 status => {
44 if (status === 409) { 52 if (status === 409) {
45 alert('Already made friends!'); 53 alert('Already made friends!');
46 } 54 } else {
47 else {
48 alert('Made friends!'); 55 alert('Made friends!');
49 } 56 }
50 }, 57 },
diff --git a/client/angular/videos/components/add/videos-add.component.ts b/client/angular/videos/components/add/videos-add.component.ts
index 97e3bb3b5..8ff6cfec8 100644
--- a/client/angular/videos/components/add/videos-add.component.ts
+++ b/client/angular/videos/components/add/videos-add.component.ts
@@ -1,9 +1,10 @@
1import {Component, ElementRef, Inject, OnInit} from 'angular2/core'; 1import { Component, ElementRef, Inject, OnInit } from 'angular2/core';
2import {Router} from 'angular2/router'; 2import { Router } from 'angular2/router';
3import {NgForm} from 'angular2/common'; 3import { NgForm } from 'angular2/common';
4 4
5import {Video} from '../../models/video'; 5import { Video } from '../../models/video';
6 6
7// TODO: import it with systemjs
7declare var jQuery:any; 8declare var jQuery:any;
8 9
9@Component({ 10@Component({
@@ -22,9 +23,10 @@ export class VideosAddComponent implements OnInit {
22 23
23 ngOnInit() { 24 ngOnInit() {
24 jQuery(this._elementRef.nativeElement).find('#input_video').fileupload({ 25 jQuery(this._elementRef.nativeElement).find('#input_video').fileupload({
26 url: '/api/v1/videos',
27 dataType: 'json',
25 singleFileUploads: true, 28 singleFileUploads: true,
26 multipart: true, 29 multipart: true,
27 url: '/api/v1/videos',
28 autoupload: false, 30 autoupload: false,
29 31
30 add: (e, data) => { 32 add: (e, data) => {
@@ -38,7 +40,8 @@ export class VideosAddComponent implements OnInit {
38 }, 40 },
39 41
40 done: (e, data) => { 42 done: (e, data) => {
41 console.log('finished'); 43 console.log('Video uploaded.');
44
42 // Print all the videos once it's finished 45 // Print all the videos once it's finished
43 this._router.navigate(['VideosList']); 46 this._router.navigate(['VideosList']);
44 } 47 }
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts
index e5af87448..eb23ed1ff 100644
--- a/client/angular/videos/components/list/videos-list.component.ts
+++ b/client/angular/videos/components/list/videos-list.component.ts
@@ -1,8 +1,8 @@
1import {Component, OnInit} from 'angular2/core'; 1import { Component, OnInit } from 'angular2/core';
2import {ROUTER_DIRECTIVES} from 'angular2/router'; 2import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router';
3 3
4import {VideosService} from '../../services/videos.service'; 4import { VideosService } from '../../services/videos.service';
5import {Video} from '../../models/video'; 5import { Video } from '../../models/video';
6 6
7@Component({ 7@Component({
8 selector: 'my-videos-list', 8 selector: 'my-videos-list',
@@ -14,16 +14,29 @@ import {Video} from '../../models/video';
14export class VideosListComponent implements OnInit { 14export class VideosListComponent implements OnInit {
15 videos: Video[]; 15 videos: Video[];
16 16
17 private search: string;
18
17 constructor( 19 constructor(
18 private _videosService: VideosService 20 private _videosService: VideosService,
19 ) { } 21 routeParams: RouteParams
22 ) {
23 this.search = routeParams.get('search');
24 }
20 25
21 ngOnInit() { 26 ngOnInit() {
22 this.getVideos(); 27 this.getVideos();
23 } 28 }
24 29
25 getVideos() { 30 getVideos() {
26 this._videosService.getVideos().subscribe( 31 let observable = null;
32
33 if (this.search !== null) {
34 observable = this._videosService.searchVideos(this.search);
35 } else {
36 observable = this._videosService.getVideos()
37 }
38
39 observable.subscribe(
27 videos => this.videos = videos, 40 videos => this.videos = videos,
28 error => alert(error) 41 error => alert(error)
29 ); 42 );
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts
index e3a973820..da7f942db 100644
--- a/client/angular/videos/components/watch/videos-watch.component.ts
+++ b/client/angular/videos/components/watch/videos-watch.component.ts
@@ -1,8 +1,9 @@
1/// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' /> 1/// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' />
2 2
3import { Component, OnInit, ElementRef } from 'angular2/core'; 3import { Component, OnInit, ElementRef } from 'angular2/core';
4import { RouteParams } from 'angular2/router'; 4import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
5 5
6// TODO import it with systemjs
6declare var WebTorrent: any; 7declare var WebTorrent: any;
7 8
8import { Video } from '../../models/video'; 9import { Video } from '../../models/video';
@@ -14,7 +15,7 @@ import { VideosService } from '../../services/videos.service';
14 styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] 15 styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ]
15}) 16})
16 17
17export class VideosWatchComponent { 18export class VideosWatchComponent implements OnInit, CanDeactivate {
18 video: Video; 19 video: Video;
19 20
20 private client: any; 21 private client: any;
@@ -24,6 +25,7 @@ export class VideosWatchComponent {
24 private _routeParams: RouteParams, 25 private _routeParams: RouteParams,
25 private _elementRef: ElementRef 26 private _elementRef: ElementRef
26 ) { 27 ) {
28 // TODO: use a service
27 this.client = new WebTorrent({ dht: false }); 29 this.client = new WebTorrent({ dht: false });
28 } 30 }
29 31
@@ -47,4 +49,10 @@ export class VideosWatchComponent {
47 }) 49 })
48 }) 50 })
49 } 51 }
52
53 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
54 console.log('Removing video from webtorrent.');
55 this.client.remove(this.video.magnetUri);
56 return true;
57 }
50} 58}
diff --git a/client/angular/videos/services/videos.service.ts b/client/angular/videos/services/videos.service.ts
index 784eec68d..17ae89c8b 100644
--- a/client/angular/videos/services/videos.service.ts
+++ b/client/angular/videos/services/videos.service.ts
@@ -30,6 +30,12 @@ export class VideosService {
30 } 30 }
31 } 31 }
32 32
33 searchVideos(search: string) {
34 return this.http.get(this._baseVideoUrl + 'search/' + search)
35 .map(res => <Video> res.json())
36 .catch(this.handleError);
37 }
38
33 private handleError (error: Response) { 39 private handleError (error: Response) {
34 console.error(error); 40 console.error(error);
35 return Observable.throw(error.json().error || 'Server error'); 41 return Observable.throw(error.json().error || 'Server error');
diff --git a/client/package.json b/client/package.json
index dbb065974..78abde752 100644
--- a/client/package.json
+++ b/client/package.json
@@ -30,7 +30,6 @@
30 "reflect-metadata": "0.1.2", 30 "reflect-metadata": "0.1.2",
31 "rxjs": "5.0.0-beta.2", 31 "rxjs": "5.0.0-beta.2",
32 "systemjs": "0.19.22", 32 "systemjs": "0.19.22",
33 "webtorrent": "^0.85.1",
34 "zone.js": "0.5.15" 33 "zone.js": "0.5.15"
35 }, 34 },
36 "devDependencies": { 35 "devDependencies": {
diff --git a/client/stylesheets/application.scss b/client/stylesheets/application.scss
index d1b309907..b91698056 100644
--- a/client/stylesheets/application.scss
+++ b/client/stylesheets/application.scss
@@ -3,4 +3,3 @@ $icon-font-path: "/app/node_modules/bootstrap-sass/assets/fonts/bootstrap/";
3@import "bootstrap-variables"; 3@import "bootstrap-variables";
4@import "_bootstrap"; 4@import "_bootstrap";
5@import "base.scss"; 5@import "base.scss";
6@import "index.scss";
diff --git a/client/stylesheets/index.scss b/client/stylesheets/index.scss
deleted file mode 100644
index 5cba54705..000000000
--- a/client/stylesheets/index.scss
+++ /dev/null
@@ -1,5 +0,0 @@
1header div {
2 height: 50px;
3 line-height: 25px;
4 margin-bottom: 50px;
5}
diff --git a/package.json b/package.json
index 36730aaa0..6252bac47 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,9 @@
40 "dev": "npm run build && concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"", 40 "dev": "npm run build && concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"",
41 "livereload": "livereload ./client", 41 "livereload": "livereload ./client",
42 "start": "node server", 42 "start": "node server",
43 "test": "standard && mocha server/tests" 43 "test": "standard && mocha server/tests",
44
45 "postinstall": "cd client && npm install"
44 }, 46 },
45 "dependencies": { 47 "dependencies": {
46 "async": "^1.2.1", 48 "async": "^1.2.1",
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index 9398aabb7..76cad62d1 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -76,8 +76,8 @@ function addVideo (req, res, next) {
76 // Now we'll add the video's meta data to our friends 76 // Now we'll add the video's meta data to our friends
77 friends.addVideoToFriends(video_data) 77 friends.addVideoToFriends(video_data)
78 78
79 // TODO : include Location of the new video 79 // TODO : include Location of the new video -> 201
80 res.type('json').status(201).end() 80 res.type('json').status(204).end()
81 }) 81 })
82 }) 82 })
83} 83}