Use typescript standard and lint all files
authorChocobozzz <florian.bigard@gmail.com>
Fri, 16 Jun 2017 12:32:15 +0000 (14:32 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Fri, 16 Jun 2017 12:32:15 +0000 (14:32 +0200)
143 files changed:
client/package.json
client/src/app/+admin/admin-routing.module.ts
client/src/app/+admin/admin.component.ts
client/src/app/+admin/admin.module.ts
client/src/app/+admin/friends/friend-add/friend-add.component.ts
client/src/app/+admin/friends/friend-add/index.ts
client/src/app/+admin/friends/friend-list/friend-list.component.ts
client/src/app/+admin/friends/friend-list/index.ts
client/src/app/+admin/friends/friends.component.ts
client/src/app/+admin/friends/friends.routes.ts
client/src/app/+admin/friends/index.ts
client/src/app/+admin/friends/shared/friend.model.ts
client/src/app/+admin/friends/shared/friend.service.ts
client/src/app/+admin/friends/shared/index.ts
client/src/app/+admin/index.ts
client/src/app/+admin/requests/index.ts
client/src/app/+admin/requests/request-stats/index.ts
client/src/app/+admin/requests/request-stats/request-stats.component.ts
client/src/app/+admin/requests/requests.component.ts
client/src/app/+admin/requests/requests.routes.ts
client/src/app/+admin/requests/shared/index.ts
client/src/app/+admin/requests/shared/request-stats.model.ts
client/src/app/+admin/requests/shared/request.service.ts
client/src/app/+admin/users/index.ts
client/src/app/+admin/users/shared/index.ts
client/src/app/+admin/users/shared/user.service.ts
client/src/app/+admin/users/user-add/index.ts
client/src/app/+admin/users/user-add/user-add.component.ts
client/src/app/+admin/users/user-list/index.ts
client/src/app/+admin/users/user-list/user-list.component.ts
client/src/app/+admin/users/users.component.ts
client/src/app/+admin/users/users.routes.ts
client/src/app/+admin/video-abuses/index.ts
client/src/app/+admin/video-abuses/video-abuse-list/index.ts
client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
client/src/app/+admin/video-abuses/video-abuses.component.ts
client/src/app/+admin/video-abuses/video-abuses.routes.ts
client/src/app/account/account-change-password/account-change-password.component.ts
client/src/app/account/account-change-password/index.ts
client/src/app/account/account-details/account-details.component.ts
client/src/app/account/account-details/index.ts
client/src/app/account/account-routing.module.ts
client/src/app/account/account.component.ts
client/src/app/account/account.module.ts
client/src/app/account/index.ts
client/src/app/app-routing.module.ts
client/src/app/app.component.ts
client/src/app/app.module.ts
client/src/app/app.resolver.ts
client/src/app/app.service.ts
client/src/app/core/auth/auth-user.model.ts
client/src/app/core/auth/auth.service.ts
client/src/app/core/auth/index.ts
client/src/app/core/config/config.service.ts
client/src/app/core/config/index.ts
client/src/app/core/confirm/confirm.component.ts
client/src/app/core/confirm/confirm.service.ts
client/src/app/core/confirm/index.ts
client/src/app/core/core.module.ts
client/src/app/core/index.ts
client/src/app/core/menu/index.ts
client/src/app/core/menu/menu-admin.component.ts
client/src/app/core/menu/menu.component.ts
client/src/app/core/module-import-guard.ts
client/src/app/environment.ts
client/src/app/index.ts
client/src/app/login/index.ts
client/src/app/login/login-routing.module.ts
client/src/app/login/login.component.ts
client/src/app/login/login.module.ts
client/src/app/shared/auth/auth-http.service.ts
client/src/app/shared/auth/index.ts
client/src/app/shared/forms/form-reactive.ts
client/src/app/shared/forms/form-validators/host.validator.ts
client/src/app/shared/forms/form-validators/index.ts
client/src/app/shared/forms/form-validators/user.ts
client/src/app/shared/forms/form-validators/video-abuse.ts
client/src/app/shared/forms/form-validators/video.ts
client/src/app/shared/forms/index.ts
client/src/app/shared/index.ts
client/src/app/shared/rest/index.ts
client/src/app/shared/rest/rest-data-source.ts
client/src/app/shared/rest/rest-extractor.service.ts
client/src/app/shared/rest/rest-pagination.ts
client/src/app/shared/rest/rest.service.ts
client/src/app/shared/search/index.ts
client/src/app/shared/search/search-field.type.ts
client/src/app/shared/search/search.component.ts
client/src/app/shared/search/search.model.ts
client/src/app/shared/search/search.service.ts
client/src/app/shared/shared.module.ts
client/src/app/shared/users/index.ts
client/src/app/shared/users/user.model.ts
client/src/app/shared/users/user.service.ts
client/src/app/shared/utils.ts
client/src/app/shared/video-abuse/index.ts
client/src/app/shared/video-abuse/video-abuse.model.ts
client/src/app/shared/video-abuse/video-abuse.service.ts
client/src/app/signup/index.ts
client/src/app/signup/signup-routing.module.ts
client/src/app/signup/signup.component.ts
client/src/app/signup/signup.module.ts
client/src/app/videos/index.ts
client/src/app/videos/shared/index.ts
client/src/app/videos/shared/rate-type.type.ts
client/src/app/videos/shared/sort-field.type.ts
client/src/app/videos/shared/video.model.ts
client/src/app/videos/shared/video.service.ts
client/src/app/videos/video-edit/index.ts
client/src/app/videos/video-edit/video-add.component.ts
client/src/app/videos/video-edit/video-update.component.ts
client/src/app/videos/video-list/index.ts
client/src/app/videos/video-list/loader.component.ts
client/src/app/videos/video-list/video-list.component.html
client/src/app/videos/video-list/video-list.component.ts
client/src/app/videos/video-list/video-miniature.component.ts
client/src/app/videos/video-list/video-sort.component.ts
client/src/app/videos/video-watch/index.ts
client/src/app/videos/video-watch/video-magnet.component.ts
client/src/app/videos/video-watch/video-report.component.ts
client/src/app/videos/video-watch/video-share.component.ts
client/src/app/videos/video-watch/video-watch.component.ts
client/src/app/videos/video-watch/webtorrent.service.ts
client/src/app/videos/videos-routing.module.ts
client/src/app/videos/videos.component.ts
client/src/app/videos/videos.module.ts
client/src/custom-typings.d.ts
client/src/main.browser.aot.ts
client/src/main.browser.ts
client/src/polyfills.browser.ts
client/tslint.json
client/yarn.lock
package.json
scripts/check.ts
scripts/test.sh
server/controllers/index.ts
server/helpers/utils.ts
server/initializers/database.ts
server/initializers/migrator.ts
server/lib/friends.ts
server/lib/jobs/handlers/video-transcoder.ts
tslint.json
yarn.lock

index aee548c3f5e3e3b81a66d5b546f47583d7316e8a..794121ffbd0af3f4c897c7a6770c72dcdd2f2517 100644 (file)
@@ -13,7 +13,7 @@
     "url": "git://github.com/Chocobozzz/PeerTube.git"
   },
   "scripts": {
-    "test": "standard && tslint -c ./tslint.json src/**/*.ts",
+    "test": "standard && tslint --type-check --project ./tsconfig.json -c ./tslint.json 'src/app/**/*.ts'",
     "webpack": "webpack",
     "webpack-dev-server": "webpack-dev-server"
   },
@@ -78,7 +78,7 @@
     "tslib": "^1.5.0",
     "tslint": "~5.4.3",
     "tslint-loader": "^3.3.0",
-    "typescript": "~2.3.0",
+    "typescript": "~2.4.0",
     "url-loader": "^0.5.7",
     "video.js": "^5.19.2",
     "videojs-dock": "^2.0.2",
@@ -93,6 +93,7 @@
     "codelyzer": "^3.0.0-beta.4",
     "ng2-completer": "1.2.2",
     "standard": "^10.0.0",
+    "tslint-config-standard": "^6.0.1",
     "webpack-bundle-analyzer": "^2.8.2",
     "webpack-dev-server": "^2.4.5",
     "webpack-dll-bundles-plugin": "^1.0.0-beta.5"
index d3adf3f3b96c876f7a17d3132bb03b8f6a04c12b..839913135fba9da2d4416c8a147017e01ebbf9f0 100644 (file)
@@ -1,11 +1,11 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { RouterModule, Routes } from '@angular/router'
 
-import { AdminComponent } from './admin.component';
-import { FriendsRoutes } from './friends';
-import { RequestsRoutes } from './requests';
-import { UsersRoutes } from './users';
-import { VideoAbusesRoutes } from './video-abuses';
+import { AdminComponent } from './admin.component'
+import { FriendsRoutes } from './friends'
+import { RequestsRoutes } from './requests'
+import { UsersRoutes } from './users'
+import { VideoAbusesRoutes } from './video-abuses'
 
 const adminRoutes: Routes = [
   {
@@ -23,7 +23,7 @@ const adminRoutes: Routes = [
       ...VideoAbusesRoutes
     ]
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forChild(adminRoutes) ],
index 64a7400e7e954d5c8d3660a054b7c2c06cb132e7..93ec216bfd7efd12fcef1e36dc949e317d340a6f 100644 (file)
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
   template: '<router-outlet></router-outlet>'
index db1ce2d7f90a85041570526f39e64b5fc033c44c..9ecce5dc3a7722caa144ba4f7761e1a827196ffa 100644 (file)
@@ -1,12 +1,12 @@
-import { NgModule } from '@angular/core';
-
-import { AdminComponent } from './admin.component';
-import { AdminRoutingModule } from './admin-routing.module';
-import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends';
-import { RequestsComponent, RequestStatsComponent, RequestService } from './requests';
-import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users';
-import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses';
-import { SharedModule } from '../shared';
+import { NgModule } from '@angular/core'
+
+import { AdminComponent } from './admin.component'
+import { AdminRoutingModule } from './admin-routing.module'
+import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends'
+import { RequestsComponent, RequestStatsComponent, RequestService } from './requests'
+import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users'
+import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
+import { SharedModule } from '../shared'
 
 @NgModule({
   imports: [
index 12c46e5cd6fbcae63532c72108ed5c51592d4eb8..35cf4a1f7673f9cb9b3c1789ff32779b590798a4 100644 (file)
@@ -1,12 +1,12 @@
-import { Component, OnInit } from '@angular/core';
-import { FormControl, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormControl, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { ConfirmService } from '../../../core';
-import { validateHost } from '../../../shared';
-import { FriendService } from '../shared';
+import { ConfirmService } from '../../../core'
+import { validateHost } from '../../../shared'
+import { FriendService } from '../shared'
 
 @Component({
   selector: 'my-friend-add',
@@ -14,107 +14,107 @@ import { FriendService } from '../shared';
   styleUrls: [ './friend-add.component.scss' ]
 })
 export class FriendAddComponent implements OnInit {
-  form: FormGroup;
-  hosts = [ ];
-  error: string = null;
+  form: FormGroup
+  hosts = [ ]
+  error: string = null
 
-  constructor(
+  constructor (
     private router: Router,
     private notificationsService: NotificationsService,
     private confirmService: ConfirmService,
     private friendService: FriendService
   ) {}
 
-  ngOnInit() {
-    this.form = new FormGroup({});
-    this.addField();
+  ngOnInit () {
+    this.form = new FormGroup({})
+    this.addField()
   }
 
-  addField() {
-    this.form.addControl(`host-${this.hosts.length}`, new FormControl('', [ validateHost ]));
-    this.hosts.push('');
+  addField () {
+    this.form.addControl(`host-${this.hosts.length}`, new FormControl('', [ validateHost ]))
+    this.hosts.push('')
   }
 
-  canMakeFriends() {
-    return window.location.protocol === 'https:';
+  canMakeFriends () {
+    return window.location.protocol === 'https:'
   }
 
-  customTrackBy(index: number, obj: any): any {
-    return index;
+  customTrackBy (index: number, obj: any): any {
+    return index
   }
 
-  displayAddField(index: number) {
-    return index === (this.hosts.length - 1);
+  displayAddField (index: number) {
+    return index === (this.hosts.length - 1)
   }
 
-  displayRemoveField(index: number) {
-    return (index !== 0 || this.hosts.length > 1) && index !== (this.hosts.length - 1);
+  displayRemoveField (index: number) {
+    return (index !== 0 || this.hosts.length > 1) && index !== (this.hosts.length - 1)
   }
 
-  isFormValid() {
+  isFormValid () {
     // Do not check the last input
     for (let i = 0; i < this.hosts.length - 1; i++) {
-      if (!this.form.controls[`host-${i}`].valid) return false;
+      if (!this.form.controls[`host-${i}`].valid) return false
     }
 
-    const lastIndex = this.hosts.length - 1;
+    const lastIndex = this.hosts.length - 1
     // If the last input (which is not the first) is empty, it's ok
     if (this.hosts[lastIndex] === '' && lastIndex !== 0) {
-      return true;
+      return true
     } else {
-      return this.form.controls[`host-${lastIndex}`].valid;
+      return this.form.controls[`host-${lastIndex}`].valid
     }
   }
 
-  removeField(index: number) {
+  removeField (index: number) {
     // Remove the last control
-    this.form.removeControl(`host-${this.hosts.length - 1}`);
-    this.hosts.splice(index, 1);
+    this.form.removeControl(`host-${this.hosts.length - 1}`)
+    this.hosts.splice(index, 1)
   }
 
-  makeFriends() {
-    this.error = '';
+  makeFriends () {
+    this.error = ''
 
-    const notEmptyHosts = this.getNotEmptyHosts();
+    const notEmptyHosts = this.getNotEmptyHosts()
     if (notEmptyHosts.length === 0) {
-      this.error = 'You need to specify at least 1 host.';
-      return;
+      this.error = 'You need to specify at least 1 host.'
+      return
     }
 
     if (!this.isHostsUnique(notEmptyHosts)) {
-      this.error = 'Hosts need to be unique.';
-      return;
+      this.error = 'Hosts need to be unique.'
+      return
     }
 
-    const confirmMessage = 'Are you sure to make friends with:<br /> - ' + notEmptyHosts.join('<br /> - ');
+    const confirmMessage = 'Are you sure to make friends with:<br /> - ' + notEmptyHosts.join('<br /> - ')
     this.confirmService.confirm(confirmMessage, 'Make friends').subscribe(
       res => {
-        if (res === false) return;
+        if (res === false) return
 
         this.friendService.makeFriends(notEmptyHosts).subscribe(
           status => {
-            this.notificationsService.success('Sucess', 'Make friends request sent!');
-            this.router.navigate([ '/admin/friends/list' ]);
+            this.notificationsService.success('Sucess', 'Make friends request sent!')
+            this.router.navigate([ '/admin/friends/list' ])
           },
 
           err => this.notificationsService.error('Error', err.text)
-        );
+        )
       }
-    );
+    )
   }
 
-  private getNotEmptyHosts() {
-    const notEmptyHosts = [];
+  private getNotEmptyHosts () {
+    const notEmptyHosts = []
 
     Object.keys(this.form.value).forEach((hostKey) => {
-      const host = this.form.value[hostKey];
-      if (host !== '') notEmptyHosts.push(host);
-    });
+      const host = this.form.value[hostKey]
+      if (host !== '') notEmptyHosts.push(host)
+    })
 
-    return notEmptyHosts;
+    return notEmptyHosts
   }
 
-  private isHostsUnique(hosts: string[]) {
-    return hosts.every(host => hosts.indexOf(host) === hosts.lastIndexOf(host));
+  private isHostsUnique (hosts: string[]) {
+    return hosts.every(host => hosts.indexOf(host) === hosts.lastIndexOf(host))
   }
 }
index a101b3be5c6782bbcb31c3ade07d6f90ad059d80..978ab3d463756f125e758ef01b3e93b7d39cf95b 100644 (file)
@@ -1 +1 @@
-export * from './friend-add.component';
+export * from './friend-add.component'
index 525a9fbc388b3f6db76979fdd609a0a7598a4770..7bf9d2c6b577f243ee97904555962a705938bb4d 100644 (file)
@@ -1,11 +1,11 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
-import { NotificationsService } from 'angular2-notifications';
-import { ServerDataSource } from 'ng2-smart-table';
+import { NotificationsService } from 'angular2-notifications'
+import { ServerDataSource } from 'ng2-smart-table'
 
-import { ConfirmService } from '../../../core';
-import { Utils } from '../../../shared';
-import { Friend, FriendService } from '../shared';
+import { ConfirmService } from '../../../core'
+import { Utils } from '../../../shared'
+import { Friend, FriendService } from '../shared'
 
 @Component({
   selector: 'my-friend-list',
@@ -13,7 +13,7 @@ import { Friend, FriendService } from '../shared';
   styleUrls: [ './friend-list.component.scss' ]
 })
 export class FriendListComponent {
-  friendsSource = null;
+  friendsSource = null
   tableSettings = {
     attr: {
       class: 'table-hover'
@@ -49,36 +49,36 @@ export class FriendListComponent {
         valuePrepareFunction: Utils.dateToHuman
       }
     }
-  };
+  }
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private confirmService: ConfirmService,
     private friendService: FriendService
   ) {
-    this.friendsSource = this.friendService.getDataSource();
+    this.friendsSource = this.friendService.getDataSource()
   }
 
-  hasFriends() {
-    return this.friendsSource.count() !== 0;
+  hasFriends () {
+    return this.friendsSource.count() !== 0
   }
 
-  quitFriends() {
-    const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.';
+  quitFriends () {
+    const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.'
     this.confirmService.confirm(confirmMessage, 'Quit friends').subscribe(
       res => {
-        if (res === false) return;
+        if (res === false) return
 
         this.friendService.quitFriends().subscribe(
           status => {
-            this.notificationsService.success('Sucess', 'Friends left!');
+            this.notificationsService.success('Sucess', 'Friends left!')
 
-            this.friendsSource.refresh();
+            this.friendsSource.refresh()
           },
 
           err => this.notificationsService.error('Error', err.text)
-        );
+        )
       }
-    );
+    )
   }
 }
index 354c978a44a9747ed9da0de6bc654c4a43b89408..c9cbd2800d94361cf165c191f086389b3d6d1ad6 100644 (file)
@@ -1 +1 @@
-export * from './friend-list.component';
+export * from './friend-list.component'
index 5ca29111cbc1a36a316f3c201da59175bed85117..5ef0aaa030dfb78cae7bcd04987490b87b574759 100644 (file)
@@ -1,8 +1,7 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
-   template: '<router-outlet></router-outlet>'
+  template: '<router-outlet></router-outlet>'
 })
-
 export class FriendsComponent {
 }
index 747066d1fdc299194601ff90d670bf3bda1fa5b0..615b6f4f7ce708cab5e2837aa9b77d04c3488c2a 100644 (file)
@@ -1,37 +1,37 @@
-import { Routes } from '@angular/router';
+import { Routes } from '@angular/router'
 
-import { FriendsComponent } from './friends.component';
-import { FriendAddComponent } from './friend-add';
-import { FriendListComponent } from './friend-list';
+import { FriendsComponent } from './friends.component'
+import { FriendAddComponent } from './friend-add'
+import { FriendListComponent } from './friend-list'
 
 export const FriendsRoutes: Routes = [
   {
-      path: 'friends',
-      component: FriendsComponent,
-      children: [
-        {
-          path: '',
-          redirectTo: 'list',
-          pathMatch: 'full'
-        },
-        {
-          path: 'list',
-          component: FriendListComponent,
-          data: {
-            meta: {
-              title: 'Friends list'
-            }
+    path: 'friends',
+    component: FriendsComponent,
+    children: [
+      {
+        path: '',
+        redirectTo: 'list',
+        pathMatch: 'full'
+      },
+      {
+        path: 'list',
+        component: FriendListComponent,
+        data: {
+          meta: {
+            title: 'Friends list'
           }
-        },
-        {
-          path: 'add',
-          component: FriendAddComponent,
-          data: {
-            meta: {
-              title: 'Add friends'
-            }
+        }
+      },
+      {
+        path: 'add',
+        component: FriendAddComponent,
+        data: {
+          meta: {
+            title: 'Add friends'
           }
         }
-      ]
-    }
-];
+      }
+    ]
+  }
+]
index dd4df2538e4a5d305f1e87e0cd5f8181315c6b50..356dee8e998d9bfe69f81c0090f6ff2764a53def 100644 (file)
@@ -1,5 +1,5 @@
-export * from './friend-add';
-export * from './friend-list';
-export * from './shared';
-export * from './friends.component';
-export * from './friends.routes';
+export * from './friend-add'
+export * from './friend-list'
+export * from './shared'
+export * from './friends.component'
+export * from './friends.routes'
index f72156d05b601170386af15d74f4030cfc9f789f..6950405b920188f0a1c78df5e17e175a839c7aac 100644 (file)
@@ -1,7 +1,7 @@
 export interface Friend {
-  id: string;
-  host: string;
-  score: number;
-  email: string;
-  createdAt: Date;
+  id: string
+  host: string
+  score: number
+  email: string
+  createdAt: Date
 }
index 6e51c954fff8814fd51eed5fd1324cdc9bf53778..f4ecd36ad3f78bcda4838b6385915752951ee85b 100644 (file)
@@ -1,39 +1,39 @@
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
+import { Injectable } from '@angular/core'
+import { Observable } from 'rxjs/Observable'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
 
-import { ServerDataSource } from 'ng2-smart-table';
+import { ServerDataSource } from 'ng2-smart-table'
 
-import { Friend } from './friend.model';
-import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared';
+import { Friend } from './friend.model'
+import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared'
 
 @Injectable()
 export class FriendService {
-  private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/';
+  private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/'
 
   constructor (
     private authHttp: AuthHttp,
     private restExtractor: RestExtractor
   ) {}
 
-  getDataSource() {
-    return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL);
+  getDataSource () {
+    return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL)
   }
 
-  makeFriends(notEmptyHosts) {
+  makeFriends (notEmptyHosts) {
     const body = {
       hosts: notEmptyHosts
-    };
+    }
 
     return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  quitFriends() {
+  quitFriends () {
     return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
                         .map(res => res.status)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 }
index 0d671637d11b8cfd6cc7119080262ff6edf1db59..41aa6edd644bb52b804236cfd8de0716f116feb1 100644 (file)
@@ -1,2 +1,2 @@
-export * from './friend.model';
-export * from './friend.service';
+export * from './friend.model'
+export * from './friend.service'
index 2f47a3cc30b8ba246df1128e2d9d6d3dd87e8d0f..11e2587c088e9f234fb168b821cddd9ee330b7b1 100644 (file)
@@ -1,6 +1,6 @@
-export * from './friends';
-export * from './requests';
-export * from './users';
-export * from './admin-routing.module';
-export * from './admin.module';
-export * from './admin.component';
+export * from './friends'
+export * from './requests'
+export * from './users'
+export * from './admin-routing.module'
+export * from './admin.module'
+export * from './admin.component'
index 236a9ee8fc4ee5bc3497bf31bb35cd51cc4a4604..d96a893c34ead6bf303f6fe0a0433eba1717834d 100644 (file)
@@ -1,4 +1,4 @@
-export * from './request-stats';
-export * from './shared';
-export * from './requests.component';
-export * from './requests.routes';
+export * from './request-stats'
+export * from './shared'
+export * from './requests.component'
+export * from './requests.routes'
index be3a66f77dec65f41e1cb837300bb9055ddcec98..740c401bbf27cc3db45152c769162bedb86ff511 100644 (file)
@@ -1 +1 @@
-export * from './request-stats.component';
+export * from './request-stats.component'
index 85dd7e492918d733d8cc4d18af75dc8cf4e33485..cca4926cf237c901bb8a8e35910cf53223ef8c18 100644 (file)
@@ -1,12 +1,12 @@
-import { Component, OnInit, OnDestroy } from '@angular/core';
+import { Component, OnInit, OnDestroy } from '@angular/core'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { RequestService, RequestStats } from '../shared';
+import { RequestService, RequestStats } from '../shared'
 
 @Component({
-       selector: 'my-request-stats',
-       templateUrl: './request-stats.component.html',
+  selector: 'my-request-stats',
+  templateUrl: './request-stats.component.html',
   styleUrls: [ './request-stats.component.scss' ]
 })
 export class RequestStatsComponent implements OnInit, OnDestroy {
@@ -14,70 +14,67 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
     requestScheduler: 'Basic request scheduler',
     requestVideoEventScheduler: 'Video events request scheduler',
     requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
-  };
+  }
 
   stats: { [ id: string ]: RequestStats } = {
     requestScheduler: null,
     requestVideoEventScheduler: null,
     requestVideoQaduScheduler: null
-  };
+  }
 
   private intervals: { [ id: string ]: number } = {
     requestScheduler: null,
     requestVideoEventScheduler: null,
     requestVideoQaduScheduler: null
-  };
+  }
 
   private timeouts: { [ id: string ]: number } = {
     requestScheduler: null,
     requestVideoEventScheduler: null,
     requestVideoQaduScheduler: null
-  };
-
+  }
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private requestService: RequestService
-  ) {  }
+  ) { }
 
-  ngOnInit() {
-    this.getStats();
-    this.runIntervals();
+  ngOnInit () {
+    this.getStats()
+    this.runIntervals()
   }
 
-  ngOnDestroy() {
+  ngOnDestroy () {
     Object.keys(this.stats).forEach(requestSchedulerName => {
       if (this.intervals[requestSchedulerName] !== null) {
-        window.clearInterval(this.intervals[requestSchedulerName]);
+        window.clearInterval(this.intervals[requestSchedulerName])
       }
 
       if (this.timeouts[requestSchedulerName] !== null) {
-        window.clearTimeout(this.timeouts[requestSchedulerName]);
+        window.clearTimeout(this.timeouts[requestSchedulerName])
       }
-    });
+    })
   }
 
-  getStats() {
+  getStats () {
     this.requestService.getStats().subscribe(
       stats => this.stats = stats,
 
       err => this.notificationsService.error('Error', err.text)
-    );
+    )
   }
 
-  private runIntervals() {
+  private runIntervals () {
     Object.keys(this.intervals).forEach(requestSchedulerName => {
       this.intervals[requestSchedulerName] = window.setInterval(() => {
-        const stats = this.stats[requestSchedulerName];
+        const stats = this.stats[requestSchedulerName]
 
-        stats.remainingMilliSeconds -= 1000;
+        stats.remainingMilliSeconds -= 1000
 
         if (stats.remainingMilliSeconds <= 0) {
-          this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100);
+          this.timeouts[requestSchedulerName] = window.setTimeout(() => this.getStats(), stats.remainingMilliSeconds + 100)
         }
-      }, 1000);
-    });
+      }, 1000)
+    })
   }
-
-
 }
index 471112b45befc19845d99c8043f438dd4f9fecd0..88a90fa4e7f13cc9510546d3eb9462b738e0b378 100644 (file)
@@ -1,8 +1,7 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
-    template: '<router-outlet></router-outlet>'
+  template: '<router-outlet></router-outlet>'
 })
-
 export class RequestsComponent {
 }
index 251dd0da81991eec67bf9c66c72af8d18955076e..84db3fea88476dcdd14306a65def27a086201258 100644 (file)
@@ -1,27 +1,27 @@
-import { Routes } from '@angular/router';
+import { Routes } from '@angular/router'
 
