src/app/app-component.ts
selector | app-root |
templateUrl | ./app-component.html |
constructor(router: Router, localStorage: LocalStorage, commBroker: CommBroker, rp: RedPepperService, authService: AuthService, yp: YellowPepperService, activatedRoute: ActivatedRoute, vRef: ViewContainerRef, titleService: Title, eventManager: EventManager, toastr: ToastsManager)
|
Defined in src/app/app-component.ts:67
|
ngOnInit |
ngOnInit()
|
Defined in src/app/app-component.ts:112
|
Returns :
void
|
_onMenuIcon |
_onMenuIcon(icon: any, event: any)
|
Defined in src/app/app-component.ts:134
|
Returns :
void
|
saveAndRestartPrompt |
saveAndRestartPrompt(i_callBack: any)
|
Defined in src/app/app-component.ts:169
|
Save and serialize configuration to remote mediaSERVER> Save and restart will check if
Parameters :
Returns :
void
|
ngAfterViewInit |
ngAfterViewInit()
|
Defined in src/app/app-component.ts:208
|
Returns :
void
|
_onLocaleChanged |
_onLocaleChanged(i_localSelected: any)
|
Defined in src/app/app-component.ts:213
|
Returns :
void
|
Protected listenAppStateChange |
listenAppStateChange()
|
Defined in src/app/app-component.ts:219
|
Returns :
void
|
Protected save |
save(i_cb: () => void)
|
Defined in src/app/app-component.ts:281
|
Returns :
void
|
Protected viewMode |
viewMode(i_mode: MainAppShowModeEnum)
|
Defined in src/app/app-component.ts:297
|
Returns :
void
|
Protected checkPlatform |
checkPlatform()
|
Defined in src/app/app-component.ts:319
|
Returns :
void
|
Protected listenUpgradeEnterpris |
listenUpgradeEnterpris()
|
Defined in src/app/app-component.ts:335
|
Returns :
void
|
Protected listenSaves |
listenSaves()
|
Defined in src/app/app-component.ts:342
|
Returns :
void
|
Static appResized |
appResized()
|
Defined in src/app/app-component.ts:349
|
Returns :
void
|
Protected listenRouterUpdateTitle |
listenRouterUpdateTitle()
|
Defined in src/app/app-component.ts:370
|
Returns :
void
|
demoModeMsg |
demoModeMsg: |
Default value : Sorry cannot save while in demo mode, <a href="https://secure.digitalsignage.com/msgetstarted/#selectStudioLite">please open a new FREE account</a> to be able to use all features...
|
Defined in src/app/app-component.ts:67
|
isBrandingDisabled |
isBrandingDisabled: |
Default value : false
|
Defined in src/app/app-component.ts:66
|
localSelector |
localSelector: |
Decorators : ViewChild
|
Defined in src/app/app-component.ts:110
|
m_hidden |
m_hidden: |
Default value : false
|
Defined in src/app/app-component.ts:60
|
m_localSelected |
m_localSelected: |
Defined in src/app/app-component.ts:61
|
m_logoutState |
m_logoutState: |
Defined in src/app/app-component.ts:64
|
m_showMode |
m_showMode: |
Defined in src/app/app-component.ts:59
|
m_ShowModeEnum |
m_ShowModeEnum: |
Default value : MainAppShowModeEnum
|
Defined in src/app/app-component.ts:58
|
modal |
modal: |
Decorators : ViewChild
|
Defined in src/app/app-component.ts:104
|
modalLocale |
modalLocale: |
Decorators : ViewChild
|
Defined in src/app/app-component.ts:107
|
ngVersion |
ngVersion: |
Defined in src/app/app-component.ts:56
|
offlineDevMode |
offlineDevMode: |
Defined in src/app/app-component.ts:57
|
productName |
productName: |
Default value : Studio-Lite
|
Defined in src/app/app-component.ts:65
|
syncOnSave |
syncOnSave: |
Default value : false
|
Defined in src/app/app-component.ts:63
|
version |
version: |
Defined in src/app/app-component.ts:55
|
import {AfterViewInit, Component, VERSION, ViewChild, ViewContainerRef} from "@angular/core";
import "rxjs/add/operator/catch";
import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
import {CommBroker} from "../services/CommBroker";
import {EventManager, Title} from "@angular/platform-browser";
import {ToastsManager} from "ng2-toastr";
import {Observable} from "rxjs";
import * as packageJson from "../../package.json";
import {AuthService} from "../services/AuthService";
import {LocalStorage} from "../services/LocalStorage";
import {YellowPepperService} from "../services/yellowpepper.service";
import {RedPepperService} from "../services/redpepper.service";
import {IUiState} from "../store/store.data";
import {ACTION_LIVELOG_UPDATE, ACTION_UISTATE_UPDATE} from "../store/actions/appdb.actions";
import {ModalComponent} from "ng2-bs3-modal/ng2-bs3-modal";
import {Map, List} from 'immutable';
import {Consts} from "../interfaces/Consts";
import {animate, state, style, transition, trigger} from "@angular/animations";
import * as moment from 'moment'
import {LiveLogModel} from "../models/live-log-model";
import {LocaleSelector} from "./locale-selector/local-selector";
enum MainAppShowModeEnum {
MAIN,
SAVE,
PREVIEW,
LOGOUT
}
export enum MainAppShowStateEnum {
INIT,
NORMAL,
SAVE,
SAVING,
SAVE_AND_PREVIEW,
SAVED,
GOODBYE
}
@Component({
selector: 'app-root',
templateUrl: './app-component.html',
animations: [
trigger('logoutState', [
state('active', style({
transform: 'scale(2)',
alpha: 0
})),
transition('* => active', animate('1000ms ease-out'))
])
]
})
export class AppComponent implements AfterViewInit {
version: string;
ngVersion: string;
offlineDevMode: any = window['offlineDevMode'];
m_ShowModeEnum = MainAppShowModeEnum;
m_showMode: any = MainAppShowModeEnum.MAIN;
m_hidden = false;
m_localSelected;
// isBrandingDisabled: Observable<boolean>;
syncOnSave = false;
m_logoutState = '';
productName = 'Studio-Lite';
isBrandingDisabled: boolean = false;
demoModeMsg = `Sorry cannot save while in demo mode, <a href="https://secure.digitalsignage.com/msgetstarted/#selectStudioLite">please open a new FREE account</a> to be able to use all features...`;
constructor(private router: Router,
private localStorage: LocalStorage,
private commBroker: CommBroker,
private rp: RedPepperService,
private authService: AuthService,
private yp: YellowPepperService,
private activatedRoute: ActivatedRoute,
private vRef: ViewContainerRef,
private titleService: Title,
private eventManager: EventManager,
private toastr: ToastsManager) {
// this.version = packageJson.version;
// this.ngVersion = VERSION.full
// this.localStorage.removeItem('remember_me')
// this.localStorage.removeItem('business_id')
// this.localStorage.removeItem('no_show_limited')
this.checkPlatform();
this.listenAppStateChange();
this.toastr.setRootViewContainerRef(vRef);
this.listenRouterUpdateTitle();
this.listenUpgradeEnterpris();
this.listenSaves();
this.appResized();
Observable.fromEvent(window, 'resize').debounceTime(250)
.subscribe(() => {
this.appResized();
}, (e) => {
console.error(e)
});
}
@ViewChild('modalProUpgrade')
modal: ModalComponent;
@ViewChild('modalLocale')
modalLocale: ModalComponent;
@ViewChild('localSelector')
localSelector: LocaleSelector;
ngOnInit() {
this.yp.isBrandingDisabled()
.subscribe((v) => {
this.isBrandingDisabled = v;
if (!this.isBrandingDisabled)
this.productName = this.rp.getUserData().resellerName;
}, (e) => console.error(e));
let s = this.router.events
.subscribe((val) => {
if (val instanceof NavigationEnd) {
if (val.url.indexOf('data') > -1 || val.url.indexOf('remoteStatus') > -1) {
this.router.navigate(['/FasterqTerminal', val.url.split('?')[1]]);
} else {
this.authService.start();
}
s.unsubscribe();
}
}, (e) => console.error(e));
}
_onMenuIcon(icon, event) {
event.stopImmediatePropagation();
event.preventDefault();
switch (icon) {
case 'web': {
window.open('http://www.digitalsignage.com', '_blank');
break;
}
case 'chat': {
window.open('http://www.digitalsignage.com/_html/live_chat.html', '_blank');
break;
}
case 'upgrade': {
this.modal.open();
break;
}
case 'save': {
this.saveAndRestartPrompt(() => {
})
break;
}
case 'locale': {
this.modalLocale.open();
break;
}
}
}
/**
Save and serialize configuration to remote mediaSERVER> Save and restart will check if
the Stations module has been loaded and if no connected stations are present, it will NOT
prompt for option to restart station on save, otherwise it will.
@method saveAndRestartPrompt
@param {Function} call back after save
**/
saveAndRestartPrompt(i_callBack) {
bootbox.dialog({
message: 'Restart connected stations and apply your saved work?',
title: 'Save work to remote server',
buttons: {
success: {
label: 'OK',
className: "btn-success",
callback: () => {
let uiState: IUiState = {mainAppState: MainAppShowStateEnum.SAVE}
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
this.yp.dispatch(({type: ACTION_LIVELOG_UPDATE, payload: new LiveLogModel({event: 'app saved'})}));
}
},
danger: {
label: 'Save & restart stations',
className: "btn-success",
callback: () => {
// reboot will reboot the PC or exits presentation android
// pepper.sendCommand('rebootStation', -1, function () {});
// reboot player exits player
// pepper.sendCommand('rebootPlayer', -1, function () {
// sync and restart does a fast / soft restart of player
this.syncOnSave = true;
let uiState: IUiState = {mainAppState: MainAppShowStateEnum.SAVE}
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
this.yp.dispatch(({type: ACTION_LIVELOG_UPDATE, payload: new LiveLogModel({event: 'app saved and restarting all stations'})}));
}
},
main: {
label: 'Cancel',
callback: () => {
return;
}
}
}
});
}
ngAfterViewInit() {
let uiState: IUiState = {mainAppState: MainAppShowStateEnum.NORMAL}
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
}
_onLocaleChanged(i_localSelected) {
this.m_localSelected = i_localSelected;
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: {mainAppState: MainAppShowStateEnum.SAVE}}));
this.modalLocale.close();
}
private listenAppStateChange() {
this.yp.listenMainAppState()
.subscribe((i_value: MainAppShowStateEnum) => {
switch (i_value) {
case MainAppShowStateEnum.SAVE_AND_PREVIEW: {
if (this.rp.getUserData().businessID == 459848) {
this.viewMode(MainAppShowModeEnum.MAIN);
const uiState: IUiState = {mainAppState: MainAppShowStateEnum.NORMAL};
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}));
return bootbox.alert(this.demoModeMsg);
}
this.save(() => {
this.yp.dispatch(({type: ACTION_LIVELOG_UPDATE, payload: new LiveLogModel({event: 'loading preview'})}));
this.viewMode(MainAppShowModeEnum.PREVIEW);
});
break;
}
case MainAppShowStateEnum.NORMAL: {
this.viewMode(MainAppShowModeEnum.MAIN);
break;
}
case MainAppShowStateEnum.SAVED: {
con('Saved to server');
if (this.syncOnSave)
this.rp.sendCommand('syncAndStart', -1, () => {
});
this.syncOnSave = false;
const uiState: IUiState = {appSaved: moment().format('h:mm:ss')};
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}));
if (this.m_localSelected)
this.localSelector.redirect(this.m_localSelected)
break;
}
case MainAppShowStateEnum.GOODBYE: {
con('Goodbye');
this.m_logoutState = 'active'
this.viewMode(MainAppShowModeEnum.LOGOUT);
break;
}
case MainAppShowStateEnum.SAVE: {
if (this.rp.getUserData().businessID == 459848) {
this.viewMode(MainAppShowModeEnum.MAIN);
const uiState: IUiState = {mainAppState: MainAppShowStateEnum.NORMAL};
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}));
return bootbox.alert(this.demoModeMsg);
}
this.save(() => {
this.viewMode(MainAppShowModeEnum.MAIN);
const uiState: IUiState = {mainAppState: MainAppShowStateEnum.NORMAL};
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}));
});
break;
}
}
}, (e) => console.error(e))
}
private save(i_cb: () => void) {
this.viewMode(MainAppShowModeEnum.SAVE);
let uiState: IUiState = {mainAppState: MainAppShowStateEnum.SAVING}
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
this.rp.save((result) => {
if (result.status == true) {
this.rp.reduxCommit(null, true)
let uiState: IUiState = {mainAppState: MainAppShowStateEnum.SAVED}
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
i_cb();
} else {
alert('error ' + JSON.stringify(result));
}
})
}
private viewMode(i_mode: MainAppShowModeEnum) {
this.m_showMode = i_mode;
switch (i_mode) {
case MainAppShowModeEnum.MAIN: {
this.m_hidden = false;
break;
}
case MainAppShowModeEnum.PREVIEW: {
this.m_hidden = true;
break;
}
case MainAppShowModeEnum.SAVE: {
this.m_hidden = true;
break;
}
case MainAppShowModeEnum.LOGOUT: {
this.m_hidden = true;
break;
}
}
}
private checkPlatform() {
switch (platform.name.toLowerCase()) {
case 'microsoft edge': {
// alert(`${platform.name} browser not supported at this time, please use Google Chrome`);
break;
}
case 'chrome': {
break;
}
default: {
// alert('for best performance please use Google Chrome');
break;
}
}
}
private listenUpgradeEnterpris() {
this.commBroker.onEvent(Consts.Events().UPGRADE_ENTERPRISE)
.subscribe((v) => {
this.modal.open();
}, (e) => console.error(e));
}
private listenSaves() {
this.eventManager.addGlobalEventListener('window', 'keydown.control.s', (event) => {
event.preventDefault();
this.yp.ngrxStore.dispatch(({type: ACTION_UISTATE_UPDATE, payload: {mainAppState: MainAppShowStateEnum.SAVE}}));
})
}
public appResized(): void {
var appHeight = document.body.clientHeight;
var appWidth = document.body.clientWidth;
var uiState: IUiState = {appSized: Map({width: appWidth, height: appHeight})}
this.yp.dispatch(({type: ACTION_UISTATE_UPDATE, payload: uiState}))
this.commBroker.setValue(Consts.Values().APP_SIZE, {
height: appHeight,
width: appWidth
});
this.commBroker.fire({
fromInstance: self,
event: Consts.Events().WIN_SIZED,
context: '',
message: {
height: appHeight,
width: appWidth
}
})
}
private listenRouterUpdateTitle() {
this.router.events
.filter(event => event instanceof NavigationEnd)
.map(() => this.activatedRoute)
.map(route => {
while (route.firstChild) {
route = route.firstChild
}
return route;
}).filter(route => route.outlet === 'primary')
.mergeMap(route => route.data)
.subscribe((event) => {
this.titleService.setTitle(event['title'])
}, (e) => console.error(e));
}
}
<div id="domRoot" [ngClass]="{hidden: m_hidden}">
<div id="headerPad"></div>
<nav id="fileMenu" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="pull-left" id="angularText" style="color: ghostwhite; padding-top: 5px; padding-left: 10px">
<Logo class="pull-left" *ngIf="isBrandingDisabled" style="padding-left: 5px; padding-top: 5px"></Logo>
<reseller-logo class="pull-left" *ngIf="!isBrandingDisabled" style="padding-left: 5px; padding-top: 5px"></reseller-logo>
<span class="pull-left" style="padding-top: 4px; padding-left: 4px">
<span style="font-size: 1.4em">{{productName}}</span>
<!--<label [ngClass]="{offline: offlineDevMode}" style="padding-left: 20px; font-size: 10px; color: gray; font-family: Arial">version {{version}} | angular build {{ngVersion}} | {{offlineDevMode==true ? 'offline' : 'online'}}</label>-->
</span>
<div class="clearfix"></div>
</span>
</div>
<div id="appNavigatorComp" class="noCollapsing collapse navbar-collapse" id="bs-example-navbar-collapse-1">>
<ng-menu [routePrefix]="'App1'" [fileMenuMode]="false">
<ng-menu-item [fontawesome]="'fa-dashboard'" i18n-title name="Dashboard" title="Dashboard"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-navicon'" i18n-title name="Campaigns" title="Campaigns"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-certificate'" i18n-title name="Resources" title="Resources"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-edit'" i18n-title name="Scenes" title="Scenes"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-laptop'" i18n-title name="Stations" title="Stations"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-group'" i18n-title name="Fasterq" title="Fasterq"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-heart'" i18n-title name="Help" title="Help"></ng-menu-item>
<ng-menu-item *ngIf="isBrandingDisabled" [fontawesome]="'fa-laptop'" i18n-title name="Install" title="Install"></ng-menu-item>
<!--<ng-menu-item [fontawesome]="'fa-cog'" name="Settings" title="'Settings'"></ng-menu-item>-->
<ng-menu-item [fontawesome]="'fa-cloud-upload'" i18n-title name="Studiopro" title="Studiopro"></ng-menu-item>
<ng-menu-item [fontawesome]="'fa-power-off'" i18n-title name="Logout" title="Logout"></ng-menu-item>
</ng-menu>
<ul style="height: 20px" class="nav navbar-nav navbar-right noCollapsing">
<li>
<a i18n-title title="upgrade" style="padding-bottom: 0px; margin-bottom: 0px" (click)="_onMenuIcon('upgrade',$event)" *ngIf="isBrandingDisabled" class="showUpgradeModal reshid" href="#"><i style="color: red" class="faHeader fa fa-cloud-upload"></i></a>
</li>
<li>
<a i18n-title title="Cont-S" style="padding-bottom: 0px; margin-bottom: 0px" (click)="_onMenuIcon('save',$event)" href="#"><i style="color: greenyellow" class="faHeader fa fa-save"></i></a>
</li>
<li>
<a i18n-title title="language" style="padding-bottom: 0px; margin-bottom: 0px" (click)="_onMenuIcon('locale',$event)" href="#"><i class="faHeader fa fa-question-circle"></i></a>
</li>
<li>
<a i18n-title title="live chat" (click)="_onMenuIcon('chat',$event)" *ngIf="isBrandingDisabled" class="reshid" id="liveChat" href="#"><i class="faHeader fa fa-comments-o"></i></a>
</li>
<li style="padding-right: 20px">
<a i18n-title title="web site" style="padding-bottom: 0px; margin-bottom: 0px" (click)="_onMenuIcon('web',$event)" *ngIf="isBrandingDisabled" href="#"><i class="faHeader fa fa-globe"></i></a>
</li>
<!--<li style="padding-right: 20px">-->
<!--<a (click)="_onMenuIcon('dash',$event)" id="dashboard" href="#"><i class="faHeader fa fa-dashboard"></i></a>-->
<!--</li>-->
</ul>
</div>
</nav>
<div id="appEntry">
<router-outlet></router-outlet>
<div id="waitScreenEntryApp" style="display: none">
<span style="position: absolute; left: 45%; top: 20%"> <img src="./assets/preload5.gif"> </span>
</div>
<div id="appLogout" style="display: none"> <span style="position: absolute; left: 40%; top: 20%">
<h3 data-localize="haveNiceDay">Have a nice day :)</h3>
</span>
</div>
<div id="appSelector" class="noScroll container" style="display: none">
<div align="center" style="padding-top: 100px">
<button type="button" name="mailWasp" class="btn btn-default">
<i style="margin: 20px; padding: 20px; font-size: 5em" class="fa fa-envelope"></i>
<span data-localize="none"></span>
</button>
<button type="button" name="everNodes" class="btn btn-default">
<i style="margin: 20px; padding: 20px ; font-size: 5em" class="fa fa-sitemap"></i>
<span data-localize="none"></span>
</button>
</div>
</div>
<div id="appMailWaspContent" class="noScroll container" style="display: none"></div>
<div id="appEverNodesContent" class="noScroll container" style="display: none"></div>
</div>
</div>
<div *ngIf="m_showMode == m_ShowModeEnum.SAVE">
<loading [style]="{'margin-top': '150px'}"></loading>
<h5 style="text-align: center; margin-top: 20px" i18n>loading...</h5>
</div>
<div [@logoutState]="m_logoutState" *ngIf="m_showMode == m_ShowModeEnum.LOGOUT">
<h1 style="text-align: center; margin-top: 200px"><span i18n>have a nice day </span></h1>
<h1 style="text-align: center"><i class="fa fa-smile-o"></i></h1>
</div>
<live-preview *ngIf="m_showMode == m_ShowModeEnum.PREVIEW"></live-preview>
<modal #modalProUpgrade>
<modal-header [show-close]="true">
<h4 i18n class="modal-title">Upgrade to Enterprise - $99.00 per month</h4>
</modal-header>
<modal-body>
<pro-upgrade></pro-upgrade>
</modal-body>
<modal-footer [show-default-buttons]="false"></modal-footer>
</modal>
<modal #modalLocale>
<modal-header [show-close]="true">
<h4 i18n class="modal-title">Pick your language</h4>
</modal-header>
<modal-body>
<locale-selector #localSelector (onLocaleChanged)="_onLocaleChanged($event)" [orientation]="'modal'"></locale-selector>
</modal-body>
<modal-footer [show-default-buttons]="false"></modal-footer>
</modal>