    currentAccount: any;
    <%= entityInstancePlural %>: I<%= entityAngularName %>[];
    error: any;
    success: any;
    eventSubscriber: Subscription;
    <%_ if (searchEngine === 'elasticsearch') { _%>
    currentSearch: string;
    filters: any;
    <%_ } _%>
    <%_ if (databaseType !== 'cassandra') { _%>
    routeData: any;
    links: any;
    totalItems: any;
    queryCount: any;
    itemsPerPage: any;
    page: any;
    predicate: any;
    previousPage: any;
    reverse: any;
    // added for Clarity
    loading: any;
    loadDebounce: Subject<ClrDatagridStateInterface>;
    sorters: any;
    selected: Array<I<%= entityAngularName %>>;
    <%_ } _%>
    <%_ if (searchEngine === 'elasticsearch') {
      for (idx in fields) { 
        if (fields[idx].fieldIsEnum) { _%>
    <%=fields[idx].fieldName%>: Array<<%=fields[idx].fieldType%>>;
    <%_ }}} _%>

    constructor(
        private <%= entityInstance %>DeleteDialogService: <%= entityAngularName %>DeleteDialogService,
        private <%= entityInstance %>SelectDialogService: <%= entityAngularName %>SelectDialogService,
        private <%= entityInstance %>Service: <%= entityAngularName %>Service,
        private parseLinks: JhiParseLinks,
        private jhiAlertService: JhiAlertService,
        private principal: Principal,
        private activatedRoute: ActivatedRoute,
        <%_ if (fieldsContainBlob) { _%>
        private dataUtils: JhiDataUtils,
        <%_ } _%>
        private eventManager: JhiEventManager,
        private router: Router
    ) {
        // added for Clarity
        this.sorters = {
          id: ClrDatagridSortOrder.UNSORTED,
          <%_ for (idx in fields) { _%>
          <%= fields[idx].fieldName %>: ClrDatagridSortOrder.UNSORTED,
          <%_ } _%>
        };
        <%_ if (searchEngine === 'elasticsearch') { _%>
        this.filters = {
          id: null,
          <%_ for (idx in fields) { _%>
          <%= fields[idx].fieldName %>: null,
          <%_ } _%>
        };
        <%_ } _%>
        <%_ if (databaseType !== 'cassandra') { _%>
        this.itemsPerPage = ITEMS_PER_PAGE;
        this.routeData = this.activatedRoute.data.subscribe(data => {
            this.page = data.pagingParams.page;
            this.previousPage = data.pagingParams.page;
            this.reverse = data.pagingParams.ascending;
            this.predicate = data.pagingParams.predicate;
            // added for Clarity
            if (this.predicate !== 'id') {
              this.sorters[this.predicate] = this.reverse ? ClrDatagridSortOrder.DESC : ClrDatagridSortOrder.ASC;
            }
        });
        <%_ if (searchEngine === 'elasticsearch') { _%>
        this.currentSearch = null;
        this.filters = decodeFiltersQueryParam(this.filters,
        this.activatedRoute.snapshot && this.activatedRoute.snapshot.queryParams['query'] ?
        this.activatedRoute.snapshot.queryParams['query'] : '');
        <%_ } _%>
        this.loading = true;
        this.selected = [];
        this.loadDebounce = new Subject<ClrDatagridStateInterface>();
        this.loadDebounce.debounceTime(SEARCH_DEBOUNCE_TIME).subscribe(() => this.loadAll());
        <%_ } _%>

        <%_ if (searchEngine === 'elasticsearch') {
        for (idx in fields) { 
          if (fields[idx].fieldIsEnum) {
            const values = fields[idx].fieldValues.replace(/\s/g, '').split(',');
        _%>
        this.<%=fields[idx].fieldName%> = [
          <%_
            for (key in values) {
          _%>
            <%= fields[idx].fieldType %>.<%=values[key]%>,
          <%_ } _%>
        ];
        <%_ }}} _%>
    }

    // added for Clarity
    refresh(state: ClrDatagridStateInterface) {
      // added grid sort
      this.predicate = state.sort ? state.sort.by : 'id';
      this.reverse = state.sort ? state.sort.reverse : true;
      <%_ if (searchEngine === 'elasticsearch') { _%>
      // added grid filter
      this.currentSearch = null;
      if (state.filters) {
        this.currentSearch = '';
        state.filters.forEach(filter => {
          if (filter['value'] !== '') {
            switch (filter['property']) {
              <%_ for (idx in fields) { _%>
              case '<%= fields[idx].fieldName %>':
                this.currentSearch += `(${resolveFilter(filter)}) AND `;
                break;
              <%_ } _%>
              <%_ for (idx in relationships) { _%>
              case '<%=relationships[idx].relationshipName%>.<%=relationships[idx].otherEntityField%>':
                this.currentSearch += `(${resolveFilter(filter)}) AND `;
                break;
              <%_ } _%>
            }
          }
        });
        this.currentSearch += '*:*';
      }
      <%_ } _%>
      this.router.navigate(['/<%= microserviceName %>/<%= entityUrl %>'], {
        queryParams: {
          page: this.page,
          size: this.itemsPerPage,
          <%_ if (searchEngine === 'elasticsearch') { _%>
          query: encodeFiltersQueryParam(state.filters),
          <%_ } _%>
          sort: this.predicate + ',' + (this.reverse ? 'asc' : 'desc')
        }
      });
      <%_ if (searchEngine === 'elasticsearch') { _%>
      // fixed filter refresh debounce
      if (state.filters) {
        this.loadDebounce.next();
        return;
      }
      <%_ } _%>
      this.loadAll();
    }

    loadAll() {
        // added for Clarity
        this.loading = true;

        <%_ if (searchEngine === 'elasticsearch') { _%>
        if (this.currentSearch) {
            this.<%= entityInstance %>Service.search({
                page: this.page - 1,
                query: this.currentSearch,
                size: this.itemsPerPage,
                sort: this.sort()}).subscribe(
                    (res: HttpResponse<I<%= entityAngularName %>[]>) => this.paginate<%= entityClassPlural %>(res.body, res.headers),
                    (res: HttpErrorResponse) => this.onError(res.message)
                );
            return;
        }
        <%_ } _%>
        this.<%= entityInstance %>Service.query(<%_ if (databaseType !== 'cassandra') { _%>{
            page: this.page - 1,
            size: this.itemsPerPage,
            sort: this.sort()}<%_ } _%>).subscribe(
                (res: HttpResponse<I<%= entityAngularName %>[]>) => this.paginate<%= entityClassPlural %>(res.body, res.headers),
                (res: HttpErrorResponse) => this.onError(res.message)
        );
    }

    <%_ if (databaseType !== 'cassandra') { _%>
    clear() {
        this.page = 0;
        <%_ if (searchEngine === 'elasticsearch') { _%>
        this.currentSearch = '';
        <%_ } _%>
        this.router.navigate(['/<%= microserviceName %>/<%= entityUrl %>', {
            page: this.page,
            sort: this.predicate + ',' + (this.reverse ? 'asc' : 'desc')
        }]);
        this.loadAll();
    }
    <%_ } _%>
