Skip to content

Commit

Permalink
feat: show public applications when signed out
Browse files Browse the repository at this point in the history
  • Loading branch information
faouziH21 committed Jul 30, 2024
1 parent 10804b9 commit d1ee3ef
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions shogun-boot/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,49 @@ <h3 class="pb-2 pt-4">Applications</h3>
};
}

//fetches all applications depending on authentication status
const getApplications = async (token) => {
try {
const response = await fetch('/applications', {
headers: {
'Authorization': `Bearer ${token}`
if (token){
try {
const response = await fetch('/applications', {
headers: {
'Authorization': `Bearer ${token}`
}
});
const applications = await response.json();
if (applications && applications.content) {
return applications.content;
} else {
throw new Error('Error while fetching applications');
}
});
const applications = await response.json();
if (applications && applications.content) {
return applications.content;
} catch (error) {
console.error(error);
}
}
else {
const graphqlQuery = {
query:'query{allApplications{id name clientConfig}}'
}
const requestInit = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(graphqlQuery),
}
try {
const response = await fetch('/graphql', requestInit);
const graphqlResponse = await response.json();
if (graphqlResponse && graphqlResponse.data && graphqlResponse.data.allApplications) {
return graphqlResponse.data.allApplications;
} else {
throw new Error('Error while fetching applications');
}
} catch (error) {
console.error(error);
}
}
}
</script>
</body>

Expand Down

0 comments on commit d1ee3ef

Please sign in to comment.