Revision 60202
Added by Argiro Kokogiannaki over 3 years ago
divIds.component.ts | ||
---|---|---|
12 | 12 |
import {Observable, Subscriber} from "rxjs"; |
13 | 13 |
import {map, startWith} from "rxjs/operators"; |
14 | 14 |
import {MatAutocompleteSelectedEvent, MatChipInputEvent} from "@angular/material"; |
15 |
import {properties} from "../../../../environments/environment"; |
|
16 |
import {PortalUtils} from "../portal/portalHelper"; |
|
17 |
import {CheckPortal, Portal} from "../../utils/entities/adminTool/portal"; |
|
15 | 18 |
|
16 | 19 |
@Component({ |
17 | 20 |
selector: 'divIds', |
... | ... | |
39 | 42 |
public errorMessage: string = ''; |
40 | 43 |
public updateErrorMessage: string = ''; |
41 | 44 |
public modalErrorMessage: string = ''; |
42 |
public filterForm: FormControl;
|
|
45 |
public filterForm: FormGroup;
|
|
43 | 46 |
private subscriptions: any[] = []; |
44 | 47 |
public allPages: Page[] = []; |
45 | 48 |
filteredPages: Observable<Page[]>; |
46 | 49 |
@ViewChild('PageInput') pageInput: ElementRef<HTMLInputElement>; |
47 | 50 |
selectedPages: Page[] = []; |
48 | 51 |
selectedCommunityPid = null; |
49 |
|
|
52 |
public portalUtils:PortalUtils = new PortalUtils(); |
|
50 | 53 |
ngOnInit() { |
51 |
this.filterForm = this._fb.control(''); |
|
52 |
this.pageSearchCtrl = this._fb.control(''); |
|
53 |
this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => { |
|
54 |
this.filterForm = this._fb.group({ |
|
55 |
keyword: [''], |
|
56 |
type: ['all', Validators.required]}); |
|
57 |
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => { |
|
54 | 58 |
this.filterBySearch(value); |
55 | 59 |
})); |
60 |
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => { |
|
61 |
this.applyTypeFilter(); |
|
62 |
})); |
|
63 |
this.pageSearchCtrl = this._fb.control(''); |
|
56 | 64 |
this.pagesCtrl = this._fb.array([]); |
57 | 65 |
this.myForm = this._fb.group({ |
58 | 66 |
_id: '', |
... | ... | |
60 | 68 |
pages: this.pagesCtrl, |
61 | 69 |
portalType: ['', Validators.required] |
62 | 70 |
}); |
71 |
this.properties = properties; |
|
72 |
this.getDivIds(); |
|
73 |
this.subscriptions.push(this.route.queryParams.subscribe(params => { |
|
74 |
HelperFunctions.scroll(); |
|
75 |
this.selectedCommunityPid = params['communityId']; |
|
76 |
this.getPages(); |
|
77 |
})); |
|
63 | 78 |
|
64 |
this.route.data |
|
65 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
|
66 |
HelperFunctions.scroll(); |
|
67 |
|
|
68 |
this.properties = data.envSpecific; |
|
69 |
|
|
70 |
this.getDivIds(); |
|
71 |
this.route.queryParams.subscribe(params => { |
|
72 |
this.selectedCommunityPid = params['communityId']; |
|
73 |
this.getPages(); |
|
74 |
}); |
|
75 |
}); |
|
76 | 79 |
} |
77 | 80 |
|
78 | 81 |
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService, private _fb: FormBuilder) { |
... | ... | |
101 | 104 |
this.updateErrorMessage = ""; |
102 | 105 |
this.errorMessage = ""; |
103 | 106 |
|
104 |
this._helpContentService.getAllDivIdsFull( this.properties.adminToolsAPIURL).subscribe( |
|
107 |
this.subscriptions.push(this._helpContentService.getAllDivIdsFull( this.properties.adminToolsAPIURL).subscribe(
|
|
105 | 108 |
divIds => { |
106 | 109 |
this.divIds = divIds; |
107 | 110 |
this.checkboxes = []; |
... | ... | |
113 | 116 |
|
114 | 117 |
this.showLoading = false; |
115 | 118 |
}, |
116 |
error => this.handleError('System error retrieving classes', error)); |
|
119 |
error => this.handleError('System error retrieving classes', error)));
|
|
117 | 120 |
} |
118 | 121 |
} |
119 | 122 |
|
... | ... | |
179 | 182 |
} else { |
180 | 183 |
this.showLoading = true; |
181 | 184 |
this.updateErrorMessage = ""; |
182 |
this._helpContentService.deleteDivIds(this.selectedDivIds, this.properties.adminToolsAPIURL).subscribe( |
|
185 |
this.subscriptions.push(this._helpContentService.deleteDivIds(this.selectedDivIds, this.properties.adminToolsAPIURL).subscribe(
|
|
183 | 186 |
_ => { |
184 | 187 |
this.deleteDivIdsFromArray(this.selectedDivIds); |
185 | 188 |
this.showLoading = false; |
186 | 189 |
}, |
187 | 190 |
error => this.handleUpdateError('System error deleting the selected classes', error) |
188 |
); |
|
191 |
));
|
|
189 | 192 |
} |
190 | 193 |
} |
191 | 194 |
|
... | ... | |
260 | 263 |
|
261 | 264 |
this.modalErrorMessage = ""; |
262 | 265 |
|
263 |
this._helpContentService.saveDivId(<DivId>this.myForm.value, this.properties.adminToolsAPIURL).subscribe( |
|
266 |
this.subscriptions.push(this._helpContentService.saveDivId(<DivId>this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
|
|
264 | 267 |
divId => { |
265 | 268 |
this.divIdSavedSuccessfully(divId); |
266 | 269 |
}, |
267 | 270 |
error => this.handleUpdateError("System error creating class", error) |
268 |
); |
|
271 |
));
|
|
269 | 272 |
} else { |
270 |
this._helpContentService.updateDivId(<DivId>this.myForm.value, this.properties.adminToolsAPIURL).subscribe( |
|
273 |
this.subscriptions.push(this._helpContentService.updateDivId(<DivId>this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
|
|
271 | 274 |
divId => { |
272 | 275 |
this.divIdUpdatedSuccessfully(divId); |
273 | 276 |
}, |
274 | 277 |
error => this.handleUpdateError("System error updating class", error) |
275 |
); |
|
278 |
));
|
|
276 | 279 |
|
277 | 280 |
} |
278 | 281 |
} |
... | ... | |
299 | 302 |
_ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false}) |
300 | 303 |
); |
301 | 304 |
} |
305 |
public applyTypeFilter() { |
|
306 |
this.checkboxes = []; |
|
307 |
this.divIds.filter(item => this.filterByType(item)).forEach( |
|
308 |
_ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false}) |
|
309 |
); |
|
310 |
} |
|
302 | 311 |
|
312 |
public filterByType(divId: DivId): boolean { |
|
313 |
let type = this.filterForm.get("type").value; |
|
314 |
return type == "all" || (type == divId.portalType); |
|
315 |
} |
|
303 | 316 |
public filterDivIds(divId: DivId): boolean { |
304 | 317 |
let textFlag = this.searchText.toString() == '' || (divId.name + ' ' + divId.portalType).match(this.searchText) != null; |
305 | 318 |
return textFlag; |
... | ... | |
326 | 339 |
getPages() { |
327 | 340 |
this.showLoading = true; |
328 | 341 |
this.errorMessage = ""; |
329 |
this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe( |
|
342 |
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
|
|
330 | 343 |
pages => { |
331 | 344 |
this.allPages = pages; |
332 | 345 |
this.showLoading = false; |
333 | 346 |
}, |
334 | 347 |
error => this.handleError('System error retrieving pages', error) |
335 |
); |
|
348 |
));
|
|
336 | 349 |
|
337 | 350 |
} |
338 | 351 |
|
Also available in: Unified diff
[Library | Trunk]
Dashboard - Admin tool pages:
- add tabs components
- add rout module (without guards)
- put tabs and page-content in pages, classes, entities pages
Stakeholder:
initial try to add filters for country and organization fields (doesn't work properly)