File

src/lib/components/discuss-tags/discuss-tags.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Outputs

Constructor

constructor(discussionService: DiscussionService, telemetryUtils: TelemetryUtilsService, router: Router, activatedRoute: ActivatedRoute, configService: ConfigService, discussUtils: DiscussUtilsService, navigationService: NavigationServiceService)
Parameters :
Name Type Optional
discussionService DiscussionService No
telemetryUtils TelemetryUtilsService No
router Router No
activatedRoute ActivatedRoute No
configService ConfigService No
discussUtils DiscussUtilsService No
navigationService NavigationServiceService No

Outputs

stateChange
Type : EventEmitter<any>

Methods

fetchAllTags
fetchAllTags()
Returns : void
getAllDiscussions
getAllDiscussions(tag: literal type)
Parameters :
Name Type Optional
tag literal type No
Returns : void
Public getBgColor
getBgColor(tagTitle: any)
Parameters :
Name Type Optional
tagTitle any No
Returns : { color: any; 'background-color': any; }
getContextBasedTags
getContextBasedTags(cid: any)
Parameters :
Name Type Optional
cid any No
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
cIds
Type : any
filteredTags
Type : NSDiscussData.ITag[]
getParams
Type : any
paramsSubscription
Type : Subscription
query
Type : string
queryParam
Type : any
showLoader
Default value : false
import { Component, OnInit, EventEmitter, Output } from '@angular/core';

/* tslint:disable */
import * as _ from 'lodash'
import { DiscussionService } from '../../services/discussion.service';
import { NSDiscussData } from '../../models/discuss.model';
import { TelemetryUtilsService } from './../../telemetry-utils.service';
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { ConfigService } from '../../services/config.service';
import * as CONSTANTS from './../../common/constants.json';
import { DiscussUtilsService } from '../../services/discuss-utils.service';
import { NavigationServiceService } from '../../navigation-service.service';
/* tslint:enable */

@Component({
  selector: 'lib-discuss-tags',
  templateUrl: './discuss-tags.component.html',
  styleUrls: ['./discuss-tags.component.scss']
})
export class DiscussTagsComponent implements OnInit {

  @Output() stateChange: EventEmitter<any> = new EventEmitter();
  query: string;
  filteredTags: NSDiscussData.ITag[];
  showLoader = false;
  queryParam: any;
  paramsSubscription: Subscription;
  getParams: any;
  cIds: any;
  constructor(
    private discussionService: DiscussionService,
    private telemetryUtils: TelemetryUtilsService,
    private router: Router,
    public activatedRoute: ActivatedRoute,
    private configService: ConfigService,
    private discussUtils: DiscussUtilsService,
    private navigationService: NavigationServiceService
  ) { }

  ngOnInit() {
    this.telemetryUtils.setContext([]);
    this.telemetryUtils.logImpression(NSDiscussData.IPageName.TAGS);

    this.cIds = this.configService.getCategories()
    if (this.configService.hasContext()) {
      this.getContextBasedTags(this.cIds.result)
    } else {
      this.fetchAllTags();
    }

  }

  fetchAllTags() {
    this.showLoader = true;
    this.discussionService.fetchAllTag().subscribe(data => {
      this.showLoader = false;
      this.filteredTags = _.get(data, 'tags');
    }, error => {
      this.showLoader = false;
      // TODO: toaster
      console.log('error fetching tags');
    });
  }

  getContextBasedTags(cid: any) {
    const req = {
      cids: cid
    }
    this.showLoader = true;
    this.discussionService.contextBasedTags(req).subscribe(data => {
      this.showLoader = false;
      this.filteredTags = _.get(data, 'result');
    }, error => {
      this.showLoader = false;
      // TODO: toaster
      console.log('error fetching tags');
    });
  }

  public getBgColor(tagTitle: any) {
    const bgColor = this.discussUtils.stringToColor(tagTitle.toLowerCase());
    const color = this.discussUtils.getContrast();
    return { color, 'background-color': bgColor };
  }

