src/app/campaigns/campaign-layout.ts
Compbaser
selector | campaign-layout |
styles |
:host /deep/ .svgSD {
cursor: pointer;
}
|
template |
|
mouseHoverEffect
|
|
Defined in src/app/campaigns/campaign-layout.ts:66
|
onNewCampaignMode
|
|
Defined in src/app/campaigns/campaign-layout.ts:71
|
onSelection
|
$event type: EventEmitter<IScreenTemplateData>
|
Defined in src/app/campaigns/campaign-layout.ts:100
|
constructor(yp: YellowPepperService, rp: RedPepperService)
|
Defined in src/app/campaigns/campaign-layout.ts:42
|
ngAfterViewInit |
ngAfterViewInit()
|
Defined in src/app/campaigns/campaign-layout.ts:48
|
Returns :
void
|
Protected getNewCampaignParams |
getNewCampaignParams()
|
Decorators : Once
|
Defined in src/app/campaigns/campaign-layout.ts:76
|
Returns :
void
|
Protected _render |
_render()
|
Defined in src/app/campaigns/campaign-layout.ts:103
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in src/app/campaigns/campaign-layout.ts:120
|
Returns :
void
|
destroy |
destroy()
|
Defined in src/app/campaigns/campaign-layout.ts:123
|
Returns :
void
|
_nextClick |
_nextClick: |
Defined in src/app/campaigns/campaign-layout.ts:37
|
m_addToExistingCampaignMode |
m_addToExistingCampaignMode: |
Default value : false
|
Defined in src/app/campaigns/campaign-layout.ts:38
|
m_campaignName |
m_campaignName: |
Defined in src/app/campaigns/campaign-layout.ts:40
|
m_mouseHoverEffect |
m_mouseHoverEffect: |
Default value : false
|
Defined in src/app/campaigns/campaign-layout.ts:42
|
m_onNewCampaignMode |
m_onNewCampaignMode: |
Defined in src/app/campaigns/campaign-layout.ts:41
|
Protected m_orientation |
m_orientation: |
Defined in src/app/campaigns/campaign-layout.ts:36
|
Protected m_resolution |
m_resolution: |
Defined in src/app/campaigns/campaign-layout.ts:34
|
m_screenLayouts |
m_screenLayouts: |
Defined in src/app/campaigns/campaign-layout.ts:39
|
Protected m_screenTemplateData |
m_screenTemplateData: |
Defined in src/app/campaigns/campaign-layout.ts:35
|
import {Component, EventEmitter, Input, Output} from "@angular/core";
import {Compbaser} from "ng-mslib";
import * as screenTemplates from "../../libs/screen-templates.json";
import * as _ from "lodash";
import {OrientationEnum} from "./campaign-orientation";
import {Observable, Observer} from "rxjs";
import {Once} from "../../decorators/once-decorator";
import {IUiStateCampaign} from "../../store/store.data";
import {YellowPepperService} from "../../services/yellowpepper.service";
import {RedPepperService} from "../../services/redpepper.service";
import {IScreenTemplateData} from "../../interfaces/IScreenTemplate";
import {ACTION_LIVELOG_UPDATE} from "../../store/actions/appdb.actions";
import {LiveLogModel} from "../../models/live-log-model";
@Component({
selector: 'campaign-layout',
styles: [`
:host /deep/ .svgSD {
cursor: pointer;
}
`],
template: `
<small class="debug">{{me}}</small>
<h4 i18n>screen layout</h4>
<div id="screenLayoutList" style="min-width: 500px; min-height: 500px">
<div (click)="_nextClick.next(screenLayout)" style="float: left; padding: 20px" *ngFor="let screenLayout of m_screenLayouts">
<screen-template [mouseHoverEffect]="m_mouseHoverEffect" [setTemplate]="screenLayout"></screen-template>
</div>
</div>
`
})
export class CampaignLayout extends Compbaser {
private m_resolution: string;
private m_screenTemplateData: IScreenTemplateData;
private m_orientation: OrientationEnum;
_nextClick: Observer<any>;
m_addToExistingCampaignMode = false;
m_screenLayouts: Array<IScreenTemplateData>;
m_campaignName: string;
m_onNewCampaignMode: boolean;
m_mouseHoverEffect:boolean = false;
constructor(private yp: YellowPepperService, private rp: RedPepperService) {
super();
}
ngAfterViewInit() {
this.getNewCampaignParams();
this.cancelOnDestroy(
Observable.create(observer => {
this._nextClick = observer
}).map((i_screenTemplateData: IScreenTemplateData) => {
this.m_screenTemplateData = i_screenTemplateData;
return i_screenTemplateData;
})
.debounceTime(200)
.do(() => {
this.onSelection.emit(this.m_screenTemplateData)
}).subscribe(() => {
}, (e) => console.error(e))
)
}
@Input()
set mouseHoverEffect(i_value) {
this.m_mouseHoverEffect = i_value;
}
@Input()
set onNewCampaignMode(i_value: boolean) {
this.m_onNewCampaignMode = i_value;
}
@Once()
private getNewCampaignParams() {
return this.yp.getNewCampaignParmas()
.subscribe((value: IUiStateCampaign) => {
if (this.m_onNewCampaignMode) {
this.m_addToExistingCampaignMode = false;
this.m_resolution = value.campaignCreateResolution;
this.m_orientation = value.campaignCreateOrientation;
this.m_campaignName = value.campaignCreateName;
this.yp.dispatch(({type: ACTION_LIVELOG_UPDATE, payload: new LiveLogModel({event: 'campaign created ' + this.m_campaignName})}));
} else {
this.m_addToExistingCampaignMode = true;
var recBoard = this.rp.getGlobalBoardFromCampaignId(value.campaignSelected)
var h = parseInt(recBoard.board_pixel_height);
var w = parseInt(recBoard.board_pixel_width);
this.m_resolution = `${w}x${h}`;
this.m_orientation = w > h ? OrientationEnum.HORIZONTAL : OrientationEnum.VERTICAL;
this.m_campaignName = '';
}
this._render();
}, (e) => console.error(e))
}
@Output()
onSelection: EventEmitter<IScreenTemplateData> = new EventEmitter<IScreenTemplateData>();
private _render() {
if (_.isUndefined(this.m_orientation) || _.isUndefined(this.m_resolution))
return;
this.m_screenLayouts = [];
for (var screenType in screenTemplates[this.m_orientation][this.m_resolution]) {
var screenTemplateData: IScreenTemplateData = {
orientation: this.m_orientation,
resolution: this.m_resolution,
screenType: screenType,
screenProps: screenTemplates[this.m_orientation][this.m_resolution][screenType],
scale: 14,
name: this.m_campaignName
};
this.m_screenLayouts.push(screenTemplateData);
}
}
ngOnInit() {
}
destroy() {
}
}