-import { RequestsComponent } from './requests.component';
-import { RequestStatsComponent } from './request-stats';
+import { RequestsComponent } from './requests.component'
+import { RequestStatsComponent } from './request-stats'
 
 export const RequestsRoutes: Routes = [
   {
-      path: 'requests',
-      component: RequestsComponent,
-      children: [
-        {
-          path: '',
-          redirectTo: 'stats',
-          pathMatch: 'full'
-        },
-        {
-          path: 'stats',
-          component: RequestStatsComponent,
-          data: {
-            meta: {
-              title: 'Request stats'
-            }
+    path: 'requests',
+    component: RequestsComponent,
+    children: [
+      {
+        path: '',
+        redirectTo: 'stats',
+        pathMatch: 'full'
+      },
+      {
+        path: 'stats',
+        component: RequestStatsComponent,
+        data: {
+          meta: {
+            title: 'Request stats'
           }
         }
-      ]
-    }
-];
+      }
+    ]
+  }
+]
index 32ab5767be6a1431a2cb0848e6238738b730ef44..2442e810ad3f7063078ec0c0bae7c3360f57de46 100644 (file)
@@ -1,2 +1,2 @@
-export * from './request-stats.model';
-export * from './request.service';
+export * from './request-stats.model'
+export * from './request.service'
index f658c468260e10ca0b5cfe2387e40b6d627a82a5..31550b5c08f1c091f146bb8c6b0f090f52efc9c5 100644 (file)
@@ -1,35 +1,35 @@
 export interface Request {
-  request: any;
-  to: any;
+  request: any
+  to: any
 }
 
 export class RequestStats {
-  requestsLimitPods: number;
-  requestsLimitPerPod: number;
-  milliSecondsInterval: number;
-  remainingMilliSeconds: number;
-  totalRequests: number;
+  requestsLimitPods: number
+  requestsLimitPerPod: number
+  milliSecondsInterval: number
+  remainingMilliSeconds: number
+  totalRequests: number
 
-  constructor(hash: {
+  constructor (hash: {
     requestsLimitPods: number,
     requestsLimitPerPod: number,
     milliSecondsInterval: number,
     remainingMilliSeconds: number,
-    totalRequests: number;
+    totalRequests: number
   }) {
-    this.requestsLimitPods = hash.requestsLimitPods;
-    this.requestsLimitPerPod = hash.requestsLimitPerPod;
-    this.milliSecondsInterval = hash.milliSecondsInterval;
-    this.remainingMilliSeconds = hash.remainingMilliSeconds;
-    this.totalRequests = hash.totalRequests;
+    this.requestsLimitPods = hash.requestsLimitPods
+    this.requestsLimitPerPod = hash.requestsLimitPerPod
+    this.milliSecondsInterval = hash.milliSecondsInterval
+    this.remainingMilliSeconds = hash.remainingMilliSeconds
+    this.totalRequests = hash.totalRequests
   }
 
-  get remainingSeconds() {
-    return Math.floor(this.remainingMilliSeconds / 1000);
+  get remainingSeconds () {
+    return Math.floor(this.remainingMilliSeconds / 1000)
   }
 
-  get secondsInterval() {
-    return Math.floor(this.milliSecondsInterval / 1000);
+  get secondsInterva () {
+    return Math.floor(this.milliSecondsInterval / 1000)
   }
 
 }
index 0872ba0b85350df37946c93627a94b4fc721e635..faa6b93832fabf51cecba54d8c338d6d7ceccdbf 100644 (file)
@@ -1,34 +1,34 @@
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
+import { Injectable } from '@angular/core'
+import { Observable } from 'rxjs/Observable'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
 
-import { RequestStats } from './request-stats.model';
-import { AuthHttp, RestExtractor } from '../../../shared';
+import { RequestStats } from './request-stats.model'
+import { AuthHttp, RestExtractor } from '../../../shared'
 
 @Injectable()
 export class RequestService {
-  private static BASE_REQUEST_URL = API_URL + '/api/v1/requests/';
+  private static BASE_REQUEST_URL = API_URL + '/api/v1/requests/'
 
   constructor (
     private authHttp: AuthHttp,
     private restExtractor: RestExtractor
   ) {}
 
-  getStats(): Observable<{ [ id: string ]: RequestStats }> {
+  getStats (): Observable<{ [ id: string ]: RequestStats }> {
     return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
                         .map(this.restExtractor.extractDataGet)
                         .map(this.buildRequestObjects)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  private buildRequestObjects(data: any) {
-    const requestSchedulers = {};
+  private buildRequestObjects (data: any) {
+    const requestSchedulers = {}
 
     Object.keys(data).forEach(requestSchedulerName => {
-      requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName]);
-    });
+      requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName])
+    })
 
-    return requestSchedulers;
+    return requestSchedulers
   }
 }
index e98a81f6208eb079098cff80f883ba3664718ce8..cef2c282cb59e0589896a66accd19e85561aaae1 100644 (file)
@@ -1,5 +1,5 @@
-export * from './shared';
-export * from './user-add';
-export * from './user-list';
-export * from './users.component';
-export * from './users.routes';
+export * from './shared'
+export * from './user-add'
+export * from './user-list'
+export * from './users.component'
+export * from './users.routes'
index e17ee5c7aca08d72e28c4ebd1fbe00d4162e069e..1f1302dc5ed2281fbd6b71d793b33cf7e67fc1df 100644 (file)
@@ -1 +1 @@
-export * from './user.service';
+export * from './user.service'
index 9c7176d39f12b7cbe6bfbce3d86175bdf50efed4..d52993a29efbbb66133cc20050e5fd0398c64526 100644 (file)
@@ -1,35 +1,35 @@
-import { Injectable } from '@angular/core';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
+import { Injectable } from '@angular/core'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
 
-import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared';
+import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared'
 
 @Injectable()
 export class UserService {
-  private static BASE_USERS_URL = API_URL + '/api/v1/users/';
+  private static BASE_USERS_URL = API_URL + '/api/v1/users/'
 
-  constructor(
+  constructor (
     private authHttp: AuthHttp,
     private restExtractor: RestExtractor
   ) {}
 
-  addUser(username: string, password: string, email: string) {
+  addUser (username: string, password: string, email: string) {
     const body = {
       username,
       email,
       password
-    };
+    }
 
     return this.authHttp.post(UserService.BASE_USERS_URL, body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch(this.restExtractor.handleError);
+                        .catch(this.restExtractor.handleError)
   }
 
-  getDataSource() {
-    return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL);
+  getDataSource () {
+    return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL)
   }
 
-  removeUser(user: User) {
-    return this.authHttp.delete(UserService.BASE_USERS_URL + user.id);
+  removeUser (user: User) {
+    return this.authHttp.delete(UserService.BASE_USERS_URL + user.id)
   }
 }
index 66d5ca04f14ce660895c8a5c677e40e4318b0098..3a4654101681ef4783a87635e5cbfa097047463c 100644 (file)
@@ -1 +1 @@
-export * from './user-add.component';
+export * from './user-add.component'
index f1d2fde80f177b6993bcd5dd0f23ce61b7ed89d1..2d25ab46929e4a8991ff942d7acc6b0dbad7594a 100644 (file)
@@ -1,71 +1,71 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { UserService } from '../shared';
+import { UserService } from '../shared'
 import {
   FormReactive,
   USER_USERNAME,
   USER_EMAIL,
   USER_PASSWORD
-} from '../../../shared';
+} from '../../../shared'
 
 @Component({
   selector: 'my-user-add',
   templateUrl: './user-add.component.html'
 })
 export class UserAddComponent extends FormReactive implements OnInit {
-  error: string = null;
+  error: string = null
 
-  form: FormGroup;
+  form: FormGroup
   formErrors = {
     'username': '',
     'email': '',
     'password': ''
-  };
+  }
   validationMessages = {
     'username': USER_USERNAME.MESSAGES,
     'email': USER_EMAIL.MESSAGES,
-    'password': USER_PASSWORD.MESSAGES,
-  };
+    'password': USER_PASSWORD.MESSAGES
+  }
 
-  constructor(
+  constructor (
     private formBuilder: FormBuilder,
     private router: Router,
     private notificationsService: NotificationsService,
     private userService: UserService
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       username: [ '', USER_USERNAME.VALIDATORS ],
       email:    [ '', USER_EMAIL.VALIDATORS ],
-      password: [ '', USER_PASSWORD.VALIDATORS ],
-    });
+      password: [ '', USER_PASSWORD.VALIDATORS ]
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  addUser() {
-    this.error = null;
+  addUser () {
+    this.error = null
 
-    const { username, password, email } = this.form.value;
+    const { username, password, email } = this.form.value
 
     this.userService.addUser(username, password, email).subscribe(
       () => {
-        this.notificationsService.success('Success', `User ${username} created.`);
-        this.router.navigate([ '/admin/users/list' ]);
+        this.notificationsService.success('Success', `User ${username} created.`)
+        this.router.navigate([ '/admin/users/list' ])
       },
 
       err => this.error = err.text
-    );
+    )
   }
 }
index 51fbefa8089e09aa89f05752cfbf785ebfc449f4..1826a4abee0ac6bc38b28da2d1dbcee4f9cd1fe3 100644 (file)
@@ -1 +1 @@
-export * from './user-list.component';
+export * from './user-list.component'
index 69ae4353d954a075d5b8a9a907dd06dc48a54b96..b6fb0ed99f4d8e387aa7fe12039dd84886e292c1 100644 (file)
@@ -1,10 +1,10 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { ConfirmService } from '../../../core';
-import { User, Utils } from '../../../shared';
-import { UserService } from '../shared';
+import { ConfirmService } from '../../../core'
+import { User, Utils } from '../../../shared'
+import { UserService } from '../shared'
 
 @Component({
   selector: 'my-user-list',
@@ -12,7 +12,7 @@ import { UserService } from '../shared';
   styleUrls: [ './user-list.component.scss' ]
 })
 export class UserListComponent {
-  usersSource = null;
+  usersSource = null
   tableSettings = {
     mode: 'external',
     attr: {
@@ -52,37 +52,37 @@ export class UserListComponent {
         valuePrepareFunction: Utils.dateToHuman
       }
     }
-  };
+  }
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private confirmService: ConfirmService,
     private userService: UserService
   ) {
-    this.usersSource = this.userService.getDataSource();
+    this.usersSource = this.userService.getDataSource()
   }
 
-  removeUser({ data }) {
-    const user: User = data;
+  removeUser ({ data }) {
+    const user: User = data
 
     if (user.username === 'root') {
-      this.notificationsService.error('Error', 'You cannot delete root.');
-      return;
+      this.notificationsService.error('Error', 'You cannot delete root.')
+      return
     }
 
     this.confirmService.confirm('Do you really want to delete this user?', 'Delete').subscribe(
       res => {
-        if (res === false) return;
+        if (res === false) return
 
         this.userService.removeUser(user).subscribe(
           () => {
-            this.notificationsService.success('Success', `User ${user.username} deleted.`);
-            this.usersSource.refresh();
+            this.notificationsService.success('Success', `User ${user.username} deleted.`)
+            this.usersSource.refresh()
           },
 
           err => this.notificationsService.error('Error', err.text)
-        );
+        )
       }
-    );
+    )
   }
 }
index 91af6c320754f33ae583e0275d5f6e75c665c440..e9c8f6b0d09851ec61f13fa1e128c89929f258a5 100644 (file)
@@ -1,8 +1,7 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
-   template: '<router-outlet></router-outlet>'
+  template: '<router-outlet></router-outlet>'
 })
-
 export class UsersComponent {
 }
index 21fb192e00ff829ddc14d1d703773ad13ddce9c0..723c5715d9baff8d855beb678bfcb1c2306c4d61 100644 (file)
@@ -1,8 +1,8 @@
-import { Routes } from '@angular/router';
+import { Routes } from '@angular/router'
 
-import { UsersComponent } from './users.component';
-import { UserAddComponent } from './user-add';
-import { UserListComponent } from './user-list';
+import { UsersComponent } from './users.component'
+import { UserAddComponent } from './user-add'
+import { UserListComponent } from './user-list'
 
 export const UsersRoutes: Routes = [
   {
@@ -34,4 +34,4 @@ export const UsersRoutes: Routes = [
       }
     ]
   }
-];
+]
index 7f5e65f91f5d37a21fd487621bfe2b97b28bf82c..395fac2e7f1758a13791e9dd3c3346f413271702 100644 (file)
@@ -1,3 +1,3 @@
-export * from './video-abuse-list';
-export * from './video-abuses.component';
-export * from './video-abuses.routes';
+export * from './video-abuse-list'
+export * from './video-abuses.component'
+export * from './video-abuses.routes'
index 3f2ed1714145a657a210fd666f809b31223b67d7..01c24d860a737397d120ee276310fc7e1b334c88 100644 (file)
@@ -1 +1 @@
-export * from './video-abuse-list.component';
+export * from './video-abuse-list.component'
index 55d82f79046efc32dd0770b8f27bbe4fe5b0f905..60eaebb44d9892d806d2a9654a919e92aeffbe8f 100644 (file)
@@ -1,15 +1,15 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared';
+import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared'
 
 @Component({
-       selector: 'my-video-abuse-list',
-       templateUrl: './video-abuse-list.component.html'
+  selector: 'my-video-abuse-list',
+  templateUrl: './video-abuse-list.component.html'
 })
 export class VideoAbuseListComponent {
-  videoAbusesSource = null;
+  videoAbusesSource = null
   tableSettings = {
     mode: 'external',
     attr: {
@@ -54,18 +54,18 @@ export class VideoAbuseListComponent {
         valuePrepareFunction: Utils.dateToHuman
       }
     }
-  };
+  }
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private videoAbuseService: VideoAbuseService
   ) {
-    this.videoAbusesSource = this.videoAbuseService.getDataSource();
-   }
+    this.videoAbusesSource = this.videoAbuseService.getDataSource()
+  }
 
-  buildVideoLink(videoId: string) {
+  buildVideoLink (videoId: string) {
     // TODO: transform to routerLink
     // https://github.com/akveo/ng2-smart-table/issues/57
-    return `<a href="/videos/${videoId}" title="Go to the video">${videoId}</a>`;
+    return `<a href="/videos/${videoId}" title="Go to the video">${videoId}</a>`
   }
 }
index 001f27e87ffdd3855b576c688260a515588bac37..9dae5c0b64b046730500d01892e0c5553b23a839 100644 (file)
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
   template: '<router-outlet></router-outlet>'
index 1f19d7885001d0f6c7fd901a02265153c678a05d..a8c1561cd16fe9884a9ddadb4ababdd611fb5ee1 100644 (file)
@@ -1,7 +1,7 @@
-import { Routes } from '@angular/router';
+import { Routes } from '@angular/router'
 
-import { VideoAbusesComponent } from './video-abuses.component';
-import { VideoAbuseListComponent } from './video-abuse-list';
+import { VideoAbusesComponent } from './video-abuses.component'
+import { VideoAbuseListComponent } from './video-abuse-list'
 
 export const VideoAbusesRoutes: Routes = [
   {
@@ -25,4 +25,4 @@ export const VideoAbusesRoutes: Routes = [
       }
     ]
   }
-];
+]
index 15dc42d229626e471ca86837a818072a4ecd9327..ce786cfa3da78c53eddecd9ff0bc9a1200ab50e7 100644 (file)
@@ -1,10 +1,10 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { FormReactive, UserService, USER_PASSWORD } from '../../shared';
+import { FormReactive, UserService, USER_PASSWORD } from '../../shared'
 
 @Component({
   selector: 'my-account-change-password',
@@ -12,55 +12,55 @@ import { FormReactive, UserService, USER_PASSWORD } from '../../shared';
 })
 
 export class AccountChangePasswordComponent extends FormReactive implements OnInit {
-  error: string = null;
+  error: string = null
 
-  form: FormGroup;
+  form: FormGroup
   formErrors = {
     'new-password': '',
     'new-confirmed-password': ''
-  };
+  }
   validationMessages = {
     'new-password': USER_PASSWORD.MESSAGES,
     'new-confirmed-password': USER_PASSWORD.MESSAGES
-  };
+  }
 
-  constructor(
+  constructor (
     private formBuilder: FormBuilder,
     private router: Router,
     private notificationsService: NotificationsService,
     private userService: UserService
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       'new-password': [ '', USER_PASSWORD.VALIDATORS ],
-      'new-confirmed-password': [ '', USER_PASSWORD.VALIDATORS ],
-    });
+      'new-confirmed-password': [ '', USER_PASSWORD.VALIDATORS ]
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  changePassword() {
-    const newPassword = this.form.value['new-password'];
-    const newConfirmedPassword = this.form.value['new-confirmed-password'];
+  changePassword () {
+    const newPassword = this.form.value['new-password']
+    const newConfirmedPassword = this.form.value['new-confirmed-password']
 
-    this.error = null;
+    this.error = null
 
     if (newPassword !== newConfirmedPassword) {
-      this.error = 'The new password and the confirmed password do not correspond.';
-      return;
+      this.error = 'The new password and the confirmed password do not correspond.'
+      return
     }
 
     this.userService.changePassword(newPassword).subscribe(
       () => this.notificationsService.success('Success', 'Password updated.'),
 
       err => this.error = err
-    );
+    )
   }
 }
index 72a63e48d1f74d7aab397a1ccac49692a283a5e2..44c330b668ef8e0b97335257cf76eeda78a42c94 100644 (file)
@@ -1 +1 @@
-export * from './account-change-password.component';
+export * from './account-change-password.component'
index 30e5b14ee9c069ccf2893e9c92aaec8b2c8d2908..d7531cb559eba2af4af7e8a5de8d2be4f7aeb206 100644 (file)
@@ -1,16 +1,16 @@
-import { Component, OnInit, Input } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit, Input } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { AuthService } from '../../core';
+import { AuthService } from '../../core'
 import {
   FormReactive,
   User,
   UserService,
   USER_PASSWORD
-} from '../../shared';
+} from '../../shared'
 
 @Component({
   selector: 'my-account-details',
@@ -18,51 +18,51 @@ import {
 })
 
 export class AccountDetailsComponent extends FormReactive implements OnInit {
-  @Input() user: User = null;
+  @Input() user: User = null
 
-  error: string = null;
+  error: string = null
 
-  form: FormGroup;
-  formErrors = {};
-  validationMessages = {};
+  form: FormGroup
+  formErrors = {}
+  validationMessages = {}
 
-  constructor(
+  constructor (
     private authService: AuthService,
     private formBuilder: FormBuilder,
     private router: Router,
     private notificationsService: NotificationsService,
     private userService: UserService
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
-      displayNSFW: [ this.user.displayNSFW ],
-    });
+      displayNSFW: [ this.user.displayNSFW ]
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  updateDetails() {
-    const displayNSFW = this.form.value['displayNSFW'];
+  updateDetails () {
+    const displayNSFW = this.form.value['displayNSFW']
     const details = {
       displayNSFW
-    };
+    }
 
-    this.error = null;
+    this.error = null
     this.userService.updateDetails(details).subscribe(
       () => {
-        this.notificationsService.success('Success', 'Informations updated.');
+        this.notificationsService.success('Success', 'Informations updated.')
 
-        this.authService.refreshUserInformations();
+        this.authService.refreshUserInformations()
       },
 
       err => this.error = err
-    );
+    )
   }
 }
index 28f644738e21a951fe88e1af4f7de41f0cdf24b0..4829f608a9d49c74a5454f12171c48e8ab616b03 100644 (file)
@@ -1 +1 @@
-export * from './account-details.component';
+export * from './account-details.component'
index 9004605f357e0b4c13c0822f6b10e4a764154bd3..e9b8f703145a406c4ff19b93956353abd0f14d30 100644 (file)
@@ -1,7 +1,7 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { RouterModule, Routes } from '@angular/router'
 
