File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-core-lib/src/lib/components/tibco-cloud-setting-landing/tibco-cloud-setting-landing.component.ts

Description

Configuration page home

Implements

OnInit

Example

<tc-tibco-cloud-setting-landing></tc-tibco-cloud-setting-landing>

Metadata

selector tc-tibco-cloud-setting-landing
styleUrls ./tibco-cloud-setting-landing.component.css
templateUrl ./tibco-cloud-setting-landing.component.html

Index

Properties
Methods

Constructor

constructor(route: ActivatedRoute, generalLandingPageConfigService: TcGeneralLandingPageConfigService, snackBar: MatSnackBar, dialog: MatDialog)
Parameters :
Name Type Optional
route ActivatedRoute No
generalLandingPageConfigService TcGeneralLandingPageConfigService No
snackBar MatSnackBar No
dialog MatDialog No

Methods

runDeleteConfiguration
runDeleteConfiguration()

Delete Configuration

Returns : void
runSaveFunction
runSaveFunction()

Save Configuration

Returns : void

Properties

Public allRoles
Type : RoleAttribute[]
Private claims
Type : Claim
compareObjects
Default value : () => {...}

Helper to Compare Objects

Public landingPages
Type : LandingPageConfig[]
Private landingPagesConfig
Type : GeneralLandingPageConfig
runNewConfiguration
Default value : () => {...}

New Configuration

Private sandboxId
Type : number
Public selectedRole
Type : RoleAttribute[]
Public selectedWelcomePage
Type : LandingPageConfig
Private uiAppId
Type : string
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { LandingPageConfig, LandingPageItemConfig, GeneralLandingPageConfig } from '../../models/tc-general-landing-page-config';
import { TcGeneralLandingPageConfigService } from '../../services/tc-general-landing-page-config.service';
import { Claim } from '../../models/tc-login';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { TibcoCloudNewElementComponent } from '../tibco-cloud-new-element/tibco-cloud-new-element.component';
import { RoleAttribute } from '../../models/tc-general-config';

/**
 * Configuration page home
 *
 *@example <tc-tibco-cloud-setting-landing></tc-tibco-cloud-setting-landing>
 */
@Component({
  selector: 'tc-tibco-cloud-setting-landing',
  templateUrl: './tibco-cloud-setting-landing.component.html',
  styleUrls: ['./tibco-cloud-setting-landing.component.css']
})
export class TibcoCloudSettingLandingComponent implements OnInit {

    private claims: Claim;
    private landingPagesConfig: GeneralLandingPageConfig;
    private sandboxId: number;
    private uiAppId: string;

    public landingPages: LandingPageConfig[];
    public selectedWelcomePage: LandingPageConfig;
    public allRoles: RoleAttribute[];
    public selectedRole: RoleAttribute[];

    constructor(
        private route: ActivatedRoute,
        private generalLandingPageConfigService: TcGeneralLandingPageConfigService,
        private snackBar: MatSnackBar,
        private dialog: MatDialog
    ) { }

    /**
    * @ignore
    */
    ngOnInit() {
        this.landingPagesConfig = this.route.snapshot.data.landingPagesConfigHolder;
        this.landingPages = this.landingPagesConfig.landingPage;
        this.allRoles = this.route.snapshot.data.allRolesHolder.roles.filter(element => !element.configuration);

        this.sandboxId = this.route.snapshot.data.claims.primaryProductionSandbox.id;
        this.uiAppId = this.route.snapshot.data.landingPagesConfigHolder.uiAppId;

        // If there is only one landing page selects it automatically
        if (this.landingPages.length == 1) {
            this.selectedWelcomePage = this.landingPages[0];
        }
    }

    /**
     * Save Configuration
     */
    runSaveFunction(){
        this.generalLandingPageConfigService.updateGeneralLandingPageConfig(this.sandboxId, this.uiAppId, this.landingPagesConfig, this.landingPagesConfig.id).subscribe(
            result => {
                this.snackBar.open('Landing Pages configuration saved', 'OK', {
                    duration: 3000
                });
            },
            err => {
                this.snackBar.open('Error saving Landing Pages configuration', 'OK', {
                    duration: 3000
                });
            }
        );
    }

    /**
     * Delete Configuration
     */
    runDeleteConfiguration(){
        const pages = this.landingPages;
        pages.forEach(element => {
            if (element == this.selectedWelcomePage){
                const index = pages.indexOf(element, 0);
                pages.splice(index, 1);
                this.selectedWelcomePage = undefined;
            }
        });
    }

