File

src/app/modules/workspace/components/review-submissions/review-submissions.component.ts

Description

The Review submission component

Metadata

selector app-review-submissions
templateUrl review-submissions.component.html

Constructor

constructor(searchService: any, workSpaceService: WorkSpaceService, paginationService: any, activatedRoute: ActivatedRoute, route: Router, userService: any, config: any, resourceService: any, toasterService: any, navigationhelperService: any)

Constructor to create injected service(s) object
Default method of Review submission Component class

Parameters :

Methods

fetchReviewContents
fetchReviewContents(limit: number, pageNumber: number)

This method sets the make an api call to get all reviewContent with page No and offset

Returns: void
contentClick
contentClick(param: any)

This method launch the content editior

Returns: void
navigateToPage
navigateToPage(page: number)

This method helps to navigate to different pages.
If page number is less than 1 or page number is greater than total number
of pages is less which is not possible, then it returns.

Parameters :
  • page

    Variable to know which page has been clicked

Example :

navigateToPage(1)

Returns: void
inview
inview(event: any)

get inview Data

Returns: void

Properties

Private activatedRoute
activatedRoute: ActivatedRoute

To send activatedRoute.snapshot to router navigation
service for redirection to draft component

Public config
config: any

To get url, app configs

contentIds
contentIds: string

Contains unique contentIds id

inviewLogs
inviewLogs: any[]

inviewLogs

loaderMessage
loaderMessage: any

loader message

navigationhelperService
navigationhelperService: any
noResult
noResult: boolean
Default value: false

To show / hide no result message when no result found

noResultMessage
noResultMessage: any

no result message

pageLimit
pageLimit: number

Contains page limit of review submission list

pageNumber
pageNumber: number
Default value: 1

Current page number of inbox list

pager
pager: any

Contains returned object of the pagination service
which is needed to show the pagination on inbox view

Private paginationService
paginationService: any

For showing pagination on draft list

Public resourceService
resourceService: any

To call resource service which helps to use language constant

reviewContent
reviewContent: any[]

Contains list of published course(s) of logged-in user

route
route: Router

To navigate to other pages

searchService
searchService: any
showError
showError: boolean
Default value: false

To show / hide error

showLoader
showLoader: boolean
Default value: true

To show / hide loader

state
state: string

state for content editior

telemetryImpression
telemetryImpression: any

telemetryImpression

Private toasterService
toasterService: any

To show toaster(error, success etc) after any API calls

totalCount
totalCount: Number

totalCount of the list