-import { AccountComponent } from './account.component';
+import { AccountComponent } from './account.component'
 
 const accountRoutes: Routes = [
   {
@@ -13,7 +13,7 @@ const accountRoutes: Routes = [
       }
     }
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forChild(accountRoutes) ],
index 57b3d4ccd4c052f1ab674bea3df4990c0514b9fa..929934f67adad77b38506205b0170e9cb86d2eb9 100644 (file)
@@ -1,16 +1,16 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { AuthService } from '../core';
+import { AuthService } from '../core'
 import {
   FormReactive,
   User,
   UserService,
   USER_PASSWORD
-} from '../shared';
+} from '../shared'
 
 @Component({
   selector: 'my-account',
@@ -18,11 +18,11 @@ import {
   styleUrls: [ './account.component.scss' ]
 })
 export class AccountComponent implements OnInit {
-  user: User = null;
+  user: User = null
 
-  constructor(private authService: AuthService) {}
+  constructor (private authService: AuthService) {}
 
-  ngOnInit() {
-    this.user = this.authService.getUser();
+  ngOnInit () {
+    this.user = this.authService.getUser()
   }
 }
index f6c141ae6ae4f4590c566b1ef84989e12f1a2838..380e9d2354d74a2458b9348a83e38e8e5bf1b9f2 100644 (file)
@@ -1,11 +1,11 @@
-import { NgModule } from '@angular/core';
+import { NgModule } from '@angular/core'
 
-import { AccountRoutingModule } from './account-routing.module';
-import { AccountComponent } from './account.component';
-import { AccountChangePasswordComponent } from './account-change-password';
-import { AccountDetailsComponent } from './account-details';
-import { AccountService } from './account.service';
-import { SharedModule } from '../shared';
+import { AccountRoutingModule } from './account-routing.module'
+import { AccountComponent } from './account.component'
+import { AccountChangePasswordComponent } from './account-change-password'
+import { AccountDetailsComponent } from './account-details'
+import { AccountService } from './account.service'
+import { SharedModule } from '../shared'
 
 @NgModule({
   imports: [
index 9265fa10adf369d32eecb28c443bdc5fd59b8f88..dc56ffdbdd50ad800790a07e8d861c04b78a62a8 100644 (file)
@@ -1,3 +1,3 @@
-export * from './account-routing.module';
-export * from './account.component';
-export * from './account.module';
+export * from './account-routing.module'
+export * from './account.component'
+export * from './account.module'
index f9465dc9c4ed39bccf7fd56b13d2f8990e2076d8..8036c52e6a7580800ac1f2def34de2ba8b1d8a64 100644 (file)
@@ -1,5 +1,5 @@
-import { NgModule } from '@angular/core';
-import { Routes, RouterModule } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { Routes, RouterModule } from '@angular/router'
 
 const routes: Routes = [
   {
@@ -11,11 +11,10 @@ const routes: Routes = [
     path: 'admin',
     loadChildren: './+admin#AdminModule'
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forRoot(routes) ],
   exports: [ RouterModule ]
 })
 export class AppRoutingModule {}
-
index b8b7321695ff5642931c936a204b42c1525d4b67..a90654e269dc4f0958c43b4326f643e86a3ca86a 100644 (file)
@@ -1,9 +1,9 @@
-import { Component, OnInit, ViewContainerRef } from '@angular/core';
-import { Router } from '@angular/router';
+import { Component, OnInit, ViewContainerRef } from '@angular/core'
+import { Router } from '@angular/router'
 
-import { AuthService, ConfigService } from './core';
-import { VideoService } from './videos';
-import { UserService } from './shared';
+import { AuthService, ConfigService } from './core'
+import { VideoService } from './videos'
+import { UserService } from './shared'
 
 @Component({
   selector: 'my-app',
@@ -22,11 +22,11 @@ export class AppComponent implements OnInit {
     preventDuplicates: false,
     preventLastDuplicates: 'visible',
     rtl: false
-  };
+  }
 
-  isMenuDisplayed = true;
+  isMenuDisplayed = true
 
-  constructor(
+  constructor (
     private router: Router,
     private authService: AuthService,
     private configService: ConfigService,
@@ -35,46 +35,46 @@ export class AppComponent implements OnInit {
     viewContainerRef: ViewContainerRef
   ) {}
 
-  ngOnInit() {
+  ngOnInit () {
     if (this.authService.isLoggedIn()) {
       // The service will automatically redirect to the login page if the token is not valid anymore
-      this.userService.checkTokenValidity();
+      this.userService.checkTokenValidity()
     }
 
-    this.configService.loadConfig();
-    this.videoService.loadVideoCategories();
-    this.videoService.loadVideoLicences();
-    this.videoService.loadVideoLanguages();
+    this.configService.loadConfig()
+    this.videoService.loadVideoCategories()
+    this.videoService.loadVideoLicences()
+    this.videoService.loadVideoLanguages()
 
     // Do not display menu on small screens
     if (window.innerWidth < 600) {
-      this.isMenuDisplayed = false;
+      this.isMenuDisplayed = false
     }
   }
 
-  isInAdmin() {
-    return this.router.url.indexOf('/admin/') !== -1;
+  isInAdmin () {
+    return this.router.url.indexOf('/admin/') !== -1
   }
 
-  toggleMenu() {
-    this.isMenuDisplayed = !this.isMenuDisplayed;
+  toggleMenu () {
+    this.isMenuDisplayed = !this.isMenuDisplayed
   }
 
-  getMainColClasses() {
+  getMainColClasses () {
     const colSizes = {
       md: 10,
       sm: 9,
       xs: 9
-    };
+    }
 
     // Take all width is the menu is not displayed
     if (this.isMenuDisplayed === false) {
-      Object.keys(colSizes).forEach(col => colSizes[col] = 12);
+      Object.keys(colSizes).forEach(col => colSizes[col] = 12)
     }
 
-    const classes = [ 'main-col' ];
-    Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`));
+    const classes = [ 'main-col' ]
+    Object.keys(colSizes).forEach(col => classes.push(`col-${col}-${colSizes[col]}`))
 
-    return classes;
+    return classes
   }
 }
index 8a072eaac2507beb27a7d68ff71a27cc256a6f66..d7c9f65481b9e8b3f54f3555ac91f955970900f3 100644 (file)
@@ -1,29 +1,29 @@
-import { ApplicationRef, NgModule } from '@angular/core';
-import { BrowserModule } from '@angular/platform-browser';
+import { ApplicationRef, NgModule } from '@angular/core'
+import { BrowserModule } from '@angular/platform-browser'
 import {
   removeNgStyles,
   createNewHosts,
   createInputTransfer
-} from '@angularclass/hmr';
+} from '@angularclass/hmr'
 
-import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta';
+import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta'
 // TODO: remove, we need this to avoid error in ng2-smart-table
-import 'rxjs/add/operator/toPromise';
-import 'bootstrap-loader';
+import 'rxjs/add/operator/toPromise'
+import 'bootstrap-loader'
 
-import { ENV_PROVIDERS } from './environment';
-import { AppRoutingModule } from './app-routing.module';
-import { AppComponent } from './app.component';
-import { AppState, InternalStateType } from './app.service';
+import { ENV_PROVIDERS } from './environment'
+import { AppRoutingModule } from './app-routing.module'
+import { AppComponent } from './app.component'
+import { AppState, InternalStateType } from './app.service'
 
-import { AccountModule } from './account';
-import { CoreModule } from './core';
-import { LoginModule } from './login';
-import { SignupModule } from './signup';
-import { SharedModule } from './shared';
-import { VideosModule } from './videos';
+import { AccountModule } from './account'
+import { CoreModule } from './core'
+import { LoginModule } from './login'
+import { SignupModule } from './signup'
+import { SharedModule } from './shared'
+import { VideosModule } from './videos'
 
-export function metaFactory(): MetaLoader {
+export function metaFactory (): MetaLoader {
   return new MetaStaticLoader({
     pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
     pageTitleSeparator: ' - ',
@@ -32,19 +32,19 @@ export function metaFactory(): MetaLoader {
       title: 'PeerTube',
       description: 'PeerTube, a decentralized video streaming platform using P2P (BitTorrent) directly in the web browser'
     }
-  });
+  })
 }
 
 type StoreType = {
   state: InternalStateType,
   restoreInputValues: () => void,
   disposeOldHosts: () => void
-};
+}
 
 // Application wide providers
 const APP_PROVIDERS = [
   AppState
-];
+]
 
 @NgModule({
   bootstrap: [ AppComponent ],
@@ -77,59 +77,59 @@ const APP_PROVIDERS = [
   ]
 })
 export class AppModule {
-  constructor(
+  constructor (
     public appRef: ApplicationRef,
     public appState: AppState
   ) {}
 
-  public hmrOnInit(store: StoreType) {
+  public hmrOnInit (store: StoreType) {
     if (!store || !store.state) {
-      return;
+      return
     }
-    console.log('HMR store', JSON.stringify(store, null, 2));
+    console.log('HMR store', JSON.stringify(store, null, 2))
     /**
      * Set state
      */
-    this.appState._state = store.state;
+    this.appState._state = store.state
     /**
      * Set input values
      */
     if ('restoreInputValues' in store) {
-      let restoreInputValues = store.restoreInputValues;
-      setTimeout(restoreInputValues);
+      let restoreInputValues = store.restoreInputValues
+      setTimeout(restoreInputValues)
     }
 
-    this.appRef.tick();
-    delete store.state;
-    delete store.restoreInputValues;
+    this.appRef.tick()
+    delete store.state
+    delete store.restoreInputValues
   }
 
-  public hmrOnDestroy(store: StoreType) {
-    const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement);
+  public hmrOnDestroy (store: StoreType) {
+    const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement)
     /**
      * Save state
      */
-    const state = this.appState._state;
-    store.state = state;
+    const state = this.appState._state
+    store.state = state
     /**
      * Recreate root elements
      */
-    store.disposeOldHosts = createNewHosts(cmpLocation);
+    store.disposeOldHosts = createNewHosts(cmpLocation)
     /**
      * Save input values
      */
-    store.restoreInputValues  = createInputTransfer();
+    store.restoreInputValues = createInputTransfer()
     /**
      * Remove styles
      */
-    removeNgStyles();
+    removeNgStyles()
   }
 
-  public hmrAfterDestroy(store: StoreType) {
+  public hmrAfterDestroy (store: StoreType) {
     /**
      * Display new elements
      */
-    store.disposeOldHosts();
-    delete store.disposeOldHosts;
+    store.disposeOldHosts ()
+    delete store.disposeOldHosts
   }
 }
index 45774b8d19c9bdfff7bef94ead449bce54fe3ea4..bc054e90b89bbeaf9e9b342c704562d855506688 100644 (file)
@@ -1,12 +1,14 @@
-import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/observable/of';
+/* tslint:disable */
+
+import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'
+import { Injectable } from '@angular/core'
+import { Observable } from 'rxjs/Observable'
+import 'rxjs/add/observable/of'
 
 @Injectable()
 export class DataResolver implements Resolve<any> {
   public resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
-    return Observable.of({ res: 'I am data'});
+    return Observable.of({ res: 'I am data'})
   }
 }
 
@@ -15,4 +17,4 @@ export class DataResolver implements Resolve<any> {
  */
 export const APP_RESOLVER_PROVIDERS = [
   DataResolver
-];
+]
index a7eb880a498f4cd94a366f15e7533022eb8387ee..abffc87f195c520bffa86c53f504d0045b0188ea 100644 (file)
@@ -1,46 +1,48 @@
-import { Injectable } from '@angular/core';
+/* tslint:disable */
+
+import { Injectable } from '@angular/core'
 
 export type InternalStateType = {
   [key: string]: any
-};
+}
 
 @Injectable()
 export class AppState {
 
-  public _state: InternalStateType = { };
+  public _state: InternalStateType = { }
 
   /**
    * Already return a clone of the current state.
    */
   public get state() {
-    return this._state = this._clone(this._state);
+    return this._state = this._clone(this._state)
   }
   /**
    * Never allow mutation
    */
   public set state(value) {
-    throw new Error('do not mutate the `.state` directly');
+    throw new Error('do not mutate the `.state` directly')
   }
 
   public get(prop?: any) {
     /**
      * Use our state getter for the clone.
      */
-    const state = this.state;
-    return state.hasOwnProperty(prop) ? state[prop] : state;
+    const state = this.state
+    return state.hasOwnProperty(prop) ? state[prop] : state
   }
 
   public set(prop: string, value: any) {
     /**
      * Internally mutate our state.
      */
-    return this._state[prop] = value;
+    return this._state[prop] = value
   }
 
   private _clone(object: InternalStateType) {
     /**
      * Simple object clone.
      */
-    return JSON.parse(JSON.stringify( object ));
+    return JSON.parse(JSON.stringify( object ))
   }
 }
index 1a31a783429ab134566cadad2ea5307f2827d407..65c37bcfa6e2626ea03df8e2606079904b7e3da3 100644 (file)
@@ -1,6 +1,66 @@
 // Do not use the barrel (dependency loop)
 import { UserRole } from '../../../../../shared/models/user.model'
-import { User } from '../../shared/users/user.model';
+import { User } from '../../shared/users/user.model'
+
+export type TokenOptions = {
+  accessToken: string
+  refreshToken: string
+  tokenType: string
+}
+
+// Private class only used by User
+class Tokens {
+  private static KEYS = {
+    ACCESS_TOKEN: 'access_token',
+    REFRESH_TOKEN: 'refresh_token',
+    TOKEN_TYPE: 'token_type'
+  }
+
+  accessToken: string
+  refreshToken: string
+  tokenType: string
+
+  static load () {
+    const accessTokenLocalStorage = localStorage.getItem(this.KEYS.ACCESS_TOKEN)
+    const refreshTokenLocalStorage = localStorage.getItem(this.KEYS.REFRESH_TOKEN)
+    const tokenTypeLocalStorage = localStorage.getItem(this.KEYS.TOKEN_TYPE)
+
+    if (accessTokenLocalStorage && refreshTokenLocalStorage && tokenTypeLocalStorage) {
+      return new Tokens({
+        accessToken: accessTokenLocalStorage,
+        refreshToken: refreshTokenLocalStorage,
+        tokenType: tokenTypeLocalStorage
+      })
+    }
+
+    return null
+  }
+
+  static flush () {
+    localStorage.removeItem(this.KEYS.ACCESS_TOKEN)
+    localStorage.removeItem(this.KEYS.REFRESH_TOKEN)
+    localStorage.removeItem(this.KEYS.TOKEN_TYPE)
+  }
+
+  constructor (hash?: TokenOptions) {
+    if (hash) {
+      this.accessToken = hash.accessToken
+      this.refreshToken = hash.refreshToken
+
+      if (hash.tokenType === 'bearer') {
+        this.tokenType = 'Bearer'
+      } else {
+        this.tokenType = hash.tokenType
+      }
+    }
+  }
+
+  save () {
+    localStorage.setItem(Tokens.KEYS.ACCESS_TOKEN, this.accessToken)
+    localStorage.setItem(Tokens.KEYS.REFRESH_TOKEN, this.refreshToken)
+    localStorage.setItem(Tokens.KEYS.TOKEN_TYPE, this.tokenType)
+  }
+}
 
 export class AuthUser extends User {
   private static KEYS = {
@@ -9,123 +69,69 @@ export class AuthUser extends User {
     EMAIL: 'email',
     USERNAME: 'username',
     DISPLAY_NSFW: 'display_nsfw'
-  };
+  }
 
-  tokens: Tokens;
+  tokens: Tokens
 
-  static load() {
-    const usernameLocalStorage = localStorage.getItem(this.KEYS.USERNAME);
+  static load () {
+    const usernameLocalStorage = localStorage.getItem(this.KEYS.USERNAME)
     if (usernameLocalStorage) {
       return new AuthUser(
         {
-          id: parseInt(localStorage.getItem(this.KEYS.ID)),
+          id: parseInt(localStorage.getItem(this.KEYS.ID), 10),
           username: localStorage.getItem(this.KEYS.USERNAME),
           email: localStorage.getItem(this.KEYS.EMAIL),
           role: localStorage.getItem(this.KEYS.ROLE) as UserRole,
           displayNSFW: localStorage.getItem(this.KEYS.DISPLAY_NSFW) === 'true'
         },
         Tokens.load()
-      );
+      )
     }
 
-    return null;
+    return null
   }
 
-  static flush() {
-    localStorage.removeItem(this.KEYS.USERNAME);
-    localStorage.removeItem(this.KEYS.ID);
-    localStorage.removeItem(this.KEYS.ROLE);
-    localStorage.removeItem(this.KEYS.DISPLAY_NSFW);
-    Tokens.flush();
+  static flush () {
+    localStorage.removeItem(this.KEYS.USERNAME)
+    localStorage.removeItem(this.KEYS.ID)
+    localStorage.removeItem(this.KEYS.ROLE)
+    localStorage.removeItem(this.KEYS.DISPLAY_NSFW)
+    Tokens.flush()
   }
 
-  constructor(userHash: {
+  constructor (userHash: {
     id: number,
     username: string,
     role: UserRole,
     email: string,
     displayNSFW: boolean
-  }, hashTokens: any) {
-    super(userHash);
-    this.tokens = new Tokens(hashTokens);
-  }
-
-  getAccessToken() {
-    return this.tokens.access_token;
-  }
-
-  getRefreshToken() {
-    return this.tokens.refresh_token;
-  }
-
-  getTokenType() {
-    return this.tokens.token_type;
-  }
-
-  refreshTokens(access_token: string, refresh_token: string) {
-    this.tokens.access_token = access_token;
-    this.tokens.refresh_token = refresh_token;
+  }, hashTokens: TokenOptions) {
+    super(userHash)
+    this.tokens = new Tokens(hashTokens)
   }
 
-  save() {
-    localStorage.setItem(AuthUser.KEYS.ID, this.id.toString());
-    localStorage.setItem(AuthUser.KEYS.USERNAME, this.username);
-    localStorage.setItem(AuthUser.KEYS.ROLE, this.role);
-    localStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW));
-    this.tokens.save();
+  getAccessToken () {
+    return this.tokens.accessToken
   }
-}
-
-// Private class only used by User
-class Tokens {
-  private static KEYS = {
-    ACCESS_TOKEN: 'access_token',
-    REFRESH_TOKEN: 'refresh_token',
-    TOKEN_TYPE: 'token_type',
-  };
-
-  access_token: string;
-  refresh_token: string;
-  token_type: string;
-
-  static load() {
-    const accessTokenLocalStorage = localStorage.getItem(this.KEYS.ACCESS_TOKEN);
-    const refreshTokenLocalStorage = localStorage.getItem(this.KEYS.REFRESH_TOKEN);
-    const tokenTypeLocalStorage = localStorage.getItem(this.KEYS.TOKEN_TYPE);
-
-    if (accessTokenLocalStorage && refreshTokenLocalStorage && tokenTypeLocalStorage) {
-      return new Tokens({
-        access_token: accessTokenLocalStorage,
-        refresh_token: refreshTokenLocalStorage,
-        token_type: tokenTypeLocalStorage
-      });
-    }
 
-    return null;
+  getRefreshToken () {
+    return this.tokens.refreshToken
   }
 
-  static flush() {
-    localStorage.removeItem(this.KEYS.ACCESS_TOKEN);
-    localStorage.removeItem(this.KEYS.REFRESH_TOKEN);
-    localStorage.removeItem(this.KEYS.TOKEN_TYPE);
+  getTokenType () {
+    return this.tokens.tokenType
   }
 
-  constructor(hash?: any) {
-    if (hash) {
-      this.access_token = hash.access_token;
-      this.refresh_token = hash.refresh_token;
-
-      if (hash.token_type === 'bearer') {
-        this.token_type = 'Bearer';
-      } else {
-        this.token_type = hash.token_type;
-      }
-    }
+  refreshTokens (accessToken: string, refreshToken: string) {
+    this.tokens.accessToken = accessToken
+    this.tokens.refreshToken = refreshToken
   }
 
-  save() {
-    localStorage.setItem('access_token', this.access_token);
-    localStorage.setItem('refresh_token', this.refresh_token);
-    localStorage.setItem('token_type', this.token_type);
+  save () {
+    localStorage.setItem(AuthUser.KEYS.ID, this.id.toString())
+    localStorage.setItem(AuthUser.KEYS.USERNAME, this.username)
+    localStorage.setItem(AuthUser.KEYS.ROLE, this.role)
+    localStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW))
+    this.tokens.save()
   }
 }
index 4c75df1ca4fc46b00cda7d24181e94db8611f288..32f7a5503d88342cbbe46b4cdf120ee72638f059 100644 (file)
@@ -1,40 +1,40 @@
-import { Injectable } from '@angular/core';
-import { Headers, Http, Response, URLSearchParams } from '@angular/http';
-import { Router } from '@angular/router';
-import { Observable } from 'rxjs/Observable';
-import { Subject } from 'rxjs/Subject';
-import 'rxjs/add/operator/map';
-import 'rxjs/add/operator/mergeMap';
-import 'rxjs/add/observable/throw';
-
-import { NotificationsService } from 'angular2-notifications';
-
-import { AuthStatus } from './auth-status.model';
-import { AuthUser } from './auth-user.model';
+import { Injectable } from '@angular/core'
+import { Headers, Http, Response, URLSearchParams } from '@angular/http'
+import { Router } from '@angular/router'
+import { Observable } from 'rxjs/Observable'
+import { Subject } from 'rxjs/Subject'
+import 'rxjs/add/operator/map'
+import 'rxjs/add/operator/mergeMap'
+import 'rxjs/add/observable/throw'
+
+import { NotificationsService } from 'angular2-notifications'
+
+import { AuthStatus } from './auth-status.model'
+import { AuthUser } from './auth-user.model'
 // Do not use the barrel (dependency loop)
-import { RestExtractor } from '../../shared/rest';
+import { RestExtractor } from '../../shared/rest'
 
 @Injectable()
 export class AuthService {
-  private static BASE_CLIENT_URL = API_URL + '/api/v1/clients/local';
-  private static BASE_TOKEN_URL = API_URL + '/api/v1/users/token';
-  private static BASE_USER_INFORMATIONS_URL = API_URL + '/api/v1/users/me';
+  private static BASE_CLIENT_URL = API_URL + '/api/v1/clients/local'
+  private static BASE_TOKEN_URL = API_URL + '/api/v1/users/token'
+  private static BASE_USER_INFORMATIONS_URL = API_URL + '/api/v1/users/me'
 
-  loginChangedSource: Observable<AuthStatus>;
+  loginChangedSource: Observable<AuthStatus>
 
-  private clientId: string;
-  private clientSecret: string;
-  private loginChanged: Subject<AuthStatus>;
-  private user: AuthUser = null;
+  private clientId: string
+  private clientSecret: string
+  private loginChanged: Subject<AuthStatus>
+  private user: AuthUser = null
 
-  constructor(
+  constructor (
     private http: Http,
     private notificationsService: NotificationsService,
     private restExtractor: RestExtractor,
     private router: Router
    ) {
-    this.loginChanged = new Subject<AuthStatus>();
-    this.loginChangedSource = this.loginChanged.asObservable();
+    this.loginChanged = new Subject<AuthStatus>()
+    this.loginChangedSource = this.loginChanged.asObservable()
 
     // Fetch the client_id/client_secret
     // FIXME: save in local storage?
@@ -43,120 +43,120 @@ export class AuthService {
       .catch((res) => this.restExtractor.handleError(res))
       .subscribe(
         result => {
-          this.clientId = result.client_id;
-          this.clientSecret = result.client_secret;
-          console.log('Client credentials loaded.');
+          this.clientId = result.client_id
+          this.clientSecret = result.client_secret
+          console.log('Client credentials loaded.')
         },
 
         error => {
-          let errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`;
-          errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.';
+          let errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`
+          errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.'
 
           // We put a bigger timeout
           // This is an important message
-          this.notificationsService.error('Error', errorMessage, { timeOut: 7000 });
+          this.notificationsService.error('Error', errorMessage, { timeOut: 7000 })
         }
-      );
+      )
 
     // Return null if there is nothing to load
-    this.user = AuthUser.load();
+    this.user = AuthUser.load()
   }
 
-  getRefreshToken() {
-    if (this.user === null) return null;
+  getRefreshToken () {
+    if (this.user === null) return null
 
-    return this.user.getRefreshToken();
+    return this.user.getRefreshToken()
   }
 
-  getRequestHeaderValue() {
-    return `${this.getTokenType()} ${this.getAccessToken()}`;
+  getRequestHeaderValue () {
+    return `${this.getTokenType()} ${this.getAccessToken()}`
   }
 
-  getAccessToken() {
-    if (this.user === null) return null;
+  getAccessToken () {
+    if (this.user === null) return null
 
-    return this.user.getAccessToken();
+    return this.user.getAccessToken()
   }
 
-  getTokenType() {
-    if (this.user === null) return null;
+  getTokenType () {
+    if (this.user === null) return null
 
-    return this.user.getTokenType();
+    return this.user.getTokenType()
   }
 
-  getUser(): AuthUser {
-    return this.user;
+  getUser () {
+    return this.user
   }
 
-  isAdmin() {
-    if (this.user === null) return false;
+  isAdmin () {
+    if (this.user === null) return false
 
-    return this.user.isAdmin();
+    return this.user.isAdmin()
   }
 
-  isLoggedIn() {
+  isLoggedIn () {
     if (this.getAccessToken()) {
-      return true;
+      return true
     } else {
-      return false;
+      return false
     }
   }
 
-  login(username: string, password: string) {
-    let body = new URLSearchParams();
-    body.set('client_id', this.clientId);
-    body.set('client_secret', this.clientSecret);
-    body.set('response_type', 'code');
-    body.set('grant_type', 'password');
-    body.set('scope', 'upload');
-    body.set('username', username);
-    body.set('password', password);
+  login (username: string, password: string) {
+    let body = new URLSearchParams()
+    body.set('client_id', this.clientId)
+    body.set('client_secret', this.clientSecret)
+    body.set('response_type', 'code')
+    body.set('grant_type', 'password')
+    body.set('scope', 'upload')
+    body.set('username', username)
+    body.set('password', password)
 
-    let headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    let headers = new Headers()
+    headers.append('Content-Type', 'application/x-www-form-urlencoded')
 
     let options = {
       headers: headers
-    };
+    }
 
     return this.http.post(AuthService.BASE_TOKEN_URL, body.toString(), options)
                     .map(this.restExtractor.extractDataGet)
                     .map(res => {
-                      res.username = username;
-                      return res;
+                      res.username = username
+                      return res
                     })
                     .flatMap(res => this.mergeUserInformations(res))
                     .map(res => this.handleLogin(res))
-                    .catch((res) => this.restExtractor.handleError(res));
+                    .catch((res) => this.restExtractor.handleError(res))
   }
 
-  logout() {
+  logout () {
     // TODO: make an HTTP request to revoke the tokens
-    this.user = null;
+    this.user = null
 
-    AuthUser.flush();
+    AuthUser.flush()
 
-    this.setStatus(AuthStatus.LoggedOut);
+    this.setStatus(AuthStatus.LoggedOut)
   }
 
-  refreshAccessToken() {
-    console.log('Refreshing token...');
+  refreshAccessToken () {
+    console.log('Refreshing token...')
 
-    const refreshToken = this.getRefreshToken();
+    const refreshToken = this.getRefreshToken()
 
-    let body = new URLSearchParams();
-    body.set('refresh_token', refreshToken);
-    body.set('client_id', this.clientId);
-    body.set('client_secret', this.clientSecret);
-    body.set('response_type', 'code');
-    body.set('grant_type', 'refresh_token');
+    let body = new URLSearchParams()
+    body.set('refresh_token', refreshToken)
+    body.set('client_id', this.clientId)
+    body.set('client_secret', this.clientSecret)
+    body.set('response_type', 'code')
+    body.set('grant_type', 'refresh_token')
 
-    let headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    let headers = new Headers()
+    headers.append('Content-Type', 'application/x-www-form-urlencoded')
 
     let options = {
       headers: headers
-    };
+    }
 
     return this.http.post(AuthService.BASE_TOKEN_URL, body.toString(), options)
                     .map(this.restExtractor.extractDataGet)
@@ -164,41 +164,41 @@ export class AuthService {
                     .catch((res: Response) => {
                       // The refresh token is invalid?
                       if (res.status === 400 && res.json() && res.json().error === 'invalid_grant') {
-                        console.error('Cannot refresh token -> logout...');
-                        this.logout();
-                        this.router.navigate(['/login']);
+                        console.error('Cannot refresh token -> logout...')
+                        this.logout()
+                        this.router.navigate(['/login'])
 
                         return Observable.throw({
                           json: () => '',
                           text: () => 'You need to reconnect.'
-                        });
+                        })
                       }
 
-                      return this.restExtractor.handleError(res);
-                    });
+                      return this.restExtractor.handleError(res)
+                    })
   }
 
-  refreshUserInformations() {
+  refreshUserInformations () {
     const obj = {
       access_token: this.user.getAccessToken()
-    };
+    }
 
-    this.mergeUserInformations(obj)
+    this.mergeUserInformations (obj)
         .subscribe(
           res => {
-            this.user.displayNSFW = res.displayNSFW;
-            this.user.role = res.role;
+            this.user.displayNSFW = res.displayNSFW
+            this.user.role = res.role
 
-            this.user.save();
+            this.user.save()
           }
-        );
+        )
   }
 
-  private mergeUserInformations(obj: { access_token: string }) {
+  private mergeUserInformations (obj: { access_token: string }) {
     // Do not call authHttp here to avoid circular dependencies headaches
 
-    const headers = new Headers();
-    headers.set('Authorization', `Bearer ${obj.access_token}`);
+    const headers = new Headers()
+    headers.set('Authorization', `Bearer ${obj.access_token}`)
 
     return this.http.get(AuthService.BASE_USER_INFORMATIONS_URL, { headers })
              .map(res => res.json())
@@ -207,38 +207,38 @@ export class AuthService {
                  id: res.id,
                  role: res.role,
                  displayNSFW: res.displayNSFW
-               };
+               }
 
-               return Object.assign(obj, newProperties);
+               return Object.assign(obj, newProperties)
              }
-    );
+    )
   }
 
   private handleLogin (obj: any) {
-    const id = obj.id;
-    const username = obj.username;
-    const role = obj.role;
-    const email = obj.email;
-    const displayNSFW = obj.displayNSFW;
+    const id = obj.id
+    const username = obj.username
+    const role = obj.role
+    const email = obj.email
+    const displayNSFW = obj.displayNSFW
     const hashTokens = {
-      access_token: obj.access_token,
-      token_type: obj.token_type,
-      refresh_token: obj.refresh_token
-    };
+      accessToken: obj.access_token,
+      tokenType: obj.token_type,
+      refreshToken: obj.refresh_token
+    }
 
-    this.user = new AuthUser({ id, username, role, displayNSFW, email }, hashTokens);
-    this.user.save();
+    this.user = new AuthUser({ id, username, role, displayNSFW, email }, hashTokens)
+    this.user.save()
 
-    this.setStatus(AuthStatus.LoggedIn);
+    this.setStatus(AuthStatus.LoggedIn)
   }
 
   private handleRefreshToken (obj: any) {
-    this.user.refreshTokens(obj.access_token, obj.refresh_token);
-    this.user.save();
+    this.user.refreshTokens(obj.access_token, obj.refresh_token)
+    this.user.save()
   }
 
-  private setStatus(status: AuthStatus) {
-    this.loginChanged.next(status);
+  private setStatus (status: AuthStatus) {
+    this.loginChanged.next(status)
   }
 
 }
index 67a18cfbbd389e9df52f55f804539590b03c70c0..8e5caa7ed23d00a8127b7ed886e6561cc8766463 100644 (file)
@@ -1,3 +1,3 @@
-export * from './auth-status.model';
-export * from './auth-user.model';
+export * from './auth-status.model'
+export * from './auth-user.model'
 export * from './auth.service'
index 407dca0835a9be00ac43dc246613394191a467b8..a83ec61d2a6b4eadc586fa5b6596488a18b98774 100644 (file)
@@ -1,11 +1,11 @@
-import { Injectable } from '@angular/core';
-import { Http } from '@angular/http';
+import { Injectable } from '@angular/core'
+import { Http } from '@angular/http'
 
-import { RestExtractor } from '../../shared/rest';
+import { RestExtractor } from '../../shared/rest'
 
 @Injectable()
 export class ConfigService {
-  private static BASE_CONFIG_URL = API_URL + '/api/v1/config/';
+  private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'
 
   private config: {
     signup: {
@@ -15,22 +15,22 @@ export class ConfigService {
     signup: {
       enabled: false
     }
-  };
+  }
 
-  constructor(
+  constructor (
     private http: Http,
-    private restExtractor: RestExtractor,
+    private restExtractor: RestExtractor
   ) {}
 
-  loadConfig() {
+  loadConfig () {
     this.http.get(ConfigService.BASE_CONFIG_URL)
              .map(this.restExtractor.extractDataGet)
              .subscribe(data => {
-               this.config = data;
-             });
+               this.config = data
+             })
   }
 
-  getConfig() {
-    return this.config;
+  getConfig () {
+    return this.config
   }
 }
index 90392254a8475d9799460976062f3df53f3223c3..3724e12f21d75bc6bd7baa9f4f0449a269d8d17c 100644 (file)
@@ -1 +1 @@
-export * from './config.service';
+export * from './config.service'
index ae42ff68adab53de0c9b6a7c51ccb65f1453920c..066e3fc5fca25773588638f581b7ef6123c56fd7 100644 (file)
@@ -1,12 +1,12 @@
-import { Component, HostListener, OnInit, ViewChild } from '@angular/core';
+import { Component, HostListener, OnInit, ViewChild } from '@angular/core'
 
-import { ModalDirective } from 'ngx-bootstrap/modal';
+import { ModalDirective } from 'ngx-bootstrap/modal'
 
-import { ConfirmService } from './confirm.service';
+import { ConfirmService } from './confirm.service'
 
 export interface ConfigChangedEvent {
-  columns: { [id: string]: { isDisplayed: boolean }; };
-  config: { resultsPerPage: number };
+  columns: { [id: string]: { isDisplayed: boolean } }
+  config: { resultsPerPage: number }
 }
 
 @Component({
@@ -14,48 +14,48 @@ export interface ConfigChangedEvent {
   templateUrl: './confirm.component.html'
 })
 export class ConfirmComponent implements OnInit {
-  @ViewChild('confirmModal') confirmModal: ModalDirective;
+  @ViewChild('confirmModal') confirmModal: ModalDirective
 
-  title = '';
-  message = '';
+  title = ''
+  message = ''
 
   constructor (private confirmService: ConfirmService) {
     // Empty
   }
 
-  ngOnInit() {
+  ngOnInit () {
     this.confirmModal.config = {
       backdrop: 'static',
       keyboard: false
-    };
+    }
 
     this.confirmService.showConfirm.subscribe(
       ({ title, message }) => {
-        this.title = title;
-        this.message = message;
+        this.title = title
+        this.message = message
 
-        this.showModal();
+        this.showModal()
       }
-    );
+    )
   }
 
   @HostListener('keydown.enter')
-  confirm() {
-    this.confirmService.confirmResponse.next(true);
-    this.hideModal();
+  confirm () {
+    this.confirmService.confirmResponse.next(true)
+    this.hideModal()
   }
 
   @HostListener('keydown.esc')
-  abort() {
-    this.confirmService.confirmResponse.next(false);
-    this.hideModal();
+  abort () {
+    this.confirmService.confirmResponse.next(false)
+    this.hideModal()
   }
 
-  showModal() {
-    this.confirmModal.show();
+  showModal () {
+    this.confirmModal.show()
   }
 
-  hideModal() {
-    this.confirmModal.hide();
+  hideModal () {
+    this.confirmModal.hide()
   }
 }
index 08127a66ff223f146f6530be2a9eab34b71c25a0..f12ff184800e7ca2b0eec46f8dc59bcdead51860 100644 (file)
@@ -1,15 +1,15 @@
-import { Injectable } from '@angular/core';
-import { Subject } from 'rxjs/Subject';
-import 'rxjs/add/operator/first';
+import { Injectable } from '@angular/core'
+import { Subject } from 'rxjs/Subject'
+import 'rxjs/add/operator/first'
 
 @Injectable()
 export class ConfirmService {
-  showConfirm = new Subject<{ title, message }>();
-  confirmResponse = new Subject<boolean>();
+  showConfirm = new Subject<{ title, message }>()
+  confirmResponse = new Subject<boolean>()
 
-  confirm(message = '', title = '') {
-    this.showConfirm.next({ title, message });
+  confirm (message = '', title = '') {
+    this.showConfirm.next({ title, message })
 
-    return this.confirmResponse.asObservable().first();
+    return this.confirmResponse.asObservable().first()
   }
 }
index 789e7e5473bbe39545e10913c810043f97b83e73..44aabfc130c38095f981404bf75f640e82f8adc1 100644 (file)
@@ -1,2 +1,2 @@
-export * from './confirm.component';
-export * from './confirm.service';
+export * from './confirm.component'
+export * from './confirm.service'
index 81c8f2da687a1a3ccb14660b30a1caefafda5841..382febe5c86aa4f8346053a02073a233ac6e0134 100644 (file)
@@ -1,16 +1,16 @@
-import { NgModule, Optional, SkipSelf } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { HttpModule } from '@angular/http';
-import { RouterModule } from '@angular/router';
+import { NgModule, Optional, SkipSelf } from '@angular/core'
+import { CommonModule } from '@angular/common'
+import { HttpModule } from '@angular/http'
+import { RouterModule } from '@angular/router'
 
-import { SimpleNotificationsModule } from 'angular2-notifications';
-import { ModalModule } from 'ngx-bootstrap/modal';
+import { SimpleNotificationsModule } from 'angular2-notifications'
+import { ModalModule } from 'ngx-bootstrap/modal'
 
-import { AuthService } from './auth';
-import { ConfigService } from './config';
-import { ConfirmComponent, ConfirmService } from './confirm';
-import { MenuComponent, MenuAdminComponent } from './menu';
-import { throwIfAlreadyLoaded } from './module-import-guard';
+import { AuthService } from './auth'
+import { ConfigService } from './config'
+import { ConfirmComponent, ConfirmService } from './confirm'
+import { MenuComponent, MenuAdminComponent } from './menu'
+import { throwIfAlreadyLoaded } from './module-import-guard'
 
 @NgModule({
   imports: [
@@ -43,7 +43,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard';
   ]
 })
 export class CoreModule {
-   constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
-    throwIfAlreadyLoaded(parentModule, 'CoreModule');
+  constructor ( @Optional() @SkipSelf() parentModule: CoreModule) {
+    throwIfAlreadyLoaded(parentModule, 'CoreModule')
   }
 }
index 96b28658b10c4f6e01436a285b93c718e3d977a5..01b12ce7e48153a943ef071d9eb8ce17614df648 100644 (file)
@@ -1,5 +1,5 @@
-export * from './auth';
-export * from './config';
-export * from './confirm';
-export * from './menu';
+export * from './auth'
+export * from './config'
+export * from './confirm'
+export * from './menu'
 export * from './core.module'
index ff40f26e1ac3f9c865951323d788710902488446..c905ed20a15acba132b2d4af3c75a8d204710732 100644 (file)
@@ -1,2 +1,2 @@
-export * from './menu.component';
-export * from './menu-admin.component';
+export * from './menu.component'
+export * from './menu-admin.component'
index 236161fce81523b8f2e5344193a516e37559b334..f6cc6554cb79c697edfb2696d56c35f5b0956715 100644 (file)
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
   selector: 'my-menu-admin',
index 5ab8bf46440194be7c0e9a38726cf31dadca7cd0..b725f64a7dd01cfaf628af4ebfdc34d80598b411 100644 (file)
@@ -1,8 +1,8 @@
-import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { Router } from '@angular/router'
 
-import { AuthService, AuthStatus } from '../auth';
-import { ConfigService } from '../config';
+import { AuthService, AuthStatus } from '../auth'
+import { ConfigService } from '../config'
 
 @Component({
   selector: 'my-menu',
@@ -10,7 +10,7 @@ import { ConfigService } from '../config';
   styleUrls: [ './menu.component.scss' ]
 })
 export class MenuComponent implements OnInit {
-  isLoggedIn: boolean;
+  isLoggedIn: boolean
 
   constructor (
     private authService: AuthService,
@@ -18,35 +18,35 @@ export class MenuComponent implements OnInit {
     private router: Router
   ) {}
 
-  ngOnInit() {
-    this.isLoggedIn = this.authService.isLoggedIn();
+  ngOnInit () {
+    this.isLoggedIn = this.authService.isLoggedIn()
 
     this.authService.loginChangedSource.subscribe(
       status => {
         if (status === AuthStatus.LoggedIn) {
-          this.isLoggedIn = true;
-          console.log('Logged in.');
+          this.isLoggedIn = true
+          console.log('Logged in.')
         } else if (status === AuthStatus.LoggedOut) {
-          this.isLoggedIn = false;
-          console.log('Logged out.');
+          this.isLoggedIn = false
+          console.log('Logged out.')
         } else {
-          console.error('Unknown auth status: ' + status);
+          console.error('Unknown auth status: ' + status)
         }
       }
-    );
+    )
   }
 
-  isRegistrationEnabled() {
-    return this.configService.getConfig().signup.enabled;
+  isRegistrationEnabled () {
+    return this.configService.getConfig().signup.enabled
   }
 
-  isUserAdmin() {
-    return this.authService.isAdmin();
+  isUserAdmin () {
+    return this.authService.isAdmin()
   }
 
-  logout() {
-    this.authService.logout();
+  logout () {
+    this.authService.logout()
     // Redirect to home page
-    this.router.navigate(['/videos/list']);
+    this.router.navigate(['/videos/list'])
   }
 }
index 445640c4fff2435a72e7090a37531d81fb63ed6c..32b1d8f193d1cfd72353a3225a98272e342c6429 100644 (file)
@@ -1,5 +1,5 @@
-export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) {
+export function throwIfAlreadyLoaded (parentModule: any, moduleName: string) {
   if (parentModule) {
-    throw new Error(`${moduleName} has already been loaded. Import Core modules in the AppModule only.`);
+    throw new Error(`${moduleName} has already been loaded. Import Core modules in the AppModule only.`)
   }
 }
index 799102d827364d47d1660642abf5f59448647352..dd327a62e4639886955ba80c5505a415503a6cad 100644 (file)
@@ -1,3 +1,5 @@
+/* tslint:disable */
+
 /**
  * Angular 2
  */
index da53f6aef4c17e3718a460f30273191ddd57b686..d45dbeff6b220bc0c3ef13aa6a1ce9fb4a4328ae 100644 (file)
@@ -1 +1 @@
-export * from './app.module';
+export * from './app.module'
index 5639915f7c5f7f6c8c6ab777a7c14a6826ccbbbe..f1301d8b51c4d908efb4224e3437f0c783ba9f6e 100644 (file)
@@ -1,3 +1,3 @@
-export * from './login-routing.module';
-export * from './login.component';
-export * from './login.module';
+export * from './login-routing.module'
+export * from './login.component'
+export * from './login.module'
index 37199388424e38a4b6f3217c66d3943b560ccd6d..1a91677c02fe008a370221e2fa3027fee65540c0 100644 (file)
@@ -1,7 +1,7 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { RouterModule, Routes } from '@angular/router'
 
-import { LoginComponent } from './login.component';
+import { LoginComponent } from './login.component'
 
 const loginRoutes: Routes = [
   {
@@ -13,7 +13,7 @@ const loginRoutes: Routes = [
       }
     }
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forChild(loginRoutes) ],
index fd4a314ccf18734561ab2d059d91ecb1d3284b43..77703a80c11b78636d3b5f9897560d5d9df1c51c 100644 (file)
@@ -1,9 +1,9 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup, Validators } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { AuthService } from '../core';
-import { FormReactive } from '../shared';
+import { AuthService } from '../core'
+import { FormReactive } from '../shared'
 
 @Component({
   selector: 'my-login',
@@ -11,60 +11,60 @@ import { FormReactive } from '../shared';
 })
 
 export class LoginComponent extends FormReactive implements OnInit {
-  error: string = null;
+  error: string = null
 
-  form: FormGroup;
+  form: FormGroup
   formErrors = {
     'username': '',
     'password': ''
-  };
+  }
   validationMessages = {
     'username': {
-      'required': 'Username is required.',
+      'required': 'Username is required.'
     },
     'password': {
       'required': 'Password is required.'
     }
-  };
+  }
 
-  constructor(
+  constructor (
     private authService: AuthService,
     private formBuilder: FormBuilder,
     private router: Router
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       username: [ '', Validators.required ],
-      password: [ '', Validators.required ],
-    });
+      password: [ '', Validators.required ]
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  login() {
-    this.error = null;
+  login () {
+    this.error = null
 
-    const { username, password } = this.form.value;
+    const { username, password } = this.form.value
 
     this.authService.login(username, password).subscribe(
       result => this.router.navigate(['/videos/list']),
 
       error => {
-        console.error(error.json);
+        console.error(error.json)
 
         if (error.json.error === 'invalid_grant') {
-          this.error = 'Credentials are invalid.';
+          this.error = 'Credentials are invalid.'
         } else {
-          this.error = `${error.json.error}: ${error.json.error_description}`;
+          this.error = `${error.json.error}: ${error.json.error_description}`
         }
       }
-    );
+    )
   }
 }
index 31a723b43e0b4e39db49d0bc7f6095c2e61ba1d5..1de72dbaacbd192086d373b9cdbed3ce38d31856 100644 (file)
@@ -1,8 +1,8 @@
-import { NgModule } from '@angular/core';
+import { NgModule } from '@angular/core'
 
-import { LoginRoutingModule } from './login-routing.module';
-import { LoginComponent } from './login.component';
-import { SharedModule } from '../shared';
+import { LoginRoutingModule } from './login-routing.module'
+import { LoginComponent } from './login.component'
+import { SharedModule } from '../shared'
 
 @NgModule({
   imports: [
index c4114aa023c5e555e5db47c8cb4fc39e35649f43..0fbaab0a845e72eebb0ad150da4b326004ad1a1b 100644 (file)
@@ -1,4 +1,4 @@
-import { Injectable } from '@angular/core';
+import { Injectable } from '@angular/core'
 import {
   ConnectionBackend,
   Headers,
@@ -9,79 +9,79 @@ import {
   RequestOptionsArgs,
   Response,
   XHRBackend
-} from '@angular/http';
-import { Observable } from 'rxjs/Observable';
+} from '@angular/http'
+import { Observable } from 'rxjs/Observable'
 
-import { AuthService } from '../../core';
+import { AuthService } from '../../core'
 
 @Injectable()
 export class AuthHttp extends Http {
-  constructor(backend: ConnectionBackend, defaultOptions: RequestOptions, private authService: AuthService) {
-    super(backend, defaultOptions);
+  constructor (backend: ConnectionBackend, defaultOptions: RequestOptions, private authService: AuthService) {
+    super(backend, defaultOptions)
   }
 
-  request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
-    if (!options) options = {};
+  request (url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
+    if (!options) options = {}
 
-    options.headers = new Headers();
-    this.setAuthorizationHeader(options.headers);
+    options.headers = new Headers()
+    this.setAuthorizationHeader(options.headers)
 
     return super.request(url, options)
                 .catch((err) => {
                   if (err.status === 401) {
-                    return this.handleTokenExpired(url, options);
+                    return this.handleTokenExpired(url, options)
                   }
 
-                  return Observable.throw(err);
-                });
+                  return Observable.throw(err)
+                })
   }
 
-  delete(url: string, options?: RequestOptionsArgs): Observable<Response> {
-    if (!options) options = {};
-    options.method = RequestMethod.Delete;
+  delete (url: string, options?: RequestOptionsArgs): Observable<Response> {
+    if (!options) options = {}
+    options.method = RequestMethod.Delete
 
-    return this.request(url, options);
+    return this.request(url, options)
   }
 
-  get(url: string, options?: RequestOptionsArgs): Observable<Response> {
-    if (!options) options = {};
-    options.method = RequestMethod.Get;
+  get (url: string, options?: RequestOptionsArgs): Observable<Response> {
+    if (!options) options = {}
+    options.method = RequestMethod.Get
 
-    return this.request(url, options);
+    return this.request(url, options)
   }
 
-  post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
-    if (!options) options = {};
-    options.method = RequestMethod.Post;
-    options.body = body;
+  post (url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
+    if (!options) options = {}
+    options.method = RequestMethod.Post
+    options.body = body
 
-    return this.request(url, options);
+    return this.request(url, options)
   }
 
-  put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
-    if (!options) options = {};
-    options.method = RequestMethod.Put;
-    options.body = body;
+  put (url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
+    if (!options) options = {}
+    options.method = RequestMethod.Put
+    options.body = body
 
-    return this.request(url, options);
+    return this.request(url, options)
   }
 
-  private handleTokenExpired(url: string | Request, options: RequestOptionsArgs) {
+  private handleTokenExpired (url: string | Request, options: RequestOptionsArgs) {
     return this.authService.refreshAccessToken()
                            .flatMap(() => {
-                              this.setAuthorizationHeader(options.headers);
+                             this.setAuthorizationHeader(options.headers)
 
-                              return super.request(url, options);
-                            });
+                             return super.request(url, options)
+                           })
   }
 
-  private setAuthorizationHeader(headers: Headers) {
-    headers.set('Authorization', this.authService.getRequestHeaderValue());
+  private setAuthorizationHeader (headers: Headers) {
+    headers.set('Authorization', this.authService.getRequestHeaderValue())
   }
 }
 
-export function useFactory(backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) {
-  return new AuthHttp(backend, defaultOptions, authService);
+export function useFactory (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) {
+  return new AuthHttp(backend, defaultOptions, authService)
 }
 
 export const AUTH_HTTP_PROVIDERS = [
@@ -89,5 +89,5 @@ export const AUTH_HTTP_PROVIDERS = [
     provide: AuthHttp,
     useFactory,
     deps: [ XHRBackend, RequestOptions, AuthService ]
-  },
-];
+  }
+]
index c488aed695936bda84a723a9a62614c37285cd89..0f2bfb0d68cb111deb0dbfdeb297ddf6f108ff6a 100644 (file)
@@ -1 +1 @@
-export * from './auth-http.service';
+export * from './auth-http.service'
index a5732e083a647422335ae176a797477e7257acbb..e7764d0695d1fe197e500f298c54159d7d6c7343 100644 (file)
@@ -1,38 +1,38 @@
-import { FormGroup } from '@angular/forms';
+import { FormGroup } from '@angular/forms'
 
 export abstract class FormReactive {
-  abstract form: FormGroup;
-  abstract formErrors: Object;
-  abstract validationMessages: Object;
+  abstract form: FormGroup
+  abstract formErrors: Object
+  abstract validationMessages: Object
 
-  abstract buildForm(): void;
+  abstract buildForm (): void
 
-  protected onValueChanged(data?: any) {
+  protected onValueChanged (data?: any) {
     for (const field in this.formErrors) {
       // clear previous error message (if any)
-      this.formErrors[field] = '';
-      const control = this.form.get(field);
+      this.formErrors[field] = ''
+      const control = this.form.get(field)
 
       if (control && control.dirty && !control.valid) {
-        const messages = this.validationMessages[field];
+        const messages = this.validationMessages[field]
         for (const key in control.errors) {
-          this.formErrors[field] += messages[key] + ' ';
+          this.formErrors[field] += messages[key] + ' '
         }
       }
     }
   }
 
   // Same as onValueChanged but force checking even if the field is not dirty
-  protected forceCheck() {
+  protected forceCheck () {
     for (const field in this.formErrors) {
       // clear previous error message (if any)
-      this.formErrors[field] = '';
-      const control = this.form.get(field);
+      this.formErrors[field] = ''
+      const control = this.form.get(field)
 
       if (control && !control.valid) {
-        const messages = this.validationMessages[field];
+        const messages = this.validationMessages[field]
         for (const key in control.errors) {
-          this.formErrors[field] += messages[key] + ' ';
+          this.formErrors[field] += messages[key] + ' '
         }
       }
     }
index ec417e0795601cd1981ba21963a8ec260d7ecc3d..03e810fdb902c2e23bb7359d2741aff6a8025c10 100644 (file)
@@ -1,14 +1,14 @@
-import { FormControl } from '@angular/forms';
+import { FormControl } from '@angular/forms'
 
-export function validateHost(c: FormControl) {
+export function validateHost (c: FormControl) {
   // Thanks to http://stackoverflow.com/a/106223
   const HOST_REGEXP = new RegExp(
     '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$'
-  );
+  )
 
   return HOST_REGEXP.test(c.value) ? null : {
     validateHost: {
       valid: false
     }
-  };
+  }
 }
index ab7c2df319441dc18cb76e1dc4b59abed5a19c83..efe77d4ae41f7d964eaa2382f3f7b34d8895e6ab 100644 (file)
@@ -1,4 +1,4 @@
-export * from './host.validator';
-export * from './user';
-export * from './video-abuse';
-export * from './video';
+export * from './host.validator'
+export * from './user'
+export * from './video-abuse'
+export * from './video'
index 259d2b868965f6fb3187d7edbdc0e086886eb7d5..fd316583e98b9a80795e4cc4b534b990b853f161 100644 (file)
@@ -1,4 +1,4 @@
-import { Validators } from '@angular/forms';
+import { Validators } from '@angular/forms'
 
 export const USER_USERNAME = {
   VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ],
@@ -7,18 +7,18 @@ export const USER_USERNAME = {
     'minlength': 'Username must be at least 3 characters long.',
     'maxlength': 'Username cannot be more than 20 characters long.'
   }
-};
+}
 export const USER_EMAIL = {
   VALIDATORS: [ Validators.required, Validators.email ],
   MESSAGES: {
     'required': 'Email is required.',
-    'email': 'Email must be valid.',
+    'email': 'Email must be valid.'
   }
-};
+}
 export const USER_PASSWORD = {
   VALIDATORS: [ Validators.required, Validators.minLength(6) ],
   MESSAGES: {
     'required': 'Password is required.',
-    'minlength': 'Password must be at least 6 characters long.',
+    'minlength': 'Password must be at least 6 characters long.'
   }
-};
+}
index 94a29a3b7b840d0ae7fead29dba2d013d5af9c9c..3c7f26205fbede0bf32db8b203d3a1b8ee90d195 100644 (file)
@@ -1,4 +1,4 @@
-import { Validators } from '@angular/forms';
+import { Validators } from '@angular/forms'
 
 export const VIDEO_ABUSE_REASON = {
   VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ],
@@ -7,4 +7,4 @@ export const VIDEO_ABUSE_REASON = {
     'minlength': 'Report reson must be at least 2 characters long.',
     'maxlength': 'Report reson cannot be more than 300 characters long.'
   }
-};
+}
index f7e4e5e4b175829c875e22c11b096a43c79b2b41..6542cf8f6e34db47e0ae57627bff64306446e094 100644 (file)
@@ -1,4 +1,4 @@
-import { Validators } from '@angular/forms';
+import { Validators } from '@angular/forms'
 
 export const VIDEO_NAME = {
   VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(50) ],
@@ -7,26 +7,26 @@ export const VIDEO_NAME = {
     'minlength': 'Video name must be at least 3 characters long.',
     'maxlength': 'Video name cannot be more than 50 characters long.'
   }
-};
+}
 
 export const VIDEO_CATEGORY = {
   VALIDATORS: [ Validators.required ],
   MESSAGES: {
     'required': 'Video category is required.'
   }
-};
+}
 
 export const VIDEO_LICENCE = {
   VALIDATORS: [ Validators.required ],
   MESSAGES: {
     'required': 'Video licence is required.'
   }
-};
+}
 
 export const VIDEO_LANGUAGE = {
   VALIDATORS: [ ],
   MESSAGES: {}
-};
+}
 
 export const VIDEO_DESCRIPTION = {
   VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],
@@ -35,7 +35,7 @@ export const VIDEO_DESCRIPTION = {
     'minlength': 'Video description must be at least 3 characters long.',
     'maxlength': 'Video description cannot be more than 250 characters long.'
   }
-};
+}
 
 export const VIDEO_TAGS = {
   VALIDATORS: [ Validators.minLength(2), Validators.maxLength(10) ],
@@ -43,4 +43,4 @@ export const VIDEO_TAGS = {
     'minlength': 'A tag should be more than 2 characters long.',
     'maxlength': 'A tag should be less than 10 characters long.'
   }
-};
+}
index 588ebb4be4f97b707f788f2996ac2e2cf88252b3..7464bb0222f91bf4c334c8e5dc48bb6e98ebf7f9 100644 (file)
@@ -1,2 +1,2 @@
-export * from './form-validators';
-export * from './form-reactive';
+export * from './form-validators'
+export * from './form-reactive'
index 61e8ed5232c73e3d0b744346e44b6f797e45b0bc..212645c51988360a68335058488a482dd9b123c6 100644 (file)
@@ -1,8 +1,8 @@
-export * from './auth';
-export * from './forms';
-export * from './rest';
-export * from './search';
-export * from './users';
-export * from './video-abuse';
-export * from './shared.module';
-export * from './utils';
+export * from './auth'
+export * from './forms'
+export * from './rest'
+export * from './search'
+export * from './users'
+export * from './video-abuse'
+export * from './shared.module'
+export * from './utils'
index 3cb123c3b8a1c59f4a30a18337833da08e7adbc0..e0be155cf7e87415dfc56ca641a58d2688310203 100644 (file)
@@ -1,4 +1,4 @@
-export * from './rest-data-source';
-export * from './rest-extractor.service';
-export * from './rest-pagination';
-export * from './rest.service';
+export * from './rest-data-source'
+export * from './rest-extractor.service'
+export * from './rest-pagination'
+export * from './rest.service'
index 1def38c73acb45a5e86250bf546bbe9df721b145..2ef5d38da8883bdbec4cbf0ff54a89929f43fd85 100644 (file)
@@ -1,51 +1,51 @@
-import { Http, RequestOptionsArgs, URLSearchParams,  } from '@angular/http';
+import { Http, RequestOptionsArgs, URLSearchParams, Response } from '@angular/http'
 
-import { ServerDataSource } from 'ng2-smart-table';
+import { ServerDataSource } from 'ng2-smart-table'
 
 export class RestDataSource extends ServerDataSource {
constructor(http: Http, endpoint: string) {
-   const options = {
-     endPoint: endpoint,
-     sortFieldKey: 'sort',
-     dataKey: 'data'
-   };
-
-   super(http, options);
- }
-
protected extractTotalFromResponse(res) {
-    const rawData = res.json();
-    return rawData ? parseInt(rawData.total) : 0;
 constructor (http: Http, endpoint: string) {
+    const options = {
+      endPoint: endpoint,
+      sortFieldKey: 'sort',
+      dataKey: 'data'
+    }
+
+    super(http, options)
 }
+
 protected extractTotalFromResponse (res: Response) {
+    const rawData = res.json()
+    return rawData ? parseInt(rawData.total, 10) : 0
   }
 
protected addSortRequestOptions(requestOptions: RequestOptionsArgs) {
-    let searchParams: URLSearchParams = <URLSearchParams> requestOptions.search;
 protected addSortRequestOptions (requestOptions: RequestOptionsArgs) {
+    const searchParams = requestOptions.search as URLSearchParams
 
     if (this.sortConf) {
       this.sortConf.forEach((fieldConf) => {
-        const sortPrefix = fieldConf.direction === 'desc' ? '-' : '';
+        const sortPrefix = fieldConf.direction === 'desc' ? '-' : ''
 
-        searchParams.set(this.conf.sortFieldKey, sortPrefix + fieldConf.field);
-      });
+        searchParams.set(this.conf.sortFieldKey, sortPrefix + fieldConf.field)
+      })
     }
 
-    return requestOptions;
+    return requestOptions
   }
 
-  protected addPagerRequestOptions(requestOptions: RequestOptionsArgs) {
-    let searchParams: URLSearchParams = <URLSearchParams> requestOptions.search;
+  protected addPagerRequestOptions (requestOptions: RequestOptionsArgs) {
+    const searchParams = requestOptions.search as URLSearchParams
 
     if (this.pagingConf && this.pagingConf['page'] && this.pagingConf['perPage']) {
-      const perPage = this.pagingConf['perPage'];
-      const page = this.pagingConf['page'];
+      const perPage = this.pagingConf['perPage']
+      const page = this.pagingConf['page']
 
-      const start = (page - 1) * perPage;
-      const count = perPage;
+      const start = (page - 1) * perPage
+      const count = perPage
 
-      searchParams.set('start', start.toString());
-      searchParams.set('count', count.toString());
+      searchParams.set('start', start.toString())
+      searchParams.set('count', count.toString())
     }
 
-    return requestOptions;
+    return requestOptions
   }
 }
index fcb1598f4393385a78521c7e8225cd83c73e5abc..f6a818ec86515abaf24fb6f4fca6d036d2ecefb5 100644 (file)
@@ -1,52 +1,52 @@
-import { Injectable } from '@angular/core';
-import { Response } from '@angular/http';
-import { Observable } from 'rxjs/Observable';
+import { Injectable } from '@angular/core'
+import { Response } from '@angular/http'
+import { Observable } from 'rxjs/Observable'
 
 export interface ResultList {
-  data: any[];
-  total: number;
+  data: any[]
+  total: number
 }
 
 @Injectable()
 export class RestExtractor {
 
-  constructor () { ; }
-
-  extractDataBool(res: Response) {
-    return true;
+  extractDataBool (res: Response) {
+    return true
   }
 
-  extractDataList(res: Response) {
-    const body = res.json();
+  extractDataList (res: Response) {
+    const body = res.json()
 
     const ret: ResultList = {
       data: body.data,
       total: body.total
-    };
+    }
 
-    return ret;
+    return ret
   }
 
-  extractDataGet(res: Response) {
-    return res.json();
+  extractDataGet (res: Response) {
+    return res.json()
   }
 
-  handleError(res: Response) {
-    let text = 'Server error: ';
-    text += res.text();
-    let json = '';
+  handleError (res: Response) {
+    let text = 'Server error: '
+    text += res.text()
+    let json = ''
 
     try {
-      json = res.json();
-    } catch (err) { ; }
+      json = res.json()
+    } catch (err) {
+      console.error('Cannot get JSON from response.')
+    }
 
     const error = {
       json,
       text
-    };
+    }
 
-    console.error(error);
+    console.error(error)
 
-    return Observable.throw(error);
+    return Observable.throw(error)
   }
 }
index 0cfa4f4681aee7bcb4102d057d9da20f203e7c6e..766e7a9e5cf91ba24bd674a55b167abb97050e03 100644 (file)
@@ -1,5 +1,5 @@
 export interface RestPagination {
-  currentPage: number;
-  itemsPerPage: number;
-  totalItems: number;
-};
+  currentPage: number
+  itemsPerPage: number
+  totalItems: number
+}
index 16b47e9574d771d2b55dc7dee89033f24582bcb7..43dc20b34e09eb4618e17e43708baf2e34f276e5 100644 (file)
@@ -1,27 +1,27 @@
-import { Injectable } from '@angular/core';
-import { URLSearchParams } from '@angular/http';
+import { Injectable } from '@angular/core'
+import { URLSearchParams } from '@angular/http'
 
-import { RestPagination } from './rest-pagination';
+import { RestPagination } from './rest-pagination'
 
 @Injectable()
 export class RestService {
 
-  buildRestGetParams(pagination?: RestPagination, sort?: string) {
-    const params = new URLSearchParams();
+  buildRestGetParams (pagination?: RestPagination, sort?: string) {
+    const params = new URLSearchParams()
 
     if (pagination) {
-      const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage;
-      const count: number = pagination.itemsPerPage;
+      const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage
+      const count: number = pagination.itemsPerPage
 
-      params.set('start', start.toString());
-      params.set('count', count.toString());
+      params.set('start', start.toString())
+      params.set('count', count.toString())
     }
 
     if (sort) {
-      params.set('sort', sort);
+      params.set('sort', sort)
     }
 
-    return params;
+    return params
   }
 
 }
index a897ed09959a6e38f52efac4b0453190559f1315..d4016cf8997c0a4074fe2fd5d661b56f51f71a39 100644 (file)
@@ -1,4 +1,4 @@
-export * from './search-field.type';
-export * from './search.component';
-export * from './search.model';
-export * from './search.service';
+export * from './search-field.type'
+export * from './search.component'
+export * from './search.model'
+export * from './search.service'
index 6be584ed15d2ca4679c5c29535bf436af2c91a5d..63557898a9981eb3a85ed8d8e0ca592ec2137fae 100644 (file)
@@ -1 +1 @@
-export type SearchField = "name" | "author" | "host" | "magnetUri" | "tags";
+export type SearchField = 'name' | 'author' | 'host' | 'magnetUri' | 'tags'
index 48413b4f2332ab6c0454e039edfd40bb96977e8c..ecce20666e5442cea4d8b07e70d54a32681a1809 100644 (file)
@@ -1,9 +1,9 @@
-import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { Router } from '@angular/router'
 
-import { Search } from './search.model';
-import { SearchField } from './search-field.type';
-import { SearchService } from './search.service';
+import { Search } from './search.model'
+import { SearchField } from './search-field.type'
+import { SearchService } from './search.service'
 
 @Component({
   selector: 'my-search',
@@ -18,53 +18,53 @@ export class SearchComponent implements OnInit {
     host: 'Pod Host',
     magnetUri: 'Magnet URI',
     tags: 'Tags'
-  };
+  }
   searchCriterias: Search = {
     field: 'name',
     value: ''
-  };
+  }
 
-  constructor(private searchService: SearchService, private router: Router) {}
+  constructor (private searchService: SearchService, private router: Router) {}
 
-  ngOnInit() {
+  ngOnInit () {
     // Subscribe if the search changed
     // Usually changed by videos list component
     this.searchService.updateSearch.subscribe(
       newSearchCriterias => {
         // Put a field by default
         if (!newSearchCriterias.field) {
-          newSearchCriterias.field = 'name';
+          newSearchCriterias.field = 'name'
         }
 
-        this.searchCriterias = newSearchCriterias;
+        this.searchCriterias = newSearchCriterias
       }
-    );
+    )
   }
 
-  get choiceKeys() {
-    return Object.keys(this.fieldChoices);
+  get choiceKeys () {
+    return Object.keys(this.fieldChoices)
   }
 
-  choose($event: MouseEvent, choice: SearchField) {
-    $event.preventDefault();
-    $event.stopPropagation();
+  choose ($event: MouseEvent, choice: SearchField) {
+    $event.preventDefault()
+    $event.stopPropagation()
 
-    this.searchCriterias.field = choice;
+    this.searchCriterias.field = choice
 
     if (this.searchCriterias.value) {
-      this.doSearch();
+      this.doSearch()
     }
   }
 
-  doSearch() {
+  doSearch () {
     if (this.router.url.indexOf('/videos/list') === -1) {
-      this.router.navigate([ '/videos/list' ]);
+      this.router.navigate([ '/videos/list' ])
     }
 
-    this.searchService.searchUpdated.next(this.searchCriterias);
+    this.searchService.searchUpdated.next(this.searchCriterias)
   }
 
-  getStringChoice(choiceKey: SearchField) {
-    return this.fieldChoices[choiceKey];
+  getStringChoice (choiceKey: SearchField) {
+    return this.fieldChoices[choiceKey]
   }
 }
index 932a6566c4499aa5b104ef0bf730d1e3a68e9440..174adf2c6b6775a592d7515ff95ee44679b6a2f9 100644 (file)
@@ -1,6 +1,6 @@
-import { SearchField } from './search-field.type';
+import { SearchField } from './search-field.type'
 
 export interface Search {
-  field: SearchField;
-  value: string;
+  field: SearchField
+  value: string
 }
index 717a7fa500e044fecc9bdce2d0aa0440196220eb..0480b46bd8581bae90353948ae4142f32c95481f 100644 (file)
@@ -1,18 +1,18 @@
-import { Injectable } from '@angular/core';
-import { Subject } from 'rxjs/Subject';
-import { ReplaySubject } from 'rxjs/ReplaySubject';
+import { Injectable } from '@angular/core'
+import { Subject } from 'rxjs/Subject'
+import { ReplaySubject } from 'rxjs/ReplaySubject'
 
-import { Search } from './search.model';
+import { Search } from './search.model'
 
 // This class is needed to communicate between videos/ and search component
 // Remove it when we'll be able to subscribe to router changes
 @Injectable()
 export class SearchService {
-  searchUpdated: Subject<Search>;
-  updateSearch: Subject<Search>;
+  searchUpdated: Subject<Search>
+  updateSearch: Subject<Search>
 
-  constructor() {
-    this.updateSearch = new Subject<Search>();
-    this.searchUpdated = new ReplaySubject<Search>(1);
+  constructor () {
+    this.updateSearch = new Subject<Search>()
+    this.searchUpdated = new ReplaySubject<Search>(1)
   }
 }
index 8ffaf964b624391af4c6b971175e0be2c57475c5..99b51aa4e6f2706c4041bb98e03fb2cb4fbf2315 100644 (file)
@@ -1,23 +1,23 @@
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { HttpModule } from '@angular/http';
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { RouterModule } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { CommonModule } from '@angular/common'
+import { HttpModule } from '@angular/http'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { RouterModule } from '@angular/router'
 
-import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
-import { KeysPipe } from 'angular-pipes/src/object/keys.pipe';
-import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
-import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
-import { PaginationModule } from 'ngx-bootstrap/pagination';
-import { ModalModule } from 'ngx-bootstrap/modal';
-import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
-import { Ng2SmartTableModule } from 'ng2-smart-table';
+import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'
+import { KeysPipe } from 'angular-pipes/src/object/keys.pipe'
+import { BsDropdownModule } from 'ngx-bootstrap/dropdown'
+import { ProgressbarModule } from 'ngx-bootstrap/progressbar'
+import { PaginationModule } from 'ngx-bootstrap/pagination'
+import { ModalModule } from 'ngx-bootstrap/modal'
+import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'
+import { Ng2SmartTableModule } from 'ng2-smart-table'
 
-import { AUTH_HTTP_PROVIDERS } from './auth';
-import { RestExtractor, RestService } from './rest';
-import { SearchComponent, SearchService } from './search';
-import { UserService } from './users';
-import { VideoAbuseService } from './video-abuse';
+import { AUTH_HTTP_PROVIDERS } from './auth'
+import { RestExtractor, RestService } from './rest'
+import { SearchComponent, SearchService } from './search'
+import { UserService } from './users'
+import { VideoAbuseService } from './video-abuse'
 
 @NgModule({
   imports: [
index ff009e89b49e269651399c8a074db677c45ffeb8..7b5a67bc78513926957a988459da0da1a01df486 100644 (file)
@@ -1,2 +1,2 @@
-export * from './user.model';
-export * from './user.service';
+export * from './user.model'
+export * from './user.service'
index d4695ab67e6cd5c00f099a0dba486ac765383c78..1c2b481e34d41bb695ca81d72b919a1b9ecc0b39 100644 (file)
@@ -1,33 +1,33 @@
-import { User as UserServerModel, UserRole } from '../../../../../shared';
+import { User as UserServerModel, UserRole } from '../../../../../shared'
 
 export class User implements UserServerModel {
-  id: number;
-  username: string;
-  email: string;
-  role: UserRole;
-  displayNSFW: boolean;
-  createdAt: Date;
+  id: number
+  username: string
+  email: string
+  role: UserRole
+  displayNSFW: boolean
+  createdAt: Date
 
-  constructor(hash: {
+  constructor (hash: {
     id: number,
     username: string,
     email: string,
     role: UserRole,
     displayNSFW?: boolean,
-    createdAt?: Date,
+    createdAt?: Date
   }) {
-    this.id = hash.id;
-    this.username = hash.username;
-    this.email = hash.email;
-    this.role = hash.role;
-    this.displayNSFW = hash.displayNSFW;
+    this.id = hash.id
+    this.username = hash.username
+    this.email = hash.email
+    this.role = hash.role
+    this.displayNSFW = hash.displayNSFW
 
     if (hash.createdAt) {
-      this.createdAt = hash.createdAt;
+      this.createdAt = hash.createdAt
     }
   }
 
-  isAdmin() {
-    return this.role === 'admin';
+  isAdmin () {
+    return this.role === 'admin'
   }
 }
index f1265be0a875863818b28760e6058b64425fdb6d..e956df5b1c14c38589221b4d22e4a3da7527ee80 100644 (file)
@@ -1,58 +1,58 @@
-import { Injectable } from '@angular/core';
-import { Http } from '@angular/http';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
+import { Injectable } from '@angular/core'
+import { Http } from '@angular/http'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
 
-import { AuthService } from '../../core';
-import { AuthHttp } from '../auth';
-import { RestExtractor } from '../rest';
+import { AuthService } from '../../core'
+import { AuthHttp } from '../auth'
+import { RestExtractor } from '../rest'
 
 @Injectable()
 export class UserService {
-  static BASE_USERS_URL = API_URL + '/api/v1/users/';
+  static BASE_USERS_URL = API_URL + '/api/v1/users/'
 
-  constructor(
+  constructor (
     private http: Http,
     private authHttp: AuthHttp,
     private authService: AuthService,
     private restExtractor: RestExtractor
   ) {}
 
-  checkTokenValidity() {
-    const url = UserService.BASE_USERS_URL + 'me';
+  checkTokenValidity () {
+    const url = UserService.BASE_USERS_URL + 'me'
 
     // AuthHttp will redirect us to the login page if the oken is not valid anymore
-    this.authHttp.get(url).subscribe(() => { ; });
+    this.authHttp.get(url).subscribe()
   }
 
-  changePassword(newPassword: string) {
-    const url = UserService.BASE_USERS_URL + this.authService.getUser().id;
+  changePassword (newPassword: string) {
+    const url = UserService.BASE_USERS_URL + this.authService.getUser().id
     const body = {
       password: newPassword
-    };
+    }
 
     return this.authHttp.put(url, body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  updateDetails(details: { displayNSFW: boolean }) {
-    const url = UserService.BASE_USERS_URL + this.authService.getUser().id;
+  updateDetails (details: { displayNSFW: boolean }) {
+    const url = UserService.BASE_USERS_URL + this.authService.getUser().id
 
     return this.authHttp.put(url, details)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  signup(username: string, password: string, email: string) {
+  signup (username: string, password: string, email: string) {
     const body = {
       username,
       email,
       password
-    };
+    }
 
     return this.http.post(UserService.BASE_USERS_URL + 'register', body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch(this.restExtractor.handleError);
+                        .catch(this.restExtractor.handleError)
   }
 }
index 5ab41fe5a3fac07c11f74c2bf59f48b9e6e5cf16..832311f892c900059aa9c29cfbdee8c04f558af6 100644 (file)
@@ -1,12 +1,12 @@
-import { DatePipe } from '@angular/common';
+import { DatePipe } from '@angular/common'
 
 export class Utils {
 
-  static dateToHuman(date: String) {
-    return new DatePipe('en').transform(date, 'medium');
+  static dateToHuman (date: String) {
+    return new DatePipe('en').transform(date, 'medium')
   }
 
-  static getRowDeleteButton() {
-    return '<span class="glyphicon glyphicon-remove glyphicon-black"></span>';
+  static getRowDeleteButton () {
+    return '<span class="glyphicon glyphicon-remove glyphicon-black"></span>'
   }
 }
index 563533ba52b316efba997183089a046f71196057..7cf24c87df110329ef790abafe50b421cfc87715 100644 (file)
@@ -1,2 +1,2 @@
-export * from './video-abuse.service';
-export * from './video-abuse.model';
+export * from './video-abuse.service'
+export * from './video-abuse.model'
index bb0373027d3d17f16db05487dda8ba2ad442a281..49c87d6b86594195a5d54ab0d09ad036d639383a 100644 (file)
@@ -1,8 +1,8 @@
 export interface VideoAbuse {
-  id: string;
-  reason: string;
-  reporterPodHost: string;
-  reporterUsername: string;
-  videoId: string;
-  createdAt: Date;
+  id: string
+  reason: string
+  reporterPodHost: string
+  reporterUsername: string
+  videoId: string
+  createdAt: Date
 }
index da7b2ef8a34f8bb0356a646b45aa99a180817fbe..4317f935381a493475a07ba924d56e3ff149fc50 100644 (file)
@@ -1,42 +1,42 @@
-import { Injectable } from '@angular/core';
-import { Http } from '@angular/http';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
+import { Injectable } from '@angular/core'
+import { Http } from '@angular/http'
+import { Observable } from 'rxjs/Observable'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
 
-import { AuthService } from '../core';
-import { AuthHttp } from '../auth';
-import { RestDataSource, RestExtractor, ResultList } from '../rest';
-import { VideoAbuse } from './video-abuse.model';
+import { AuthService } from '../core'
+import { AuthHttp } from '../auth'
+import { RestDataSource, RestExtractor, ResultList } from '../rest'
+import { VideoAbuse } from './video-abuse.model'
 
 @Injectable()
 export class VideoAbuseService {
-  private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/';
+  private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/'
 
-  constructor(
+  constructor (
     private authHttp: AuthHttp,
     private restExtractor: RestExtractor
   ) {}
 
-  getDataSource() {
-    return new RestDataSource(this.authHttp, VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse');
+  getDataSource () {
+    return new RestDataSource(this.authHttp, VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse')
   }
 
-  reportVideo(id: string, reason: string) {
+  reportVideo (id: string, reason: string) {
     const body = {
       reason
-    };
-    const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse';
+    }
+    const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse'
 
     return this.authHttp.post(url, body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  private extractVideoAbuses(result: ResultList) {
-    const videoAbuses: VideoAbuse[] = result.data;
-    const totalVideoAbuses = result.total;
+  private extractVideoAbuses (result: ResultList) {
+    const videoAbuses: VideoAbuse[] = result.data
+    const totalVideoAbuses = result.total
 
-    return { videoAbuses, totalVideoAbuses };
+    return { videoAbuses, totalVideoAbuses }
   }
 }
index 1f4290ab5e8c54c3b02e2744b3aa0b8fbb88e192..b0aca9723649be45873054f26534e5c401ba2169 100644 (file)
@@ -1,3 +1,3 @@
-export * from './signup-routing.module';
-export * from './signup.component';
-export * from './signup.module';
+export * from './signup-routing.module'
+export * from './signup.component'
+export * from './signup.module'
index 367eed90c9d43c06435e72b1d4cd759656830cbb..122d6c976f25954429d2829fb7e9acb751bb032b 100644 (file)
@@ -1,7 +1,7 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { RouterModule, Routes } from '@angular/router'
 
-import { SignupComponent } from './signup.component';
+import { SignupComponent } from './signup.component'
 
 const signupRoutes: Routes = [
   {
@@ -13,7 +13,7 @@ const signupRoutes: Routes = [
       }
     }
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forChild(signupRoutes) ],
index 85f93793b805b259ce99f9432e04a06413c11da5..bcbc8ded3b620c195a1ac68512c2d5539a5d7a82 100644 (file)
@@ -1,72 +1,72 @@
-import { Component, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup, Validators } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { AuthService } from '../core';
+import { AuthService } from '../core'
 import {
   FormReactive,
   UserService,
   USER_USERNAME,
   USER_EMAIL,
   USER_PASSWORD
-} from '../shared';
+} from '../shared'
 
 @Component({
   selector: 'my-signup',
   templateUrl: './signup.component.html'
 })
 export class SignupComponent extends FormReactive implements OnInit {
-  error: string = null;
+  error: string = null
 
-  form: FormGroup;
+  form: FormGroup
   formErrors = {
     'username': '',
     'email': '',
     'password': ''
-  };
+  }
   validationMessages = {
     'username': USER_USERNAME.MESSAGES,
     'email': USER_EMAIL.MESSAGES,
-    'password': USER_PASSWORD.MESSAGES,
-  };
+    'password': USER_PASSWORD.MESSAGES
+  }
 
-  constructor(
+  constructor (
     private formBuilder: FormBuilder,
     private router: Router,
     private notificationsService: NotificationsService,
     private userService: UserService
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       username: [ '', USER_USERNAME.VALIDATORS ],
       email:    [ '', USER_EMAIL.VALIDATORS ],
-      password: [ '', USER_PASSWORD.VALIDATORS ],
-    });
+      password: [ '', USER_PASSWORD.VALIDATORS ]
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  signup() {
-    this.error = null;
+  signup () {
+    this.error = null
 
-    const { username, password, email } = this.form.value;
+    const { username, password, email } = this.form.value
 
     this.userService.signup(username, password, email).subscribe(
       () => {
-        this.notificationsService.success('Success', `Registration for ${username} complete.`);
-        this.router.navigate([ '/videos/list' ]);
+        this.notificationsService.success('Success', `Registration for ${username} complete.`)
+        this.router.navigate([ '/videos/list' ])
       },
 
       err => this.error = err.text
-    );
+    )
   }
 }
index acb7e55155691afc214ed76ddf50da99148d78d7..61560ddcfdf03b69205c8c7ae58c4d5f4aae698c 100644 (file)
@@ -1,8 +1,8 @@
-import { NgModule } from '@angular/core';
+import { NgModule } from '@angular/core'
 
-import { SignupRoutingModule } from './signup-routing.module';
-import { SignupComponent } from './signup.component';
-import { SharedModule } from '../shared';
+import { SignupRoutingModule } from './signup-routing.module'
+import { SignupComponent } from './signup.component'
+import { SharedModule } from '../shared'
 
 @NgModule({
   imports: [
index 5158a23f835032de6c81d8aa6fc542ea2479bfd6..83edcc75868e6e7ff8e3370eb9eff146b275f192 100644 (file)
@@ -1,7 +1,7 @@
-export * from './shared';
-export * from './video-edit';
-export * from './video-list';
-export * from './video-watch';
-export * from './videos-routing.module';
-export * from './videos.component';
-export * from './videos.module';
+export * from './shared'
+export * from './video-edit'
+export * from './video-list'
+export * from './video-watch'
+export * from './videos-routing.module'
+export * from './videos.component'
+export * from './videos.module'
index a68491022545e1a286a5c1161d71a70de9f196cc..0fa14f6417cff0eb34e808f937c4f689e326e70f 100644 (file)
@@ -1,4 +1,4 @@
-export * from './sort-field.type';
-export * from './rate-type.type';
-export * from './video.model';
-export * from './video.service';
+export * from './sort-field.type'
+export * from './rate-type.type'
+export * from './video.model'
+export * from './video.service'
index 88034d1ff1dfa81bc92fb675c4b282a2fd967741..20eea3ae531d0ec742e560e4af8fc3d3909e6e58 100644 (file)
@@ -1 +1 @@
-export type RateType = 'like' | 'dislike';
+export type RateType = 'like' | 'dislike'
index 6cc598d8b677cf58bf2a6f3383415b5c50bd68a8..776f360f8de43f838f9dc6f44f6a317da2b294e1 100644 (file)
@@ -2,5 +2,4 @@ export type SortField = 'name' | '-name'
                       | 'duration' | '-duration'
                       | 'createdAt' | '-createdAt'
                       | 'views' | '-views'
-                      | 'likes' | '-likes';
-
+                      | 'likes' | '-likes'
index e897eb17503447cca0defae1600f76b225358200..f5e16fc13f9ffc1ef10c4bf3c56ddcb5858dbc56 100644 (file)
@@ -1,56 +1,56 @@
-import { Video as VideoServerModel } from '../../../../../shared';
-import { User } from '../../shared';
+import { Video as VideoServerModel } from '../../../../../shared'
+import { User } from '../../shared'
 
 export class Video implements VideoServerModel {
-  author: string;
-  by: string;
-  createdAt: Date;
-  categoryLabel: string;
-  category: number;
-  licenceLabel: string;
-  licence: number;
-  languageLabel: string;
-  language: number;
-  description: string;
-  duration: number;
-  durationLabel: string;
-  id: string;
-  isLocal: boolean;
-  magnetUri: string;
-  name: string;
-  podHost: string;
-  tags: string[];
-  thumbnailPath: string;
-  thumbnailUrl: string;
-  views: number;
-  likes: number;
-  dislikes: number;
-  nsfw: boolean;
+  author: string
+  by: string
+  createdAt: Date
+  categoryLabel: string
+  category: number
+  licenceLabel: string
+  licence: number
+  languageLabel: string
+  language: number
+  description: string
+  duration: number
+  durationLabel: string
+  id: string
+  isLocal: boolean
+  magnetUri: string
+  name: string
+  podHost: string
+  tags: string[]
+  thumbnailPath: string
+  thumbnailUrl: string
+  views: number
+  likes: number
+  dislikes: number
+  nsfw: boolean
 
-  private static createByString(author: string, podHost: string) {
-    return author + '@' + podHost;
+  private static createByString (author: string, podHost: string) {
+    return author + '@' + podHost
   }
 
-  private static createDurationString(duration: number) {
-    const minutes = Math.floor(duration / 60);
-    const seconds = duration % 60;
-    const minutes_padding = minutes >= 10 ? '' : '0';
-    const seconds_padding = seconds >= 10 ? '' : '0';
+  private static createDurationString (duration: number) {
+    const minutes = Math.floor(duration / 60)
+    const seconds = duration % 60
+    const minutesPadding = minutes >= 10 ? '' : '0'
+    const secondsPadding = seconds >= 10 ? '' : '0'
 
-    return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
+    return minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString()
   }
 
-  constructor(hash: {
+  constructor (hash: {
     author: string,
     createdAt: string,
     categoryLabel: string,
     category: number,
     licenceLabel: string,
     licence: number,
-    languageLabel: string;
-    language: number;
+    languageLabel: string
+    language: number
     description: string,
-    duration: number;
+    duration: number
     id: string,
     isLocal: boolean,
     magnetUri: string,
@@ -63,57 +63,57 @@ export class Video implements VideoServerModel {
     dislikes: number,
     nsfw: boolean
   }) {
-    this.author  = hash.author;
-    this.createdAt = new Date(hash.createdAt);
-    this.categoryLabel = hash.categoryLabel;
-    this.category = hash.category;
-    this.licenceLabel = hash.licenceLabel;
-    this.licence = hash.licence;
-    this.languageLabel = hash.languageLabel;
-    this.language = hash.language;
-    this.description = hash.description;
-    this.duration = hash.duration;
-    this.durationLabel = Video.createDurationString(hash.duration);
-    this.id = hash.id;
-    this.isLocal = hash.isLocal;
-    this.magnetUri = hash.magnetUri;
-    this.name = hash.name;
-    this.podHost = hash.podHost;
-    this.tags = hash.tags;
-    this.thumbnailPath = hash.thumbnailPath;
-    this.thumbnailUrl = API_URL + hash.thumbnailPath;
-    this.views = hash.views;
-    this.likes = hash.likes;
-    this.dislikes = hash.dislikes;
-    this.nsfw = hash.nsfw;
+    this.author = hash.author
+    this.createdAt = new Date(hash.createdAt)
+    this.categoryLabel = hash.categoryLabel
+    this.category = hash.category
+    this.licenceLabel = hash.licenceLabel
+    this.licence = hash.licence
+    this.languageLabel = hash.languageLabel
+    this.language = hash.language
+    this.description = hash.description
+    this.duration = hash.duration
+    this.durationLabel = Video.createDurationString(hash.duration)
+    this.id = hash.id
+    this.isLocal = hash.isLocal
+    this.magnetUri = hash.magnetUri
+    this.name = hash.name
+    this.podHost = hash.podHost
+    this.tags = hash.tags
+    this.thumbnailPath = hash.thumbnailPath
+    this.thumbnailUrl = API_URL + hash.thumbnailPath
+    this.views = hash.views
+    this.likes = hash.likes
+    this.dislikes = hash.dislikes
+    this.nsfw = hash.nsfw
 
-    this.by = Video.createByString(hash.author, hash.podHost);
+    this.by = Video.createByString(hash.author, hash.podHost)
   }
 
-  isRemovableBy(user) {
-    return user && this.isLocal === true && (this.author === user.username || user.isAdmin() === true);
+  isRemovableBy (user) {
+    return user && this.isLocal === true && (this.author === user.username || user.isAdmin() === true)
   }
 
-  isBlackistableBy(user) {
-    return user && user.isAdmin() === true && this.isLocal === false;
+  isBlackistableBy (user) {
+    return user && user.isAdmin() === true && this.isLocal === false
   }
 
-  isUpdatableBy(user) {
-    return user && this.isLocal === true && user.username === this.author;
+  isUpdatableBy (user) {
+    return user && this.isLocal === true && user.username === this.author
   }
 
-  isVideoNSFWForUser(user: User) {
+  isVideoNSFWForUser (user: User) {
     // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
-    return (this.nsfw && (!user || user.displayNSFW === false));
+    return (this.nsfw && (!user || user.displayNSFW === false))
   }
 
-  patch(values: Object) {
+  patch (values: Object) {
     Object.keys(values).forEach((key) => {
-      this[key] = values[key];
-    });
+      this[key] = values[key]
+    })
   }
 
-  toJSON() {
+  toJSON () {
     return {
       author: this.author,
       createdAt: this.createdAt,
@@ -133,6 +133,6 @@ export class Video implements VideoServerModel {
       likes: this.likes,
       dislikes: this.dislikes,
       nsfw: this.nsfw
-    };
+    }
   }
 }
index a53ea1064872aa4be92667623193644c10f895c1..a4e3d16dfc0ae13e598fd72e20cc96390025ff3f 100644 (file)
@@ -1,13 +1,13 @@
-import { Injectable } from '@angular/core';
-import { Http, Headers, RequestOptions } from '@angular/http';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/operator/catch';
-import 'rxjs/add/operator/map';
-
-import { Search } from '../../shared';
-import { SortField } from './sort-field.type';
-import { RateType } from './rate-type.type';
-import { AuthService } from '../../core';
+import { Injectable } from '@angular/core'
+import { Http, Headers, RequestOptions } from '@angular/http'
+import { Observable } from 'rxjs/Observable'
+import 'rxjs/add/operator/catch'
+import 'rxjs/add/operator/map'
+
+import { Search } from '../../shared'
+import { SortField } from './sort-field.type'
+import { RateType } from './rate-type.type'
+import { AuthService } from '../../core'
 import {
   AuthHttp,
   RestExtractor,
@@ -15,18 +15,18 @@ import {
   RestService,
   ResultList,
   UserService
-} from '../../shared';
-import { Video } from './video.model';
+} from '../../shared'
+import { Video } from './video.model'
 
 @Injectable()
 export class VideoService {
-  private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/';
+  private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/'
 
-  videoCategories: Array<{ id: number, label: string }> = [];
-  videoLicences: Array<{ id: number, label: string }> = [];
-  videoLanguages: Array<{ id: number, label: string }> = [];
+  videoCategories: Array<{ id: number, label: string }> = []
+  videoLicences: Array<{ id: number, label: string }> = []
+  videoLanguages: Array<{ id: number, label: string }> = []
 
-  constructor(
+  constructor (
     private authService: AuthService,
     private authHttp: AuthHttp,
     private http: Http,
@@ -34,54 +34,54 @@ export class VideoService {
     private restService: RestService
   ) {}
 
-  loadVideoCategories() {
+  loadVideoCategories () {
     return this.http.get(VideoService.BASE_VIDEO_URL + 'categories')
                     .map(this.restExtractor.extractDataGet)
                     .subscribe(data => {
                       Object.keys(data).forEach(categoryKey => {
                         this.videoCategories.push({
-                          id: parseInt(categoryKey),
+                          id: parseInt(categoryKey, 10),
                           label: data[categoryKey]
-                        });
-                      });
-                    });
+                        })
+                      })
+                    })
   }
 
-  loadVideoLicences() {
+  loadVideoLicences () {
     return this.http.get(VideoService.BASE_VIDEO_URL + 'licences')
                     .map(this.restExtractor.extractDataGet)
                     .subscribe(data => {
                       Object.keys(data).forEach(licenceKey => {
                         this.videoLicences.push({
-                          id: parseInt(licenceKey),
+                          id: parseInt(licenceKey, 10),
                           label: data[licenceKey]
-                        });
-                      });
-                    });
+                        })
+                      })
+                    })
   }
 
-  loadVideoLanguages() {
+  loadVideoLanguages () {
     return this.http.get(VideoService.BASE_VIDEO_URL + 'languages')
                     .map(this.restExtractor.extractDataGet)
                     .subscribe(data => {
                       Object.keys(data).forEach(languageKey => {
                         this.videoLanguages.push({
-                          id: parseInt(languageKey),
+                          id: parseInt(languageKey, 10),
                           label: data[languageKey]
-                        });
-                      });
-                    });
+                        })
+                      })
+                    })
   }
 
-  getVideo(id: string): Observable<Video> {
+  getVideo (id: string): Observable<Video> {
     return this.http.get(VideoService.BASE_VIDEO_URL + id)
                     .map(this.restExtractor.extractDataGet)
-                    .map(video_hash => new Video(video_hash))
-                    .catch((res) => this.restExtractor.handleError(res));
+                    .map(videoHash => new Video(videoHash))
+                    .catch((res) => this.restExtractor.handleError(res))
   }
 
-  updateVideo(video: Video) {
-    const language = video.language ? video.language : null;
+  updateVideo (video: Video) {
+    const language = video.language ? video.language : null
 
     const body = {
       name: video.name,
@@ -90,94 +90,94 @@ export class VideoService {
       language,
       description: video.description,
       tags: video.tags
-    };
+    }
 
-    const headers = new Headers({ 'Content-Type': 'application/json' });
-    const options = new RequestOptions({ headers: headers });
+    const headers = new Headers({ 'Content-Type': 'application/json' })
+    const options = new RequestOptions({ headers: headers })
 
     return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${video.id}`, body, options)
                         .map(this.restExtractor.extractDataBool)
-                        .catch(this.restExtractor.handleError);
+                        .catch(this.restExtractor.handleError)
   }
 
-  getVideos(pagination: RestPagination, sort: SortField) {
-    const params = this.restService.buildRestGetParams(pagination, sort);
+  getVideos (pagination: RestPagination, sort: SortField) {
+    const params = this.restService.buildRestGetParams(pagination, sort)
 
     return this.http.get(VideoService.BASE_VIDEO_URL, { search: params })
                     .map(res => res.json())
                     .map(this.extractVideos)
-                    .catch((res) => this.restExtractor.handleError(res));
+                    .catch((res) => this.restExtractor.handleError(res))
   }
 
-  removeVideo(id: string) {
+  removeVideo (id: string) {
     return this.authHttp.delete(VideoService.BASE_VIDEO_URL + id)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  searchVideos(search: Search, pagination: RestPagination, sort: SortField) {
-    const params = this.restService.buildRestGetParams(pagination, sort);
+  searchVideos (search: Search, pagination: RestPagination, sort: SortField) {
+    const params = this.restService.buildRestGetParams(pagination, sort)
 
-    if (search.field) params.set('field', search.field);
+    if (search.field) params.set('field', search.field)
 
     return this.http.get(VideoService.BASE_VIDEO_URL + 'search/' + encodeURIComponent(search.value), { search: params })
                     .map(this.restExtractor.extractDataList)
                     .map(this.extractVideos)
-                    .catch((res) => this.restExtractor.handleError(res));
+                    .catch((res) => this.restExtractor.handleError(res))
   }
 
-  reportVideo(id: string, reason: string) {
-    const url = VideoService.BASE_VIDEO_URL + id + '/abuse';
+  reportVideo (id: string, reason: string) {
+    const url = VideoService.BASE_VIDEO_URL + id + '/abuse'
     const body = {
       reason
-    };
+    }
 
     return this.authHttp.post(url, body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  setVideoLike(id: string) {
-    return this.setVideoRate(id, 'like');
+  setVideoLike (id: string) {
+    return this.setVideoRate(id, 'like')
   }
 
-  setVideoDislike(id: string) {
-    return this.setVideoRate(id, 'dislike');
+  setVideoDislike (id: string) {
+    return this.setVideoRate(id, 'dislike')
   }
 
-  getUserVideoRating(id: string) {
-    const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating';
+  getUserVideoRating (id: string) {
+    const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating'
 
     return this.authHttp.get(url)
                         .map(this.restExtractor.extractDataGet)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  blacklistVideo(id: string) {
+  blacklistVideo (id: string) {
     return this.authHttp.post(VideoService.BASE_VIDEO_URL + id + '/blacklist', {})
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  private setVideoRate(id: string, rateType: RateType) {
-    const url = VideoService.BASE_VIDEO_URL + id + '/rate';
+  private setVideoRate (id: string, rateType: RateType) {
+    const url = VideoService.BASE_VIDEO_URL + id + '/rate'
     const body = {
       rating: rateType
-    };
+    }
 
     return this.authHttp.put(url, body)
                         .map(this.restExtractor.extractDataBool)
-                        .catch((res) => this.restExtractor.handleError(res));
+                        .catch((res) => this.restExtractor.handleError(res))
   }
 
-  private extractVideos(result: ResultList) {
-    const videosJson = result.data;
-    const totalVideos = result.total;
-    const videos = [];
+  private extractVideos (result: ResultList) {
+    const videosJson = result.data
+    const totalVideos = result.total
+    const videos = []
     for (const videoJson of videosJson) {
-      videos.push(new Video(videoJson));
+      videos.push(new Video(videoJson))
     }
 
-    return { videos, totalVideos };
+    return { videos, totalVideos }
   }
 }
index 5ce4fb9b1ce11b8374dccdd35c75fadff9375576..3b4a9cb87401c0baf8827d54ceab5cd170f9953b 100644 (file)
@@ -1,2 +1,2 @@
-export * from './video-add.component';
-export * from './video-update.component';
+export * from './video-add.component'
+export * from './video-update.component'
index e5eb9a9f42dfc60c11169f08222ef64f3d8c6644..0653f5ac4aff38e80470d28673f15e44b7eb870a 100644 (file)
@@ -1,11 +1,11 @@
-import { Component, ElementRef, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { Router } from '@angular/router';
+import { Component, ElementRef, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { Router } from '@angular/router'
 
-import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
-import { NotificationsService } from 'angular2-notifications';
+import { FileUploader } from 'ng2-file-upload/ng2-file-upload'
+import { NotificationsService } from 'angular2-notifications'
 
-import { AuthService } from '../../core';
+import { AuthService } from '../../core'
 import {
   FormReactive,
   VIDEO_NAME,
@@ -14,8 +14,8 @@ import {
   VIDEO_LANGUAGE,
   VIDEO_DESCRIPTION,
   VIDEO_TAGS
-} from '../../shared';
-import { VideoService } from '../shared';
+} from '../../shared'
+import { VideoService } from '../shared'
 
 @Component({
   selector: 'my-videos-add',
@@ -24,36 +24,36 @@ import { VideoService } from '../shared';
 })
 
 export class VideoAddComponent extends FormReactive implements OnInit {
-  tags: string[] = [];
-  uploader: FileUploader;
-  videoCategories = [];
-  videoLicences = [];
-  videoLanguages = [];
+  tags: string[] = []
+  uploader: FileUploader
+  videoCategories = []
+  videoLicences = []
+  videoLanguages = []
 
-  tagValidators = VIDEO_TAGS.VALIDATORS;
-  tagValidatorsMessages = VIDEO_TAGS.MESSAGES;
+  tagValidators = VIDEO_TAGS.VALIDATORS
+  tagValidatorsMessages = VIDEO_TAGS.MESSAGES
 
-  error: string = null;
-  form: FormGroup;
+  error: string = null
+  form: FormGroup
   formErrors = {
     name: '',
     category: '',
     licence: '',
     language: '',
     description: ''
-  };
+  }
   validationMessages = {
     name: VIDEO_NAME.MESSAGES,
     category: VIDEO_CATEGORY.MESSAGES,
     licence: VIDEO_LICENCE.MESSAGES,
     language: VIDEO_LANGUAGE.MESSAGES,
     description: VIDEO_DESCRIPTION.MESSAGES
-  };
+  }
 
   // Special error messages
-  fileError = '';
+  fileError = ''
 
-  constructor(
+  constructor (
     private authService: AuthService,
     private elementRef: ElementRef,
     private formBuilder: FormBuilder,
@@ -61,18 +61,18 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     private notificationsService: NotificationsService,
     private videoService: VideoService
   ) {
-    super();
+    super()
   }
 
-  get filename() {
+  get filename () {
     if (this.uploader.queue.length === 0) {
-      return null;
+      return null
     }
 
-    return this.uploader.queue[0].file.name;
+    return this.uploader.queue[0].file.name
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       name: [ '', VIDEO_NAME.VALIDATORS ],
       nsfw: [ false ],
@@ -81,115 +81,106 @@ export class VideoAddComponent extends FormReactive implements OnInit {
       language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
       description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
       tags: [ '']
-    });
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.videoCategories = this.videoService.videoCategories;
-    this.videoLicences = this.videoService.videoLicences;
-    this.videoLanguages = this.videoService.videoLanguages;
+  ngOnInit () {
+    this.videoCategories = this.videoService.videoCategories
+    this.videoLicences = this.videoService.videoLicences
+    this.videoLanguages = this.videoService.videoLanguages
 
     this.uploader = new FileUploader({
       authToken: this.authService.getRequestHeaderValue(),
       queueLimit: 1,
       url: API_URL + '/api/v1/videos',
       removeAfterUpload: true
-    });
+    })
 
     this.uploader.onBuildItemForm = (item, form) => {
-      const name = this.form.value['name'];
-      const nsfw = this.form.value['nsfw'];
-      const category = this.form.value['category'];
-      const licence = this.form.value['licence'];
-      const language = this.form.value['language'];
-      const description = this.form.value['description'];
-      const tags = this.form.value['tags'];
-
-      form.append('name', name);
-      form.append('category', category);
-      form.append('nsfw', nsfw);
-      form.append('licence', licence);
+      const name = this.form.value['name']
+      const nsfw = this.form.value['nsfw']
+      const category = this.form.value['category']
+      const licence = this.form.value['licence']
+      const language = this.form.value['language']
+      const description = this.form.value['description']
+      const tags = this.form.value['tags']
+
+      form.append('name', name)
+      form.append('category', category)
+      form.append('nsfw', nsfw)
+      form.append('licence', licence)
 
       // Language is optional
       if (language) {
-        form.append('language', language);
+        form.append('language', language)
       }
 
-      form.append('description', description);
+      form.append('description', description)
 
       for (let i = 0; i < tags.length; i++) {
-        form.append(`tags[${i}]`, tags[i]);
+        form.append(`tags[${i}]`, tags[i])
       }
-    };
+    }
 
-    this.buildForm();
+    this.buildForm()
   }
 
-  checkForm() {
-    this.forceCheck();
+  checkForm () {
+    this.forceCheck()
 
     if (this.filename === null) {
-      this.fileError = 'You did not add a file.';
+      this.fileError = 'You did not add a file.'
     }
 
-    return this.form.valid === true && this.fileError === '';
+    return this.form.valid === true && this.fileError === ''
   }
 
-  fileChanged() {
-    this.fileError = '';
+  fileChanged () {
+    this.fileError = ''
   }
 
-  removeFile() {
-    this.uploader.clearQueue();
+  removeFile () {
+    this.uploader.clearQueue()
   }
 
-  upload() {
+  upload () {
     if (this.checkForm() === false) {
-      return;
+      return
     }
 
-    const item = this.uploader.queue[0];
+    const item = this.uploader.queue[0]
     // TODO: wait for https://github.com/valor-software/ng2-file-upload/pull/242
-    item.alias = 'videofile';
-
-    // FIXME: remove
-    // Run detection change for progress bar
-    const interval = setInterval(() => { ; }, 250);
+    item.alias = 'videofile'
 
     item.onSuccess = () => {
-      clearInterval(interval);
-
-      console.log('Video uploaded.');
-      this.notificationsService.success('Success', 'Video uploaded.');
-
+      console.log('Video uploaded.')
+      this.notificationsService.success('Success', 'Video uploaded.')
 
       // Print all the videos once it's finished
-      this.router.navigate(['/videos/list']);
-    };
+      this.router.navigate(['/videos/list'])
+    }
 
     item.onError = (response: string, status: number) => {
-      clearInterval(interval);
-
       // We need to handle manually these cases beceause we use the FileUpload component
       if (status === 400) {
-        this.error = response;
+        this.error = response
       } else if (status === 401) {
-        this.error = 'Access token was expired, refreshing token...';
+        this.error = 'Access token was expired, refreshing token...'
         this.authService.refreshAccessToken().subscribe(
           () => {
             // Update the uploader request header
-            this.uploader.authToken = this.authService.getRequestHeaderValue();
-            this.error += ' access token refreshed. Please retry your request.';
+            this.uploader.authToken = this.authService.getRequestHeaderValue()
+            this.error += ' access token refreshed. Please retry your request.'
           }
-        );
+        )
       } else {
-        this.error = 'Unknow error';
-        console.error(this.error);
+        this.error = 'Unknow error'
+        console.error(this.error)
       }
-    };
+    }
 
-    this.uploader.uploadAll();
+    this.uploader.uploadAll()
   }
 }
index 933132cc0643077de1b8573fb882de6001f72a51..9ee7ca6a8cb81b0df17ee4125c36c046a90929c9 100644 (file)
@@ -1,11 +1,11 @@
-import { Component, ElementRef, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { ActivatedRoute, Router } from '@angular/router';
+import { Component, ElementRef, OnInit } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
+import { ActivatedRoute, Router } from '@angular/router'
 
-import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
-import { NotificationsService } from 'angular2-notifications';
+import { FileUploader } from 'ng2-file-upload/ng2-file-upload'
+import { NotificationsService } from 'angular2-notifications'
 
-import { AuthService } from '../../core';
+import { AuthService } from '../../core'
 import {
   FormReactive,
   VIDEO_NAME,
@@ -14,8 +14,8 @@ import {
   VIDEO_LANGUAGE,
   VIDEO_DESCRIPTION,
   VIDEO_TAGS
-} from '../../shared';
-import { Video, VideoService } from '../shared';
+} from '../../shared'
+import { Video, VideoService } from '../shared'
 
 @Component({
   selector: 'my-videos-update',
@@ -24,35 +24,35 @@ import { Video, VideoService } from '../shared';
 })
 
 export class VideoUpdateComponent extends FormReactive implements OnInit {
-  tags: string[] = [];
-  videoCategories = [];
-  videoLicences = [];
-  videoLanguages = [];
-  video: Video;
+  tags: string[] = []
+  videoCategories = []
+  videoLicences = []
+  videoLanguages = []
+  video: Video
 
-  tagValidators = VIDEO_TAGS.VALIDATORS;
-  tagValidatorsMessages = VIDEO_TAGS.MESSAGES;
+  tagValidators = VIDEO_TAGS.VALIDATORS
+  tagValidatorsMessages = VIDEO_TAGS.MESSAGES
 
-  error: string = null;
-  form: FormGroup;
+  error: string = null
+  form: FormGroup
   formErrors = {
     name: '',
     category: '',
     licence: '',
     language: '',
     description: ''
-  };
+  }
   validationMessages = {
     name: VIDEO_NAME.MESSAGES,
     category: VIDEO_CATEGORY.MESSAGES,
     licence: VIDEO_LICENCE.MESSAGES,
     language: VIDEO_LANGUAGE.MESSAGES,
     description: VIDEO_DESCRIPTION.MESSAGES
-  };
+  }
 
-  fileError = '';
+  fileError = ''
 
-  constructor(
+  constructor (
     private authService: AuthService,
     private elementRef: ElementRef,
     private formBuilder: FormBuilder,
@@ -61,10 +61,10 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
     private notificationsService: NotificationsService,
     private videoService: VideoService
   ) {
-    super();
+    super()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       name: [ '', VIDEO_NAME.VALIDATORS ],
       nsfw: [ false ],
@@ -73,60 +73,63 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
       language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
       description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
       tags: [ '' ]
-    });
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
 
-    this.videoCategories = this.videoService.videoCategories;
-    this.videoLicences = this.videoService.videoLicences;
-    this.videoLanguages = this.videoService.videoLanguages;
+    this.videoCategories = this.videoService.videoCategories
+    this.videoLicences = this.videoService.videoLicences
+    this.videoLanguages = this.videoService.videoLanguages
 
-    const id = this.route.snapshot.params['id'];
+    const id = this.route.snapshot.params['id']
     this.videoService.getVideo(id)
                      .subscribe(
                        video => {
-                         this.video = video;
+                         this.video = video
 
-                         this.hydrateFormFromVideo();
+                         this.hydrateFormFromVideo()
                        },
 
-                       err => this.error = 'Cannot fetch video.'
-                     );
+                       err => {
+                         console.error(err)
+                         this.error = 'Cannot fetch video.'
+                       }
+                     )
   }
 
-  checkForm() {
-    this.forceCheck();
+  checkForm () {
+    this.forceCheck()
 
-    return this.form.valid;
+    return this.form.valid
   }
 
-  update() {
+  update () {
     if (this.checkForm() === false) {
-      return;
+      return
     }
 
-    this.video.patch(this.form.value);
+    this.video.patch(this.form.value)
 
     this.videoService.updateVideo(this.video)
                      .subscribe(
                        () => {
-                         this.notificationsService.success('Success', 'Video updated.');
-                         this.router.navigate([ '/videos/watch', this.video.id ]);
+                         this.notificationsService.success('Success', 'Video updated.')
+                         this.router.navigate([ '/videos/watch', this.video.id ])
                        },
 
                        err => {
-                         this.error = 'Cannot update the video.';
-                         console.error(err);
+                         this.error = 'Cannot update the video.'
+                         console.error(err)
                        }
-                      );
+                      )
 
   }
 
-  private hydrateFormFromVideo() {
-    this.form.patchValue(this.video.toJSON());
+  private hydrateFormFromVideo () {
+    this.form.patchValue(this.video.toJSON())
   }
 }
index 71d3b78e6cc6c25a01680e0b3e1f67756bd722c0..a490e6bb56819a8157ee08cb7de74f69f4b56f39 100644 (file)
@@ -1,4 +1,4 @@
-export * from './loader.component';
-export * from './video-list.component';
-export * from './video-miniature.component';
-export * from './video-sort.component';
+export * from './loader.component'
+export * from './video-list.component'
+export * from './video-miniature.component'
+export * from './video-sort.component'
index e72d2f3f3d605bd0d5f0fcdb87f3a41e976229f9..e5780e0fa2ba782f19b940d2112de21b4b4e4859 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, Input } from '@angular/core';
+import { Component, Input } from '@angular/core'
 
 @Component({
   selector: 'my-loader',
@@ -7,5 +7,5 @@ import { Component, Input } from '@angular/core';
 })
 
 export class LoaderComponent {
-  @Input() loading: boolean;
+  @Input() loading: boolean
 }
index f805922798292249a6def1a485f39d89828ce8e5..680fba3f5ae7b8098547e77bba9288e7719a1d9d 100644 (file)
@@ -17,7 +17,7 @@
 
   <my-video-miniature
     class="ng-animate"
-    *ngFor="let video of videos" [video]="video" [user]="user" [currentSort]="sort" (removed)="onRemoved(video)"
+    *ngFor="let video of videos" [video]="video" [user]="user" [currentSort]="sort"
   >
   </my-video-miniature>
 </div>
index 16a40bdc4fa9812de7ab22ea2b723e6399ebad1e..0c36e5b0893cbf0784572097818044d26bb11db9 100644 (file)
@@ -1,17 +1,17 @@
-import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
-import { BehaviorSubject } from 'rxjs/BehaviorSubject';
+import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'
+import { ActivatedRoute, Router } from '@angular/router'
+import { BehaviorSubject } from 'rxjs/BehaviorSubject'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
 import {
   SortField,
   Video,
   VideoService
-} from '../shared';
-import { AuthService, AuthUser } from '../../core';
-import { RestPagination, Search, SearchField } from '../../shared';
-import { SearchService } from '../../shared';
+} from '../shared'
+import { AuthService, AuthUser } from '../../core'
+import { RestPagination, Search, SearchField } from '../../shared'
+import { SearchService } from '../../shared'
 
 @Component({
   selector: 'my-videos-list',
@@ -19,21 +19,21 @@ import { SearchService } from '../../shared';
   templateUrl: './video-list.component.html'
 })
 export class VideoListComponent implements OnInit, OnDestroy {
-  loading: BehaviorSubject<boolean> = new BehaviorSubject(false);
+  loading: BehaviorSubject<boolean> = new BehaviorSubject(false)
   pagination: RestPagination = {
     currentPage: 1,
     itemsPerPage: 25,
     totalItems: null
-  };
-  sort: SortField;
-  user: AuthUser = null;
-  videos: Video[] = [];
+  }
+  sort: SortField
+  user: AuthUser = null
+  videos: Video[] = []
 
-  private search: Search;
-  private subActivatedRoute: any;
-  private subSearch: any;
+  private search: Search
+  private subActivatedRoute: any
+  private subSearch: any
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private authService: AuthService,
     private changeDetector: ChangeDetectorRef,
@@ -43,114 +43,114 @@ export class VideoListComponent implements OnInit, OnDestroy {
     private searchService: SearchService
   ) {}
 
-  ngOnInit() {
+  ngOnInit () {
     if (this.authService.isLoggedIn()) {
-      this.user = AuthUser.load();
+      this.user = AuthUser.load()
     }
 
     // Subscribe to route changes
     this.subActivatedRoute = this.route.params.subscribe(routeParams => {
-      this.loadRouteParams(routeParams);
+      this.loadRouteParams(routeParams)
 
       // Update the search service component
-      this.searchService.updateSearch.next(this.search);
-      this.getVideos();
-    });
+      this.searchService.updateSearch.next(this.search)
+      this.getVideos()
+    })
 
     // Subscribe to search changes
     this.subSearch = this.searchService.searchUpdated.subscribe(search => {
-      this.search = search;
+      this.search = search
       // Reset pagination
-      this.pagination.currentPage = 1;
+      this.pagination.currentPage = 1
 
-      this.navigateToNewParams();
-    });
+      this.navigateToNewParams()
+    })
   }
 
-  ngOnDestroy() {
-    this.subActivatedRoute.unsubscribe();
-    this.subSearch.unsubscribe();
+  ngOnDestroy () {
+    this.subActivatedRoute.unsubscribe()
+    this.subSearch.unsubscribe()
   }
 
-  getVideos() {
-    this.loading.next(true);
-    this.videos = [];
+  getVideos () {
+    this.loading.next(true)
+    this.videos = []
 
-    let observable = null;
+    let observable = null
     if (this.search.value) {
-      observable = this.videoService.searchVideos(this.search, this.pagination, this.sort);
+      observable = this.videoService.searchVideos(this.search, this.pagination, this.sort)
     } else {
-      observable = this.videoService.getVideos(this.pagination, this.sort);
+      observable = this.videoService.getVideos(this.pagination, this.sort)
     }
 
     observable.subscribe(
       ({ videos, totalVideos }) => {
-        this.videos = videos;
-        this.pagination.totalItems = totalVideos;
+        this.videos = videos
+        this.pagination.totalItems = totalVideos
 
-        this.loading.next(false);
+        this.loading.next(false)
       },
       error => this.notificationsService.error('Error', error.text)
-    );
+    )
   }
 
-  isThereNoVideo() {
-    return !this.loading.getValue() && this.videos.length === 0;
+  isThereNoVideo () {
+    return !this.loading.getValue() && this.videos.length === 0
   }
 
-  onPageChanged(event: any) {
+  onPageChanged (event: any) {
     // Be sure the current page is set
-    this.pagination.currentPage = event.page;
+    this.pagination.currentPage = event.page
 
-    this.navigateToNewParams();
+    this.navigateToNewParams()
   }
 
-  onSort(sort: SortField) {
-    this.sort = sort;
+  onSort (sort: SortField) {
+    this.sort = sort
 
-    this.navigateToNewParams();
+    this.navigateToNewParams()
   }
 
-  private buildRouteParams() {
+  private buildRouteParams () {
     // There is always a sort and a current page
     const params: any = {
       sort: this.sort,
       page: this.pagination.currentPage
-    };
+    }
 
     // Maybe there is a search
     if (this.search.value) {
-      params.field = this.search.field;
-      params.search = this.search.value;
+      params.field = this.search.field
+      params.search = this.search.value
     }
 
-    return params;
+    return params
   }
 
-  private loadRouteParams(routeParams) {
+  private loadRouteParams (routeParams) {
     if (routeParams['search'] !== undefined) {
       this.search = {
         value: routeParams['search'],
-        field: <SearchField>routeParams['field']
-      };
+        field: routeParams['field'] as SearchField
+      }
     } else {
       this.search = {
         value: '',
         field: 'name'
-      };
+      }
     }
 
-    this.sort = <SortField>routeParams['sort'] || '-createdAt';
+    this.sort = routeParams['sort'] as SortField || '-createdAt'
 
     if (routeParams['page'] !== undefined) {
-      this.pagination.currentPage = parseInt(routeParams['page']);
+      this.pagination.currentPage = parseInt(routeParams['page'], 10)
     } else {
-      this.pagination.currentPage = 1;
+      this.pagination.currentPage = 1
     }
   }
 
-  private navigateToNewParams() {
-    const routeParams = this.buildRouteParams();
-    this.router.navigate(['/videos/list', routeParams]);
+  private navigateToNewParams () {
+    const routeParams = this.buildRouteParams()
+    this.router.navigate(['/videos/list', routeParams])
   }
 }
index 28601ca7f06b10baa9ba96bea1b70cbdb9b74815..1cfeacf36192c4e82ca1a7d28b77e06251485b60 100644 (file)
@@ -1,10 +1,10 @@
-import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { Component, Input, Output, EventEmitter } from '@angular/core'
 
-import { NotificationsService } from 'angular2-notifications';
+import { NotificationsService } from 'angular2-notifications'
 
-import { ConfirmService, ConfigService } from '../../core';
-import { SortField, Video, VideoService } from '../shared';
-import { User } from '../../shared';
+import { ConfirmService, ConfigService } from '../../core'
+import { SortField, Video, VideoService } from '../shared'
+import { User } from '../../shared'
 
 @Component({
   selector: 'my-video-miniature',
@@ -13,25 +13,26 @@ import { User } from '../../shared';
 })
 
 export class VideoMiniatureComponent {
-  @Input() currentSort: SortField;
-  @Input() user: User;
-  @Input() video: Video;
+  @Input() currentSort: SortField
+  @Input() user: User
+  @Input() video: Video
 
-  constructor(
+  constructor (
     private notificationsService: NotificationsService,
     private confirmService: ConfirmService,
     private configService: ConfigService,
     private videoService: VideoService
   ) {}
 
-  getVideoName() {
-    if (this.isVideoNSFWForThisUser())
-      return 'NSFW';
+  getVideoName () {
+    if (this.isVideoNSFWForThisUser()) {
+      return 'NSFW'
+    }
 
-    return this.video.name;
+    return this.video.name
   }
 
-  isVideoNSFWForThisUser() {
-    return this.video.isVideoNSFWForUser(this.user);
+  isVideoNSFWForThisUser () {
+    return this.video.isVideoNSFWForUser(this.user)
   }
 }
index 20979a3950ede88993ee7e54c8e0629d5d31bbe4..64916bf1668e5c00217de70e5344612064da22a3 100644 (file)
@@ -1,6 +1,6 @@
-import { Component, EventEmitter, Input, Output } from '@angular/core';
+import { Component, EventEmitter, Input, Output } from '@angular/core'
 
-import { SortField } from '../shared';
+import { SortField } from '../shared'
 
 @Component({
   selector: 'my-video-sort',
@@ -8,9 +8,9 @@ import { SortField } from '../shared';
 })
 
 export class VideoSortComponent {
-  @Output() sort = new EventEmitter<any>();
+  @Output() sort = new EventEmitter<any>()
 
-  @Input() currentSort: SortField;
+  @Input() currentSort: SortField
 
   sortChoices: { [ P in SortField ]: string } = {
     'name': 'Name - Asc',
@@ -23,17 +23,17 @@ export class VideoSortComponent {
     '-views': 'Views - Desc',
     'likes': 'Likes - Asc',
     '-likes': 'Likes - Desc'
-  };
+  }
 
-  get choiceKeys() {
-    return Object.keys(this.sortChoices);
+  get choiceKeys () {
+    return Object.keys(this.sortChoices)
   }
 
-  getStringChoice(choiceKey: SortField) {
-    return this.sortChoices[choiceKey];
+  getStringChoice (choiceKey: SortField) {
+    return this.sortChoices[choiceKey]
   }
 
-  onSortChange() {
-    this.sort.emit(this.currentSort);
+  onSortChange () {
+    this.sort.emit(this.currentSort)
   }
 }
index ed0ed2fc03e4e448122e17dd9d116c366294c916..6e35262d309a91b9196ca94853fe63d32526b185 100644 (file)
@@ -1,5 +1,5 @@
-export * from './video-magnet.component';
-export * from './video-share.component';
-export * from './video-report.component';
-export * from './video-watch.component';
-export * from './webtorrent.service';
+export * from './video-magnet.component'
+export * from './video-share.component'
+export * from './video-report.component'
+export * from './video-watch.component'
+export * from './webtorrent.service'
index 894fa45fc43715b79eb4923df736eb390a69693b..f9432e92cccaffc9049c814a103fa8ebb25d836a 100644 (file)
@@ -1,27 +1,27 @@
-import { Component, Input, ViewChild } from '@angular/core';
+import { Component, Input, ViewChild } from '@angular/core'
 
-import { ModalDirective } from 'ngx-bootstrap/modal';
+import { ModalDirective } from 'ngx-bootstrap/modal'
 
-import { Video } from '../shared';
+import { Video } from '../shared'
 
 @Component({
   selector: 'my-video-magnet',
   templateUrl: './video-magnet.component.html'
 })
 export class VideoMagnetComponent {
-  @Input() video: Video = null;
+  @Input() video: Video = null
 
-  @ViewChild('modal') modal: ModalDirective;
+  @ViewChild('modal') modal: ModalDirective
 
-  constructor() {
+  constructor () {
     // empty
   }
 
-  show() {
-    this.modal.show();
+  show () {
+    this.modal.show()
   }
 
-  hide() {
-    this.modal.hide();
+  hide () {
+    this.modal.hide()
   }
 }
index 528005b84126428e46095264ff552042aa94c7e9..61213cd684dab17ab40123c1619f513741e636ec 100644 (file)
@@ -1,69 +1,69 @@
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
-import { FormBuilder, FormGroup } from '@angular/forms';
+import { Component, Input, OnInit, ViewChild } from '@angular/core'
+import { FormBuilder, FormGroup } from '@angular/forms'
 
-import { ModalDirective } from 'ngx-bootstrap/modal';
-import { NotificationsService } from 'angular2-notifications';
+import { ModalDirective } from 'ngx-bootstrap/modal'
+import { NotificationsService } from 'angular2-notifications'
 
-import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared';
-import { Video, VideoService } from '../shared';
+import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared'
+import { Video, VideoService } from '../shared'
 
 @Component({
   selector: 'my-video-report',
   templateUrl: './video-report.component.html'
 })
 export class VideoReportComponent extends FormReactive implements OnInit {
-  @Input() video: Video = null;
+  @Input() video: Video = null
 
-  @ViewChild('modal') modal: ModalDirective;
+  @ViewChild('modal') modal: ModalDirective
 
-  error: string = null;
-  form: FormGroup;
+  error: string = null
+  form: FormGroup
   formErrors = {
     reason: ''
-  };
+  }
   validationMessages = {
     reason: VIDEO_ABUSE_REASON.MESSAGES
-  };
+  }
 
-  constructor(
+  constructor (
     private formBuilder: FormBuilder,
     private videoAbuseService: VideoAbuseService,
     private notificationsService: NotificationsService
    ) {
-    super();
+    super()
   }
 
-  ngOnInit() {
-    this.buildForm();
+  ngOnInit () {
+    this.buildForm()
   }
 
-  buildForm() {
+  buildForm () {
     this.form = this.formBuilder.group({
       reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
-    });
+    })
 
-    this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+    this.form.valueChanges.subscribe(data => this.onValueChanged(data))
   }
 
-  show() {
-    this.modal.show();
+  show () {
+    this.modal.show()
   }
 
-  hide() {
-    this.modal.hide();
+  hide () {
+    this.modal.hide()
   }
 
-  report() {
-    const reason = this.form.value['reason'];
+  report () {
+    const reason = this.form.value['reason']
 
     this.videoAbuseService.reportVideo(this.video.id, reason)
                           .subscribe(
                             () => {
-                              this.notificationsService.success('Success', 'Video reported.');
-                              this.hide();
+                              this.notificationsService.success('Success', 'Video reported.')
+                              this.hide()
                             },
 
                             err => this.notificationsService.error('Error', err.text)
-                           );
+                           )
   }
 }
index aa921afc2c2048004a275d867c91c5d3e95e35cf..bbd25f5ef0e8963a8fe093f3339d1caebe742342 100644 (file)
@@ -1,42 +1,42 @@
-import { Component, Input, ViewChild } from '@angular/core';
+import { Component, Input, ViewChild } from '@angular/core'
 
-import { ModalDirective } from 'ngx-bootstrap/modal';
+import { ModalDirective } from 'ngx-bootstrap/modal'
 
-import { Video } from '../shared';
+import { Video } from '../shared'
 
 @Component({
   selector: 'my-video-share',
   templateUrl: './video-share.component.html'
 })
 export class VideoShareComponent {
-  @Input() video: Video = null;
+  @Input() video: Video = null
 
-  @ViewChild('modal') modal: ModalDirective;
+  @ViewChild('modal') modal: ModalDirective
 
-  constructor() {
+  constructor () {
     // empty
   }
 
-  show() {
-    this.modal.show();
+  show () {
+    this.modal.show()
   }
 
-  hide() {
-    this.modal.hide();
+  hide () {
+    this.modal.hide()
   }
 
-  getVideoIframeCode() {
+  getVideoIframeCode () {
     return '<iframe width="560" height="315" ' +
            'src="' + window.location.origin + '/videos/embed/' + this.video.id + '" ' +
            'frameborder="0" allowfullscreen>' +
-           '</iframe>';
+           '</iframe>'
   }
 
-  getVideoUrl() {
-    return window.location.href;
+  getVideoUrl () {
+    return window.location.href
   }
 
-  notSecure() {
-    return window.location.protocol === 'http:';
+  notSecure () {
+    return window.location.protocol === 'http:'
   }
 }
index bcfebf2fd12549468b5782960eb5c902de5efa88..4a547f7e480a6fa2ef445f0c6fba3db0a0cd0c87 100644 (file)
@@ -1,18 +1,18 @@
-import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
-import { Observable } from 'rxjs/Observable';
-import { Subscription } from 'rxjs/Subscription';
-
-import * as videojs from 'video.js';
-import { MetaService } from '@nglibs/meta';
-import { NotificationsService } from 'angular2-notifications';
-
-import { AuthService, ConfirmService } from '../../core';
-import { VideoMagnetComponent } from './video-magnet.component';
-import { VideoShareComponent } from './video-share.component';
-import { VideoReportComponent } from './video-report.component';
-import { RateType, Video, VideoService } from '../shared';
-import { WebTorrentService } from './webtorrent.service';
+import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
+import { ActivatedRoute, Router } from '@angular/router'
+import { Observable } from 'rxjs/Observable'
+import { Subscription } from 'rxjs/Subscription'
+
+import * as videojs from 'video.js'
+import { MetaService } from '@nglibs/meta'
+import { NotificationsService } from 'angular2-notifications'
+
+import { AuthService, ConfirmService } from '../../core'
+import { VideoMagnetComponent } from './video-magnet.component'
+import { VideoShareComponent } from './video-share.component'
+import { VideoReportComponent } from './video-report.component'
+import { RateType, Video, VideoService } from '../shared'
+import { WebTorrentService } from './webtorrent.service'
 
 @Component({
   selector: 'my-video-watch',
@@ -21,30 +21,30 @@ import { WebTorrentService } from './webtorrent.service';
 })
 
 export class VideoWatchComponent implements OnInit, OnDestroy {
-  private static LOADTIME_TOO_LONG = 20000;
-
-  @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent;
-  @ViewChild('videoShareModal') videoShareModal: VideoShareComponent;
-  @ViewChild('videoReportModal') videoReportModal: VideoReportComponent;
-
-  downloadSpeed: number;
-  error = false;
-  loading = false;
-  numPeers: number;
-  player: videojs.Player;
-  playerElement: Element;
-  uploadSpeed: number;
-  userRating: RateType = null;
-  video: Video = null;
-  videoNotFound = false;
-
-  private errorTimer: number;
-  private paramsSub: Subscription;
-  private errorsSub: Subscription;
-  private warningsSub: Subscription;
-  private torrentInfosInterval: number;
-
-  constructor(
+  private static LOADTIME_TOO_LONG = 20000
+
+  @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent
+  @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
+  @ViewChild('videoReportModal') videoReportModal: VideoReportComponent
+
+  downloadSpeed: number
+  error = false
+  loading = false
+  numPeers: number
+  player: videojs.Player
+  playerElement: Element
+  uploadSpeed: number
+  userRating: RateType = null
+  video: Video = null
+  videoNotFound = false
+
+  private errorTimer: number
+  private paramsSub: Subscription
+  private errorsSub: Subscription
+  private warningsSub: Subscription
+  private torrentInfosInterval: number
+
+  constructor (
     private elementRef: ElementRef,
     private ngZone: NgZone,
     private route: ActivatedRoute,
@@ -57,278 +57,281 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     private notificationsService: NotificationsService
   ) {}
 
-  ngOnInit() {
+  ngOnInit () {
     this.paramsSub = this.route.params.subscribe(routeParams => {
-      let id = routeParams['id'];
+      let id = routeParams['id']
       this.videoService.getVideo(id).subscribe(
         video => this.onVideoFetched(video),
 
-        error => this.videoNotFound = true
-      );
-    });
+        error => {
+          console.error(error)
+          this.videoNotFound = true
+        }
+      )
+    })
 
-    this.playerElement = this.elementRef.nativeElement.querySelector('#video-container');
+    this.playerElement = this.elementRef.nativeElement.querySelector('#video-container')
 
     const videojsOptions = {
       controls: true,
       autoplay: false
-    };
+    }
 
-    const self = this;
+    const self = this
     videojs(this.playerElement, videojsOptions, function () {
-      self.player = this;
-    });
+      self.player = this
+    })
 
-    this.errorsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.error('Error', err.message));
-    this.warningsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.alert('Warning', err.message));
+    this.errorsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.error('Error', err.message))
+    this.warningsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.alert('Warning', err.message))
   }
 
-  ngOnDestroy() {
+  ngOnDestroy () {
     // Remove WebTorrent stuff
-    console.log('Removing video from webtorrent.');
-    window.clearInterval(this.torrentInfosInterval);
-    window.clearTimeout(this.errorTimer);
+    console.log('Removing video from webtorrent.')
+    window.clearInterval(this.torrentInfosInterval)
+    window.clearTimeout(this.errorTimer)
 
     if (this.video !== null && this.webTorrentService.has(this.video.magnetUri)) {
-      this.webTorrentService.remove(this.video.magnetUri);
+      this.webTorrentService.remove(this.video.magnetUri)
     }
 
     // Remove player
-    videojs(this.playerElement).dispose();
+    videojs(this.playerElement).dispose()
 
     // Unsubscribe subscriptions
-    this.paramsSub.unsubscribe();
-    this.errorsSub.unsubscribe();
-    this.warningsSub.unsubscribe();
+    this.paramsSub.unsubscribe()
+    this.errorsSub.unsubscribe()
+    this.warningsSub.unsubscribe()
   }
 
-  loadVideo() {
+  loadVideo () {
     // Reset the error
-    this.error = false;
+    this.error = false
     // We are loading the video
-    this.loading = true;
+    this.loading = true
 
-    console.log('Adding ' + this.video.magnetUri + '.');
+    console.log('Adding ' + this.video.magnetUri + '.')
 
     // The callback might never return if there are network issues
     // So we create a timer to inform the user the load is abnormally long
-    this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG);
+    this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG)
 
     this.webTorrentService.add(this.video.magnetUri, (torrent) => {
       // Clear the error timer
-      window.clearTimeout(this.errorTimer);
+      window.clearTimeout(this.errorTimer)
       // Maybe the error was fired by the timer, so reset it
-      this.error = false;
+      this.error = false
 
       // We are not loading the video anymore
-      this.loading = false;
+      this.loading = false
 
-      console.log('Added ' + this.video.magnetUri + '.');
+      console.log('Added ' + this.video.magnetUri + '.')
       torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => {
         if (err) {
-          this.notificationsService.error('Error', 'Cannot append the file in the video element.');
-          console.error(err);
+          this.notificationsService.error('Error', 'Cannot append the file in the video element.')
+          console.error(err)
         }
-      });
+      })
 
-      this.runInProgress(torrent);
-    });
+      this.runInProgress(torrent)
+    })
   }
 
-  setLike() {
-    if (this.isUserLoggedIn() === false) return;
+  setLike () {
+    if (this.isUserLoggedIn() === false) return
     // Already liked this video
-    if (this.userRating === 'like') return;
+    if (this.userRating === 'like') return
 
     this.videoService.setVideoLike(this.video.id)
                      .subscribe(
                       () => {
                         // Update the video like attribute
-                        this.updateVideoRating(this.userRating, 'like');
-                        this.userRating = 'like';
+                        this.updateVideoRating(this.userRating, 'like')
+                        this.userRating = 'like'
                       },
 
                       err => this.notificationsService.error('Error', err.text)
-                     );
+                     )
   }
 
-  setDislike() {
-    if (this.isUserLoggedIn() === false) return;
+  setDislike () {
+    if (this.isUserLoggedIn() === false) return
     // Already disliked this video
-    if (this.userRating === 'dislike') return;
+    if (this.userRating === 'dislike') return
 
     this.videoService.setVideoDislike(this.video.id)
                      .subscribe(
                       () => {
                         // Update the video dislike attribute
-                        this.updateVideoRating(this.userRating, 'dislike');
-                        this.userRating = 'dislike';
+                        this.updateVideoRating(this.userRating, 'dislike')
+                        this.userRating = 'dislike'
                       },
 
                       err => this.notificationsService.error('Error', err.text)
-                     );
+                     )
   }
 
-  removeVideo(event: Event) {
-    event.preventDefault();
+  removeVideo (event: Event) {
+    event.preventDefault()
 
     this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
       res => {
-        if (res === false) return;
+        if (res === false) return
 
         this.videoService.removeVideo(this.video.id)
                          .subscribe(
                            status => {
-                             this.notificationsService.success('Success', `Video ${this.video.name} deleted.`);
+                             this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
                              // Go back to the video-list.
-                             this.router.navigate(['/videos/list']);
+                             this.router.navigate(['/videos/list'])
                            },
 
                            error => this.notificationsService.error('Error', error.text)
-                          );
+                          )
       }
-    );
+    )
   }
 
-  blacklistVideo(event: Event) {
-    event.preventDefault();
+  blacklistVideo (event: Event) {
+    event.preventDefault()
 
     this.confirmService.confirm('Do you really want to blacklist this video ?', 'Blacklist').subscribe(
       res => {
-        if (res === false) return;
+        if (res === false) return
 
         this.videoService.blacklistVideo(this.video.id)
                          .subscribe(
                            status => {
-                             this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`);
-                             this.router.navigate(['/videos/list']);
+                             this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`)
+                             this.router.navigate(['/videos/list'])
                            },
 
                            error => this.notificationsService.error('Error', error.text)
-                         );
+                         )
       }
-    );
+    )
   }
 
-  showReportModal(event: Event) {
-    event.preventDefault();
-    this.videoReportModal.show();
+  showReportModal (event: Event) {
+    event.preventDefault()
+    this.videoReportModal.show()
   }
 
-  showShareModal() {
-    this.videoShareModal.show();
+  showShareModal () {
+    this.videoShareModal.show()
   }
 
-  showMagnetUriModal(event: Event) {
-    event.preventDefault();
-    this.videoMagnetModal.show();
+  showMagnetUriModal (event: Event) {
+    event.preventDefault()
+    this.videoMagnetModal.show()
   }
 
-  isUserLoggedIn() {
-    return this.authService.isLoggedIn();
+  isUserLoggedIn () {
+    return this.authService.isLoggedIn()
   }
 
-  canUserUpdateVideo() {
-    return this.video.isUpdatableBy(this.authService.getUser());
+  canUserUpdateVideo () {
+    return this.video.isUpdatableBy(this.authService.getUser())
   }
 
-  isVideoRemovable() {
-    return this.video.isRemovableBy(this.authService.getUser());
+  isVideoRemovable () {
+    return this.video.isRemovableBy(this.authService.getUser())
   }
 
-  isVideoBlacklistable() {
-    return this.video.isBlackistableBy(this.authService.getUser());
+  isVideoBlacklistable () {
+    return this.video.isBlackistableBy(this.authService.getUser())
   }
 
-  private checkUserRating() {
+  private checkUserRating () {
     // Unlogged users do not have ratings
-    if (this.isUserLoggedIn() === false) return;
+    if (this.isUserLoggedIn() === false) return
 
     this.videoService.getUserVideoRating(this.video.id)
                      .subscribe(
                        ratingObject => {
                          if (ratingObject) {
-                           this.userRating = ratingObject.rating;
+                           this.userRating = ratingObject.rating
                          }
                        },
 
                        err => this.notificationsService.error('Error', err.text)
-                      );
+                      )
   }
 
-  private onVideoFetched(video: Video) {
-    this.video = video;
+  private onVideoFetched (video: Video) {
+    this.video = video
 
-    let observable;
+    let observable
     if (this.video.isVideoNSFWForUser(this.authService.getUser())) {
-      observable = this.confirmService.confirm('This video is not safe for work. Are you sure you want to watch it?', 'NSFW');
+      observable = this.confirmService.confirm('This video is not safe for work. Are you sure you want to watch it?', 'NSFW')
     } else {
-      observable = Observable.of(true);
+      observable = Observable.of(true)
     }
 
     observable.subscribe(
       res => {
         if (res === false) {
-          return this.router.navigate([ '/videos/list' ]);
+          return this.router.navigate([ '/videos/list' ])
         }
 
-        this.setOpenGraphTags();
-        this.loadVideo();
-        this.checkUserRating();
+        this.setOpenGraphTags()
+        this.loadVideo()
+        this.checkUserRating()
       }
-    );
+    )
   }
 
-  private updateVideoRating(oldRating: RateType, newRating: RateType) {
-    let likesToIncrement = 0;
-    let dislikesToIncrement = 0;
+  private updateVideoRating (oldRating: RateType, newRating: RateType) {
+    let likesToIncrement = 0
+    let dislikesToIncrement = 0
 
     if (oldRating) {
-      if (oldRating === 'like') likesToIncrement--;
-      if (oldRating === 'dislike') dislikesToIncrement--;
+      if (oldRating === 'like') likesToIncrement--
+      if (oldRating === 'dislike') dislikesToIncrement--
     }
 
-    if (newRating === 'like') likesToIncrement++;
-    if (newRating === 'dislike') dislikesToIncrement++;
+    if (newRating === 'like') likesToIncrement++
+    if (newRating === 'dislike') dislikesToIncrement++
 
-    this.video.likes += likesToIncrement;
-    this.video.dislikes += dislikesToIncrement;
+    this.video.likes += likesToIncrement
+    this.video.dislikes += dislikesToIncrement
   }
 
-  private loadTooLong() {
-    this.error = true;
-    console.error('The video load seems to be abnormally long.');
+  private loadTooLong () {
+    this.error = true
+    console.error('The video load seems to be abnormally long.')
   }
 
-  private setOpenGraphTags() {
-    this.metaService.setTitle(this.video.name);
+  private setOpenGraphTags () {
+    this.metaService.setTitle(this.video.name)
 
-    this.metaService.setTag('og:type', 'video');
+    this.metaService.setTag('og:type', 'video')
 
-    this.metaService.setTag('og:title', this.video.name);
-    this.metaService.setTag('name', this.video.name);
+    this.metaService.setTag('og:title', this.video.name)
+    this.metaService.setTag('name', this.video.name)
 
-    this.metaService.setTag('og:description', this.video.description);
-    this.metaService.setTag('description', this.video.description);
+    this.metaService.setTag('og:description', this.video.description)
+    this.metaService.setTag('description', this.video.description)
 
-    this.metaService.setTag('og:image', this.video.thumbnailPath);
+    this.metaService.setTag('og:image', this.video.thumbnailPath)
 
-    this.metaService.setTag('og:duration', this.video.duration.toString());
+    this.metaService.setTag('og:duration', this.video.duration.toString())
 
-    this.metaService.setTag('og:site_name', 'PeerTube');
+    this.metaService.setTag('og:site_name', 'PeerTube')
 
-    this.metaService.setTag('og:url', window.location.href);
-    this.metaService.setTag('url', window.location.href);
+    this.metaService.setTag('og:url', window.location.href)
+    this.metaService.setTag('url', window.location.href)
   }
 
-  private runInProgress(torrent: any) {
+  private runInProgress (torrent: any) {
     // Refresh each second
     this.torrentInfosInterval = window.setInterval(() => {
       this.ngZone.run(() => {
-        this.downloadSpeed = torrent.downloadSpeed;
-        this.numPeers = torrent.numPeers;
-        this.uploadSpeed = torrent.uploadSpeed;
-      });
-    }, 1000);
+        this.downloadSpeed = torrent.downloadSpeed
+        this.numPeers = torrent.numPeers
+        this.uploadSpeed = torrent.uploadSpeed
+      })
+    }, 1000)
   }
 }
index 8936e79925f4daa5f02c7c2fc6dfb1e512eb7472..211894bfd3e546559c13955745d9fc957a29b7de 100644 (file)
@@ -1,33 +1,33 @@
-import { Injectable } from '@angular/core';
-import { Subject } from 'rxjs/Subject';
+import { Injectable } from '@angular/core'
+import { Subject } from 'rxjs/Subject'
 
-import * as WebTorrent from 'webtorrent';
+import * as WebTorrent from 'webtorrent'
 
 @Injectable()
 export class WebTorrentService {
-  errors = new Subject<Error>();
-  warnings = new Subject<Error>();
+  errors = new Subject<Error>()
+  warnings = new Subject<Error>()
 
   // TODO: use WebTorrent @type
-  // private client: WebTorrent.Client;
-  private client: any;
+  // private client: WebTorrent.Client
+  private client: any
 
-  constructor() {
-    this.client = new WebTorrent({ dht: false });
+  constructor () {
+    this.client = new WebTorrent({ dht: false })
 
-    this.client.on('error', (err) => this.errors.next(err));
-    this.client.on('warning', (err) => this.warnings.next(err));
+    this.client.on('error', (err) => this.errors.next(err))
+    this.client.on('warning', (err) => this.warnings.next(err))
   }
 
-  add(magnetUri: string, callback: Function) {
-    return this.client.add(magnetUri, callback);
+  add (magnetUri: string, callback: Function) {
+    return this.client.add(magnetUri, callback)
   }
 
-  remove(magnetUri: string) {
-    return this.client.remove(magnetUri);
+  remove (magnetUri: string) {
+    return this.client.remove(magnetUri)
   }
 
-  has(magnetUri: string) {
-    return this.client.get(magnetUri) !== null;
+  has (magnetUri: string) {
+    return this.client.get(magnetUri) !== null
   }
 }
index 70968b4d1d90681142ce34838c23ab40c8cfa91e..7d002abdedd5f24ecaf1f785bf3b09a6e1559387 100644 (file)
@@ -1,10 +1,10 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core'
+import { RouterModule, Routes } from '@angular/router'
 
-import { VideoAddComponent, VideoUpdateComponent } from './video-edit';
-import { VideoListComponent } from './video-list';
-import { VideosComponent } from './videos.component';
-import { VideoWatchComponent } from './video-watch';
+import { VideoAddComponent, VideoUpdateComponent } from './video-edit'
+import { VideoListComponent } from './video-list'
+import { VideosComponent } from './videos.component'
+import { VideoWatchComponent } from './video-watch'
 
 const videosRoutes: Routes = [
   {
@@ -48,7 +48,7 @@ const videosRoutes: Routes = [
       }
     ]
   }
-];
+]
 
 @NgModule({
   imports: [ RouterModule.forChild(videosRoutes) ],
index 591e7523d1db690d18530044b9eed7090d8597e1..972c2221f5c70dbaf42527015ec18e28fcb28f68 100644 (file)
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
 
 @Component({
   template: '<router-outlet></router-outlet>'
index adfbe703104404275527a0dbdc900c2b47f08dfe..75a8dd24f9eb969716a8b2b7a340d7d5cb40733d 100644 (file)
@@ -1,20 +1,20 @@
-import { NgModule } from '@angular/core';
+import { NgModule } from '@angular/core'
 
-import { TagInputModule } from 'ng2-tag-input';
+import { TagInputModule } from 'ng2-tag-input'
 
-import { VideosRoutingModule } from './videos-routing.module';
-import { VideosComponent } from './videos.component';
-import { VideoAddComponent, VideoUpdateComponent } from './video-edit';
-import { LoaderComponent, VideoListComponent, VideoMiniatureComponent, VideoSortComponent } from './video-list';
+import { VideosRoutingModule } from './videos-routing.module'
+import { VideosComponent } from './videos.component'
+import { VideoAddComponent, VideoUpdateComponent } from './video-edit'
+import { LoaderComponent, VideoListComponent, VideoMiniatureComponent, VideoSortComponent } from './video-list'
 import {
   VideoWatchComponent,
   VideoMagnetComponent,
   VideoReportComponent,
   VideoShareComponent,
   WebTorrentService
-} from './video-watch';
-import { VideoService } from './shared';
-import { SharedModule } from '../shared';
+} from './video-watch'
+import { VideoService } from './shared'
+import { SharedModule } from '../shared'
 
 @NgModule({
   imports: [
index 67e069cc61e229ea6f3ce6e2467c608d9d94227e..882d15d54b2888a057907f2b5f411b9b52c64528 100644 (file)
@@ -1,3 +1,5 @@
+/* tslint: disable */
+
 /*
  * Custom Type Definitions
  * When including 3rd party modules you also need to include the type definition for the module
index 718cb3a80917a4a46ef0e04877b5444ffa687fd4..9635d615b570280f46366839d167a734c2fad0cf 100644 (file)
@@ -1,3 +1,5 @@
+/* tslint: disable */
+
 import { platformBrowser } from '@angular/platform-browser';
 import { decorateModuleRef } from './app/environment';
 
index f627ba7dffdc8a7de0f2a73605f4b3cf74fc7373..aeae06e045d4b5a23ebc3019f3f176f8c520063f 100644 (file)
@@ -1,3 +1,5 @@
+/* tslint: disable */
+
 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
 import { decorateModuleRef } from './app/environment';
 
index 5119cf4b94fecfaadabaf38a05b1af6b5c1127f5..b1a63165551f2ea4a1cb1d2b4bc023ae5565c829 100644 (file)
@@ -1,3 +1,5 @@
+/* tslint: disable */
+
 // Polyfills
 // (these modules are what are in 'angular2/bundles/angular2-polyfills' so don't use that here)
 
index 50b90be65c5a8b9138780a3197b76a1b6a2cbe31..cfad2a5d94184e9bf2859fdbe0bca620d3c84939 100644 (file)
@@ -1,36 +1,18 @@
 {
+  "extends": "tslint-config-standard",
   "rulesDirectory": ["./node_modules/codelyzer"],
   "rules": {
-    "class-name": true,
     "no-inferrable-types": true,
-    "curly": false,
     "eofline": true,
     "indent": ["spaces"],
     "max-line-length": [true, 140],
+    "no-floating-promises": false,
+    "no-unused-variable": false, // Bug, wait TypeScript 2.4
     "member-ordering": [true,
       "public-before-private",
       "static-before-instance",
       "variables-before-functions"
     ],
-    "no-arg": true,
-    "no-construct": true,
-    "no-duplicate-variable": true,
-    "no-empty": true,
-    "no-eval": true,
-    "no-trailing-whitespace": true,
-    "no-unused-expression": true,
-    "no-use-before-declare": true,
-    "one-line": [true,
-      "check-open-brace",
-      "check-catch",
-      "check-else",
-      "check-whitespace"
-    ],
-    "quotemark": [true, "single"],
-    "semicolon": true,
-    "trailing-comma": true,
-    "triple-equals": true,
-    "variable-name": false,
 
     "directive-selector": [true, "attribute", "my", "camelCase"],
     "component-selector": [true, "element", "my", "kebab-case"],
     "directive-class-suffix": true,
     "templates-use-public": true,
     "no-access-missing-member": true,
-    "invoke-injectable": true,
-
-    "typedef-whitespace": [ true,
-      {
-        "call-signature": "nospace",
-        "index-signature": "nospace",
-        "parameter": "nospace",
-        "property-declaration": "nospace",
-        "variable-declaration": "nospace"
-      }
-    ],
-    "whitespace": [ true,
-      "check-branch",
-      "check-decl",
-      "check-operator",
-      "check-separator",
-      "check-type"
-    ]
+    "invoke-injectable": true
   }
 }
index 68e4116acf464582cdf541ab8f0d419ee46b231a..7fd6628b15d4782351a280952d12abddda44c754 100644 (file)
@@ -172,10 +172,11 @@ ajv@^4.7.0, ajv@^4.9.1:
     json-stable-stringify "^1.0.1"
 
 ajv@^5.0.0:
-  version "5.1.5"
-  resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.1.5.tgz#8734931b601f00d4feef7c65738d77d1b65d1f68"
+  version "5.1.6"
+  resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.1.6.tgz#4b2f1a19dece93d57ac216037e3e9791c7dd1564"
   dependencies:
     co "^4.6.0"
+    json-schema-traverse "^0.3.0"
     json-stable-stringify "^1.0.1"
 
 align-text@^0.1.1, align-text@^0.1.3:
@@ -415,10 +416,14 @@ babel-runtime@^6.9.2:
     core-js "^2.4.0"
     regenerator-runtime "^0.10.0"
 
-balanced-match@^0.4.1, balanced-match@^0.4.2:
+balanced-match@^0.4.2:
   version "0.4.2"
   resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
 
+balanced-match@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
+
 base64-js@^1.0.2:
   version "1.2.0"
   resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"
@@ -591,10 +596,10 @@ bootstrap@^3.3.6:
   resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.3.7.tgz#5a389394549f23330875a3b150656574f8a9eb71"
 
 brace-expansion@^1.1.7:
-  version "1.1.7"
-  resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+  version "1.1.8"
+  resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
   dependencies:
-    balanced-match "^0.4.1"
+    balanced-match "^1.0.0"
     concat-map "0.0.1"
 
 braces@^1.8.2:
@@ -761,8 +766,8 @@ caniuse-api@^1.5.2:
     lodash.uniq "^4.5.0"
 
 caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
-  version "1.0.30000683"
-  resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000683.tgz#58b57ed1e0bb9da54eaf1462985147bbe16679fa"
+  version "1.0.30000686"
+  resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000686.tgz#d55b479ed6e6402c1fd3f1fd8f46e694d86ea464"
 
 cardinal@^1.0.0:
   version "1.0.0"
@@ -830,14 +835,14 @@ circular-json@^0.3.1:
   resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d"
 
 clap@^1.0.9:
-  version "1.1.3"
-  resolved "https://registry.yarnpkg.com/clap/-/clap-1.1.3.tgz#b3bd36e93dd4cbfb395a3c26896352445265c05b"
+  version "1.2.0"
+  resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.0.tgz#59c90fe3e137104746ff19469a27a634ff68c857"
   dependencies:
     chalk "^1.1.3"
 
 clean-css@4.1.x:
-  version "4.1.3"
-  resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.3.tgz#07cfe8980edb20d455ddc23aadcf1e04c6e509ce"
+  version "4.1.4"
+  resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.4.tgz#eec8811db27457e0078d8ca921fa81b72fa82bf4"
   dependencies:
     source-map "0.5.x"
 
@@ -880,14 +885,13 @@ cliui@^3.2.0:
     strip-ansi "^3.0.1"
     wrap-ansi "^2.0.0"
 
-clone-deep@^0.2.4:
-  version "0.2.4"
-  resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-0.2.4.tgz#4e73dd09e9fb971cc38670c5dced9c1896481cc6"
+clone-deep@^0.3.0:
+  version "0.3.0"
+  resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-0.3.0.tgz#348c61ae9cdbe0edfe053d91ff4cc521d790ede8"
   dependencies:
-    for-own "^0.1.3"
+    for-own "^1.0.0"
     is-plain-object "^2.0.1"
-    kind-of "^3.0.2"
-    lazy-cache "^1.0.3"
+    kind-of "^3.2.2"
     shallow-clone "^0.1.2"
 
 clone@^1.0.2:
@@ -1400,6 +1404,13 @@ doctrine@1.5.0, doctrine@^1.2.2:
     esutils "^2.0.2"
     isarray "^1.0.0"
 
+doctrine@^0.7.2:
+  version "0.7.2"
+  resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523"
+  dependencies:
+    esutils "^1.1.6"
+    isarray "0.0.1"
+
 doctrine@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63"
@@ -1776,6 +1787,10 @@ estree-walker@^0.3.0:
   version "0.3.1"
   resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.3.1.tgz#e6b1a51cf7292524e7237c312e5fe6660c1ce1aa"
 
+esutils@^1.1.6:
+  version "1.1.6"
+  resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375"
+
 esutils@^2.0.2:
   version "2.0.2"
   resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
@@ -2008,12 +2023,18 @@ for-in@^1.0.1:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
 
-for-own@^0.1.3, for-own@^0.1.4:
+for-own@^0.1.4:
   version "0.1.5"
   resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce"
   dependencies:
     for-in "^1.0.1"
 
+for-own@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/for-own/-/for-own-1.0.0.tgz#c63332f415cedc4b04dbfe70cf836494c53cb44b"
+  dependencies:
+    for-in "^1.0.1"
+
 foreach@^2.0.5:
   version "2.0.5"
   resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
@@ -2064,11 +2085,11 @@ fs.realpath@^1.0.0:
   resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
 
 fsevents@^1.0.0:
-  version "1.1.1"
-  resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff"
+  version "1.1.2"
+  resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4"
   dependencies:
     nan "^2.3.0"
-    node-pre-gyp "^0.6.29"
+    node-pre-gyp "^0.6.36"
 
 fstream-ignore@^1.0.5:
   version "1.0.5"
@@ -2760,6 +2781,10 @@ json-loader@^0.5.4:
   version "0.5.4"
   resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de"
 
+json-schema-traverse@^0.3.0:
+  version "0.3.0"
+  resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.0.tgz#0016c0b1ca1efe46d44d37541bcdfc19dcfae0db"
+
 json-schema@0.2.3:
   version "0.2.3"
   resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
@@ -2841,7 +2866,7 @@ kind-of@^2.0.1:
   dependencies:
     is-buffer "^1.0.2"
 
-kind-of@^3.0.2:
+kind-of@^3.0.2, kind-of@^3.2.2:
   version "3.2.2"
   resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
   dependencies:
@@ -3508,7 +3533,7 @@ node-notifier@^4.1.0:
     shellwords "^0.1.0"
     which "^1.0.5"
 
-node-pre-gyp@^0.6.29:
+node-pre-gyp@^0.6.36:
   version "0.6.36"
   resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786"
   dependencies:
@@ -3880,10 +3905,14 @@ piece-length@^1.0.0:
   dependencies:
     closest-to "~2.0.0"
 
-pify@^2.0.0, pify@^2.3.0:
+pify@^2.0.0:
   version "2.3.0"
   resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
 
+pify@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
+
 pinkie-promise@^2.0.0:
   version "2.0.1"
   resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
@@ -4172,8 +4201,8 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0
     supports-color "^3.2.3"
 
 postcss@^6.0.1:
-  version "6.0.1"
-  resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.1.tgz#000dbd1f8eef217aa368b9a212c5fc40b2a8f3f2"
+  version "6.0.2"
+  resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.2.tgz#5c4fea589f0ac3b00caa75b1cbc3a284195b7e5d"
   dependencies:
     chalk "^1.1.3"
     source-map "^0.5.6"
@@ -4588,8 +4617,8 @@ resolve-from@^1.0.0:
   resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
 
 resolve-url-loader@^2.0.0:
-  version "2.0.2"
-  resolved "https://registry.yarnpkg.com/resolve-url-loader/-/resolve-url-loader-2.0.2.tgz#c465e97ea0a4791f3961f766cea775ff2e3ceb8c"
+  version "2.0.3"
+  resolved "https://registry.yarnpkg.com/resolve-url-loader/-/resolve-url-loader-2.0.3.tgz#f54cd1b040e8f0ab72b2cb32c9fbb8544152d9e9"
   dependencies:
     adjust-sourcemap-loader "^1.1.0"
     camelcase "^4.0.0"
@@ -4710,14 +4739,14 @@ sass-graph@^2.1.1:
     yargs "^7.0.0"
 
 sass-loader@^6.0.3:
-  version "6.0.5"
-  resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-6.0.5.tgz#a847910f36442aa56c5985879d54eb519e24a328"
+  version "6.0.6"
+  resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-6.0.6.tgz#e9d5e6c1f155faa32a4b26d7a9b7107c225e40f9"
   dependencies:
     async "^2.1.5"
-    clone-deep "^0.2.4"
+    clone-deep "^0.3.0"
     loader-utils "^1.0.1"
     lodash.tail "^4.1.1"
-    pify "^2.3.0"
+    pify "^3.0.0"
 
 sass-resources-loader@^1.2.1:
   version "1.2.1"
@@ -5093,8 +5122,8 @@ stream-browserify@^2.0.1:
     readable-stream "^2.0.2"
 
 stream-http@^2.3.1:
-  version "2.7.1"
-  resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.1.tgz#546a51741ad5a6b07e9e31b0b10441a917df528a"
+  version "2.7.2"
+  resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.2.tgz#40a050ec8dc3b53b33d9909415c02c0bf1abfbad"
   dependencies:
     builtin-status-codes "^3.0.0"
     inherits "^2.0.1"
@@ -5380,10 +5409,24 @@ tsickle@^0.21.0:
     source-map "^0.5.6"
     source-map-support "^0.4.2"
 
-tslib@^1.5.0, tslib@^1.6.0, tslib@^1.7.1:
+tslib@^1.0.0, tslib@^1.5.0, tslib@^1.6.0, tslib@^1.7.1:
   version "1.7.1"
   resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
 
+tslint-config-standard@^6.0.1:
+  version "6.0.1"
+  resolved "https://registry.yarnpkg.com/tslint-config-standard/-/tslint-config-standard-6.0.1.tgz#a04ba0a794759e877287056f549b081e47a56d6c"
+  dependencies:
+    tslint-eslint-rules "^4.0.0"
+
+tslint-eslint-rules@^4.0.0:
+  version "4.1.1"
+  resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-4.1.1.tgz#7c30e7882f26bc276bff91d2384975c69daf88ba"
+  dependencies:
+    doctrine "^0.7.2"
+    tslib "^1.0.0"
+    tsutils "^1.4.0"
+
 tslint-loader@^3.3.0:
   version "3.5.3"
   resolved "https://registry.yarnpkg.com/tslint-loader/-/tslint-loader-3.5.3.tgz#343f74122d94f356b689457d3f59f64a69ab606f"
@@ -5413,6 +5456,10 @@ tsml@1.0.1:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/tsml/-/tsml-1.0.1.tgz#89f8218b9d9e257f47d7f6b56d01c5a4d2c68fc3"
 
+tsutils@^1.4.0:
+  version "1.9.1"
+  resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0"
+
 tsutils@^2.3.0:
   version "2.4.0"
   resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.4.0.tgz#ad4ce6dba0e5a3edbddf8626b7ca040782189fea"
@@ -5458,20 +5505,20 @@ typedarray@^0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
 
-typescript@~2.3.0:
-  version "2.3.4"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.4.tgz#3d38321828231e434f287514959c37a82b629f42"
+typescript@~2.4.0:
+  version "2.4.0"
+  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd"
 
 uglify-js@3.0.x:
-  version "3.0.15"
-  resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.15.tgz#aacb323a846b234602270dead8a32441a8806f42"
+  version "3.0.17"
+  resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.17.tgz#d228cd55c2df9b3d2f53f147568cb4cc4a72cc06"
   dependencies:
     commander "~2.9.0"
     source-map "~0.5.1"
 
 uglify-js@^2.8.27:
-  version "2.8.28"
-  resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.28.tgz#e335032df9bb20dcb918f164589d5af47f38834a"
+  version "2.8.29"
+  resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
   dependencies:
     source-map "~0.5.1"
     yargs "~3.10.0"
@@ -5533,8 +5580,8 @@ urix@^0.1.0, urix@~0.1.0:
   resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
 
 url-loader@^0.5.7:
-  version "0.5.8"
-  resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.8.tgz#b9183b1801e0f847718673673040bc9dc1c715c5"
+  version "0.5.9"
+  resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.9.tgz#cc8fea82c7b906e7777019250869e569e995c295"
   dependencies:
     loader-utils "^1.0.2"
     mime "1.3.x"
index 095d380bfdadde0105cc8a1c09b28c07eab49b0d..ac542c3f9e866a44b7deb2176aed56e48051210d 100644 (file)
@@ -41,7 +41,8 @@
     "postinstall": "cd client && yarn install",
     "tsc": "tsc",
     "nodemon": "nodemon",
-    "ts-node": "ts-node"
+    "ts-node": "ts-node",
+    "tslint": "tslint"
   },
   "dependencies": {
     "async": "^2.0.0",
@@ -76,7 +77,7 @@
     "scripty": "^1.5.0",
     "sequelize": "4.0.0-2",
     "ts-node": "^3.0.6",
-    "typescript": "~2.2.0",
+    "typescript": "^2.3.4",
     "validator": "^7.0.0",
     "winston": "^2.1.1",
     "ws": "^2.0.0"
@@ -94,7 +95,7 @@
     "@types/morgan": "^1.7.32",
     "@types/multer": "^0.0.34",
     "@types/node": "^7.0.18",
-    "@types/request": "^0.0.43",
+    "@types/request": "^0.0.44",
     "@types/sequelize": "^4.0.55",
     "@types/validator": "^6.2.0",
     "@types/winston": "^2.3.2",
     "standard": "^10.0.0",
     "supertest": "^3.0.0",
     "tslint": "^5.2.0",
-    "tslint-config-standard": "^5.0.2",
+    "tslint-config-standard": "^6.0.0",
     "webtorrent": "^0.98.0"
   },
   "standard": {
index 28167482cf5060370c6cc2fee0d09e6bd506bf8c..24f4806af6c8998a074a5952243243793f848477 100755 (executable)
@@ -130,7 +130,7 @@ function isThereValidCORSHeaders (res: request.RequestResponse) {
     console.error(headerAllowMethodsKey + ' is not present.')
     fail = true
   } else {
-    const allowMethodsMissed = findPatternNotInString(headerAllowMethods, [ 'get' ])
+    const allowMethodsMissed = findPatternNotInString(headerAllowMethods as string, [ 'get' ])
     if (allowMethodsMissed !== null) {
       console.error(headerAllowMethodsKey + ' misses the ' + allowMethodsMissed + ' method.')
       fail = true
@@ -147,7 +147,7 @@ function isThereValidCORSHeaders (res: request.RequestResponse) {
     const headersThatShouldBePresent = [
       'Range'
     ]
-    const allowHeadersMissed = findPatternNotInString(headerAllowHeaders, headersThatShouldBePresent)
+    const allowHeadersMissed = findPatternNotInString(headerAllowHeaders as string, headersThatShouldBePresent)
     if (allowHeadersMissed !== null) {
       console.error(headerAllowHeadersKey + ' misses the ' + allowHeadersMissed + ' header.')
       fail = true
index b341fc0d07049121575c1c53dad8f76488053ea6..701dea8d04baee8bd8cc84d3f82cf486c4311b77 100755 (executable)
@@ -4,5 +4,5 @@ cd client || exit -1
 npm test || exit -1
 
 cd .. || exit -1
-standard || exit -1
+npm run tslint -- --type-check --project ./tsconfig.json -c ./tslint.json server.ts server/**/*.ts || exit -1
 mocha server/tests
index bb56fd7cfcfb099ff29d0d66e0bdf71a89f7bb85..0223a98f119556a6912f3744b7ac6154f8d2803e 100644 (file)
@@ -1,3 +1,3 @@
-export * from './static';
-export * from './client';
-export * from './api';
+export * from './static'
+export * from './client'
+export * from './api'
index 8e489de9664c2c951c56c9225a7c3541128d44c0..07c1b3f51adffa1b01e042d211c8cba465be309c 100644 (file)
@@ -1,7 +1,6 @@
 import * as express from 'express'
 
 import { pseudoRandomBytes } from 'crypto'
-import { join } from 'path'
 
 import { logger } from './logger'
 
index 1662c1968f2fb102111ac3ee7035c472233e8d2d..47604c6b014c2aa9a66b13ae545e21af46d48b42 100644 (file)
@@ -144,7 +144,7 @@ function getModelFiles (modelDirectory: string, callback: (err: Error, filePaths
 
         return eachCallback(null)
       })
-    }, function(err: Error) {
+    }, function (err: Error) {
       return callback(err, modelFilePaths)
     })
   })
index d72c60638a2c58a23290a1308446d3abb7bc5e6c..d8faaebc6d12d2caca680001fe1d906363b1672a 100644 (file)
@@ -6,7 +6,6 @@ import * as Sequelize from 'sequelize'
 import { database as db } from './database'
 import { LAST_MIGRATION_VERSION } from './constants'
 import { logger } from '../helpers'
-import { ApplicationInstance } from '../models'
 
 function migrate (finalCallback: (err: Error) => void) {
   waterfall([
index d07433a5dd72b97445d3777f60f1bd232b9a350d..522cb82b341bae0055ae17deca15aa6b31f594a1 100644 (file)
@@ -103,7 +103,11 @@ function quickAndDirtyUpdateVideoToFriends (qaduParam: QaduParam, transaction?:
   return createVideoQaduRequest(options, callback)
 }
 
-function quickAndDirtyUpdatesVideoToFriends (qadusParams: QaduParam[], transaction: Sequelize.Transaction, finalCallback: (err: Error) => void) {
+function quickAndDirtyUpdatesVideoToFriends (
+  qadusParams: QaduParam[],
+  transaction: Sequelize.Transaction,
+  finalCallback: (err: Error) => void
+) {
   const tasks = []
 
   qadusParams.forEach(function (qaduParams) {
index efa18ef2d66e3b4017ca619cbfbf873f94a2f024..6f606a7d34dea8be474cb42357f7737837a0b5e3 100644 (file)
@@ -13,9 +13,9 @@ function process (data: { id: string }, callback: (err: Error, videoInstance?: V
   })
 }
 
-function onError (err: Error, jobId: number, video: VideoInstance, callback: () => void) {
+function onError (err: Error, jobId: number, video: VideoInstance, callback: (err: Error) => void) {
   logger.error('Error when transcoding video file in job %d.', jobId, { error: err })
-  return callback()
+  return callback(null)
 }
 
 function onSuccess (data: any, jobId: number, video: VideoInstance, callback: (err: Error) => void) {
index 8887798568c59436d95d1e9d2d6bc4a19abe28d3..70e5d9bb4103f67ae7d18b4b3f1f7cc641f3855d 100644 (file)
@@ -1,3 +1,10 @@
 {
-  "extends": "tslint-config-standard"
+  "extends": "tslint-config-standard",
+  "rules": {
+    "no-inferrable-types": true,
+    "eofline": true,
+    "indent": ["spaces"],
+    "max-line-length": [true, 140],
+    "no-floating-promises": false
+  }
 }
index 9c0af9d327791d9547d5e4b733d42000bfe97f41..85143ca6acf3e599f959c1803c5be1775e6a7f19 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
   resolved "https://registry.yarnpkg.com/@types/config/-/config-0.0.32.tgz#c106055802d78e234e28374adc4dad460d098558"
 
 "@types/express-serve-static-core@*":
-  version "4.0.45"
-  resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.0.45.tgz#71bb1f87d7187482d0d8851f5b294458e1c78667"
+  version "4.0.47"
+  resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.0.47.tgz#71b3c6b060ba8aea97d205171ff3f3a69d3db465"
   dependencies:
     "@types/node" "*"
 
 "@types/express@*", "@types/express@^4.0.35", "@types/express@~4.0.34":
-  version "4.0.35"
-  resolved "https://registry.yarnpkg.com/@types/express/-/express-4.0.35.tgz#6267c7b60a51fac473467b3c4a02cd1e441805fe"
+  version "4.0.36"
+  resolved "https://registry.yarnpkg.com/@types/express/-/express-4.0.36.tgz#14eb47de7ecb10319f0a2fb1cf971aa8680758c2"
   dependencies:
     "@types/express-serve-static-core" "*"
     "@types/serve-static" "*"
@@ -55,8 +55,8 @@
   resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-1.0.2.tgz#b02d10ab028e2928ac592a051aaa4981a1941d03"
 
 "@types/lodash@*", "@types/lodash@^4.14.64":
-  version "4.14.65"
-  resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.65.tgz#a0f78d71ffcd3c02628d5f616410c98c424326d5"
+  version "4.14.66"
+  resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.66.tgz#3dbb83477becf130611f8fac82a8fdb199805981"
 
 "@types/magnet-uri@^5.1.1":
   version "5.1.1"
@@ -65,8 +65,8 @@
     "@types/node" "*"
 
 "@types/mime@*":
-  version "0.0.29"
-  resolved "https://registry.yarnpkg.com/@types/mime/-/mime-0.0.29.tgz#fbcfd330573b912ef59eeee14602bface630754b"
+  version "1.3.0"
+  resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.0.tgz#d24ffac7d1006fe68517202fb2aeba3dbe48284b"
 
 "@types/mkdirp@^0.3.29":
   version "0.3.29"
     "@types/express" "*"
 
 "@types/node@*", "@types/node@^7.0.18":
-  version "7.0.29"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.29.tgz#ccfcec5b7135c7caf6c4ffb8c7f33102340d99df"
+  version "7.0.31"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86"
 
-"@types/request@^0.0.43":
-  version "0.0.43"
-  resolved "https://registry.yarnpkg.com/@types/request/-/request-0.0.43.tgz#fcc59cfd88e63034e813c6884a0aade2d0f7e935"
+"@types/request@^0.0.44":
+  version "0.0.44"
+  resolved "https://registry.yarnpkg.com/@types/request/-/request-0.0.44.tgz#77572176765376d2ba98654079311650cf4113af"
   dependencies:
     "@types/form-data" "*"
     "@types/node" "*"
@@ -319,9 +319,9 @@ babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
     esutils "^2.0.2"
     js-tokens "^3.0.0"
 
-balanced-match@^0.4.1:
-  version "0.4.2"
-  resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+balanced-match@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
 
 basic-auth@^1.0.0, basic-auth@~1.1.0:
   version "1.1.0"
@@ -485,10 +485,10 @@ boom@2.x.x:
     hoek "2.x.x"
 
 brace-expansion@^1.1.7:
-  version "1.1.7"
-  resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+  version "1.1.8"
+  resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
   dependencies:
-    balanced-match "^0.4.1"
+    balanced-match "^1.0.0"
     concat-map "0.0.1"
 
 braces@^1.8.2:
@@ -1521,13 +1521,13 @@ fs.realpath@^1.0.0:
   resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
 
 fsevents@^1.0.0:
-  version "1.1.1"
-  resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff"
+  version "1.1.2"
+  resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4"
   dependencies:
     nan "^2.3.0"
-    node-pre-gyp "^0.6.29"
+    node-pre-gyp "^0.6.36"
 
-fstream-ignore@~1.0.5:
+fstream-ignore@^1.0.5, fstream-ignore@~1.0.5:
   version "1.0.5"
   resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105"
   dependencies:
@@ -1535,7 +1535,7 @@ fstream-ignore@~1.0.5:
     inherits "2"
     minimatch "^3.0.0"
 
-fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10:
+fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2, fstream@~1.0.10:
   version "1.0.11"
   resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171"
   dependencies:
@@ -2473,7 +2473,7 @@ node-abi@^2.0.0:
   version "2.0.3"
   resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.0.3.tgz#0ca67e5e667b8e1343549ca17153a815d0bbfdaa"
 
-node-pre-gyp@0.6.32, node-pre-gyp@^0.6.29:
+node-pre-gyp@0.6.32:
   version "0.6.32"
   resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz#fc452b376e7319b3d255f5f34853ef6fd8fe1fd5"
   dependencies:
@@ -2487,6 +2487,20 @@ node-pre-gyp@0.6.32, node-pre-gyp@^0.6.29:
     tar "~2.2.1"
     tar-pack "~3.3.0"
 
+node-pre-gyp@^0.6.36:
+  version "0.6.36"
+  resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786"
+  dependencies:
+    mkdirp "^0.5.1"
+    nopt "^4.0.1"
+    npmlog "^4.0.2"
+    rc "^1.1.7"
+    request "^2.81.0"
+    rimraf "^2.6.1"
+    semver "^5.3.0"
+    tar "^2.2.1"
+    tar-pack "^3.4.0"
+
 node-uuid@~1.4.4:
   version "1.4.8"
   resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907"
@@ -2510,6 +2524,13 @@ noop-logger@^0.1.1:
   version "0.1.1"
   resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2"
 
+nopt@^4.0.1:
+  version "4.0.1"
+  resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d"
+  dependencies:
+    abbrev "1"
+    osenv "^0.1.4"
+
 nopt@~1.0.10:
   version "1.0.10"
   resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
@@ -2528,7 +2549,7 @@ normalize-path@^2.0.1:
   dependencies:
     remove-trailing-separator "^1.0.1"
 
-npmlog@^4.0.1:
+npmlog@^4.0.1, npmlog@^4.0.2:
   version "4.1.0"
   resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5"
   dependencies:
@@ -2645,7 +2666,7 @@ os-tmpdir@^1.0.0:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
 
-osenv@^0.1.0:
+osenv@^0.1.0, osenv@^0.1.4:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644"
   dependencies:
@@ -2997,7 +3018,7 @@ raw-body@~2.2.0:
     iconv-lite "0.4.15"
     unpipe "1.0.0"
 
-rc@^1.0.1, rc@^1.1.6, rc@~1.1.6:
+rc@^1.0.1, rc@^1.1.6, rc@^1.1.7, rc@~1.1.6:
   version "1.1.7"
   resolved "https://registry.yarnpkg.com/rc/-/rc-1.1.7.tgz#c5ea564bb07aff9fd3a5b32e906c1d3a65940fea"
   dependencies:
@@ -3179,7 +3200,7 @@ retry@^0.10.0:
   version "0.10.1"
   resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
 
-rimraf@2, rimraf@^2.2.8, rimraf@^2.4.2, rimraf@^2.5.4:
+rimraf@2, rimraf@^2.2.8, rimraf@^2.4.2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
   version "2.6.1"
   resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
   dependencies:
@@ -3650,6 +3671,19 @@ tar-fs@^1.13.0:
     pump "^1.0.0"
     tar-stream "^1.1.2"
 
+tar-pack@^3.4.0:
+  version "3.4.0"
+  resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984"
+  dependencies:
+    debug "^2.2.0"
+    fstream "^1.0.10"
+    fstream-ignore "^1.0.5"
+    once "^1.3.3"
+    readable-stream "^2.1.4"
+    rimraf "^2.5.1"
+    tar "^2.2.1"
+    uid-number "^0.0.6"
+
 tar-pack@~3.3.0:
   version "3.3.0"
   resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae"
@@ -3672,7 +3706,7 @@ tar-stream@^1.1.2:
     readable-stream "^2.0.0"
     xtend "^4.0.0"
 
-tar@~2.2.1:
+tar@^2.2.1, tar@~2.2.1:
   version "2.2.1"
   resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1"
   dependencies:
@@ -3787,9 +3821,9 @@ tslib@^1.0.0, tslib@^1.7.1:
   version "1.7.1"
   resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
 
-tslint-config-standard@^5.0.2:
-  version "5.0.2"
-  resolved "https://registry.yarnpkg.com/tslint-config-standard/-/tslint-config-standard-5.0.2.tgz#e98fd5c412a6b973798366dc2c85508cf0ed740f"
+tslint-config-standard@^6.0.0:
+  version "6.0.1"
+  resolved "https://registry.yarnpkg.com/tslint-config-standard/-/tslint-config-standard-6.0.1.tgz#a04ba0a794759e877287056f549b081e47a56d6c"
   dependencies:
     tslint-eslint-rules "^4.0.0"
 
@@ -3869,11 +3903,11 @@ typedarray@^0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
 
-typescript@~2.2.0:
-  version "2.2.2"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c"
+typescript@^2.3.4:
+  version "2.4.0"
+  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd"
 
-uid-number@~0.0.6:
+uid-number@^0.0.6, uid-number@~0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"