2018-07-23 16:42:17 +02:00
|
|
|
import { BaseModel } from '../base.model';
|
2018-07-12 14:11:31 +02:00
|
|
|
import { File } from './file';
|
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-07-04 17:51:31 +02:00
|
|
|
export class Mediafile extends BaseModel {
|
2018-07-12 14:11:31 +02:00
|
|
|
protected _collectionString: string;
|
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-08-29 13:21:25 +02:00
|
|
|
public constructor(
|
2018-07-12 14:11:31 +02:00
|
|
|
id?: number,
|
|
|
|
title?: string,
|
|
|
|
mediafile?: File,
|
|
|
|
media_url_prefix?: string,
|
|
|
|
uploader_id?: number,
|
2018-07-04 17:51:31 +02:00
|
|
|
filesize?: string,
|
|
|
|
hidden?: boolean,
|
2018-07-12 14:11:31 +02:00
|
|
|
timestamp?: string
|
2018-07-04 17:51:31 +02:00
|
|
|
) {
|
2018-07-12 14:11:31 +02:00
|
|
|
super();
|
|
|
|
this._collectionString = 'mediafiles/mediafile';
|
|
|
|
this.id = id;
|
|
|
|
this.title = title;
|
|
|
|
this.mediafile = mediafile;
|
|
|
|
this.media_url_prefix = media_url_prefix;
|
|
|
|
this.uploader_id = uploader_id;
|
2018-07-04 17:51:31 +02:00
|
|
|
this.filesize = filesize;
|
|
|
|
this.hidden = hidden;
|
|
|
|
this.timestamp = timestamp;
|
|
|
|
}
|
|
|
|
|
2018-08-29 13:21:25 +02:00
|
|
|
public deserialize(input: any): this {
|
2018-07-12 14:11:31 +02:00
|
|
|
Object.assign(this, input);
|
|
|
|
this.mediafile = new File().deserialize(input.mediafile);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-08-29 13:21:25 +02:00
|
|
|
public getUploader(): BaseModel | BaseModel[] {
|
2018-07-12 14:11:31 +02:00
|
|
|
return this.DS.get('users/user', this.uploader_id);
|
2018-07-04 17:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-24 13:05:03 +02:00
|
|
|
|
|
|
|
BaseModel.registerCollectionElement('amediafiles/mediafile', Mediafile);
|