import { MY_GROUPS } from '../routerLinks';
import { Component, OnInit } from '@angular/core';
import { ResourceService, NavigationHelperService, LayoutService } from '@sunbird/shared';
import { TelemetryService, IImpressionEventInput } from '@sunbird/telemetry';
import { ActivatedRoute, Router } from '@angular/router';
import * as _ from 'lodash-es';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { UtilService } from '../../../../../shared/services/util/util.service';
import { ElectronService } from '../../../../../core/services/electron/electron.service';
import { ConfigService } from '../../../../../shared/services/config/config.service';
@Component({
selector: 'app-explore-group',
templateUrl: './explore-group.component.html',
styleUrls: ['./explore-group.component.scss']
})
export class ExploreGroupComponent implements OnInit {
showWelcomePopup = true;
telemetryImpression: IImpressionEventInput;
layoutConfiguration;
isDesktopApp = false;
public unsubscribe$ = new Subject<void>();
constructor(
public resourceService: ResourceService, private activatedRoute: ActivatedRoute,
private telemetryService: TelemetryService, private router: Router,
private navigationhelperService: NavigationHelperService, public layoutService: LayoutService,
private utilService: UtilService, private electronService: ElectronService, private config: ConfigService
) { }
redirectTologin() {
if (this.isDesktopApp) {
this.electronService.get({ url: this.config.urlConFig.URLS.OFFLINE.LOGIN}).subscribe();
} else {
window.location.href = MY_GROUPS;
}
}
showFtuPopup(visibility: boolean = false) {
this.showWelcomePopup = visibility;
}
goBack() {
this.navigationhelperService.goBack();
}
ngOnInit() {
this.isDesktopApp = this.utilService.isDesktopApp;
this.showWelcomePopup = !localStorage.getItem('anonymous_ftu_groups');
this.initLayout();
this.telemetryImpression = {
context: {
env: _.get(this.activatedRoute, 'snapshot.data.telemetry.env')
},
edata: {
type: _.get(this.activatedRoute, 'snapshot.data.telemetry.type'),
pageid: _.get(this.activatedRoute, 'snapshot.data.telemetry.pageid'),
subtype: _.get(this.activatedRoute, 'snapshot.data.telemetry.subtype'),
uri: this.router.url,
duration: this.navigationhelperService.getPageLoadTime()
}
};
}
initLayout() {
this.layoutConfiguration = this.layoutService.initlayoutConfig();
this.layoutService.switchableLayout().
pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
if (layoutConfig != null) {
this.layoutConfiguration = layoutConfig.layout;
}
});
}
addTelemetry (id) {
const interactData = {
context: {
env: _.get(this.activatedRoute, 'snapshot.data.telemetry.env'),
cdata: []
},
edata: {
id: id,
type: 'click',
pageid: _.get(this.activatedRoute, 'snapshot.data.telemetry.pageid'),
},
};
this.telemetryService.interact(interactData);
}
ngOnDestroy() {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
}
<app-landing-section [textToDisplay]=""
[layoutConfiguration]="layoutConfiguration" [noTitle]="true"></app-landing-section>
<!-- welcome screen -->
<app-explore-ftu-popup *ngIf="showWelcomePopup" (close)="showFtuPopup(false)"></app-explore-ftu-popup>
<div [ngClass]="layoutConfiguration ? 'sb-back-actionbar mt-0' : 'sb-bg-white cc-player__btn-back'" class="relative position mt-0" [appTelemetryImpression]="telemetryImpression">
<div class="ui container d-flex flex-ai-center">
<button type="button" (click)="goBack()" [ngClass]="layoutConfiguration ? 'sb-btn-primary sb-btn-round' : 'sb-btn-link sb-btn-link-primary sb-left-icon-btn px-0'" class="sb-btn sb-btn-normal" tabindex="0" attr.aria-label=“{{resourceService?.frmelmnts?.btn?.back}}”><i
class="icon-svg icon-svg--xxs icon-back mr-4"><svg class="icon icon-svg--primary">
<use xlink:href="assets/images/sprite.svg#arrow-long-left"></use>
</svg></i><span>{{resourceService?.frmelmnts?.btn?.back}}</span> </button>
<div class="d-flex flex-ai-center flex-jc-space-between flex-w-wrap ml-16 w-100">
<div class="d-flex flex-dc ml-8">
<h4 class="mb-4 font-weight-bold sb__ellipsis sb__ellipsis--one d-flex">{{resourceService?.frmelmnts?.tab?.mygroups}}</h4>
<div class="fsmall"></div>
</div>
<div class="d-flex flex-ai-end flex-w-wrap content-header__buttons">
<button class="sb-btn sb-btn-normal sb-btn-link-primary min-w-auto p-0 px-8" aria-label="showFtuPopup" type="button" tabindex="0" (click)="showFtuPopup(true);addTelemetry('group-info')">
<i class="icon-svg icon-svg--sm icon-info"><svg class="icon icon-svg--primary">
<use xlink:href="./assets/images/sprite.svg#info"></use>
</svg></i>
</button>
</div>
</div>
</div>
</div>
<div [ngClass]="layoutConfiguration ? 'sbt-center-container sbt-groups-login sbt-fluid-content-bg pt-24' : ''">
<!-- login screen -->
<div class="flex-ai-jc-center mt-48 sb-group-container sb-group-container--sm">
<!-- content comes from CC -->
<img alt="{{ resourceService?.frmelmnts?.lbl?.loginToCreateGroup }}" src="./assets/images/mygroups.svg" width="220">
<div class="mt-8 fs-1">{{ resourceService?.frmelmnts?.lbl?.loginToCreateGroup }}</div>
<button class="sb-btn sb-btn-primary sb-btn-normal mt-16 mb-8 w-50" type="button" tabindex="0" (click)="redirectTologin();addTelemetry('group-login')">{{ resourceService?.frmelmnts?.btn?.login }}</button>
<!-- content comes from CC -->
</div>
</div>