Stefan Huber

chore: interface updated

...@@ -243,6 +243,8 @@ var PROGRAM_ITEM_TYPE_SLIDESHOW = "slideshow"; ...@@ -243,6 +243,8 @@ var PROGRAM_ITEM_TYPE_SLIDESHOW = "slideshow";
243 var PROGRAM_ITEM_TYPE_VIDEO = "video"; 243 var PROGRAM_ITEM_TYPE_VIDEO = "video";
244 var ProgramItem = (function () { 244 var ProgramItem = (function () {
245 function ProgramItem() { 245 function ProgramItem() {
246 + this._type = "";
247 + this._data = {};
246 } 248 }
247 Object.defineProperty(ProgramItem.prototype, "type", { 249 Object.defineProperty(ProgramItem.prototype, "type", {
248 get: function () { 250 get: function () {
...@@ -318,14 +320,16 @@ var ProgramItemFactory = (function () { ...@@ -318,14 +320,16 @@ var ProgramItemFactory = (function () {
318 var _this = this; 320 var _this = this;
319 return this._programRepository.findByIds(data.images) 321 return this._programRepository.findByIds(data.images)
320 .then(function (images) { 322 .then(function (images) {
321 - programItem.data = { 323 + programItem.data.speed = data.settings.speed;
322 - speed: data.settings.speed, 324 + programItem.data.effect = data.settings.effect;
323 - effect: data.settings.effect, 325 + programItem.data.images = [];
324 - images: [] 326 + if (images && images.length > 0) {
325 - }; 327 + for (var _i = 0, images_1 = images; _i < images_1.length; _i++) {
326 - for (var _i = 0, images_1 = images; _i < images_1.length; _i++) { 328 + var image = images_1[_i];
327 - var image = images_1[_i]; 329 + if (image && image.filename) {
328 - programItem.data.images.push(_this.basePath + image.filename); 330 + programItem.data.images.push(_this.basePath + image.filename);
331 + }
332 + }
329 } 333 }
330 return programItem; 334 return programItem;
331 }); 335 });
...@@ -334,9 +338,7 @@ var ProgramItemFactory = (function () { ...@@ -334,9 +338,7 @@ var ProgramItemFactory = (function () {
334 var _this = this; 338 var _this = this;
335 return this._programRepository.findById(data.video) 339 return this._programRepository.findById(data.video)
336 .then(function (data) { 340 .then(function (data) {
337 - programItem.data = { 341 + programItem.data.video = _this.basePath + data['filename'];
338 - video: _this.basePath + data['filename']
339 - };
340 return programItem; 342 return programItem;
341 }); 343 });
342 }; 344 };
......
This diff is collapsed. Click to expand it.
...@@ -2,7 +2,7 @@ interface ProgramRepository { ...@@ -2,7 +2,7 @@ interface ProgramRepository {
2 findById(id:string) : Promise<any>; 2 findById(id:string) : Promise<any>;
3 findByIds(ids:Array<string>) : Promise<Array<any>>; 3 findByIds(ids:Array<string>) : Promise<Array<any>>;
4 findByType(type:string) : Promise<Array<any>>; 4 findByType(type:string) : Promise<Array<any>>;
5 - replicate() : Promise<void>; 5 + replicate() : Promise<boolean>;
6 } 6 }
7 7
8 interface Player { 8 interface Player {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 "scripts": { 7 "scripts": {
8 "pretest": "tsc --target es5 --outDir .tmp spec/index.ts", 8 "pretest": "tsc --target es5 --outDir .tmp spec/index.ts",
9 "test": "jasmine .tmp/spec/index.js", 9 "test": "jasmine .tmp/spec/index.js",
10 - "posttest": "rm -R .tmp", 10 + "posttest": "rm -rf .tmp",
11 "build:tsc": "rollup -c rollup.config.js" 11 "build:tsc": "rollup -c rollup.config.js"
12 }, 12 },
13 "author": "Stefan Huber <stefan.huber@beyondit.at>", 13 "author": "Stefan Huber <stefan.huber@beyondit.at>",
......
...@@ -50,15 +50,17 @@ export class ProgramItemFactory { ...@@ -50,15 +50,17 @@ export class ProgramItemFactory {
50 prepareSlideshowItem(programItem:ProgramItem, data:any) : Promise<ProgramItem> { 50 prepareSlideshowItem(programItem:ProgramItem, data:any) : Promise<ProgramItem> {
51 return this._programRepository.findByIds(data.images) 51 return this._programRepository.findByIds(data.images)
52 .then(images => { 52 .then(images => {
53 - programItem.data = { 53 + programItem.data.speed = data.settings.speed;
54 - speed : data.settings.speed , 54 + programItem.data.effect = data.settings.effect;
55 - effect : data.settings.effect , 55 + programItem.data.images = [];
56 - images : []
57 - };
58 56
59 - for (let image of images) { 57 + if (images && images.length > 0) {
60 - programItem.data.images.push(this.basePath + image.filename); 58 + for (let image of images) {
61 - } 59 + if (image && image.filename) {
60 + programItem.data.images.push(this.basePath + image.filename);
61 + }
62 + }
63 + }
62 64
63 return programItem; 65 return programItem;
64 }); 66 });
...@@ -67,9 +69,7 @@ export class ProgramItemFactory { ...@@ -67,9 +69,7 @@ export class ProgramItemFactory {
67 prepareVideoItem(programItem:ProgramItem, data:any) : Promise<ProgramItem> { 69 prepareVideoItem(programItem:ProgramItem, data:any) : Promise<ProgramItem> {
68 return this._programRepository.findById(data.video) 70 return this._programRepository.findById(data.video)
69 .then((data) => { 71 .then((data) => {
70 - programItem.data = { 72 + programItem.data.video = this.basePath + data['filename'];
71 - video : this.basePath + data['filename']
72 - };
73 return programItem; 73 return programItem;
74 }); 74 });
75 } 75 }
......
...@@ -3,8 +3,8 @@ export const PROGRAM_ITEM_TYPE_VIDEO = "video"; ...@@ -3,8 +3,8 @@ export const PROGRAM_ITEM_TYPE_VIDEO = "video";
3 3
4 export class ProgramItem { 4 export class ProgramItem {
5 5
6 - protected _type:string; 6 + protected _type:string = "";
7 - protected _data:any; 7 + protected _data:any = {};
8 8
9 set type(t:string) { 9 set type(t:string) {
10 this._type = t; 10 this._type = t;
......