Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
insertClaim.component.ts | ||
---|---|---|
4 | 4 |
import {ModalLoading} from '../../../utils/modal/loading.component'; |
5 | 5 |
import {AlertModal} from '../../../utils/modal/alert'; |
6 | 6 |
import {Md5} from 'ts-md5/dist/md5'; |
7 |
import {Session, User} from '../../../login/utils/helper.class'; |
|
8 | 7 |
import {LoginErrorCodes} from '../../../login/utils/guardHelper.class'; |
9 | 8 |
import {EnvProperties} from '../../../utils/properties/env-properties'; |
10 | 9 |
import { |
... | ... | |
15 | 14 |
Message |
16 | 15 |
} from "../../claim-utils/claimHelper.class"; |
17 | 16 |
import {UserManagementService} from "../../../services/user-management.service"; |
17 |
import {Subscriber} from "rxjs"; |
|
18 | 18 |
|
19 | 19 |
@Component({ |
20 | 20 |
selector: 'claim-insert', |
... | ... | |
55 | 55 |
constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute, |
56 | 56 |
private userManagementService: UserManagementService) { |
57 | 57 |
} |
58 |
|
|
58 |
subscriptions = []; |
|
59 |
ngOnDestroy() { |
|
60 |
this.subscriptions.forEach(subscription => { |
|
61 |
if (subscription instanceof Subscriber) { |
|
62 |
subscription.unsubscribe(); |
|
63 |
} |
|
64 |
}); |
|
65 |
} |
|
59 | 66 |
ngOnInit() { |
60 |
this.route.queryParams.subscribe(params => { |
|
67 |
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
61 | 68 |
this.params = params; |
62 |
}); |
|
69 |
}));
|
|
63 | 70 |
} |
64 | 71 |
|
65 | 72 |
params = {}; |
... | ... | |
106 | 113 |
this.errorInClaims = []; |
107 | 114 |
this.insertedRecords = []; |
108 | 115 |
this.errorInRecords = []; |
109 |
this.userManagementService.getUserInfo().subscribe(user => { |
|
116 |
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
110 | 117 |
if (!user) { |
111 | 118 |
this.saveAndNavigate(); |
112 | 119 |
} else { |
... | ... | |
178 | 185 |
// console.log("directclaims"); |
179 | 186 |
// console.log(directclaims); |
180 | 187 |
if (directclaims.length > 0 && this.properties.environment != "development"){ |
181 |
this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe( |
|
188 |
this.subscriptions.push(this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe(
|
|
182 | 189 |
data => { |
183 | 190 |
this.insertedRecords = data.insertedIds; |
184 | 191 |
|
... | ... | |
200 | 207 |
|
201 | 208 |
ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err); |
202 | 209 |
} |
203 |
); |
|
210 |
));
|
|
204 | 211 |
} else { |
205 | 212 |
this.isertBulkClaims(claims); |
206 | 213 |
} |
207 | 214 |
} |
208 |
}); |
|
215 |
}));
|
|
209 | 216 |
} |
210 | 217 |
|
211 | 218 |
private isertBulkClaims(claims: ClaimRecord2Insert[]) { |
212 | 219 |
console.log("claims"); |
213 | 220 |
console.log(claims); |
214 | 221 |
this.errors.splice(0, this.errors.length); |
215 |
this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe( |
|
222 |
this.subscriptions.push(this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe(
|
|
216 | 223 |
data => { |
217 | 224 |
this.insertedClaims = data.insertedIds; |
218 | 225 |
this.errorInClaims = data.errorInClaims; |
... | ... | |
265 | 272 |
|
266 | 273 |
ClaimInsertComponent.handleError("Error inserting bulk claims: " + JSON.stringify(claims), err); |
267 | 274 |
} |
268 |
); |
|
275 |
));
|
|
269 | 276 |
} |
270 | 277 |
|
271 | 278 |
createErrorMessagesPerEntity(applyToAll: boolean) { |
Also available in: Unified diff
[Library|Trunk]
code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())