Revision 60950
Added by Konstantinos Triantafyllou about 3 years ago
modules/uoa-admin-portal/branches/new-UI/src/app/utils/fabModule.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import { CommonModule} from '@angular/common'; |
|
3 |
import { FormsModule } from '@angular/forms'; |
|
4 |
import {FABComponent} from './fab.component'; |
|
5 |
|
|
6 |
@NgModule({ |
|
7 |
imports: [ |
|
8 |
CommonModule, |
|
9 |
FormsModule |
|
10 |
], |
|
11 |
declarations: [ |
|
12 |
FABComponent |
|
13 |
], |
|
14 |
exports: [ |
|
15 |
FABComponent |
|
16 |
] |
|
17 |
}) |
|
18 |
|
|
19 |
export class FABModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/utils/fab.component.ts | ||
---|---|---|
1 |
import { Component, EventEmitter, Output } from '@angular/core'; |
|
2 |
|
|
3 |
@Component({ |
|
4 |
selector: 'fab', |
|
5 |
template: ` |
|
6 |
<div (click)="onClick()" class=" uk-float-right " style="z-index: 100; bottom: 45px; position: fixed; right: 45px;"> |
|
7 |
<a style="padding: 14px;" class=" uk-button uk-button-danger "> |
|
8 |
<!--span class="uk-icon" uk-icon="icon: plus; ratio: 1.5"> |
|
9 |
</span--> |
|
10 |
<span class="uk-icon"> |
|
11 |
<svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="currentColor" icon="plus" ratio="1.5"> |
|
12 |
<rect x="9" y="1" width="1" height="17" fill="currentColor"></rect> |
|
13 |
<rect x="1" y="9" width="17" height="1" fill="currentColor"></rect></svg> |
|
14 |
</span> |
|
15 |
</a> |
|
16 |
</div> |
|
17 |
` |
|
18 |
}) |
|
19 |
|
|
20 |
export class FABComponent { |
|
21 |
@Output() public clicked:EventEmitter<any> = new EventEmitter(); |
|
22 |
|
|
23 |
constructor () {} |
|
24 |
|
|
25 |
public ngOnInit() {} |
|
26 |
|
|
27 |
public onClick() { |
|
28 |
this.clicked.emit(true); |
|
29 |
} |
|
30 |
|
|
31 |
} |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-contents.component.ts | ||
---|---|---|
1 |
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; |
|
2 |
import { Router, ActivatedRoute } from "@angular/router"; |
|
3 |
import { FormGroup } from "@angular/forms"; |
|
4 |
import { HelpContentService } from "../../services/help-content.service"; |
|
5 |
import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content"; |
|
6 |
import { Page } from "../../domain/page"; |
|
7 |
import { Portal } from "../../domain/portal"; |
|
8 |
import { DivId } from "../../domain/divId"; |
|
9 |
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; |
|
10 |
import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; |
|
11 |
|
|
12 |
import {Session} from '../../openaireLibrary/login/utils/helper.class'; |
|
13 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
14 |
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; |
|
15 |
import {PageHelpContent} from "../../domain/page-help-content"; |
|
16 |
import {Title} from '@angular/platform-browser'; |
|
17 |
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; |
|
18 |
|
|
19 |
@Component({ |
|
20 |
selector: 'div-help-contents', |
|
21 |
templateUrl: './div-help-contents.component.html', |
|
22 |
}) |
|
23 |
|
|
24 |
export class DivHelpContentsComponent implements OnInit { |
|
25 |
// @ViewChild('deleteConfirmationModal') |
|
26 |
// public deleteConfirmationModal : DeleteConfirmationDialogComponent; |
|
27 |
@ViewChild('AlertModalDeleteDivHelpContents') alertModalDeleteDivHelpContents; |
|
28 |
private selectedDivContents: string[] = []; |
|
29 |
|
|
30 |
public checkboxes : CheckDivHelpContent[] = []; |
|
31 |
|
|
32 |
public divHelpContents : DivHelpContent[] = []; |
|
33 |
|
|
34 |
//public errorMessage: string; |
|
35 |
|
|
36 |
public formGroup : FormGroup; |
|
37 |
|
|
38 |
public pages: Page[]; |
|
39 |
|
|
40 |
public checkboxAll : boolean = false; |
|
41 |
|
|
42 |
public filters : DivHelpContentFilterOptions = {id : '', active : null, text : new RegExp('')}; |
|
43 |
public keyword: string = ""; |
|
44 |
|
|
45 |
public counter = {all : 0, active : 0, inactive : 0}; |
|
46 |
|
|
47 |
public communities: Portal[] = []; |
|
48 |
|
|
49 |
public selectedCommunityPid: string; |
|
50 |
|
|
51 |
public selectedPageId: string; |
|
52 |
|
|
53 |
public community: Portal; |
|
54 |
|
|
55 |
public page: Page; |
|
56 |
public properties:EnvProperties = null; |
|
57 |
|
|
58 |
public showLoading: boolean = true; |
|
59 |
public errorMessage: string = ''; |
|
60 |
public updateErrorMessage: string = ''; |
|
61 |
|
|
62 |
ngOnInit() { |
|
63 |
this.route.data |
|
64 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
65 |
this.properties = data.envSpecific; |
|
66 |
|
|
67 |
this.route.queryParams.subscribe(params => { |
|
68 |
HelperFunctions.scroll(); |
|
69 |
this.title.setTitle('Administration Dashboard | Class Help Texts'); |
|
70 |
this.selectedCommunityPid = params['communityId']; |
|
71 |
this.selectedPageId = params['pageId']; |
|
72 |
|
|
73 |
if(this.selectedCommunityPid && this.selectedPageId) { |
|
74 |
this.getPage(this.selectedPageId); |
|
75 |
} else if(this.selectedCommunityPid){ |
|
76 |
this.selectedPageId = ""; |
|
77 |
this.getPages(this.selectedCommunityPid); |
|
78 |
} |
|
79 |
}); |
|
80 |
}); |
|
81 |
} |
|
82 |
|
|
83 |
constructor(private element: ElementRef, private route: ActivatedRoute, |
|
84 |
private title: Title, |
|
85 |
private _helpService: HelpContentService, private router : Router, |
|
86 |
private _clearCacheService: ClearCacheService) {} |
|
87 |
|
|
88 |
getPage(pageId: string) { |
|
89 |
if(!Session.isLoggedIn()){ |
|
90 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
91 |
} else { |
|
92 |
this.showLoading = true; |
|
93 |
this.updateErrorMessage = ""; |
|
94 |
this.errorMessage = ""; |
|
95 |
this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( |
|
96 |
page => { |
|
97 |
// if( (this.selectedCommunityPid == 'openaire' && !page.openaire) |
|
98 |
// || (this.selectedCommunityPid == 'connect' && !page.connect) |
|
99 |
// || (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) { |
|
100 |
if(this.properties.adminToolsPortalType != page.portalType) { |
|
101 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.selectedCommunityPid} }); |
|
102 |
} else { |
|
103 |
this.page = page; |
|
104 |
this.getDivHelpContents(this.selectedCommunityPid); |
|
105 |
} |
|
106 |
}, |
|
107 |
error => this.handleError('System error retrieving page', error)); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
getPages(community_pid: string) { |
|
112 |
if(!Session.isLoggedIn()){ |
|
113 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
114 |
} else { |
|
115 |
this.showLoading = true; |
|
116 |
this.updateErrorMessage = ""; |
|
117 |
this.errorMessage = ""; |
|
118 |
|
|
119 |
this._helpService.getCommunityPagesWithDivId(community_pid, this.properties.adminToolsAPIURL).subscribe( |
|
120 |
//this._helpService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( |
|
121 |
pages => { |
|
122 |
this.pages = pages; |
|
123 |
this.getDivHelpContents(this.selectedCommunityPid); |
|
124 |
}, |
|
125 |
error => this.handleError('System error retrieving pages', error)); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
public countDivHelpContents() { |
|
130 |
this.counter = {all : 0, active : 0, inactive : 0}; |
|
131 |
let filter = Object.assign({},this.filters); |
|
132 |
filter.active = null; |
|
133 |
this.divHelpContents.forEach(_ => { |
|
134 |
if(this.filterDivHelpContent(_,filter)){ |
|
135 |
if (_.isActive==true) this.counter.active++; |
|
136 |
else this.counter.inactive++ |
|
137 |
} |
|
138 |
}); |
|
139 |
this.counter.all = this.counter.active + this.counter.inactive; |
|
140 |
} |
|
141 |
|
|
142 |
getDivHelpContents(community_pid: string) { |
|
143 |
if(!Session.isLoggedIn()){ |
|
144 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
145 |
} else { |
|
146 |
this._helpService.getCommunityDivHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe( |
|
147 |
divHelpContents => { |
|
148 |
this.divHelpContents = divHelpContents as Array<DivHelpContent>; |
|
149 |
this.counter.all = this.divHelpContents.length; |
|
150 |
this.checkboxes = []; |
|
151 |
|
|
152 |
for (let i = this.divHelpContents.length - 1; i >= 0; i -= 1) { |
|
153 |
//for (let i = 0; i < this.divHelpContents.length; i++) { |
|
154 |
let divId: DivId = this.divHelpContents[i].divId as DivId; |
|
155 |
let pages: Page[] = divId.pages as Page[]; |
|
156 |
const pageIds = pages.map(x => x._id); |
|
157 |
|
|
158 |
if(!this.selectedPageId || pageIds.includes(this.selectedPageId)) { |
|
159 |
this.cutContent(this.divHelpContents[i]); |
|
160 |
this.checkboxes.unshift(<CheckDivHelpContent>{divHelpContent : this.divHelpContents[i], checked : false}); |
|
161 |
} else { |
|
162 |
this.divHelpContents.splice(i, 1); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
this.countDivHelpContents(); |
|
167 |
|
|
168 |
this.showLoading = false; |
|
169 |
}, |
|
170 |
error => this.handleError('System error retrieving page contents', error)); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
public toggleCheckBoxes(event) { |
|
175 |
this.checkboxes.forEach(_ => _.checked = event.target.checked); |
|
176 |
this.checkboxAll = event.target.checked; |
|
177 |
} |
|
178 |
|
|
179 |
public applyCheck(flag : boolean) { |
|
180 |
this.checkboxes.forEach(_ => _.checked = flag); |
|
181 |
this.checkboxAll = false; |
|
182 |
} |
|
183 |
|
|
184 |
public getSelectedDivHelpContents() : string[] { |
|
185 |
return this.checkboxes.filter(divHelpContent => divHelpContent.checked == true) |
|
186 |
.map(checkedDivHelpContent => checkedDivHelpContent.divHelpContent).map(res => res._id); |
|
187 |
} |
|
188 |
|
|
189 |
public confirmDeleteDivHelpContent(id : string) { |
|
190 |
//this.deleteConfirmationModal.ids = [id]; |
|
191 |
//this.deleteConfirmationModal.showModal(); |
|
192 |
this.selectedDivContents = [id]; |
|
193 |
this.confirmModalOpen(); |
|
194 |
} |
|
195 |
|
|
196 |
public confirmDeleteSelectedDivHelpContents() { |
|
197 |
//this.deleteConfirmationModal.ids = this.getSelectedDivHelpContents(); |
|
198 |
//this.deleteConfirmationModal.showModal(); |
|
199 |
this.selectedDivContents = this.getSelectedDivHelpContents(); |
|
200 |
this.confirmModalOpen(); |
|
201 |
} |
|
202 |
|
|
203 |
private confirmModalOpen() { |
|
204 |
if(!Session.isLoggedIn()){ |
|
205 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
206 |
} else { |
|
207 |
this.alertModalDeleteDivHelpContents.cancelButton = true; |
|
208 |
this.alertModalDeleteDivHelpContents.okButton = true; |
|
209 |
this.alertModalDeleteDivHelpContents.alertTitle = "Delete Confirmation"; |
|
210 |
this.alertModalDeleteDivHelpContents.message = "Are you sure you want to delete the help text(s)?"; |
|
211 |
this.alertModalDeleteDivHelpContents.okButtonText = "Yes"; |
|
212 |
this.alertModalDeleteDivHelpContents.open(); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
public confirmedDeleteDivHelpContents(data: any) { |
|
217 |
if(!Session.isLoggedIn()){ |
|
218 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
219 |
} else { |
|
220 |
this.showLoading = true; |
|
221 |
this.updateErrorMessage = ""; |
|
222 |
|
|
223 |
this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( |
|
224 |
_ => { |
|
225 |
this.deleteDivHelpContentsFromArray(this.selectedDivContents); |
|
226 |
this.showLoading = false; |
|
227 |
this._clearCacheService.clearCache("class help contents deleted"); |
|
228 |
}, |
|
229 |
error => this.handleUpdateError('System error deleting the selected class content(s)', error) |
|
230 |
); |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
private deleteDivHelpContentsFromArray(ids : string[]) : void { |
|
235 |
for(let id of ids) { |
|
236 |
let iqc = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); |
|
237 |
let iq = this.divHelpContents.findIndex(_ => _._id == id); |
|
238 |
this.checkboxes.splice(iqc, 1); |
|
239 |
this.divHelpContents.splice(iqc, 1); |
|
240 |
} |
|
241 |
this.countDivHelpContents(); |
|
242 |
} |
|
243 |
|
|
244 |
public editDivHelpContent(id : string) { |
|
245 |
//this.router.navigate(['/pageContents/edit/', _id]); |
|
246 |
if(this.selectedPageId) { |
|
247 |
this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "communityId": this.selectedCommunityPid, "pageId": this.selectedPageId } } ); |
|
248 |
} else { |
|
249 |
this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "communityId": this.selectedCommunityPid } } ); |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
253 |
public toggleDivHelpContents(status : boolean, ids : string[]) { |
|
254 |
if(!Session.isLoggedIn()){ |
|
255 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
256 |
} else { |
|
257 |
this.updateErrorMessage = ""; |
|
258 |
|
|
259 |
this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( |
|
260 |
() => { |
|
261 |
for(let id of ids) { |
|
262 |
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); |
|
263 |
this.checkboxes[i].divHelpContent.isActive=status; |
|
264 |
} |
|
265 |
this.countDivHelpContents(); |
|
266 |
this.applyCheck(false); |
|
267 |
this._clearCacheService.clearCache("class help contents toggled (status: "+status+")"); |
|
268 |
}, |
|
269 |
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error) |
|
270 |
); |
|
271 |
} |
|
272 |
} |
|
273 |
|
|
274 |
public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) { |
|
275 |
this.cutContent(divHelpContent); |
|
276 |
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent : divHelpContent, checked : false}); |
|
277 |
this.divHelpContents.push(divHelpContent); |
|
278 |
this.applyCheck(false); |
|
279 |
this.countDivHelpContents(); |
|
280 |
} |
|
281 |
|
|
282 |
public divHelpContentUpdatedSuccessfully(divHelpContent : DivHelpContent) { |
|
283 |
this.checkboxes.find(checkItem => checkItem.divHelpContent._id==divHelpContent._id).divHelpContent = divHelpContent; |
|
284 |
let index = this.divHelpContents.findIndex(checkItem => checkItem._id==divHelpContent._id); |
|
285 |
this.divHelpContents[index] = divHelpContent; |
|
286 |
this.applyCheck(false); |
|
287 |
this.countDivHelpContents(); |
|
288 |
} |
|
289 |
|
|
290 |
|
|
291 |
public filterDivHelpContent(divHelpContent : DivHelpContent, filters : DivHelpContentFilterOptions) : boolean { |
|
292 |
let divId: DivId = divHelpContent.divId as DivId; |
|
293 |
let pages: Page[] = <Page[]>divId.pages; |
|
294 |
let pageIds: string[] = pages.map(x => x._id); |
|
295 |
|
|
296 |
let idFlag = filters.id == '' || /*(<Page[]>divId.pages)._id == filters.id*/ pageIds.includes(filters.id); |
|
297 |
let activeFlag = filters.active == null || divHelpContent.isActive == filters.active; |
|
298 |
let textFlag = filters.text.toString() == '' || (divHelpContent.content).match(filters.text) != null |
|
299 |
|| ((<DivId>divHelpContent.divId).name).match(filters.text) != null; |
|
300 |
return idFlag && activeFlag && textFlag; |
|
301 |
} |
|
302 |
|
|
303 |
public cutContent(divHelpContent: DivHelpContent) { |
|
304 |
divHelpContent.content = divHelpContent.content.replace(/<[^>]*>/g, ''); |
|
305 |
divHelpContent.content = divHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm," "); |
|
306 |
if(divHelpContent.content.length > 200) { |
|
307 |
divHelpContent.content = divHelpContent.content.substr(0, 200) + "..."; |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
public applyFilter() { |
|
312 |
this.checkboxes = []; |
|
313 |
this.divHelpContents.filter(item => this.filterDivHelpContent(item,this.filters)).forEach( |
|
314 |
_ => { |
|
315 |
this.cutContent(_); |
|
316 |
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false}) |
|
317 |
} |
|
318 |
); |
|
319 |
this.countDivHelpContents(); |
|
320 |
} |
|
321 |
|
|
322 |
public filterByPage(event: any) { |
|
323 |
this.filters.id = event.target.value; |
|
324 |
this.applyFilter(); |
|
325 |
} |
|
326 |
|
|
327 |
public displayAllDivHelpContents() { |
|
328 |
this.filters.active = null; |
|
329 |
this.applyFilter(); |
|
330 |
} |
|
331 |
|
|
332 |
public displayActiveDivHelpContents() { |
|
333 |
this.filters.active = true; |
|
334 |
this.applyFilter(); |
|
335 |
} |
|
336 |
|
|
337 |
public filterBySearch(text : string) { |
|
338 |
this.filters.text = new RegExp(text, "i"); |
|
339 |
this.applyFilter(); |
|
340 |
} |
|
341 |
|
|
342 |
public displayInactiveDivHelpContents() { |
|
343 |
this.filters.active = false; |
|
344 |
this.applyFilter(); |
|
345 |
} |
|
346 |
|
|
347 |
handleError(message: string, error) { |
|
348 |
this.errorMessage = message; |
|
349 |
console.log('Server responded: ' + error); |
|
350 |
|
|
351 |
this.showLoading = false; |
|
352 |
} |
|
353 |
|
|
354 |
handleUpdateError(message: string, error) { |
|
355 |
this.updateErrorMessage = message; |
|
356 |
console.log('Server responded: ' +error); |
|
357 |
|
|
358 |
this.showLoading = false; |
|
359 |
} |
|
360 |
|
|
361 |
public newClassContent() { |
|
362 |
if(this.selectedPageId) { |
|
363 |
this.router.navigate( ['/classContents/new'], { queryParams: {communityId: this.selectedCommunityPid, pageId: this.selectedPageId} } ); |
|
364 |
} else { |
|
365 |
this.router.navigate( ['/classContents/new'], { queryParams: {communityId: this.selectedCommunityPid} } ); |
|
366 |
} |
|
367 |
} |
|
368 |
} |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/edit-div-help-content.component.ts | ||
---|---|---|
1 |
import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; |
|
2 |
import { DivContentFormComponent } from "./div-help-content-form.component"; |
|
3 |
import { Subscription } from "rxjs"; |
|
4 |
import { HelpContentService } from "../../services/help-content.service"; |
|
5 |
import { DivHelpContent } from "../../domain/div-help-content"; |
|
6 |
import { ActivatedRoute, Router } from "@angular/router"; |
|
7 |
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; |
|
8 |
|
|
9 |
import {Session} from '../../openaireLibrary/login/utils/helper.class'; |
|
10 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
11 |
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; |
|
12 |
import {Page} from "../../domain/page"; |
|
13 |
import {Title} from '@angular/platform-browser'; |
|
14 |
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; |
|
15 |
|
|
16 |
@Component({ |
|
17 |
selector: 'edit-div-help-content', |
|
18 |
templateUrl: 'edit-div-help-content.component.html', |
|
19 |
}) |
|
20 |
|
|
21 |
export class EditDivHelpContentComponent implements OnInit, OnDestroy{ |
|
22 |
|
|
23 |
@ViewChild(DivContentFormComponent) |
|
24 |
public formComponent : DivContentFormComponent; |
|
25 |
|
|
26 |
public communityPid: string; |
|
27 |
public pageId: string; |
|
28 |
public page: Page; |
|
29 |
|
|
30 |
private sub: Subscription; |
|
31 |
|
|
32 |
private divHelpContent: DivHelpContent; |
|
33 |
|
|
34 |
public properties:EnvProperties = null; |
|
35 |
|
|
36 |
public showLoading: boolean = true; |
|
37 |
public errorMessage: string = ''; |
|
38 |
public updateErrorMessage: string = ''; |
|
39 |
|
|
40 |
constructor( |
|
41 |
private element: ElementRef, |
|
42 |
private route: ActivatedRoute, |
|
43 |
private router: Router, |
|
44 |
private title: Title, |
|
45 |
private _helpContentService: HelpContentService, |
|
46 |
private _clearCacheService: ClearCacheService) {} |
|
47 |
|
|
48 |
ngOnInit() { |
|
49 |
this.route.data |
|
50 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
51 |
this.properties = data.envSpecific; |
|
52 |
this.sub = this.route.queryParams.subscribe(params => { |
|
53 |
HelperFunctions.scroll(); |
|
54 |
|
|
55 |
//let id = params['id']; |
|
56 |
let divContentId = params['classContentId']; |
|
57 |
this.communityPid = params['communityId']; |
|
58 |
this.pageId = params['pageId']; |
|
59 |
this.title.setTitle('Administration Dashboard | Edit Class Help Text'); |
|
60 |
if(!divContentId) { |
|
61 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); |
|
62 |
} |
|
63 |
|
|
64 |
this.getDivHelpContent(divContentId); |
|
65 |
}); |
|
66 |
}); |
|
67 |
} |
|
68 |
ngOnDestroy() { |
|
69 |
this.sub.unsubscribe(); |
|
70 |
} |
|
71 |
|
|
72 |
handleError(message: string, error) { |
|
73 |
this.errorMessage = message; |
|
74 |
console.log('Server responded: ' + error); |
|
75 |
this.showLoading = false; |
|
76 |
} |
|
77 |
|
|
78 |
handleUpdateError(message: string, error) { |
|
79 |
this.updateErrorMessage = message; |
|
80 |
console.log('Server responded: ' + error); |
|
81 |
this.showLoading = false; |
|
82 |
} |
|
83 |
|
|
84 |
private getPage(pageId: string) { |
|
85 |
this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
86 |
page => { |
|
87 |
// if( (this.communityPid == 'openaire' && !page.openaire) |
|
88 |
// || (this.communityPid == 'connect' && !page.connect) |
|
89 |
// || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { |
|
90 |
if(this.properties.adminToolsPortalType != page.portalType) { |
|
91 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); |
|
92 |
} else { |
|
93 |
this.page = page; |
|
94 |
this.showLoading = false; |
|
95 |
} |
|
96 |
}, |
|
97 |
error => this.handleError('System error retrieving page with id: '+pageId, error) |
|
98 |
); |
|
99 |
} |
|
100 |
|
|
101 |
private getDivHelpContent(divContentId: string) { |
|
102 |
if(!Session.isLoggedIn()){ |
|
103 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
104 |
} else { |
|
105 |
this.showLoading = true; |
|
106 |
this.errorMessage = ""; |
|
107 |
this.updateErrorMessage = ""; |
|
108 |
|
|
109 |
this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
110 |
divHelpContent => { |
|
111 |
if(this.pageId) { |
|
112 |
this.getPage(this.pageId); |
|
113 |
} |
|
114 |
this.updateForm(divHelpContent); |
|
115 |
this.showLoading = false; |
|
116 |
}, |
|
117 |
error => this.handleError('System error retrieving class help content', error)); |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
getDivId(divId: string) { |
|
122 |
if(!Session.isLoggedIn()){ |
|
123 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
124 |
} else { |
|
125 |
this.showLoading = true; |
|
126 |
|
|
127 |
this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
128 |
div => { |
|
129 |
this.formComponent.selectedDiv = div; |
|
130 |
|
|
131 |
if(!this.pageId) { |
|
132 |
this.formComponent.getDivs(""); |
|
133 |
} |
|
134 |
|
|
135 |
this.showLoading = false; |
|
136 |
}, |
|
137 |
error => this.handleError('System error retrieving class', error) |
|
138 |
); |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
private updateForm(divHelpContent : DivHelpContent) { |
|
143 |
this.divHelpContent = divHelpContent; |
|
144 |
|
|
145 |
this.getDivId(divHelpContent.divId as string); |
|
146 |
|
|
147 |
this.formComponent.myForm.patchValue((divHelpContent)); |
|
148 |
} |
|
149 |
|
|
150 |
public saveCustom() { |
|
151 |
if(!Session.isLoggedIn()){ |
|
152 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
153 |
} else { |
|
154 |
if(this.formComponent.myForm.valid) { |
|
155 |
this.showLoading = true; |
|
156 |
this.updateErrorMessage = ""; |
|
157 |
|
|
158 |
let divHelpContent : DivHelpContent = this.formComponent.myForm.value; |
|
159 |
|
|
160 |
this._helpContentService.updateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
161 |
_ => { |
|
162 |
if(this.pageId) { |
|
163 |
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); |
|
164 |
} else { |
|
165 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); |
|
166 |
} |
|
167 |
this.showLoading = false; |
|
168 |
this._clearCacheService.clearCache("class help content updated"); |
|
169 |
}, |
|
170 |
err => this.handleUpdateError('System error updating class content', err) |
|
171 |
); |
|
172 |
} else { |
|
173 |
this.errorMessage = "Please fill all required fields"; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
public cancelCustom() { |
|
179 |
this.errorMessage = ""; |
|
180 |
this.updateErrorMessage = ""; |
|
181 |
|
|
182 |
if(this.pageId) { |
|
183 |
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); |
|
184 |
} else { |
|
185 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-content-form.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {CommonModule} from '@angular/common'; |
|
3 |
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
|
4 |
import {FABModule} from '../../utils/fabModule.module'; |
|
5 |
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; |
|
6 |
import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; |
|
7 |
import {DivContentFormComponent} from './div-help-content-form.component'; |
|
8 |
import {CKEditorModule} from 'ng2-ckeditor'; |
|
9 |
|
|
10 |
@NgModule({ |
|
11 |
imports: [ |
|
12 |
CommonModule, FormsModule, |
|
13 |
FABModule, SafeHtmlPipeModule, CKEditorModule, |
|
14 |
AlertModalModule, ReactiveFormsModule |
|
15 |
], |
|
16 |
declarations: [ |
|
17 |
DivContentFormComponent |
|
18 |
], |
|
19 |
exports: [DivContentFormComponent] |
|
20 |
}) |
|
21 |
export class DivHelpContentFormModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/new-div-help-content.component.html | ||
---|---|---|
1 |
<div id="newDivHelpContent" class="uk-card uk-card-default uk-padding"> |
|
2 |
<div id="content"> |
|
3 |
<div class="menubar fixed"> |
|
4 |
<div class="sidebar-toggler visible-xs"> |
|
5 |
<i class="ion-navicon"></i> |
|
6 |
</div> |
|
7 |
|
|
8 |
<div class="uk-text-large">New Class help text <span *ngIf="page && page.name">of page "{{page.name}}"</span></div> |
|
9 |
</div> |
|
10 |
|
|
11 |
<div class="content-wrapper"> |
|
12 |
|
|
13 |
<div> |
|
14 |
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div> |
|
15 |
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div> |
|
16 |
|
|
17 |
<div-content-form [communityPid]="communityPid" [pageId]="pageId" [updateErrorMessage]="updateErrorMessage"></div-content-form> |
|
18 |
<button (click)="saveCustom()" class="uk-button uk-button-primary">Save class help text</button> |
|
19 |
<button (click)="cancelCustom()" class="uk-button">Cancel</button> |
|
20 |
</div> |
|
21 |
</div> |
|
22 |
</div> |
|
23 |
</div> |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-contents.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {CommonModule} from '@angular/common'; |
|
4 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
5 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
6 |
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
|
7 |
import {FABModule} from '../../utils/fabModule.module'; |
|
8 |
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; |
|
9 |
import {DivHelpContentsRoutingModule} from './div-help-contents-routing.module'; |
|
10 |
import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; |
|
11 |
import {DivHelpContentsComponent} from './div-help-contents.component'; |
|
12 |
import {MatSlideToggleModule} from '@angular/material'; |
|
13 |
|
|
14 |
@NgModule({ |
|
15 |
imports: [ |
|
16 |
CommonModule, RouterModule, FormsModule, FABModule, SafeHtmlPipeModule, |
|
17 |
AlertModalModule, ReactiveFormsModule, DivHelpContentsRoutingModule, MatSlideToggleModule |
|
18 |
], |
|
19 |
declarations: [ |
|
20 |
DivHelpContentsComponent |
|
21 |
], |
|
22 |
providers: [IsCommunity, ConnectAdminLoginGuard], |
|
23 |
exports: [DivHelpContentsComponent] |
|
24 |
}) |
|
25 |
export class DivHelpContentsModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/edit-div-help-content.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {CommonModule} from '@angular/common'; |
|
4 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
5 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
6 |
import {EditDivHelpContentRoutingModule} from './edit-div-help-content-routing.module'; |
|
7 |
import {EditDivHelpContentComponent} from './edit-div-help-content.component'; |
|
8 |
import {DivHelpContentFormModule} from './div-help-content-form.module'; |
|
9 |
|
|
10 |
@NgModule({ |
|
11 |
imports: [ |
|
12 |
CommonModule, RouterModule, |
|
13 |
DivHelpContentFormModule, EditDivHelpContentRoutingModule |
|
14 |
], |
|
15 |
declarations: [ |
|
16 |
EditDivHelpContentComponent |
|
17 |
], |
|
18 |
providers: [IsCommunity, ConnectAdminLoginGuard], |
|
19 |
exports: [EditDivHelpContentComponent] |
|
20 |
}) |
|
21 |
export class EditDivHelpContentModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/new-div-help-content.component.ts | ||
---|---|---|
1 |
import { Component, ViewChild, ElementRef } from '@angular/core'; |
|
2 |
import { ActivatedRoute, Router } from "@angular/router"; |
|
3 |
import { DivContentFormComponent } from "./div-help-content-form.component"; |
|
4 |
import { DivHelpContent } from "../../domain/div-help-content"; |
|
5 |
import { HelpContentService } from "../../services/help-content.service"; |
|
6 |
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; |
|
7 |
|
|
8 |
import {Session} from '../../openaireLibrary/login/utils/helper.class'; |
|
9 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
10 |
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; |
|
11 |
import {Page} from "../../domain/page"; |
|
12 |
import {Title} from '@angular/platform-browser'; |
|
13 |
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; |
|
14 |
|
|
15 |
@Component({ |
|
16 |
selector: 'new-div-help-content', |
|
17 |
templateUrl: 'new-div-help-content.component.html', |
|
18 |
}) |
|
19 |
|
|
20 |
export class NewDivHelpContentComponent { |
|
21 |
|
|
22 |
@ViewChild(DivContentFormComponent) |
|
23 |
public formComponent : DivContentFormComponent; |
|
24 |
|
|
25 |
//private errorMessage : string = null; |
|
26 |
|
|
27 |
public communityPid: string; |
|
28 |
|
|
29 |
public pageId: string; |
|
30 |
public page: Page; |
|
31 |
|
|
32 |
public properties:EnvProperties = null; |
|
33 |
|
|
34 |
public showLoading: boolean = true; |
|
35 |
public errorMessage: string = ''; |
|
36 |
public updateErrorMessage: string = ''; |
|
37 |
|
|
38 |
constructor( |
|
39 |
private element: ElementRef, |
|
40 |
private route: ActivatedRoute, |
|
41 |
private router: Router, |
|
42 |
private title: Title, |
|
43 |
private _helpContentService: HelpContentService, |
|
44 |
private _clearCacheService: ClearCacheService) {} |
|
45 |
|
|
46 |
ngOnInit() { |
|
47 |
this.route.data |
|
48 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
49 |
this.properties = data.envSpecific; |
|
50 |
this.route.queryParams.subscribe(params => { |
|
51 |
HelperFunctions.scroll(); |
|
52 |
this.title.setTitle('Administration Dashboard | New Class Help Text'); |
|
53 |
this.communityPid = params['communityId']; |
|
54 |
this.pageId = params['pageId']; |
|
55 |
|
|
56 |
|
|
57 |
if(this.pageId) { |
|
58 |
this.getPage(this.pageId); |
|
59 |
} else { |
|
60 |
this.showLoading = false; |
|
61 |
} |
|
62 |
}); |
|
63 |
}); |
|
64 |
} |
|
65 |
|
|
66 |
private getPage(pageId: string) { |
|
67 |
this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
68 |
page => { |
|
69 |
// if( (this.communityPid == 'openaire' && !page.openaire) |
|
70 |
// || (this.communityPid == 'connect' && !page.connect) |
|
71 |
// || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { |
|
72 |
if(this.properties.adminToolsPortalType != page.portalType) { |
|
73 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); |
|
74 |
} else { |
|
75 |
this.page = page; |
|
76 |
this.showLoading = false; |
|
77 |
console.info(this.page); |
|
78 |
} |
|
79 |
}, |
|
80 |
error => this.handleError('System error retrieving page with id: '+pageId, error) |
|
81 |
); |
|
82 |
} |
|
83 |
|
|
84 |
public saveCustom() { |
|
85 |
if(!Session.isLoggedIn()){ |
|
86 |
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); |
|
87 |
} else { |
|
88 |
if(this.formComponent.myForm.valid) { |
|
89 |
this.showLoading = true; |
|
90 |
this.updateErrorMessage = ""; |
|
91 |
|
|
92 |
let divHelpContent : DivHelpContent = this.formComponent.myForm.value; |
|
93 |
|
|
94 |
this._helpContentService.saveDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
95 |
_ => { |
|
96 |
if(this.pageId) { |
|
97 |
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); |
|
98 |
} else { |
|
99 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); |
|
100 |
} |
|
101 |
this.showLoading = false; |
|
102 |
this._clearCacheService.clearCache("class help content saved"); |
|
103 |
}, |
|
104 |
err => this.handleUpdateError('System error saving page content', err) |
|
105 |
); |
|
106 |
} else { |
|
107 |
this.errorMessage = "Please fill all required fields"; |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
public cancelCustom() { |
|
113 |
if(this.pageId) { |
|
114 |
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); |
|
115 |
} else { |
|
116 |
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
handleUpdateError(message: string, error) { |
|
121 |
this.errorMessage = message; |
|
122 |
console.log('Server responded: ' + error); |
|
123 |
this.showLoading = false; |
|
124 |
} |
|
125 |
|
|
126 |
handleError(message: string, error) { |
|
127 |
this.errorMessage = message; |
|
128 |
console.log('Server responded: ' + error); |
|
129 |
this.showLoading = false; |
|
130 |
} |
|
131 |
} |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/new-div-help-content.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {CommonModule} from '@angular/common'; |
|
4 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
5 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
6 |
import {NewDivHelpContentRoutingModule} from './new-div-help-content-routing.module'; |
|
7 |
import {NewDivHelpContentComponent} from './new-div-help-content.component'; |
|
8 |
import {DivHelpContentFormModule} from './div-help-content-form.module'; |
|
9 |
|
|
10 |
@NgModule({ |
|
11 |
imports: [ |
|
12 |
CommonModule, RouterModule, |
|
13 |
DivHelpContentFormModule, NewDivHelpContentRoutingModule |
|
14 |
], |
|
15 |
declarations: [ |
|
16 |
NewDivHelpContentComponent |
|
17 |
], |
|
18 |
providers: [IsCommunity, ConnectAdminLoginGuard], |
|
19 |
exports: [NewDivHelpContentComponent] |
|
20 |
}) |
|
21 |
export class NewDivHelpContentModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-contents-routing.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
4 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
5 |
import {DivHelpContentsComponent} from './div-help-contents.component'; |
|
6 |
|
|
7 |
@NgModule({ |
|
8 |
imports: [ |
|
9 |
RouterModule.forChild([ |
|
10 |
{ path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: DivHelpContentsComponent} |
|
11 |
]) |
|
12 |
] |
|
13 |
}) |
|
14 |
export class DivHelpContentsRoutingModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/edit-div-help-content-routing.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
4 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
5 |
import {EditDivHelpContentComponent} from './edit-div-help-content.component'; |
|
6 |
|
|
7 |
@NgModule({ |
|
8 |
imports: [ |
|
9 |
RouterModule.forChild([ |
|
10 |
{ path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: EditDivHelpContentComponent} |
|
11 |
]) |
|
12 |
] |
|
13 |
}) |
|
14 |
export class EditDivHelpContentRoutingModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-content-form.component.html | ||
---|---|---|
1 |
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div> |
|
2 |
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div> |
|
3 |
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div> |
|
4 |
<div class="uk-alert uk-alert-primary uk-margin-top-large"> |
|
5 |
<span class="uk-margin-small-right uk-icon" uk-icon="info"></span> |
|
6 |
Create or edit help text |
|
7 |
<div class="uk-text-small"> |
|
8 |
Select the class to be displayed, add the content and click active to make it visible to dashboard |
|
9 |
</div> |
|
10 |
|
|
11 |
</div> |
|
12 |
<form *ngIf="!errorMessage && !showLoading" [formGroup]="myForm"> |
|
13 |
<div class="form-group"> |
|
14 |
<div class="uk-margin-bottom" *ngIf="selectedDiv">Class content displayed in page(s): <span *ngFor="let page of selectedDiv.pages let i=index">{{page.name}}<span *ngIf="i<(selectedDiv.pages.length-1)">, </span></span></div> |
|
15 |
|
|
16 |
<div *ngIf="showPageSelect && !editMode" class="form-group"> |
|
17 |
<label for="pageTag">Select Page</label> |
|
18 |
<select id="pageTag" (change)="pageSelected($event)" [value]="pageId ? pageId : ''"> |
|
19 |
<option *ngIf="!pageId"></option> |
|
20 |
<option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option> |
|
21 |
</select> |
|
22 |
</div> |
|
23 |
|
|
24 |
<div *ngIf="pageId || selectedDiv" class="form-group"> |
|
25 |
<label for="divTag">Select Class</label> |
|
26 |
<select formControlName="divId" id="divTag" class="form-control"> |
|
27 |
<!-- <option *ngIf="selectedDiv" [value]="selectedDiv._id">{{selectedDiv.name}}</option> --> |
|
28 |
<option *ngFor="let div of availableDivs" [value]="div._id" (click)="divIdSelected(div)">{{div.name}}</option> |
|
29 |
</select> |
|
30 |
</div> |
|
31 |
|
|
32 |
</div> |
|
33 |
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.content.valid && myForm.controls.content.dirty}"> |
|
34 |
<label>Content</label> |
|
35 |
<div> |
|
36 |
<!-- [config]="{allowedContent: true,extraAllowedContent : '*(*)'}"> --> |
|
37 |
<ckeditor |
|
38 |
[readonly]="false" |
|
39 |
debounce="500" |
|
40 |
formControlName="content" |
|
41 |
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print', |
|
42 |
extraPlugins: 'divarea'}"> |
|
43 |
</ckeditor> |
|
44 |
</div> |
|
45 |
</div> |
|
46 |
<div class="form-group"> |
|
47 |
<label>Select Status</label> |
|
48 |
<label class="checkbox"> |
|
49 |
<span style="font-weight: normal;">Active</span> |
|
50 |
<input tabindex="0" type="checkbox" formControlName="isActive"> |
|
51 |
|
|
52 |
</label> |
|
53 |
</div> |
|
54 |
<input type="hidden" formControlName="_id"> |
|
55 |
</form> |
|
56 |
<!-- <div *ngIf="selectedDiv"><span *ngFor="let page of selectedDiv.pages">{{page.name}} </span></div> --> |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/new-div-help-content-routing.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
4 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
5 |
import {NewDivHelpContentComponent} from './new-div-help-content.component'; |
|
6 |
|
|
7 |
@NgModule({ |
|
8 |
imports: [ |
|
9 |
RouterModule.forChild([ |
|
10 |
{ path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: NewDivHelpContentComponent} |
|
11 |
]) |
|
12 |
] |
|
13 |
}) |
|
14 |
export class NewDivHelpContentRoutingModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-content-form.component.ts | ||
---|---|---|
1 |
import { Component, OnInit, Input } from '@angular/core'; |
|
2 |
import { ActivatedRoute, Router } from "@angular/router"; |
|
3 |
import { FormGroup, FormBuilder, Validators } from "@angular/forms"; |
|
4 |
import { Page } from "../../domain/page"; |
|
5 |
import { DivId } from "../../domain/divId"; |
|
6 |
import { HelpContentService } from "../../services/help-content.service"; |
|
7 |
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; |
|
8 |
|
|
9 |
import {Session} from '../../openaireLibrary/login/utils/helper.class'; |
|
10 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
11 |
|
|
12 |
@Component({ |
|
13 |
selector: 'div-content-form', |
|
14 |
templateUrl: './div-help-content-form.component.html', |
|
15 |
}) |
|
16 |
|
|
17 |
export class DivContentFormComponent implements OnInit{ |
|
18 |
|
|
19 |
@Input('group') |
|
20 |
myForm: FormGroup; |
|
21 |
@Input('communityPid') |
|
22 |
communityPid: string; |
|
23 |
@Input('pageId') |
|
24 |
pageId: string; |
|
25 |
@Input('editMode') |
|
26 |
editMode: boolean = false; |
|
27 |
|
|
28 |
//public divIdName: string = ''; |
|
29 |
|
|
30 |
private communityId: string = ''; |
|
31 |
|
|
32 |
showPageSelect: boolean = true; |
|
33 |
selectedDiv: DivId; |
|
34 |
|
|
35 |
private availablePages : Page[] = []; |
|
36 |
private availableDivs : DivId[] = []; |
|
37 |
|
|
38 |
private ckeditorContent : string; |
|
39 |
|
|
40 |
public properties:EnvProperties = null; |
|
41 |
|
|
42 |
public showLoading: boolean = true; |
|
43 |
public errorMessage: string = ''; |
|
44 |
@Input() updateErrorMessage: string = ''; |
|
45 |
|
|
46 |
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){} |
|
47 |
|
|
48 |
ngOnInit() { |
|
49 |
this.myForm = this.form; |
|
50 |
this.route.data |
|
51 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
52 |
this.properties = data.envSpecific; |
|
53 |
this.route.queryParams.subscribe(params => { |
|
54 |
|
|
55 |
if(!Session.isLoggedIn()){ |
|
56 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
57 |
} else { |
|
58 |
if(this.pageId) { |
|
59 |
this.showPageSelect = false; |
|
60 |
this.getDivs(this.pageId); |
|
61 |
} else { |
|
62 |
if(!this.editMode) { |
|
63 |
this._helpContentService.getCommunityPagesWithDivId(this.communityPid, this.properties.adminToolsAPIURL).subscribe( |
|
64 |
pages => { |
|
65 |
this.availablePages = pages; |
|
66 |
this.showLoading = false; |
|
67 |
}, |
|
68 |
error => this.handleError('System error retrieving pages', error)); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
this.getCommunity(this.communityPid); |
|
73 |
} |
|
74 |
}); |
|
75 |
}); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
public pageSelected(event) { |
|
80 |
if(!Session.isLoggedIn()){ |
|
81 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
82 |
} else { |
|
83 |
this.getDivs(event.target.value); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
public divIdSelected(div: DivId) { |
|
88 |
this.selectedDiv = div; |
|
89 |
} |
|
90 |
|
|
91 |
public getCommunity(communityPid: string) { |
|
92 |
if(!Session.isLoggedIn()){ |
|
93 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
94 |
} else { |
|
95 |
this.showLoading = true; |
|
96 |
this.errorMessage = ''; |
|
97 |
|
|
98 |
this._helpContentService.getCommunity(this.communityPid, this.properties.adminToolsAPIURL).subscribe( |
|
99 |
community => { |
|
100 |
this.communityId = community._id; |
|
101 |
|
|
102 |
this.myForm.patchValue({ |
|
103 |
community: this.communityId |
|
104 |
}); |
|
105 |
this.showLoading = false; |
|
106 |
}, |
|
107 |
error => this.handleError('System error retrieving community', error) |
|
108 |
); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
public getDivs(pageId: string) { |
|
113 |
if(!Session.isLoggedIn()){ |
|
114 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
115 |
} else { |
|
116 |
//this.showLoading = true; |
|
117 |
this.errorMessage = ''; |
|
118 |
|
|
119 |
this._helpContentService.getDivIdsFullByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( |
|
120 |
divs => { |
|
121 |
this.availableDivs = divs; |
|
122 |
this.pageId = pageId; |
|
123 |
|
|
124 |
this.showLoading = false; |
|
125 |
}, |
|
126 |
error => this.handleError('System error retrieving pages', error)); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
// public selectedDiv(event) { |
|
131 |
// console.info(event.target.value); |
|
132 |
// } |
|
133 |
|
|
134 |
public get form() { |
|
135 |
return this._fb.group({ |
|
136 |
divId: ['', Validators.required], |
|
137 |
content: ['', Validators.required], |
|
138 |
isActive: true, |
|
139 |
portal: this.communityPid, |
|
140 |
_id : '', |
|
141 |
}); |
|
142 |
} |
|
143 |
|
|
144 |
public reset() { |
|
145 |
this.myForm.patchValue({ |
|
146 |
divId: '', |
|
147 |
content: '', |
|
148 |
isActive: true, |
|
149 |
portal: this.communityPid, |
|
150 |
_id : '' |
|
151 |
}); |
|
152 |
this.myForm.markAsPristine(); |
|
153 |
} |
|
154 |
|
|
155 |
handleError(message: string, error) { |
|
156 |
this.errorMessage = message; |
|
157 |
console.log('Server responded: ' + error); |
|
158 |
|
|
159 |
this.showLoading = false; |
|
160 |
} |
|
161 |
} |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/div-help-contents.component.html | ||
---|---|---|
1 |
<div id="divHelpContents"> |
|
2 |
|
|
3 |
<div class="menubar "> |
|
4 |
|
|
5 |
<div *ngIf="!selectedPageId" class="divHelpContent-title uk-text-large">Class help texts</div> |
|
6 |
<div *ngIf="selectedPageId && page" class="divHelpContent-title uk-text-large">Class help texts of page '{{page.name}}'</div> |
|
7 |
|
|
8 |
<div *ngIf="updateErrorMessage" class="uk-alert-danger" uk-alert> |
|
9 |
<a class="uk-alert-close" uk-close></a> |
|
10 |
{{updateErrorMessage}} |
|
11 |
</div> |
|
12 |
|
|
13 |
<div *ngIf="!errorMessage && !showLoading" class="page-controls"> |
|
14 |
<div class=" filters "> |
|
15 |
<div class="show-options uk-float-right"> |
|
16 |
<button class="uk-button" type="button">Bulk Actions</button> |
|
17 |
<div uk-dropdown="mode: click"> |
|
18 |
<ul class="uk-nav uk-navbar-dropdown-nav" |
|
19 |
[attr.uk-tooltip]="getSelectedDivHelpContents().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'" |
|
20 |
title="Select at least one help text"> |
|
21 |
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''" (click)="toggleDivHelpContents(true,getSelectedDivHelpContents())"><i></i> Activate </a></li> |
|
22 |
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''" (click)="toggleDivHelpContents(false,getSelectedDivHelpContents())"><i></i> Deactivate </a></li> |
|
23 |
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''" (click)="confirmDeleteSelectedDivHelpContents()"><i></i> Delete </a></li> |
|
24 |
</ul> |
|
25 |
</div> |
|
26 |
</div> |
|
27 |
</div> |
|
28 |
</div> |
|
29 |
<!-- <a *ngIf="!selectedPageId" [queryParams]="{communityId: selectedCommunityPid}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New help text </a> --> |
|
30 |
<!-- <a *ngIf="selectedPageId" [queryParams]="{communityId: selectedCommunityPid, pageId: selectedPageId}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New class help text </a> --> |
|
31 |
<div class="uk-grid uk-margin-bottom"> |
|
32 |
<form target="BSFormPanel_Admin_1" class="search"> |
|
33 |
<!-- <input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Class Help text..." type="text" class="uk-input uk-width-medium"/> |
|
34 |
<button class="uk-button" type="submit">Search</button> --> |
|
35 |
<input type="text" class="uk-input uk-width-medium" placeholder="Class name, content..." aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" > |
|
36 |
<button (click)="filterBySearch(keyword)" type="submit" class=" uk-button"> |
|
37 |
<span class="uk-icon"> |
|
38 |
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg> |
|
39 |
</span>Search |
|
40 |
</button> |
|
41 |
</form> |
|
42 |
<div *ngIf="!selectedPageId" class="filters marginBottom20"> |
|
43 |
<div class="links form-group form-inline"> |
|
44 |
<span>Filter by page:</span> |
|
45 |
<select class="uk-select uk-width-medium" (change)="filterByPage($event)"> |
|
46 |
<option value="">-- none selected --</option> |
|
47 |
<option *ngFor="let page of pages" value="{{page._id}}">{{page.name}}</option> |
|
48 |
</select> |
|
49 |
</div> |
|
50 |
</div> |
|
51 |
</div> |
|
52 |
</div> |
|
53 |
|
|
54 |
<div class="content-wrapper" id="contentWrapper"> |
|
55 |
<div> |
|
56 |
<div class="contentPanel"> |
|
57 |
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger uk-margin-large-top" role="alert">{{errorMessage}}</div> |
|
58 |
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div> |
|
59 |
|
|
60 |
<div *ngIf="!errorMessage && !showLoading"> |
|
61 |
<div class="gwt-HTML"> |
|
62 |
<div class="users-list"> <!--"row" class removed"--> |
|
63 |
<div class="col-md-12"> |
|
64 |
|
|
65 |
<!-- <div *ngIf="!selectedPageId" class="filters marginBottom20"> |
|
66 |
<div class="links form-group form-inline"> |
|
67 |
<span>Filter by community:</span> |
|
68 |
<select class="uk-select uk-width-medium" (change)="filterByCommunity($event)"> |
|
69 |
<option *ngFor="let community of communities" value="{{community.pid}}">{{community.name}}</option> |
|
70 |
</select> |
|
71 |
</div> |
|
72 |
</div> --> |
|
73 |
<div class="uk-alert uk-alert-primary uk-margin-top-large"> |
|
74 |
<span class="uk-margin-small-right uk-icon" uk-icon="info"></span> |
|
75 |
Enable or disable help text to show or hide it from the dashboard |
|
76 |
|
|
77 |
</div> |
|
78 |
|
|
79 |
<ul uk-tab class="links"> |
|
80 |
<li [ngClass]="{'uk-active' : filters.active==null}" (click)="displayAllDivHelpContents()"> |
|
81 |
<a>All class help texts <span class="uk-badge">{{counter.all | number}}</span></a> |
|
82 |
</li> |
|
83 |
<li [ngClass]="{'uk-active' : filters.active==true}" (click)="displayActiveDivHelpContents()"> |
|
84 |
<a>Active <span class="uk-badge">{{counter.active | number}}</span></a> |
|
85 |
</li> |
|
86 |
<li [ngClass]="{'uk-active' : filters.active==false}" (click)="displayInactiveDivHelpContents()"> |
|
87 |
<a>Inactive <span class="uk-badge">{{counter.inactive | number}}</span></a> |
|
88 |
</li> |
|
89 |
</ul> |
|
90 |
|
|
91 |
<table class="uk-table uk-table-striped"> |
|
92 |
<thead> |
|
93 |
<tr> |
|
94 |
<th><input id="allDivHelpContentsCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th> |
|
95 |
<th *ngIf="!selectedPageId">Page</th> |
|
96 |
<!--th *ngIf="!selectedPageId">Community</th--> |
|
97 |
<th>Class</th> |
|
98 |
<th>Content</th> |
|
99 |
<th>Change status</th> |
|
100 |
<th>Actions</th> |
|
101 |
</tr> |
|
102 |
</thead> |
|
103 |
<tbody > |
|
104 |
<tr *ngFor="let check of checkboxes; let i=index"> |
|
105 |
<td><input id="{{check.divHelpContent._id}}" class="checkBox" type="checkbox" |
|
106 |
name="entitiescb[]" value="{{check.divHelpContent._id}}" [(ngModel)]="check.checked"> |
|
107 |
</td> |
|
108 |
<td *ngIf="!selectedPageId"> |
|
109 |
<!-- <div class="page" href="#">{{check.divHelpContent.divId.page.name}}</div> --> |
|
110 |
<div class="pages" href="#"> |
|
111 |
<span *ngFor="let page of check.divHelpContent.divId.pages let i=index">{{page.name}}<span *ngIf="i<(check.divHelpContent.divId.pages.length-1)">, </span></span> |
|
112 |
</div> |
|
113 |
</td> |
|
114 |
<!--td *ngIf="!selectedPageId"> |
|
115 |
<div class="community" href="#">{{check.divHelpContent.community.name}}</div> |
|
116 |
</td--> |
|
117 |
<td> |
|
118 |
<div class="divId" href="#">{{check.divHelpContent.divId.name}}</div> |
|
119 |
</td> |
|
120 |
<td> |
|
121 |
<!-- <div class="content" [innerHTML]="check.divHelpContent.content | safeHtml"></div>--> |
|
122 |
<div class="content">{{check.divHelpContent.content}}</div> |
|
123 |
</td> |
|
124 |
<td> |
|
125 |
<mat-slide-toggle [checked]="check.divHelpContent.isActive" |
|
126 |
(change)="($event.source.checked = check.divHelpContent.isActive);toggleDivHelpContents(!check.divHelpContent.isActive,[check.divHelpContent._id])"></mat-slide-toggle> |
|
127 |
</td> |
|
128 |
<td> |
|
129 |
<div class="actions" href="#"> |
|
130 |
<input title="Edit" src="assets/imgs/icn_edit.png" class="edit uk-margin-small-right" type="image" (click)="editDivHelpContent(check.divHelpContent._id)"> |
|
131 |
<input title="Delete" src="assets/imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteDivHelpContent(check.divHelpContent._id)"> |
|
132 |
</div> |
|
133 |
</td> |
|
134 |
</tr> |
|
135 |
</tbody> |
|
136 |
</table> |
|
137 |
|
|
138 |
<div *ngIf="checkboxes.length==0" class="col-md-12"> |
|
139 |
<div class="uk-alert-warning" uk-alert>No class help texts found</div> |
|
140 |
</div> |
|
141 |
</div> |
|
142 |
</div> |
|
143 |
</div> |
|
144 |
<a *ngIf="selectedPageId && page" [queryParams]="{type: page.type, communityId: selectedCommunityPid}" routerLink="/pages">Go back to {{page.type}} pages</a> |
|
145 |
</div> |
|
146 |
</div> |
|
147 |
</div> |
|
148 |
</div> |
|
149 |
<fab (clicked)="newClassContent()"></fab> |
|
150 |
</div> |
|
151 |
|
|
152 |
<!-- <delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteDivHelpContents($event)"> |
|
153 |
Are you sure you want to delete the selected help text(s)? |
|
154 |
</delete-confirmation-dialog> --> |
|
155 |
<modal-alert #AlertModalDeleteDivHelpContents (alertOutput)="confirmedDeleteDivHelpContents($event)"></modal-alert> |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/divhelpcontent/edit-div-help-content.component.html | ||
---|---|---|
1 |
<div id="editDivHelpContent" class="uk-card uk-card-default uk-padding"> |
|
2 |
<div id="content"> |
|
3 |
<div class="menubar fixed"> |
|
4 |
<div class="sidebar-toggler visible-xs"> |
|
5 |
<i class="ion-navicon"></i> |
|
6 |
</div> |
|
7 |
|
|
8 |
<div class="uk-text-large">Edit Class help text <span *ngIf="page && page.name">of page "{{page.name}}"</span></div> |
|
9 |
</div> |
|
10 |
|
|
11 |
<div class="content-wrapper"> |
|
12 |
|
|
13 |
<div> |
|
14 |
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div> |
|
15 |
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div> |
|
16 |
|
|
17 |
<div-content-form [communityPid]="communityPid" [pageId]="pageId" [editMode]="true" |
|
18 |
[updateErrorMessage]="updateErrorMessage"></div-content-form> |
|
19 |
<button (click)="saveCustom()" class="uk-button uk-button-primary">Update class help text</button> |
|
20 |
<button (click)="cancelCustom()" class="uk-button">Cancel</button> |
|
21 |
</div> |
|
22 |
</div> |
|
23 |
</div> |
|
24 |
</div> |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {HttpClientModule} from '@angular/common/http'; |
|
3 |
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
|
4 |
import {RouterModule} from '@angular/router'; |
|
5 |
|
|
6 |
|
|
7 |
import {ErrorMessagesModule} from '../../openaireLibrary/utils/errorMessages.module'; |
|
8 |
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; |
|
9 |
import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; |
|
10 |
|
|
11 |
import {HtmlPageContentFormComponent} from './html-page-content-form.component'; |
|
12 |
import {EditHtmlPageContentComponent} from './edit-htmlpage-content.component'; |
|
13 |
import {HtmlPageContentService} from './html-page-content.service'; |
|
14 |
import {EditHtmlPageContentRoutingModule} from './edit-html-page-content-routing.module'; |
|
15 |
import {CommonModule} from '@angular/common'; |
|
16 |
import {CKEditorModule} from 'ng2-ckeditor'; |
|
17 |
|
|
18 |
@NgModule({ |
|
19 |
imports: [ |
|
20 |
CommonModule, |
|
21 |
HttpClientModule, |
|
22 |
FormsModule, |
|
23 |
ReactiveFormsModule, |
|
24 |
RouterModule, |
|
25 |
CKEditorModule, |
|
26 |
ErrorMessagesModule, |
|
27 |
AlertModalModule, |
|
28 |
SafeHtmlPipeModule, |
|
29 |
EditHtmlPageContentRoutingModule |
|
30 |
], |
|
31 |
declarations: [ |
|
32 |
HtmlPageContentFormComponent, |
|
33 |
EditHtmlPageContentComponent, |
|
34 |
], |
|
35 |
providers: [ |
|
36 |
HtmlPageContentService |
|
37 |
], |
|
38 |
exports: [EditHtmlPageContentComponent] |
|
39 |
}) |
|
40 |
|
|
41 |
export class EditHtmlPageContentModule { } |
modules/uoa-admin-portal/branches/new-UI/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts | ||
---|---|---|
1 |
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; |
|
2 |
import { FormGroup } from "@angular/forms"; |
|
3 |
import { ActivatedRoute, Router } from "@angular/router"; |
|
4 |
//import { Location } from "@angular/common"; |
|
5 |
import { HelpContentService } from "../../services/help-content.service"; |
|
6 |
import { HtmlPageContentService } from "./html-page-content.service"; |
|
7 |
import { HtmlPageContent, CheckHtmlPageContent } from "../../domain/html-page-content"; |
|
8 |
import { HtmlPageContentFormComponent } from "./html-page-content-form.component"; |
|
9 |
|
|
10 |
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; |
|
11 |
import { Subscription } from "rxjs"; |
|
12 |
|
|
13 |
import {Session} from '../../openaireLibrary/login/utils/helper.class'; |
|
14 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
15 |
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; |
|
16 |
import {Title} from '@angular/platform-browser'; |
|
17 |
declare var UIkit: any; |
|
18 |
|
|
19 |
@Component({ |
|
20 |
selector: 'edit-htmlpage-content', |
|
21 |
templateUrl: './edit-htmlpage-content.component.html', |
|
22 |
}) |
|
23 |
|
|
24 |
export class EditHtmlPageContentComponent implements OnInit { |
|
25 |
@ViewChild(HtmlPageContentFormComponent) |
|
26 |
public formComponent : HtmlPageContentFormComponent; |
|
27 |
|
|
28 |
communityPid: string; |
|
29 |
pageId: string; |
|
30 |
pageName: string = ""; |
|
31 |
//public mode: string = "edit"; |
|
32 |
|
|
33 |
private sub: Subscription; |
|
34 |
|
|
35 |
private htmlPageContent: HtmlPageContent; |
|
36 |
|
|
37 |
public properties:EnvProperties = null; |
|
38 |
|
|
39 |
public showLoading: boolean = true; |
|
40 |
public errorMessage: string = ''; |
|
41 |
public updateErrorMessage: string = ''; |
|
42 |
|
|
43 |
constructor( |
|
44 |
private element: ElementRef, |
|
45 |
private route: ActivatedRoute, |
|
46 |
private router: Router, |
|
47 |
private title: Title, |
|
48 |
private _helpContentService: HelpContentService, |
|
49 |
private _htmlContentService: HtmlPageContentService) { |
|
50 |
this.router.routeReuseStrategy.shouldReuseRoute = function(){ |
|
51 |
return false; |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
ngOnInit() { |
|
56 |
this.route.data |
|
57 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
58 |
this.properties = data.envSpecific; |
|
59 |
this.sub = this.route.queryParams.subscribe(params => { |
|
60 |
HelperFunctions.scroll(); |
|
61 |
this.title.setTitle('Administration Dashboard | Edit HTML page'); |
|
62 |
this.communityPid = params['communityId']; |
|
63 |
this.pageId = params['pageId']; |
|
64 |
|
|
65 |
this.getPage(this.communityPid, this.pageId); |
|
66 |
}); |
|
67 |
}); |
|
68 |
} |
|
69 |
ngOnDestroy() { |
|
70 |
this.sub.unsubscribe(); |
|
71 |
} |
|
72 |
|
|
73 |
handleError(message: string, error) { |
|
74 |
this.errorMessage = message; |
|
75 |
console.log('Server responded: ' + error); |
|
76 |
this.showLoading = false; |
|
77 |
} |
|
78 |
|
|
79 |
handleUpdateError(message: string, error) { |
Also available in: Unified diff
[Admin | NewUI]: Delete unneeded files. Remove connect-files from svn library