    /**
     * New Configuration
     */
    runNewConfiguration = ():void => {

        const dialogRef = this.dialog.open(TibcoCloudNewElementComponent, {
            width: '50%',
            height: '30%',
            maxWidth: '100vw',
            maxHeight: '100vh',
            panelClass: 'tcs-style-dialog',
            data: { resourceType: 'Landing Page' }
        });

        dialogRef.afterClosed().subscribe(result => {
            if (result) {
                const newElement = new LandingPageConfig().deserialize({
                    key: result.id,
                    description: result.name,
                    highlights: [new LandingPageItemConfig(), new LandingPageItemConfig(), new LandingPageItemConfig()]
                });

                this.landingPages.push(newElement);
                this.selectedWelcomePage = newElement;
            }
        });
    }

    /**
     * Helper to Compare Objects
     */
    compareObjects = (o1: string, o2: string): boolean => {
        return o1 === o2;
    }

}
<div fxLayout="column" fxFill>
    <tc-tibco-cloud-widget-header style="height: 40px;" [icon]="'tcs-capabilities'"
        [headerText]="'Landing Page Configuration'"></tc-tibco-cloud-widget-header>
    <div fxFlex style="padding: 20px; overflow: hidden" fxLayout="column">
        <div style="overflow: auto;">
            <div fxLayout="column" fxFlex>
                <p>You can manage the configuration for the landing pages here.</p>
                <br>
                <mat-form-field>
                    <mat-label>Welcome Page Configuration</mat-label>
                    <mat-select [(value)]="selectedWelcomePage">
                        <mat-option *ngFor="let landingPage of landingPages" [value]="landingPage">
                            {{landingPage.key}}-{{landingPage.description}}
                        </mat-option>
                    </mat-select>
                </mat-form-field>

                <div *ngIf="selectedWelcomePage">
                    <div fxLayoutGap="10px">
                        <mat-form-field fxFlex="50">
                            <input matInput placeholder="Title" [(ngModel)]="selectedWelcomePage.title">
                        </mat-form-field>
                        <mat-form-field fxFlex="50">
                            <input matInput placeholder="Subtitle" [(ngModel)]="selectedWelcomePage.subtitle">
                        </mat-form-field>
                    </div>
                    <div fxLayoutGap="10px">
                        <mat-form-field fxFlex="50">
                            <input matInput placeholder="Background URL" [(ngModel)]="selectedWelcomePage.backgroundURL">
                        </mat-form-field>
                        <mat-form-field fxFlex="50">
                            <input matInput placeholder="Home route" [(ngModel)]="selectedWelcomePage.homeRoute">
                        </mat-form-field>
                    </div>
                    <div fxLayoutGap="10px">
                        <mat-form-field fxFlex="80">
                            <mat-label>Used in roles</mat-label>
                            <mat-select [(ngModel)]="selectedWelcomePage.roles" [compareWith]="compareObjects" multiple>
                                <mat-option *ngFor="let role of allRoles" [value]="role.id">{{role.display}}</mat-option>
                            </mat-select>
                        </mat-form-field>
                    </div>
                    <div>Hightlights</div>
                    <div *ngFor="let highlight of selectedWelcomePage.highlights" fxLayoutGap="10px">
                        <mat-form-field fxFlex="15">
                            <input matInput placeholder="Icon URL" [(ngModel)]="highlight.iconURL">
                        </mat-form-field>
                        <mat-form-field fxFlex="30">
                            <input matInput placeholder="Title" [(ngModel)]="highlight.title">
                        </mat-form-field>
                        <mat-form-field fxFlex="55">
                            <textarea matInput placeholder="Subtitle" [(ngModel)]="highlight.content" cdkAutosizeMinRows="3" cdkAutosizeMaxRows="3"></textarea>
                        </mat-form-field>
                    </div>
                </div>
            </div>
        </div>
        <div fxFlex class="tcs-filler-panel"></div>
        <div fxLayout="row" fxLayoutGap="10px" fxLayoutAlign="end end" style="min-height: 50px">
            <button mat-raised-button color="secundary" (click)="runDeleteConfiguration()">Delete</button>
            <button mat-raised-button color="secundary" (click)="runNewConfiguration()">New</button>
            <button mat-raised-button color="primary" (click)="runSaveFunction()">Save</button>
        </div>
    </div>
</div>

./tibco-cloud-setting-landing.component.css

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""