From 63c4db6d71b98523753c51747e308682d9a2e8a0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Dec 2017 17:36:46 +0100 Subject: Move to angular cli --- client/src/app/shared/account/account.model.ts | 3 ++- client/src/app/shared/forms/form-validators/host.ts | 8 ++++++++ .../src/app/shared/forms/form-validators/host.validator.ts | 8 -------- client/src/app/shared/forms/form-validators/index.ts | 2 +- .../app/shared/forms/form-validators/validator-message.ts | 5 +++++ client/src/app/shared/forms/form-validators/video.ts | 6 ------ client/src/app/shared/misc/button.component.scss | 3 +++ client/src/app/shared/users/user.service.ts | 8 ++++---- client/src/app/shared/video-abuse/video-abuse.service.ts | 12 +++++------- .../app/shared/video-blacklist/video-blacklist.service.ts | 13 ++++++------- client/src/app/shared/video/video-miniature.component.scss | 3 +++ client/src/app/shared/video/video-thumbnail.component.scss | 3 +++ client/src/app/shared/video/video.model.ts | 5 +++-- client/src/app/shared/video/video.service.ts | 6 +++--- 14 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 client/src/app/shared/forms/form-validators/host.ts delete mode 100644 client/src/app/shared/forms/form-validators/host.validator.ts create mode 100644 client/src/app/shared/forms/form-validators/validator-message.ts (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts index 0b008188a..9d1fd3e1d 100644 --- a/client/src/app/shared/account/account.model.ts +++ b/client/src/app/shared/account/account.model.ts @@ -1,5 +1,6 @@ import { Account as ServerAccount } from '../../../../../shared/models/accounts/account.model' import { Avatar } from '../../../../../shared/models/avatars/avatar.model' +import { environment } from '../../../environments/environment' export class Account implements ServerAccount { id: number @@ -15,6 +16,6 @@ export class Account implements ServerAccount { static GET_ACCOUNT_AVATAR_PATH (account: Account) { if (account && account.avatar) return account.avatar.path - return API_URL + '/client/assets/images/default-avatar.png' + return environment.apiUrl + '/client/assets/images/default-avatar.png' } } diff --git a/client/src/app/shared/forms/form-validators/host.ts b/client/src/app/shared/forms/form-validators/host.ts new file mode 100644 index 000000000..c18a35f9b --- /dev/null +++ b/client/src/app/shared/forms/form-validators/host.ts @@ -0,0 +1,8 @@ +export function validateHost (value: string) { + // 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(value) +} diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts deleted file mode 100644 index c18a35f9b..000000000 --- a/client/src/app/shared/forms/form-validators/host.validator.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function validateHost (value: string) { - // 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(value) -} diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index efe77d4ae..09ae86f8a 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts @@ -1,4 +1,4 @@ -export * from './host.validator' +export * from './host' export * from './user' export * from './video-abuse' export * from './video' diff --git a/client/src/app/shared/forms/form-validators/validator-message.ts b/client/src/app/shared/forms/form-validators/validator-message.ts new file mode 100644 index 000000000..5ce45833b --- /dev/null +++ b/client/src/app/shared/forms/form-validators/validator-message.ts @@ -0,0 +1,5 @@ +export type ValidatorMessage = { + [ id: string ]: { + [ error: string ]: string + } +} diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index 45da7df4a..500b5bc5f 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts @@ -1,11 +1,5 @@ import { Validators } from '@angular/forms' -export type ValidatorMessage = { - [ id: string ]: { - [ error: string ]: string - } -} - export const VIDEO_NAME = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], MESSAGES: { diff --git a/client/src/app/shared/misc/button.component.scss b/client/src/app/shared/misc/button.component.scss index 5fcae4f10..c380c7ae1 100644 --- a/client/src/app/shared/misc/button.component.scss +++ b/client/src/app/shared/misc/button.component.scss @@ -1,3 +1,6 @@ +@import '_variables'; +@import '_mixins'; + .action-button { @include peertube-button-link; diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 6d1017fc9..d97edbcbe 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -1,14 +1,14 @@ -import { Injectable } from '@angular/core' import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' - -import { RestExtractor } from '../rest' import { UserCreate, UserUpdateMe } from '../../../../../shared' +import { environment } from '../../../environments/environment' +import { RestExtractor } from '../rest' @Injectable() export class UserService { - static BASE_USERS_URL = API_URL + '/api/v1/users/' + static BASE_USERS_URL = environment.apiUrl + '/api/v1/users/' constructor ( private authHttp: HttpClient, diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index 8d979de31..96a1f1fd2 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts @@ -1,19 +1,17 @@ -import { Injectable } from '@angular/core' import { HttpClient, HttpParams } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { SortMeta } from 'primeng/components/common/sortmeta' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' import { Observable } from 'rxjs/Observable' - -import { SortMeta } from 'primeng/components/common/sortmeta' - -import { AuthService } from '../core' +import { ResultList, VideoAbuse } from '../../../../../shared' import { RestExtractor, RestPagination, RestService } from '../rest' import { Utils } from '../utils' -import { ResultList, VideoAbuse } from '../../../../../shared' +import { environment } from '../../../environments/environment' @Injectable() export class VideoAbuseService { - private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/' + private static BASE_VIDEO_ABUSE_URL = environment.apiUrl + '/api/v1/videos/' constructor ( private authHttp: HttpClient, diff --git a/client/src/app/shared/video-blacklist/video-blacklist.service.ts b/client/src/app/shared/video-blacklist/video-blacklist.service.ts index 17373d52e..1231690aa 100644 --- a/client/src/app/shared/video-blacklist/video-blacklist.service.ts +++ b/client/src/app/shared/video-blacklist/video-blacklist.service.ts @@ -1,18 +1,17 @@ -import { Injectable } from '@angular/core' import { HttpClient, HttpParams } from '@angular/common/http' -import { Observable } from 'rxjs/Observable' +import { Injectable } from '@angular/core' +import { SortMeta } from 'primeng/components/common/sortmeta' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' - -import { SortMeta } from 'primeng/components/common/sortmeta' - +import { Observable } from 'rxjs/Observable' +import { BlacklistedVideo, ResultList } from '../../../../../shared' +import { environment } from '../../../environments/environment' import { RestExtractor, RestPagination, RestService } from '../rest' import { Utils } from '../utils' -import { BlacklistedVideo, ResultList } from '../../../../../shared' @Injectable() export class VideoBlacklistService { - private static BASE_VIDEOS_URL = API_URL + '/api/v1/videos/' + private static BASE_VIDEOS_URL = environment.apiUrl + '/api/v1/videos/' constructor ( private authHttp: HttpClient, diff --git a/client/src/app/shared/video/video-miniature.component.scss b/client/src/app/shared/video/video-miniature.component.scss index 37e84897b..49ba1e51c 100644 --- a/client/src/app/shared/video/video-miniature.component.scss +++ b/client/src/app/shared/video/video-miniature.component.scss @@ -1,3 +1,6 @@ +@import '_variables'; +@import '_mixins'; + .video-miniature { display: inline-block; padding-right: 15px; diff --git a/client/src/app/shared/video/video-thumbnail.component.scss b/client/src/app/shared/video/video-thumbnail.component.scss index ab4f9bcb1..0fc2df220 100644 --- a/client/src/app/shared/video/video-thumbnail.component.scss +++ b/client/src/app/shared/video/video-thumbnail.component.scss @@ -1,3 +1,6 @@ +@import '_variables'; +@import '_mixins'; + .video-thumbnail { display: inline-block; position: relative; diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index d86ef8f92..32c33829d 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -1,6 +1,7 @@ -import { Video as VideoServerModel } from '../../../../../shared' import { User } from '../' +import { Video as VideoServerModel } from '../../../../../shared' import { Account } from '../../../../../shared/models/accounts' +import { environment } from '../../../environments/environment' export class Video implements VideoServerModel { accountName: string @@ -48,7 +49,7 @@ export class Video implements VideoServerModel { } constructor (hash: VideoServerModel) { - let absoluteAPIUrl = API_URL + let absoluteAPIUrl = environment.apiUrl if (!absoluteAPIUrl) { // The API is on the same domain absoluteAPIUrl = window.location.origin diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 1a0644c3d..91dd3977a 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -9,9 +9,9 @@ import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-vi import { UserVideoRate } from '../../../../../shared/models/videos/user-video-rate.model' import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type' import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model' +import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest/rest-extractor.service' import { RestService } from '../rest/rest.service' -import { Search } from '../header/search.model' import { UserService } from '../users/user.service' import { SortField } from './sort-field.type' import { VideoDetails } from './video-details.model' @@ -21,7 +21,7 @@ import { Video } from './video.model' @Injectable() export class VideoService { - private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/' + private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' constructor ( private authHttp: HttpClient, @@ -118,7 +118,7 @@ export class VideoService { loadCompleteDescription (descriptionPath: string) { return this.authHttp - .get(API_URL + descriptionPath) + .get(environment.apiUrl + descriptionPath) .map(res => res['description']) .catch((res) => this.restExtractor.handleError(res)) } -- cgit v1.2.3