  getAllDiscussions(tag: { value: any }) {
    this.queryParam = tag.value;
    const tagdata = {
      tagname: ''
    };

    tagdata.tagname = tag.value;
    this.queryParam = tagdata;
    const routerSlug = this.configService.getConfig().routerSlug ? this.configService.getConfig().routerSlug : '';
    const input = { data: { url: `${routerSlug}${CONSTANTS.ROUTES.TAG}tag-discussions`,
    queryParams: this.queryParam, tagName: this.queryParam.tagName }, action: 'tagsAll'};
    this.navigationService.navigate(input);
    this.stateChange.emit({ action: CONSTANTS.TAG_ALL_DISCUSS, title: tag.value, tid: 'sd' });
    // tslint:disable-next-line: max-line-length
    // this.router.navigate([`${this.configService.getRouterSlug()}${CONSTANTS.ROUTES.TAG}tag-discussions`], { queryParams: this.queryParam });
  }

}
<lib-app-loader *ngIf="showLoader"></lib-app-loader>
<div class="flex flex-1 margin-top-m flex-column discussion-tag-content">
  <ng-container *ngIf="filteredTags && filteredTags.length > 0">
    <div class="tags">
      <div *ngFor="let tag of filteredTags " class="tag" [ngStyle]="getBgColor(tag.value)"
        (click)="getAllDiscussions(tag)">
        <!-- Can enable random colors from below commented code -->
        <!-- <div *ngFor="let tag of filteredTags | pipeFilter:'score,value':query"
        class="tag text-capitalize" [ngStyle]="getBgColor(tag.value)"> -->
        <span class="margin-left-m">{{tag.value}}</span>
        <span class="ws-mat-default-text count">{{tag.score}}</span>
      </div>
    </div>
  </ng-container>
</div>
​
​
<div class="tag-empty-container" *ngIf="!showLoader && !filteredTags.length">
  <div class="tag-empty-img"><img src="./assets/discussion-ui/images/empty.svg" alt="empty image"></div>
  <label class="tag-empty-label">No tags Available !</label>
  <p class="tag-empty-text">Stay tuned ! we will be updating our tags library and add them here</p>
</div>

./discuss-tags.component.scss

::ng-deep:root{
	--df-tag-empty-bg:var(--df-common-bg);
}

.sb-search-box {
	display: flex;
	align-items: center;
	border: 0px;
}

.sb-search-box .sb-search-input {
	width: 100%;
	font-size: 0.875rem;
	min-height: 2rem;
	outline: 0;
	border-radius: 0;
	line-height: normal;
	background: none;
	padding: 1em;
	border-radius: 0.25rem;
	border: 0px;
}

.search-icon {
	width: 1.125rem;
	height: 1.125rem;
	margin: 1rem 0rem 1rem 1rem;
}

.sb-search-box .input-div {
	border-radius: 1.5rem;
	background: var(--white);
	display: flex;
	align-items: center;
	border: 0.0625rem solid var(--gray-100);
	width: 100%;
}

.sb-search-box .input-div:hover {
	border-color: var(--primary);
}

.tag {
	cursor: pointer;
}

@media (max-width: 768px) {
	.discuss-tags {
		flex-direction: column;
	}
}

.tag-empty-container{
	background: var(--white);
	background: var(--df-tag-empty-bg);
	color: var(--df-text);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 1.5rem;
    height: 100%;
    border-radius: 0.25rem;
    min-height: 28.125rem;

	.tag-empty-img{
      width: 100%;
	  max-width: 13.875rem;
	}

	.tag-empty-label{
		font-size: 0.875rem;
		font-weight: bold;
		margin: 1.5rem 0 0.75rem 0;
		color: var(--black) !important;
	}

	.tag-empty-text{
		font-size: 0.875rem;
		font-weight: normal;
		text-align: center;
		color: var(--black) !important;
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""