import { Component, OnInit, ViewContainerRef } from '@angular/core'
import { Router } from '@angular/router'
-import { AuthService, ConfigService } from './core'
+import { AuthService, ServerService } from './core'
import { UserService } from './shared'
@Component({
constructor (
private router: Router,
private authService: AuthService,
- private configService: ConfigService,
+ private serverService: ServerService,
private userService: UserService
) {}
this.userService.checkTokenValidity()
}
- this.configService.loadConfig()
+ // Load custom data from server
+ this.serverService.loadConfig()
+ this.serverService.loadVideoCategories()
+ this.serverService.loadVideoLanguages()
+ this.serverService.loadVideoLicences()
// Do not display menu on small screens
if (window.innerWidth < 600) {
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { HttpClient } from '@angular/common/http'
-
-import { ServerConfig } from '../../../../../shared'
-
-@Injectable()
-export class ConfigService {
- private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'
-
- private config: ServerConfig = {
- signup: {
- allowed: false
- }
- }
-
- constructor (private http: HttpClient) {}
-
- loadConfig () {
- this.http.get<ServerConfig>(ConfigService.BASE_CONFIG_URL)
- .subscribe(data => this.config = data)
- }
-
- getConfig () {
- return this.config
- }
-}
+++ /dev/null
-export * from './config.service'
import { ModalModule } from 'ngx-bootstrap/modal'
import { AuthService } from './auth'
-import { ConfigService } from './config'
+import { ServerService } from './server'
import { ConfirmComponent, ConfirmService } from './confirm'
import { MenuComponent, MenuAdminComponent } from './menu'
import { throwIfAlreadyLoaded } from './module-import-guard'
providers: [
AuthService,
ConfirmService,
- ConfigService
+ ServerService
]
})
export class CoreModule {
export * from './auth'
-export * from './config'
+export * from './server'
export * from './confirm'
export * from './menu'
export * from './routing'
import { Router } from '@angular/router'
import { AuthService, AuthStatus } from '../auth'
-import { ConfigService } from '../config'
+import { ServerService } from '../server'
@Component({
selector: 'my-menu',
constructor (
private authService: AuthService,
- private configService: ConfigService,
+ private serverService: ServerService,
private router: Router
) {}
}
isRegistrationAllowed () {
- return this.configService.getConfig().signup.allowed
+ return this.serverService.getConfig().signup.allowed
}
isUserAdmin () {
--- /dev/null
+export * from './server.service'
--- /dev/null
+import { Injectable } from '@angular/core'
+import { HttpClient } from '@angular/common/http'
+
+import { ServerConfig } from '../../../../../shared'
+
+@Injectable()
+export class ServerService {
+ private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'
+ private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/'
+
+ private config: ServerConfig = {
+ signup: {
+ allowed: false
+ }
+ }
+ private videoCategories: Array<{ id: number, label: string }> = []
+ private videoLicences: Array<{ id: number, label: string }> = []
+ private videoLanguages: Array<{ id: number, label: string }> = []
+
+ constructor (private http: HttpClient) {}
+
+ loadConfig () {
+ this.http.get<ServerConfig>(ServerService.BASE_CONFIG_URL)
+ .subscribe(data => this.config = data)
+ }
+
+ loadVideoCategories () {
+ return this.loadVideoAttributeEnum('categories', this.videoCategories)
+ }
+
+ loadVideoLicences () {
+ return this.loadVideoAttributeEnum('licences', this.videoLicences)
+ }
+
+ loadVideoLanguages () {
+ return this.loadVideoAttributeEnum('languages', this.videoLanguages)
+ }
+
+ getConfig () {
+ return this.config
+ }
+
+ getVideoCategories () {
+ return this.videoCategories
+ }
+
+ getVideoLicences () {
+ return this.videoLicences
+ }
+
+ getVideoLanguages () {
+ return this.videoLanguages
+ }
+
+ private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) {
+ return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
+ .subscribe(data => {
+ Object.keys(data)
+ .forEach(dataKey => {
+ hashToPopulate.push({
+ id: parseInt(dataKey, 10),
+ label: data[dataKey]
+ })
+ })
+ })
+ }
+}
VIDEO_LICENCE,
VIDEO_LANGUAGE,
VIDEO_DESCRIPTION,
- VIDEO_TAGS
+ VIDEO_TAGS,
+ VIDEO_FILE
} from '../../shared'
+import { ServerService} from '../../core'
import { VideoService } from '../shared'
import { VideoCreate } from '../../../../../shared'
import { HttpEventType, HttpResponse } from '@angular/common/http'
-import { VIDEO_FILE } from '../../shared/forms/form-validators/video'
@Component({
selector: 'my-videos-add',
private formBuilder: FormBuilder,
private router: Router,
private notificationsService: NotificationsService,
+ private serverService: ServerService,
private videoService: VideoService
) {
super()
}
ngOnInit () {
- this.videoCategories = this.videoService.videoCategories
- this.videoLicences = this.videoService.videoLicences
- this.videoLanguages = this.videoService.videoLanguages
+ this.videoCategories = this.serverService.getVideoCategories()
+ this.videoLicences = this.serverService.getVideoLicences()
+ this.videoLanguages = this.serverService.getVideoLanguages()
this.buildForm()
}
-import { Component, ElementRef, OnInit } from '@angular/core'
+import { Component, OnInit } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
-import { AuthService } from '../../core'
+import { ServerService } from '../../core'
import {
FormReactive,
VIDEO_NAME,
fileError = ''
constructor (
- private authService: AuthService,
- private elementRef: ElementRef,
private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private notificationsService: NotificationsService,
+ private serverService: ServerService,
private videoService: VideoService
) {
super()
ngOnInit () {
this.buildForm()
- this.videoCategories = this.videoService.videoCategories
- this.videoLicences = this.videoService.videoLicences
- this.videoLanguages = this.videoService.videoLanguages
+ this.videoCategories = this.serverService.getVideoCategories()
+ this.videoLicences = this.serverService.getVideoLicences()
+ this.videoLanguages = this.serverService.getVideoLanguages()
const uuid: string = this.route.snapshot.params['uuid']
this.videoService.getVideo(uuid)
import { Video } from './video.model'
import { VideoPagination } from './video-pagination.model'
import {
- VideoCreate,
UserVideoRate,
VideoRateType,
VideoUpdate,
export class VideoService {
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 }> = []
-
constructor (
private authHttp: HttpClient,
private restExtractor: RestExtractor,
private restService: RestService
) {}
- loadVideoCategories () {
- return this.loadVideoAttributeEnum('categories', this.videoCategories)
- }
-
- loadVideoLicences () {
- return this.loadVideoAttributeEnum('licences', this.videoLicences)
- }
-
- loadVideoLanguages () {
- return this.loadVideoAttributeEnum('languages', this.videoLanguages)
- }
-
getVideo (uuid: string) {
return this.authHttp.get<VideoServerModel>(VideoService.BASE_VIDEO_URL + uuid)
.map(videoHash => new Video(videoHash))
.catch(this.restExtractor.handleError)
}
- // uploadVideo (video: VideoCreate) {
- uploadVideo (video: any) {
+ uploadVideo (video: FormData) {
const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true })
return this.authHttp.request(req)
return { videos, totalVideos }
}
-
- private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) {
- return this.authHttp.get(VideoService.BASE_VIDEO_URL + attributeName)
- .subscribe(data => {
- Object.keys(data).forEach(dataKey => {
- hashToPopulate.push({
- id: parseInt(dataKey, 10),
- label: data[dataKey]
- })
- })
- })
- }
}
-import { Component, Input, Output, EventEmitter } from '@angular/core'
+import { Component, Input } from '@angular/core'
-import { NotificationsService } from 'angular2-notifications'
-
-import { ConfirmService, ConfigService } from '../../core'
-import { SortField, Video, VideoService } from '../shared'
+import { SortField, Video } from '../shared'
import { User } from '../../shared'
@Component({
styleUrls: [ './video-miniature.component.scss' ],
templateUrl: './video-miniature.component.html'
})
-
export class VideoMiniatureComponent {
@Input() currentSort: SortField
@Input() user: User
@Input() video: Video
- constructor (
- private notificationsService: NotificationsService,
- private confirmService: ConfirmService,
- private configService: ConfigService,
- private videoService: VideoService
- ) {}
-
getVideoName () {
if (this.isVideoNSFWForThisUser()) {
return 'NSFW'
-import { Component, OnInit } from '@angular/core'
-
-import { VideoService } from './shared'
+import { Component } from '@angular/core'
@Component({
template: '<router-outlet></router-outlet>'
})
-export class VideosComponent implements OnInit {
- constructor (private videoService: VideoService) {}
-
- ngOnInit () {
- this.videoService.loadVideoCategories()
- this.videoService.loadVideoLicences()
- this.videoService.loadVideoLanguages()
- }
-}
+export class VideosComponent {}