Revision 53302
Added by Myrto Koukouli about 6 years ago
register-datasource-shareable.component.ts | ||
---|---|---|
6 | 6 |
noRepositoryChosenMsg, |
7 | 7 |
noServiceMessage } from '../../../domain/shared-messages'; |
8 | 8 |
import { Country, Repository, RepositorySnippet } from '../../../domain/typeScriptClasses'; |
9 |
import { finalize } from 'rxjs/operators'; |
|
9 | 10 |
|
10 | 11 |
@Component({ |
11 | 12 |
selector: 'register-datasource-shareable', |
... | ... | |
15 | 16 |
export class RegisterDatasourceShareableComponent implements OnInit { |
16 | 17 |
countries: Country[] = []; |
17 | 18 |
hasSelectedCountry: boolean; |
18 |
selectedCountry: string;
|
|
19 |
selectedCountry: Country;
|
|
19 | 20 |
countryRepos: RepositorySnippet[] = []; |
20 | 21 |
hasSelectedRepo: boolean; |
21 | 22 |
|
... | ... | |
42 | 43 |
this.setUpSourceInfo(); |
43 | 44 |
this.getCountries(); |
44 | 45 |
this.hasSelectedCountry = false; |
45 |
this.selectedCountry = ''; |
|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
setUpSourceInfo() { |
... | ... | |
60 | 60 |
this.repoService.getCountries() |
61 | 61 |
.subscribe( |
62 | 62 |
countries => { |
63 |
/* check for null values */ |
|
64 |
let i = countries.findIndex(el => el.name === null); |
|
65 |
/* remove null values from array */ |
|
66 |
if (i !== -1) { countries.splice(i, 1); } |
|
63 |
// TODO: check again getCountries null return values |
|
64 |
/*/!* check for null values *!/ |
|
65 |
let nullVals = countries.filter(el => el.name === null); |
|
66 |
/!* remove null values from array *!/ |
|
67 |
for (let nullVal of nullVals) { |
|
68 |
let i = countries.findIndex(el => el === nullVal); |
|
69 |
/!* remove null value from array *!/ |
|
70 |
if (i !== -1) { countries.splice(i, 1); } |
|
71 |
}*/ |
|
67 | 72 |
|
68 | 73 |
/* sort countries array */ |
69 | 74 |
this.countries = countries.sort( function(a,b) { |
70 | 75 |
if (a.name<b.name) { |
71 | 76 |
return -1; |
72 |
} else if(a.name>b.name){ |
|
77 |
} else if(a.name>b.name) {
|
|
73 | 78 |
return 1; |
74 | 79 |
} else { |
75 | 80 |
return 0; |
... | ... | |
82 | 87 |
}); |
83 | 88 |
} |
84 | 89 |
|
85 |
getReposInCountry(country: string){
|
|
90 |
getReposInCountry(i: number){
|
|
86 | 91 |
setTimeout( () => { |
92 |
const country = this.countries[i]; |
|
87 | 93 |
console.log(`I got ${country} and ${this.mode}`); |
88 | 94 |
this.countryRepos = []; |
89 | 95 |
this.selectedCountry = country; |
90 | 96 |
this.hasSelectedCountry = false; |
91 | 97 |
this.loadingMessage = loadingReposMessage; |
92 | 98 |
this.noRepositories = ''; |
93 |
this.repoService.getRepositoriesOfCountry(country, this.mode).subscribe(
|
|
99 |
this.repoService.getRepositoriesOfCountry(country.code, this.mode).subscribe (
|
|
94 | 100 |
repos => { |
95 | 101 |
this.countryRepos = repos; |
96 | 102 |
}, |
... | ... | |
105 | 111 |
this.noRepositories = noRepositoriesFound; |
106 | 112 |
} else { |
107 | 113 |
this.noRepositories = ''; |
108 |
if (this.selectedCountry == country) {
|
|
114 |
if (this.selectedCountry.code == country.code) {
|
|
109 | 115 |
/* to make sure that the correct set of repositories is displayed - in case of consequent country selections */ |
110 | 116 |
this.hasSelectedCountry = true; |
111 | 117 |
} else { |
... | ... | |
114 | 120 |
} |
115 | 121 |
this.loadingMessage = ''; |
116 | 122 |
this.alertMessage = ''; |
123 |
console.log('this.selectedCountry became', JSON.stringify(this.selectedCountry)); |
|
117 | 124 |
} |
118 | 125 |
); |
119 | 126 |
}, 500); |
Also available in: Unified diff
fixed redirecting to redirectUrl after login