Skip to content

Commit 0d9d960

Browse files
Description for functions
1 parent 4074894 commit 0d9d960

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

project/ws/app/src/lib/routes/home/routes/add-thumbnail/add-thumbnail.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ export class AddThumbnailComponent implements OnInit {
6969

7070
}
7171

72+
// upload icon
7273
onFileSelected(files: any) {
73-
if (files.length === 0) {
74+
if (files.length === sectorConstants.zero) {
7475
return
7576
}
7677

@@ -88,25 +89,29 @@ export class AddThumbnailComponent implements OnInit {
8889
this.imgURL = reader.result
8990
}
9091
}
91-
92+
// toggle the button
9293
showHideButton() {
9394
this.showMainContent = this.showMainContent ? false : true
9495
}
9596

97+
// when user load icon
9698
onValChange(val: any | null = null) {
9799
this.isChecked = true
98100
this.thumbanilSelectval = val ? val.identifier : ''
99101
this.toggle = val
100102
}
101103

104+
// get all icons
102105
filter(key: string | 'myimages' | 'all') {
103106
if (key) {
104107
this.fetchContent(false, null)
105108
}
106109
}
110+
// get default icon
107111
changeToDefaultImg($event: any) {
108112
$event.target.src = '/assets/instances/eagle/app_logos/default.png'
109113
}
114+
// get the icon using API
110115
fetchContent(loadMoreFlag: boolean, createdBy: string | null) {
111116
const requestData = {
112117
request: {
@@ -144,21 +149,23 @@ export class AddThumbnailComponent implements OnInit {
144149
console.log(error)
145150
})
146151
}
152+
// format the URL to dispaly sector image
147153
public bypass(uri: string) {
148154
// tslint:disable-next-line: triple-equals
149155
if (uri && uri.indexOf(environment.contentBucket) != -1) {
150156
return this.sanitizer.bypassSecurityTrustResourceUrl(uri)
151157
}
152158
return '/assets/instances/eagle/app_logos/default.png'
153159
}
160+
// upload new icon
154161
public uploadThumbnail() {
155162
this.dialogRef.close({ imgUrl: this.toggle ? this.toggle.artifactUrl : '' })
156163
}
157-
164+
// upload the selected the icon
158165
public uploadSelectedThumbnail() {
159166
this.dialogRef.close({ file: this.imagePath })
160167
}
161-
168+
// format the URL to dispaly sector image
162169
getUrl(url: string) {
163170
if (this.sectotsService.getChangedArtifactUrl(url)) {
164171
return this.sanitizer.bypassSecurityTrustResourceUrl(this.sectotsService.getChangedArtifactUrl(url))

project/ws/app/src/lib/routes/home/routes/sectors/add-sector/add-sector.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ export class AddSectorComponent implements OnInit {
4343
ngOnInit() {
4444

4545
}
46-
46+
// Navigate to sectors page
4747
goToList() {
4848
this.router.navigateByUrl('/app/home/sectors')
4949
}
5050

51+
// create sectors
5152
onSubmit() {
5253
const reqestBody = {
5354
request: {
@@ -68,6 +69,7 @@ export class AddSectorComponent implements OnInit {
6869
})
6970
}
7071

72+
// format the URL to dispaly sector image
7173
generateUrl(oldUrl: string) {
7274
const chunk = oldUrl ? oldUrl.split('/') : []
7375
const newChunk = environment.contentBucket.split('/')
@@ -84,7 +86,7 @@ export class AddSectorComponent implements OnInit {
8486
const newUrl = newLink.join('/')
8587
return newUrl
8688
}
87-
89+
// Show modal to select the sector image
8890
openDialog() {
8991
const dialogConfig = new MatDialogConfig()
9092
const dialogRef = this.dialog.open(AddThumbnailComponent, dialogConfig)
@@ -99,6 +101,7 @@ export class AddSectorComponent implements OnInit {
99101
})
100102
}
101103

104+
// upload sector icon
102105
uploadAppIcon(file: File) {
103106
if (!file) {
104107
return
@@ -178,6 +181,7 @@ export class AddSectorComponent implements OnInit {
178181
})
179182
}
180183

184+
// format the URL to dispaly sector image
181185
getUrl(url: string) {
182186
if (this.sectorsService.getChangedArtifactUrl(url)) {
183187
return this.sanitizer.bypassSecurityTrustResourceUrl(this.sectorsService.getChangedArtifactUrl(url))

project/ws/app/src/lib/routes/home/routes/sectors/edit-sector/edit-sector.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@ export class EditSectorComponent implements OnInit {
4747
textboxes: this.formBuilder.array([], Validators.required),
4848
})
4949
}
50-
50+
// Initialize the textbox
5151
get textboxes() {
5252
return this.myForm.get('textboxes') as FormArray
5353
}
54-
54+
// Dynamically add textbox for sub sectors
5555
addTextbox(value: string = '') {
5656
this.textboxes.push(
5757
this.formBuilder.control({ value, disabled: value.length }, [Validators.required])
5858
)
5959
}
6060

61+
// Remove sub sectors textbox
6162
removeTextbox(index: number) {
6263
this.textboxes.removeAt(index)
6364
}
@@ -83,14 +84,12 @@ export class EditSectorComponent implements OnInit {
8384
}
8485
})
8586
}
86-
87+
// Navigate to sectors page
8788
goToList() {
8889
this.router.navigateByUrl('/app/home/sectors')
8990
}
9091

91-
addSubSector() {
92-
}
93-
92+
// Add sub sectors
9493
onSubSectorSubmit() {
9594
const requestBody = {
9695
request: {
@@ -115,6 +114,7 @@ export class EditSectorComponent implements OnInit {
115114

116115
}
117116

117+
// format the URL to dispaly sector image
118118
getUrl(url: string) {
119119
if (this.sectorsService.getChangedArtifactUrl(url)) {
120120
return this.sanitizer.bypassSecurityTrustResourceUrl(this.sectorsService.getChangedArtifactUrl(url))

project/ws/app/src/lib/routes/home/routes/sectors/sector-list-view/sector-list-view.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class SectorListViewComponent implements OnInit {
3838
this.dataSource.paginator = this.paginator
3939
}
4040

41+
// find the action column data
4142
getFinalColumns() {
4243
if (this.tableData !== undefined) {
4344
const columns = _.map(this.tableData.columns, c => c.key)
@@ -67,6 +68,7 @@ export class SectorListViewComponent implements OnInit {
6768
setTimeout(() => this.dataSource.paginator = this.paginator)
6869
}
6970

71+
// Filter sectors based on the user search
7072
applyFilter(event: string) {
7173
if (event) {
7274
this.dataSource.data = this.data.filter((d: any) => d.name.toString().toLowerCase().includes(event.toLowerCase()))
@@ -75,10 +77,11 @@ export class SectorListViewComponent implements OnInit {
7577
}
7678
}
7779

80+
// Navigate to create sector
7881
onCreateClick() {
7982
this.router.navigateByUrl('/app/home/sectors/new')
8083
}
81-
84+
// Navigate to create sub sectors
8285
onClickButton(row: any) {
8386
this.router.navigateByUrl(`/app/home/sectors/${row.code}/sub-sectors`)
8487
}

project/ws/app/src/lib/routes/home/routes/sectors/sectors.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class SectorsComponent implements OnInit {
3939
actions: [{ icon: '', label: 'Action', name: 'DownloadFile', type: 'Standard', disabled: false }],
4040
}
4141
this.isLoading = true
42+
// Get all sectors
4243
this.sectorsService.getAllSectors().subscribe((resp: any) => {
4344
if (resp && resp.result && resp.result.sectors) {
4445
resp.result.sectors.forEach((obj: any) => {
@@ -55,6 +56,7 @@ export class SectorsComponent implements OnInit {
5556
})
5657
}
5758

59+
// Get all sub sectors
5860
getSubSectors(children: any) {
5961
const namesArray: any = []
6062
children.forEach((obj: any) => {

0 commit comments

Comments
 (0)