44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import {Component, OnInit} from '@angular/core';
|
|
import {Title} from '@angular/platform-browser';
|
|
import {VideoService} from '../../../_services/video.service';
|
|
import {Video} from '../../../_models/video';
|
|
import {DatePipe} from '@angular/common';
|
|
|
|
@Component({
|
|
selector: 'app-home',
|
|
imports: [
|
|
DatePipe
|
|
],
|
|
templateUrl: './home.component.html',
|
|
styleUrl: './home.component.css'
|
|
})
|
|
export class HomeComponent implements OnInit {
|
|
|
|
videos: Video[] = []
|
|
|
|
constructor(private title: Title, private videoService: VideoService) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.title.setTitle('Accueil - YouVideo');
|
|
this.videoService.getVideo().subscribe(v => {
|
|
this.videos = v.data;
|
|
})
|
|
}
|
|
|
|
generatorLink() {
|
|
const baseId = 'qiSOyusTaeo';
|
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
const length = 11;
|
|
|
|
let randomPart = '';
|
|
for (let i = 0; i < length; i++) {
|
|
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
randomPart += characters.charAt(randomIndex);
|
|
}
|
|
|
|
return `https://youtube.com/watch?v=${randomPart}`;
|
|
}
|
|
|
|
}
|