workSpaceService
workSpaceService: WorkSpaceService
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import { Component, OnInit, AfterViewInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { WorkSpace } from '../../classes/workspace';
import { SearchService, UserService } from '@sunbird/core';
import {
  ServerResponse, PaginationService, ToasterService,
  ResourceService, ConfigService, IContents, ILoaderMessage, INoResultMessage,
  NavigationHelperService
} from '@sunbird/shared';
import { WorkSpaceService } from '../../services';
import * as _ from 'lodash-es';
import { IInteractEventInput, IImpressionEventInput } from '@sunbird/telemetry';

/**
 * The Review submission  component
*/

@Component({
  selector: 'app-review-submissions',
  templateUrl: './review-submissions.component.html'
})
export class ReviewSubmissionsComponent extends WorkSpace implements OnInit, AfterViewInit {
  /**
  * state for content editior
 */
  state: string;
  /**
    * To navigate to other pages
  */
  route: Router;

  /**
   * To send activatedRoute.snapshot to router navigation
   * service for redirection to draft  component
  */
  private activatedRoute: ActivatedRoute;

  /**
   * Contains unique contentIds id
  */
  contentIds: string;
  /**
   * Contains list of published course(s) of logged-in user
  */
  reviewContent: Array<IContents> = [];

  /**
   * To show / hide loader
  */
  showLoader = true;

  /**
   * loader message
  */
  loaderMessage: ILoaderMessage;
  /**
     * To show / hide error
   */
  showError = false;

  /**
    * To show / hide no result message when no result found
   */
  noResult = false;

  /**
   * no result  message
  */
  noResultMessage: INoResultMessage;

  /**
    * For showing pagination on draft list
  */
  private paginationService: PaginationService;

  /**
    * To get url, app configs
  */
  public config: ConfigService;

  /**
  * Contains page limit of review submission list
  */
  pageLimit: number;

  /**
    * Current page number of inbox list
  */
  pageNumber = 1;

  /**
  * totalCount of the list
   */
  totalCount: Number;

  /**
  * Contains returned object of the pagination service
  * which is needed to show the pagination on inbox view
  */
  pager;
  /**
    * To call resource service which helps to use language constant
  */
  public resourceService: ResourceService;
  /**
	 * telemetryImpression
	*/
  telemetryImpression: IImpressionEventInput;
  /**
	 * inviewLogs
	*/
  inviewLogs = [];
  /**
  * To show toaster(error, success etc) after any API calls
  */
  private toasterService: ToasterService;
  /**
   * Constructor to create injected service(s) object
   Default method of Review submission  Component class
   * @param {SearchService} SearchService Reference of SearchService
   * @param {Router} route Reference of Router
   * @param {UserService} UserService Reference of UserService
   * @param {PaginationService} paginationService Reference of PaginationService
   * @param {ActivatedRoute} activatedRoute Reference of ActivatedRoute
   * @param {ConfigService} config Reference of ConfigService
   * @param {ToasterService} toaster Reference of toasterService
 */
  constructor(public searchService: SearchService,
    public workSpaceService: WorkSpaceService,
    paginationService: PaginationService,
    activatedRoute: ActivatedRoute,
    route: Router, userService: UserService,
    config: ConfigService, resourceService: ResourceService,
    toasterService: ToasterService,
    public navigationhelperService: NavigationHelperService) {
    super(searchService, workSpaceService, userService);
    this.paginationService = paginationService;
    this.route = route;
    this.activatedRoute = activatedRoute;
    this.config = config;
    this.resourceService = resourceService;
    this.toasterService = toasterService;
    this.state = 'review';
    this.loaderMessage = {
      'loaderMessage': this.resourceService.messages.stmsg.m0018,
    };
  }

  ngOnInit() {
    this.activatedRoute.params.subscribe(params => {
      this.pageNumber = Number(params.pageNumber);
      this.fetchReviewContents(this.config.appConfig.WORKSPACE.PAGE_LIMIT, this.pageNumber);
    });
  }
  /**
   * This method sets the make an api call to get all reviewContent with page No and offset
  */
  fetchReviewContents(limit: number, pageNumber: number) {
    this.showLoader = true;
    this.pageNumber = pageNumber;
    this.pageLimit = limit;
    const searchParams = {
      filters: {
        status: ['Review', 'FlagReview'],
        createdBy: this.userService.userid,
        contentType: this.config.appConfig.WORKSPACE.contentType,
        objectType: this.config.appConfig.WORKSPACE.objectType,
      },
      limit: this.pageLimit,
      offset: (this.pageNumber - 1) * (this.pageLimit),
      sort_by: { lastUpdatedOn: this.config.appConfig.WORKSPACE.lastUpdatedOn }
    };
    this.search(searchParams).subscribe(
      (data: ServerResponse) => {
        if (data.result.count && data.result.content.length > 0) {
          this.reviewContent = data.result.content;
          this.totalCount = data.result.count;
          this.pager = this.paginationService.getPager(data.result.count, this.pageNumber, this.pageLimit);
          const constantData = this.config.appConfig.WORKSPACE.ReviewSubmission.constantData;
          const metaData = this.config.appConfig.WORKSPACE.ReviewSubmission.metaData;
          const dynamicFields = this.config.appConfig.WORKSPACE.ReviewSubmission.dynamicFields;
          this.reviewContent = this.workSpaceService.getDataForCard(data.result.content, constantData, dynamicFields, metaData);
          this.showLoader = false;
        } else {
          this.showError = false;
          this.showLoader = false;
          this.noResult = true;
          this.noResultMessage = {
            'message': 'messages.stmsg.m0008',
            'messageText': 'messages.stmsg.m0033'
          };
        }
      },
      (err: ServerResponse) => {
        this.showLoader = false;
        this.noResult = false;
        this.showError = true;
        this.toasterService.error(this.resourceService.messages.fmsg.m0012);
      }
    );
  }
  /**
    * This method launch the content editior
  */
  contentClick(param) {
    this.workSpaceService.navigateToContent(param.data.metaData, this.state);
  }

  /**
 * This method helps to navigate to different pages.
 * If page number is less than 1 or page number is greater than total number
 * of pages is less which is not possible, then it returns.
 *
 * @param {number} page Variable to know which page has been clicked
 *
 * @example navigateToPage(1)
 */
  navigateToPage(page: number): undefined | void {
    if (page < 1 || page > this.pager.totalPages) {
      return;
    }
    this.pageNumber = page;
    this.route.navigate(['workspace/content/review', this.pageNumber]);
  }

  ngAfterViewInit () {
    setTimeout(() => {
      this.telemetryImpression = {
        context: {
          env: this.activatedRoute.snapshot.data.telemetry.env
        },
        edata: {
          type: this.activatedRoute.snapshot.data.telemetry.type,
          pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
          subtype: this.activatedRoute.snapshot.data.telemetry.subtype,
          uri: this.activatedRoute.snapshot.data.telemetry.uri + '/' + this.activatedRoute.snapshot.params.pageNumber,
          visits: this.inviewLogs,
          duration: this.navigationhelperService.getPageLoadTime()
        }
      };
      this.inview({ inview: [] });
    });
  }
  /**
  * get inview  Data
  */
  inview(event) {
    _.forEach(event.inview, (inview, key) => {
      const obj = _.find(this.inviewLogs, (o) => {
        return o.objid === inview.data.metaData.identifier;
      });
      if (obj === undefined) {
        this.inviewLogs.push({
          objid: inview.data.metaData.identifier,
          objtype: inview.data.metaData.contentType,
          index: inview.id
        });
      }
    });
    this.telemetryImpression.edata.visits = this.inviewLogs;
    this.telemetryImpression.edata.subtype = 'pageexit';
    this.telemetryImpression = Object.assign({}, this.telemetryImpression);
  }
}

results matching ""

    No results matching ""