src/app/modules/workspace/components/flag-conentplayer/flag-conentplayer.component.ts
selector | app-flag-conentplayer |
templateUrl | flag-conentplayer.component.html |
constructor(resourceService: any, activatedRoute: ActivatedRoute, playerService: any, windowScrollService: any, toasterService: any, navigationHelperService: any, configService: any, contentService: any, routerNavigationService: any, permissionService: any, userService: any)
|
Constructor to create injected service(s) object
Parameters :
|
getContent |
getContent()
|
used to fetch content details and player config. On success launches player.
Returns:
void
|
tryAgain |
tryAgain()
|
retry launching player with same content details
Returns:
void
|
close |
close()
|
closes conent player and revert to previous url
Returns:
void
|
acceptContentFlag |
acceptContentFlag()
|
acceptContentFlag api call
Returns:
void
|
discardContentFlag |
discardContentFlag()
|
discardContentFlag api call
Returns:
void
|
activatedRoute |
activatedRoute: |
Public configService |
configService: |
reference of ConfigService. |
contentData |
contentData: |
contain contentData |
contentId |
contentId: |
content id |
Public contentService |
contentService: |
reference of ContentService. |
errorMessage |
errorMessage: |
contain error message |
flagActionButton |
flagActionButton: |
Default value: false
|
isShowFlagActionButton to show button |
loaderMessage |
loaderMessage: |
loader message |
navigationHelperService |
navigationHelperService: |
Public permissionService |
permissionService: |
reference of permissionService service. |
playerConfig |
playerConfig: |
contains player configuration |
Public playerService |
playerService: |
To call PlayerService service |
Public resourceService |
resourceService: |
To call resource service which helps to use language constant |
Public routerNavigationService |
routerNavigationService: |
To navigate back to parent component |
showError |
showError: |
Default value: false
|
Flag to show error |
showLoader |
showLoader: |
Default value: true
|
To show / hide loader |
Private toasterService |
toasterService: |
To show toaster(error, success etc) after any API calls |
Private userService |
userService: |
Refrence of UserService |
Public windowScrollService |
windowScrollService: |
To call PlayerService service |
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
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {
ResourceService, ILoaderMessage, PlayerConfig, ContentData,
WindowScrollService, ToasterService, NavigationHelperService,
ConfigService, RouterNavigationService
} from '@sunbird/shared';
import { PlayerService, ContentService, PermissionService, UserService } from '@sunbird/core';
@Component({
selector: 'app-flag-conentplayer',
templateUrl: './flag-conentplayer.component.html'
})
export class FlagConentplayerComponent implements OnInit {
/**
* loader message
*/
loaderMessage: ILoaderMessage;
/**
* To show / hide loader
*/
showLoader = true;
/**
* Flag to show error
*/
showError = false;
/**
* isShowFlagActionButton to show button
*/
flagActionButton = false;
/**
* content id
*/
contentId: string;
/**
* contain error message
*/
errorMessage: string;
/**
* To call resource service which helps to use language constant
*/
public resourceService: ResourceService;
/**
* To call PlayerService service
*/
public playerService: PlayerService;
/**
* To call PlayerService service
*/
public windowScrollService: WindowScrollService;
/**
* contains player configuration
*/
playerConfig: PlayerConfig;
/**
* contain contentData
*/
contentData: ContentData;
/**
* To show toaster(error, success etc) after any API calls
*/
private toasterService: ToasterService;
/**
* reference of ConfigService.
*/
public configService: ConfigService;
/**
* reference of ContentService.
*/
public contentService: ContentService;
/**
* Refrence of UserService
*/
private userService: UserService;
/**
* To navigate back to parent component
*/
public routerNavigationService: RouterNavigationService;
/**
* reference of permissionService service.
*/
public permissionService: PermissionService;
/**
* Constructor to create injected service(s) object
Default method of Draft Component class
* @param {ResourceService} resourceService Reference of resourceService
* @param {ToasterService} toasterService Reference of ToasterService
* @param {ContentService} contentService Reference of contentService
* @param {configService} configService Reference of configService
* @param {PermissionService} permissionService Reference of PermissionService
* @param {UserService} UserService Reference of UserService
*/
constructor(resourceService: ResourceService, public activatedRoute: ActivatedRoute,
playerService: PlayerService, windowScrollService: WindowScrollService,
toasterService: ToasterService, public navigationHelperService: NavigationHelperService,
configService: ConfigService, contentService: ContentService,
routerNavigationService: RouterNavigationService,
permissionService: PermissionService,
userService: UserService) {
this.resourceService = resourceService;
this.playerService = playerService;
this.windowScrollService = windowScrollService;
this.toasterService = toasterService;
this.configService = configService;
this.contentService = contentService;
this.routerNavigationService = routerNavigationService;
this.permissionService = permissionService;
this.userService = userService;
this.loaderMessage = {
'loaderMessage': this.resourceService.messages.stmsg.m0025,
};
}
ngOnInit() {
this.activatedRoute.params.subscribe((params) => {
this.contentId = params.contentId;
this.getContent();
});
}
/**
* used to fetch content details and player config. On success launches player.
*/
getContent() {
this.showLoader = true;
this.playerService.getContent(this.contentId).subscribe(
(response) => {
const contentDetails = {
contentId: this.contentId,
contentData: response.result.content
};
this.playerConfig = this.playerService.getConfig(contentDetails);
this.contentData = response.result.content;
this.showLoader = false;
},
(err) => {
this.showError = true;
this.errorMessage = this.resourceService.messages.stmsg.m0009;
this.toasterService.error(this.resourceService.messages.fmsg.m0015);
});
}
/**
* retry launching player with same content details
* @memberof ContentPlayerComponent
*/
tryAgain() {
this.showError = false;
this.getContent();
}
/**
* closes conent player and revert to previous url
* @memberof ContentPlayerComponent
*/
close() {
this.navigationHelperService.navigateToPreviousUrl('/workspace/content/flagged/1');
}
/**
* acceptContentFlag api call
*/
acceptContentFlag() {
const option = {
url: `${this.configService.urlConFig.URLS.CONTENT.ACCEPT_FLAG}/${this.contentId}`,
data: { 'request': { versionKey: this.contentData.versionKey} }
};
this.contentService.post(option).subscribe(response => {
this.toasterService.success(this.resourceService.messages.smsg.m0007);
this.close();
}, (err) => {
this.toasterService.error(this.resourceService.messages.fmsg.m0024);
});
}
/**
* discardContentFlag api call
*/
discardContentFlag() {
const option = {
url: `${this.configService.urlConFig.URLS.CONTENT.DISCARD_FLAG}/${this.contentId}`,
data: { 'request': { } }
};
this.contentService.post(option).subscribe(response => {
this.toasterService.success(this.resourceService.messages.smsg.m0008);
this.close();
}, (err) => {
this.toasterService.error(this.resourceService.messages.fmsg.m0025);
});
}
}