mirror of https://github.com/Chocobozzz/PeerTube
Lint the client
parent
cf20596c10
commit
aff038cd78
|
@ -2,8 +2,6 @@ import { Component } from '@angular/core';
|
||||||
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated';
|
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated';
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
import { HTTP_PROVIDERS } from '@angular/http';
|
||||||
|
|
||||||
import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
|
|
||||||
|
|
||||||
import { VideosAddComponent } from '../videos/components/add/videos-add.component';
|
import { VideosAddComponent } from '../videos/components/add/videos-add.component';
|
||||||
import { VideosListComponent } from '../videos/components/list/videos-list.component';
|
import { VideosListComponent } from '../videos/components/list/videos-list.component';
|
||||||
import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
|
import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { Component, EventEmitter, Output } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated';
|
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
|
||||||
|
|
||||||
import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
|
import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
|
||||||
|
|
||||||
|
@ -16,15 +14,15 @@ export class SearchComponent {
|
||||||
@Output() search: EventEmitter<Search> = new EventEmitter<Search>();
|
@Output() search: EventEmitter<Search> = new EventEmitter<Search>();
|
||||||
|
|
||||||
searchCriterias: Search = {
|
searchCriterias: Search = {
|
||||||
field: "name",
|
field: 'name',
|
||||||
value: ""
|
value: ''
|
||||||
}
|
};
|
||||||
fieldChoices = {
|
fieldChoices = {
|
||||||
name: "Name",
|
name: 'Name',
|
||||||
author: "Author",
|
author: 'Author',
|
||||||
podUrl: "Pod Url",
|
podUrl: 'Pod Url',
|
||||||
magnetUri: "Magnet Uri"
|
magnetUri: 'Magnet Uri'
|
||||||
}
|
};
|
||||||
|
|
||||||
get choiceKeys() {
|
get choiceKeys() {
|
||||||
return Object.keys(this.fieldChoices);
|
return Object.keys(this.fieldChoices);
|
||||||
|
|
|
@ -15,12 +15,12 @@ export class VideoSortComponent {
|
||||||
|
|
||||||
sortChoices = {
|
sortChoices = {
|
||||||
'name': 'Name - Asc',
|
'name': 'Name - Asc',
|
||||||
'-name': "Name - Desc",
|
'-name': 'Name - Desc',
|
||||||
'duration': "Duration - Asc",
|
'duration': 'Duration - Asc',
|
||||||
'-duration': "Duration - Desc",
|
'-duration': 'Duration - Desc',
|
||||||
'createdDate': "Created Date - Asc",
|
'createdDate': 'Created Date - Asc',
|
||||||
'-createdDate': "Created Date - Desc"
|
'-createdDate': 'Created Date - Desc'
|
||||||
}
|
};
|
||||||
|
|
||||||
get choiceKeys() {
|
get choiceKeys() {
|
||||||
return Object.keys(this.sortChoices);
|
return Object.keys(this.sortChoices);
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class VideosListComponent implements OnInit {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
itemsPerPage: 9,
|
itemsPerPage: 9,
|
||||||
total: 0
|
total: 0
|
||||||
}
|
};
|
||||||
sort: SortField;
|
sort: SortField;
|
||||||
|
|
||||||
private search: Search;
|
private search: Search;
|
||||||
|
@ -41,7 +41,7 @@ export class VideosListComponent implements OnInit {
|
||||||
this.search = {
|
this.search = {
|
||||||
value: this._routeParams.get('search'),
|
value: this._routeParams.get('search'),
|
||||||
field: <SearchField>this._routeParams.get('field')
|
field: <SearchField>this._routeParams.get('field')
|
||||||
}
|
};
|
||||||
|
|
||||||
this.sort = <SortField>this._routeParams.get('sort') || '-createdDate';
|
this.sort = <SortField>this._routeParams.get('sort') || '-createdDate';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,27 @@ export class Video {
|
||||||
by: string;
|
by: string;
|
||||||
duration: string;
|
duration: string;
|
||||||
|
|
||||||
|
private static createDurationString(duration: number): string {
|
||||||
|
const minutes = Math.floor(duration / 60);
|
||||||
|
const seconds = duration % 60;
|
||||||
|
const minutes_padding = minutes >= 10 ? '' : '0';
|
||||||
|
const seconds_padding = seconds >= 10 ? '' : '0';
|
||||||
|
|
||||||
|
return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static createByString(author: string, podUrl: string): string {
|
||||||
|
let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
|
||||||
|
|
||||||
|
if (port === '80' || port === '443') {
|
||||||
|
port = '';
|
||||||
|
} else {
|
||||||
|
port = ':' + port;
|
||||||
|
}
|
||||||
|
|
||||||
|
return author + '@' + host + port;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(hash: {
|
constructor(hash: {
|
||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -39,22 +60,4 @@ export class Video {
|
||||||
isRemovableBy(user): boolean {
|
isRemovableBy(user): boolean {
|
||||||
return this.isLocal === true && user && this.author === user.username;
|
return this.isLocal === true && user && this.author === user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static createDurationString(duration: number): string {
|
|
||||||
const minutes = Math.floor(duration / 60);
|
|
||||||
const seconds = duration % 60;
|
|
||||||
const minutes_padding = minutes >= 10 ? '' : '0';
|
|
||||||
const seconds_padding = seconds >= 10 ? '' : '0'
|
|
||||||
|
|
||||||
return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static createByString(author: string, podUrl: string): string {
|
|
||||||
let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
|
|
||||||
|
|
||||||
if (port === '80' || port === '443') port = '';
|
|
||||||
else port = ':' + port;
|
|
||||||
|
|
||||||
return author + '@' + host + port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Http, Response, RequestOptions, URLSearchParams } from '@angular/http';
|
import { Http, Response, URLSearchParams } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
import { Pagination } from './pagination';
|
import { Pagination } from './pagination';
|
||||||
|
@ -17,7 +17,7 @@ export class VideosService {
|
||||||
getVideos(pagination: Pagination, sort: SortField) {
|
getVideos(pagination: Pagination, sort: SortField) {
|
||||||
const params = this.createPaginationParams(pagination);
|
const params = this.createPaginationParams(pagination);
|
||||||
|
|
||||||
if (sort) params.set('sort', sort)
|
if (sort) params.set('sort', sort);
|
||||||
|
|
||||||
return this.http.get(this._baseVideoUrl, { search: params })
|
return this.http.get(this._baseVideoUrl, { search: params })
|
||||||
.map(res => res.json())
|
.map(res => res.json())
|
||||||
|
@ -42,7 +42,7 @@ export class VideosService {
|
||||||
const params = this.createPaginationParams(pagination);
|
const params = this.createPaginationParams(pagination);
|
||||||
|
|
||||||
if (search.field) params.set('field', search.field);
|
if (search.field) params.set('field', search.field);
|
||||||
if (sort) params.set('sort', sort)
|
if (sort) params.set('sort', sort);
|
||||||
|
|
||||||
return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params })
|
return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params })
|
||||||
.map(res => res.json())
|
.map(res => res.json())
|
||||||
|
|
Loading…
Reference in New Issue