Revision 62389
Added by Andreas Mantas over 1 year ago
datasource-update-form.component.ts | ||
---|---|---|
43 | 43 |
softwarePlatform : '', |
44 | 44 |
platformName : '', |
45 | 45 |
officialName : ['', Validators.required], |
46 |
issn : ['', [Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$')] ],
|
|
47 |
eissn : ['', Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$') ],
|
|
48 |
lissn : ['', Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$') ],
|
|
46 |
issn : ['', [Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)')] ],
|
|
47 |
eissn : ['', Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)') ],
|
|
48 |
lissn : ['', Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)') ],
|
|
49 | 49 |
repoDescription : ['', Validators.required], |
50 | 50 |
country : '', |
51 | 51 |
longtitude : '', |
... | ... | |
101 | 101 |
|
102 | 102 |
setupUpdateForm() { |
103 | 103 |
if (this.selectedRepo) { |
104 |
|
|
104 |
console.log(this.mode); |
|
105 | 105 |
this.updateGroup.setValue({ |
106 |
softwarePlatform: this.selectedRepo.typology,
|
|
106 |
softwarePlatform: this.selectedRepo.platform,
|
|
107 | 107 |
platformName: '', |
108 |
officialName: this.selectedRepo.officialName,
|
|
108 |
officialName: this.selectedRepo.officialname,
|
|
109 | 109 |
issn: '', |
110 | 110 |
eissn: '', |
111 | 111 |
lissn: '', |
112 | 112 |
repoDescription: this.selectedRepo.description, |
113 |
country: this.selectedRepo.countryCode,
|
|
113 |
country: this.selectedRepo.organizations[0].country, // countryCode
|
|
114 | 114 |
longtitude: this.selectedRepo.longitude, |
115 | 115 |
latitude: this.selectedRepo.latitude, |
116 |
websiteUrl: this.selectedRepo.websiteUrl,
|
|
117 |
institutionName: this.selectedRepo.organization, |
|
118 |
englishName: this.selectedRepo.englishName,
|
|
119 |
logoUrl: this.selectedRepo.logoUrl,
|
|
116 |
websiteUrl: this.selectedRepo.websiteurl,
|
|
117 |
institutionName: this.selectedRepo.organizations[0].legalname,
|
|
118 |
englishName: this.selectedRepo.englishname,
|
|
119 |
logoUrl: this.selectedRepo.logourl,
|
|
120 | 120 |
timezone: this.selectedRepo.timezone, |
121 |
datasourceType: this.selectedRepo.datasourceClass,
|
|
122 |
adminEmail: this.selectedRepo.contactEmail
|
|
121 |
datasourceType: this.selectedRepo.typology, // TODO: rename to typology?
|
|
122 |
adminEmail: this.selectedRepo.contactemail
|
|
123 | 123 |
}); |
124 | 124 |
|
125 |
if ( this.selectedRepo.typology === '' || !this.typologies.some(x => x.value === this.selectedRepo.typology) ) {
|
|
125 |
if ( this.selectedRepo.platform === '' || !this.typologies.some(x => x.value === this.selectedRepo.platform) ) {
|
|
126 | 126 |
this.updateGroup.get('softwarePlatform').setValue(''); |
127 |
this.updateGroup.get('platformName').setValue(this.selectedRepo.typology);
|
|
127 |
this.updateGroup.get('platformName').setValue(this.selectedRepo.platform);
|
|
128 | 128 |
} |
129 | 129 |
|
130 |
if (this.selectedRepo.eoscDatasourceType === 'Journal archive') { |
|
131 |
console.log('inside journal'); |
|
132 |
this.updateGroup.get('issn').setValue(this.selectedRepo.issn); |
|
133 |
this.updateGroup.get('eissn').setValue(this.selectedRepo.eissn); |
|
134 |
this.updateGroup.get('lissn').setValue(this.selectedRepo.lissn); |
|
135 |
} |
|
136 |
|
|
130 | 137 |
// FIXME: Use eoscDatasourceType when we support the new model |
131 | 138 |
if ((this.mode === 'opendoar') || (this.mode === 're3data')) { |
132 | 139 |
|
... | ... | |
141 | 148 |
} else { |
142 | 149 |
this.longtitudeDesc.mandatory = true; |
143 | 150 |
this.latitudeDesc.mandatory = true; |
144 |
this.datasourceTypeDesc.label = 'Repository Type';
|
|
151 |
this.datasourceTypeDesc.label = 'Data source type';
|
|
145 | 152 |
} |
146 | 153 |
|
147 | 154 |
// FIXME: Use eoscDatasourceType when we support the new model |
... | ... | |
150 | 157 |
let ssnToShow = this.selectedRepo.issn.slice(0, 4) + '-' + this.selectedRepo.issn.toString().slice(4); |
151 | 158 |
this.updateGroup.get('issn').setValue(ssnToShow); |
152 | 159 |
this.updateGroup.get('issn').clearValidators(); |
153 |
this.updateGroup.get('issn').setValidators([Validators.required, Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$')]);
|
|
160 |
this.updateGroup.get('issn').setValidators([Validators.required, Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)')]);
|
|
154 | 161 |
|
155 | 162 |
if (this.selectedRepo.eissn.trim().length) { |
156 | 163 |
ssnToShow = this.selectedRepo.eissn.slice(0, 4) + '-' + this.selectedRepo.eissn.toString().slice(4); |
... | ... | |
172 | 179 |
|
173 | 180 |
getDatasourceClasses() { |
174 | 181 |
// FIXME: Use eoscDatasourceType when we support the new model |
175 |
this.repoService.getDatasourceClasses(this.mode).subscribe( |
|
176 |
classes => this.datasourceClasses = classes, |
|
182 |
console.log('mode b4 getdatasourceclasses ', this.mode); |
|
183 |
|
|
184 |
let param = this.selectedRepo.collectedfrom.split('::')[1]; |
|
185 |
if (this.selectedRepo.eoscDatasourceType === 'Journal archive') { param = 'journal'; } |
|
186 |
if (this.selectedRepo.eoscDatasourceType === 'Aggregator') { param = 'aggregator'; } |
|
187 |
|
|
188 |
this.repoService.getDatasourceClasses(param).subscribe( |
|
189 |
classes => { |
|
190 |
for (const [key, value] of Object.entries(classes)) { |
|
191 |
this.datasourceClasses.set(key, value); |
|
192 |
}}, |
|
177 | 193 |
error => { |
178 | 194 |
this.loadingMessage = ''; |
179 | 195 |
this.errorMessage = noServiceMessage; |
180 | 196 |
console.log(error); |
181 | 197 |
}, |
182 | 198 |
() => { |
183 |
for (const key of Object.keys(this.datasourceClasses)) { |
|
184 |
this.classCodes.push(key); |
|
185 |
} |
|
199 |
console.log('gotDatasourceClasses'); |
|
200 |
this.classCodes = Array.from(this.datasourceClasses.keys()); |
|
186 | 201 |
this.getCountries(); |
187 | 202 |
} |
188 | 203 |
); |
189 | 204 |
} |
190 | 205 |
|
191 | 206 |
getCountries() { |
192 |
this.repoService.getCountries() |
|
193 |
.subscribe( |
|
207 |
this.repoService.getCountries().subscribe( |
|
194 | 208 |
countries => this.countries = countries.sort( function(a, b) { |
195 | 209 |
if (a.name < b.name) { |
196 | 210 |
return -1; |
... | ... | |
205 | 219 |
this.errorMessage = noServiceMessage; |
206 | 220 |
console.log(error); |
207 | 221 |
}, () => { |
222 |
console.log('gotCountries'); |
|
208 | 223 |
this.getTypologies(); |
209 | 224 |
}); |
210 | 225 |
} |
... | ... | |
217 | 232 |
console.log(error); |
218 | 233 |
}, |
219 | 234 |
() => { |
235 |
console.log('gotTypologies'); |
|
220 | 236 |
this.getTimezones(); |
221 | 237 |
} |
222 | 238 |
); |
... | ... | |
230 | 246 |
console.log(error); |
231 | 247 |
}, |
232 | 248 |
() => { |
249 |
console.log('gotTimezones'); |
|
233 | 250 |
this.loadingMessage = ''; |
234 | 251 |
this.setupUpdateForm(); |
235 | 252 |
} |
... | ... | |
243 | 260 |
window.scroll(1, 1); |
244 | 261 |
|
245 | 262 |
if (this.updateGroup.valid) { |
246 |
if ( this.selectedRepo.datasourceType !== 'journal' || this.updateGroup.get('issn').value ) {
|
|
263 |
if ( this.selectedRepo.eoscDatasourceType !== 'journal' || this.updateGroup.get('issn').value ) {
|
|
247 | 264 |
this.refreshSelectedRepo(); |
248 | 265 |
|
249 | 266 |
/* |
... | ... | |
288 | 305 |
|
289 | 306 |
refreshSelectedRepo() { |
290 | 307 |
if (this.updateGroup.get('softwarePlatform').value ) { |
291 |
this.selectedRepo.typology = this.updateGroup.get('softwarePlatform').value;
|
|
308 |
this.selectedRepo.platform = this.updateGroup.get('softwarePlatform').value;
|
|
292 | 309 |
} else if (this.updateGroup.get('platformName').value) { |
293 |
this.selectedRepo.typology = this.updateGroup.get('platformName').value;
|
|
310 |
this.selectedRepo.platform = this.updateGroup.get('platformName').value;
|
|
294 | 311 |
} |
295 |
this.selectedRepo.officialName = this.updateGroup.get('officialName').value.toString(); |
|
312 |
this.selectedRepo.typology = this.updateGroup.get('datasourceType').value; |
|
313 |
console.log('typology ', this.selectedRepo.typology); |
|
314 |
console.log(this.datasourceClasses); |
|
315 |
console.log(this.updateGroup.get('datasourceType').value); |
|
316 |
// this.selectedRepo.eoscDatasourceType = this.datasourceClasses.get(this.updateGroup.get('datasourceType').value); |
|
317 |
// console.warn(this.selectedRepo.eoscDatasourceType); |
|
318 |
this.selectedRepo.officialname = this.updateGroup.get('officialName').value.toString(); |
|
296 | 319 |
this.selectedRepo.description = this.updateGroup.get('repoDescription').value.toString(); |
297 |
this.selectedRepo.countryCode = this.updateGroup.get('country').value; |
|
298 |
this.selectedRepo.countryName = this.countries.filter(x => x.code === this.updateGroup.get('country').value)[0].name; |
|
320 |
this.selectedRepo.organizations[0].country = this.updateGroup.get('country').value; // countryCode |
|
299 | 321 |
this.selectedRepo.longitude = this.updateGroup.get('longtitude').value; |
300 | 322 |
this.selectedRepo.latitude = this.updateGroup.get('latitude').value; |
301 |
this.selectedRepo.websiteUrl = this.updateGroup.get('websiteUrl').value;
|
|
302 |
this.selectedRepo.organization = this.updateGroup.get('institutionName').value.toString(); |
|
303 |
this.selectedRepo.englishName = this.updateGroup.get('englishName').value.toString();
|
|
304 |
this.selectedRepo.logoUrl = this.updateGroup.get('logoUrl').value;
|
|
323 |
this.selectedRepo.websiteurl = this.updateGroup.get('websiteUrl').value;
|
|
324 |
this.selectedRepo.organizations[0].legalname = this.updateGroup.get('institutionName').value.toString();
|
|
325 |
this.selectedRepo.englishname = this.updateGroup.get('englishName').value.toString();
|
|
326 |
this.selectedRepo.logourl = this.updateGroup.get('logoUrl').value;
|
|
305 | 327 |
this.selectedRepo.timezone = this.updateGroup.get('timezone').value; |
306 |
this.selectedRepo.datasourceClass = this.updateGroup.get('datasourceType').value; |
|
307 |
this.selectedRepo.contactEmail = this.updateGroup.get('adminEmail').value; |
|
308 |
if (this.selectedRepo.datasourceType === 'journal') { |
|
328 |
this.selectedRepo.contactemail = this.updateGroup.get('adminEmail').value; |
|
329 |
if (this.selectedRepo.eoscDatasourceType === 'journal') { |
|
309 | 330 |
let ssnParts = this.updateGroup.get('issn').value.split('-'); |
310 | 331 |
let correctSSN = ssnParts[0] + ssnParts[1]; |
311 | 332 |
this.selectedRepo.issn = correctSSN; |
... | ... | |
320 | 341 |
this.selectedRepo.lissn = correctSSN; |
321 | 342 |
} |
322 | 343 |
} |
323 |
if (!this.showButton) { |
|
324 |
this.selectedRepo.registeredBy = this.authService.getUserEmail(); |
|
325 |
this.selectedRepo.registered = true; |
|
326 |
this.selectedRepo.registrationDate = new Date(Date.now()); // NOT NEEDED ?? |
|
344 |
if (!this.showButton) { // on register |
|
345 |
this.selectedRepo.registeredby = this.authService.getUserEmail(); |
|
346 |
this.selectedRepo.managed = true; |
|
347 |
const now = new Date(Date.now()); |
|
348 |
this.selectedRepo.consentTermsOfUseDate = now; |
|
349 |
this.selectedRepo.lastConsentTermsOfUseDate = now; |
|
350 |
this.selectedRepo.registrationdate = now; |
|
327 | 351 |
this.emittedInfo.emit(this.selectedRepo); |
328 | 352 |
} |
329 | 353 |
} |
Also available in: Unified diff
svn merge -r 62321:HEAD http://svn.driver.research-infrastructures.eu/driver/dnet45/modules/uoa-repository-dashboard-gui/branches/new-datasource-mode