2018-07-12 14:11:31 +02:00
|
|
|
import { File } from './file';
|
2018-09-13 09:23:57 +02:00
|
|
|
import { ProjectableBaseModel } from '../base/projectable-base-model';
|
2018-11-07 08:43:48 +01:00
|
|
|
import { Searchable } from '../base/searchable';
|
2018-07-04 17:51:31 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* Representation of MediaFile. Has the nested property "File"
|
|
|
|
* @ignore
|
|
|
|
*/
|
2018-11-07 08:43:48 +01:00
|
|
|
export class Mediafile extends ProjectableBaseModel implements Searchable {
|
2018-08-29 13:21:25 +02:00
|
|
|
public id: number;
|
|
|
|
public title: string;
|
|
|
|
public mediafile: File;
|
|
|
|
public media_url_prefix: string;
|
|
|
|
public uploader_id: number;
|
|
|
|
public filesize: string;
|
|
|
|
public hidden: boolean;
|
|
|
|
public timestamp: string;
|
2018-07-04 17:51:31 +02:00
|
|
|
|
2018-09-04 11:33:28 +02:00
|
|
|
public constructor(input?: any) {
|
2018-11-07 08:43:48 +01:00
|
|
|
super('mediafiles/mediafile', 'Mediafile', input);
|
2018-07-04 17:51:31 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 11:33:28 +02:00
|
|
|
public deserialize(input: any): void {
|
2018-07-12 14:11:31 +02:00
|
|
|
Object.assign(this, input);
|
2018-09-04 11:33:28 +02:00
|
|
|
this.mediafile = new File(input.mediafile);
|
2018-07-12 14:11:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-10 17:54:48 +01:00
|
|
|
/**
|
|
|
|
* Determine the downloadURL
|
|
|
|
*
|
|
|
|
* @returns the download URL for the specific file as string
|
|
|
|
*/
|
|
|
|
public getDownloadUrl(): string {
|
|
|
|
return `${this.media_url_prefix}${this.mediafile.name}`;
|
|
|
|
}
|
|
|
|
|
2018-09-13 09:23:57 +02:00
|
|
|
public getTitle(): string {
|
2018-09-13 07:57:38 +02:00
|
|
|
return this.title;
|
|
|
|
}
|
2018-11-07 08:43:48 +01:00
|
|
|
|
|
|
|
public formatForSearch(): string[] {
|
|
|
|
return [this.title, this.mediafile.name];
|
|
|
|
}
|
|
|
|
|
|
|
|
public getDetailStateURL(): string {
|
|
|
|
return this.getDownloadUrl();
|
|
|
|
}
|
2018-07-04 17:51:31 +02:00
|
|
|
}
|