Revision 62550
Added by John Balasis over 1 year ago
datasource-new-interface-form.component.ts | ||
---|---|---|
39 | 39 |
readonly repoInterfaceFormDef = { |
40 | 40 |
baseurl: ['', Validators.required], |
41 | 41 |
selectValidationSet: [''], |
42 |
customValidationSet: [''], |
|
43 |
compatibilityLevel: [''], |
|
42 |
compatibilityLevel: null, |
|
43 |
desiredCompatibilityLevel: null, |
|
44 |
compatibilityLevelOverride: null, |
|
44 | 45 |
comment: [''] |
45 | 46 |
}; |
46 | 47 |
baseUrlDesc: Description = baseUrlDesc; |
... | ... | |
68 | 69 |
this.interfaceID = this.data[1]; |
69 | 70 |
this.currentRepo = this.data[2]; |
70 | 71 |
this.repoInterfaceForm = this.fb.group(this.repoInterfaceFormDef); |
71 |
this.chooseValSet(true); |
|
72 |
// this.chooseValSet(true);
|
|
72 | 73 |
if (this.data[3]) { |
73 | 74 |
this.currentInterface = this.data[3]; |
74 | 75 |
this.repoInterfaceForm.get('baseurl').setValue(this.currentInterface.baseurl); |
75 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibilityOverride); |
|
76 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibility); |
|
77 |
this.repoInterfaceForm.get('compatibilityLevelOverride').setValue(this.currentInterface.compatibilityOverride); |
|
76 | 78 |
} |
77 | 79 |
this.getInterfaceInfo(); |
78 | 80 |
this.getCompatibilityClasses(); |
... | ... | |
110 | 112 |
this.errorMessage = noServiceMessage; |
111 | 113 |
}, |
112 | 114 |
() => { |
113 |
if ( this.currentInterface && this.currentInterface.apiParams && this.currentInterface.apiParams.find(entry => entry.param === 'set')) {
|
|
114 |
if ( this.valsetList.some( x => x === this.currentInterface.apiParams['set']) ) {
|
|
115 |
this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value);
|
|
116 |
} else {
|
|
117 |
this.repoInterfaceForm.get('customValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value);
|
|
115 |
if (this.currentInterface?.apiParams?.find(entry => entry.param === 'set')) {
|
|
116 |
// it will not work if set is not on valsetList
|
|
117 |
if (this.valsetList.some(x => x === this.currentInterface.apiParams['set'])) {
|
|
118 |
this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams
|
|
119 |
.find(entry => entry.param === 'set').value);
|
|
118 | 120 |
} |
121 |
this.loadingMessage = ''; |
|
122 |
this.repoInterfaceForm.updateValueAndValidity(); |
|
123 |
this.checkIfValid(); |
|
119 | 124 |
} |
120 |
this.loadingMessage = ''; |
|
121 |
this.repoInterfaceForm.updateValueAndValidity(); |
|
122 |
this.checkIfValid(); |
|
123 | 125 |
} |
124 | 126 |
); |
125 | 127 |
} |
... | ... | |
148 | 150 |
|
149 | 151 |
getExistingCompatibilityLevel() { |
150 | 152 |
if (this.currentInterface) { |
151 |
if (this.currentInterface.compatibilityOverride &&
|
|
152 |
this.classCodes.some( x => x === this.currentInterface.compatibilityOverride ) ) {
|
|
153 |
this.existingCompLevel = this.compClasses[this.currentInterface.compatibilityOverride];
|
|
153 |
if (this.currentInterface.compatibility |
|
154 |
&& this.classCodes.some( x => x === this.currentInterface.compatibilityOverride)) {
|
|
155 |
this.existingCompLevel = this.compClasses[this.currentInterface.compatibility]; |
|
154 | 156 |
} else { |
155 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(''); |
|
156 |
this.existingCompLevel = this.currentInterface.compatibilityOverride;
|
|
157 |
// this.repoInterfaceForm.get('compatibilityLevel').setValue('');
|
|
158 |
this.existingCompLevel = this.currentInterface.compatibility; |
|
157 | 159 |
} |
158 | 160 |
} |
159 | 161 |
} |
160 | 162 |
|
161 |
chooseValSet(fromList: boolean) { |
|
162 |
this.existingValSet = fromList; |
|
163 |
if (this.existingValSet) { |
|
164 |
this.repoInterfaceForm.get('selectValidationSet').enable(); |
|
165 |
this.repoInterfaceForm.get('customValidationSet').disable(); |
|
166 |
} else { |
|
167 |
this.repoInterfaceForm.get('selectValidationSet').disable(); |
|
168 |
this.repoInterfaceForm.get('customValidationSet').enable(); |
|
169 |
} |
|
170 |
this.checkIfValid(); |
|
171 |
} |
|
172 |
|
|
173 | 163 |
checkIfCompatibilityLevelWasChosen() { |
174 | 164 |
return ( (this.repoInterfaceForm.get('compatibilityLevel').value !== '') || |
175 | 165 |
(this.existingCompLevel && (this.existingCompLevel !== '')) ); |
176 | 166 |
} |
177 | 167 |
|
178 | 168 |
formIsValid() { |
179 |
return (this.repoInterfaceForm.valid && |
|
180 |
this.identifiedBaseUrl && |
|
181 |
this.checkIfCompatibilityLevelWasChosen()); |
|
169 |
return (this.repoInterfaceForm.valid && this.identifiedBaseUrl && this.checkIfCompatibilityLevelWasChosen()); |
|
182 | 170 |
} |
183 | 171 |
|
184 | 172 |
checkIfValid() { |
... | ... | |
203 | 191 |
let valset = ''; |
204 | 192 |
if (this.existingValSet) { |
205 | 193 |
valset = this.repoInterfaceForm.get('selectValidationSet').value; |
206 |
} else { |
|
207 |
valset = this.repoInterfaceForm.get('customValidationSet').value; |
|
208 | 194 |
} |
209 |
let compLvl = '';
|
|
195 |
let desiredCompLvl = '';
|
|
210 | 196 |
if (this.repoInterfaceForm.get('compatibilityLevel').value) { |
211 |
this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value]; |
|
212 |
console.log('this.existingCompLevel is', this.existingCompLevel); |
|
213 |
compLvl = this.repoInterfaceForm.get('compatibilityLevel').value; |
|
214 |
} else { |
|
215 |
compLvl = this.existingCompLevel; |
|
197 |
// this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value]; |
|
198 |
// console.log('this.existingCompLevel is', this.existingCompLevel); |
|
199 |
desiredCompLvl = this.repoInterfaceForm.get('compatibilityLevel').value; |
|
216 | 200 |
} |
201 |
const compLvl = this.existingCompLevel; |
|
217 | 202 |
let comment = ''; |
218 | 203 |
if (this.repoInterfaceForm.get('comment').value) { |
219 | 204 |
comment = this.repoInterfaceForm.get('comment').value; |
220 | 205 |
} |
221 | 206 |
|
222 | 207 |
if (this.currentInterface) { |
223 |
this.updateCurrent(baseurl, valset, compLvl, comment); |
|
208 |
this.updateCurrent(baseurl, valset, desiredCompLvl, compLvl, comment);
|
|
224 | 209 |
} else { |
225 | 210 |
this.addCurrent(baseurl, valset, compLvl, comment); |
226 | 211 |
} |
... | ... | |
257 | 242 |
validationSet = new ApiParamDetails('set', value); |
258 | 243 |
intrf.apiParams.push(validationSet); |
259 | 244 |
} else { |
260 |
validationSet.value = this.repoInterfaceForm.get(this.existingValSet ? 'selectValidationSet' : 'customValidationSet').value;
|
|
245 |
validationSet.value = this.repoInterfaceForm.get('selectValidationSet').value;
|
|
261 | 246 |
} |
262 | 247 |
} |
263 | 248 |
|
... | ... | |
282 | 267 |
|
283 | 268 |
addInterface(newInterface: RepositoryInterface) { |
284 | 269 |
this.loadingMessage = formSubmitting; |
285 |
this.repoService.addInterface(this.currentRepo.datasourceType, |
|
286 |
this.currentRepo.id, |
|
287 |
this.currentRepo.registeredBy, |
|
288 |
this.currentRepo.comments, |
|
289 |
newInterface).subscribe( |
|
270 |
this.repoService.addInterface(this.currentRepo.datasourceType, this.currentRepo.id, |
|
271 |
this.currentRepo.registeredBy, this.currentRepo.comments, newInterface).subscribe( |
|
290 | 272 |
addedInterface => { |
291 | 273 |
console.log(`addInterface responded ${JSON.stringify(addedInterface)}`); |
292 | 274 |
this.currentInterface = addedInterface; |
... | ... | |
310 | 292 |
|
311 | 293 |
} |
312 | 294 |
|
313 |
updateCurrent (baseurl: string, valset: string, compLvl: string, comment: string) { |
|
295 |
updateCurrent (baseurl: string, valset: string, desiredCompLvl: string, compLvl: string, comment: string) {
|
|
314 | 296 |
console.log('update current'); |
315 | 297 |
this.updateValidationSet(this.currentInterface, valset); |
316 | 298 |
this.currentInterface.baseurl = baseurl; |
... | ... | |
320 | 302 |
this.currentInterface.comments = comment; |
321 | 303 |
|
322 | 304 |
if (!this.inRegister) { |
323 |
this.updateInterface(); |
|
305 |
this.updateInterface(desiredCompLvl);
|
|
324 | 306 |
} else { |
325 | 307 |
this.successMessage = 'The harvesting settings are valid!'; |
326 | 308 |
console.log('SAVED !'); |
... | ... | |
328 | 310 |
} |
329 | 311 |
} |
330 | 312 |
|
331 |
updateInterface() { |
|
313 |
updateInterface(desiredCompatibilityLevel: string) {
|
|
332 | 314 |
this.loadingMessage = formSubmitting; |
333 |
this.repoService.updateInterface(this.currentRepo.id, |
|
334 |
this.currentRepo.registeredBy, |
|
335 |
this.currentRepo.comments, |
|
336 |
this.currentInterface).subscribe( |
|
315 |
this.repoService.updateInterface(this.currentRepo.id, this.currentRepo.registeredBy, this.currentRepo.comments, |
|
316 |
this.currentInterface, this.repoInterfaceForm.get('desiredCompatibilityLevel').value).subscribe( |
|
337 | 317 |
response => { |
338 | 318 |
console.log(`updateRepository responded ${JSON.stringify(response)}`); |
339 | 319 |
if (response) { |
Also available in: Unified diff
changes for interface update form and functionality