Skip to content
Snippets Groups Projects
Commit 3f65d34c authored by Elisa Giglio's avatar Elisa Giglio
Browse files

Merge remote-tracking branch 'refs/remotes/origin/master'

update
parents 9c4337df dba7ef56
No related branches found
No related tags found
No related merge requests found
......@@ -12,8 +12,23 @@ class RequestToDomain {
* Funzione per ottenenere dal domain manager tutte le informazioni
* sui domini dell'utente che ha effettuato il login
*/
static async getMyDomains() {
const responseDomain = await fetch('http://localhost:3001/secured/domains/', { // DA FARE: NON MI PIACE LO / ALLA FINE. Secondo me non deve esserci --> modificare qui e anche il domain manager
static async getMyDomains() {
const div = document.createElement('div');
div.innerHTML = "cliccami per avere info";
div.addEventListener('click', async () => {
const responseDomain = await fetch('http://localhost:8080/realms/test00/protocol/openid-connect/userinfo', { // DA FARE: controllare che l'uri che ho specificato qui coincida con quello specificato dal domain manager
method: 'GET',
headers: {
'Authorization': `Bearer ${await getToken()}`
}
}) ;
const domainsJson = await responseDomain.json();
if(responseDomain.ok) {
console.log(domainsJson);
}
});
document.getElementsByTagName('body')[0].appendChild(div);
const responseDomain = await fetch('http://localhost:3001/secured/domains/', { // DA FARE: controllare che l'uri che ho specificato qui coincida con quello specificato dal domain manager
method: 'GET',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -29,6 +44,8 @@ class RequestToDomain {
}
else
throw domainsJson;
}
......@@ -39,7 +56,7 @@ class RequestToDomain {
* false altrimenti.
*/
static async createNewDomain(json) {
const response = await fetch('http://localhost:3001/install', {
const response = await fetch('http://localhost:3001/install/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -60,7 +77,7 @@ class RequestToDomain {
* disponibili.
*/
static async getAllServices() {
const responseDomain = await fetch('http://localhost:3001/secured/services', { // DA FARE: controllare che l'uri che ho specificato qui coincida con quello specificato dal domain manager
const responseDomain = await fetch('http://localhost:3001/secured/services/', { // DA FARE: controllare che l'uri che ho specificato qui coincida con quello specificato dal domain manager
method: 'GET',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -75,6 +92,25 @@ class RequestToDomain {
throw servicesJson;
}
/**
* Effettua la richiesta al domain manager per ottenere tutti i servizi in uso dal dominio
* @param {*} domain
* @returns
*/
static async getUsedServices(domain) {
const response = await fetch(`http://localhost:3001/secured/services?domain=${domain}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${await getToken()}`
}
});
const servicesJson = await response.json();//{response: ["servizio1", "servizio2"]};
if(response.ok) {
return servicesJson.response;
}
else
throw servicesJson;
}
/**
* Effettua la richiesta al domain manager per far partire un dominio.
......@@ -83,7 +119,7 @@ class RequestToDomain {
* false altrimenti.
*/
static async startDomain(d) {
const response = await fetch('http://localhost:3001/start', {
const response = await fetch('http://localhost:3001/start/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -106,7 +142,7 @@ class RequestToDomain {
* false altrimenti.
*/
static async stopDomain(d) {
const response = await fetch('http://localhost:3001/stop', {
const response = await fetch('http://localhost:3001/stop/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -129,7 +165,7 @@ class RequestToDomain {
* false altrimenti.
*/
static async deleteDomain(d) {
const response = await fetch('http://localhost:3001/delete', {
const response = await fetch('http://localhost:3001/delete/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${await getToken()}`
......@@ -143,27 +179,6 @@ class RequestToDomain {
return false;
}
}
/**
* Effettua la richiesta al domain manager per ottenere tutti i servizi in uso dal dominio
* @param {*} domain
* @returns
*/
static async getUsedServices(domain) {
const response = await fetch(`http://localhost:3001/secured/services?domain=${domain}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${await getToken()}`
}
});
const servicesJson = await response.json();//{response: ["servizio1", "servizio2"]};
if(response.ok) {
return servicesJson.response;
}
else
throw servicesJson;
}
/**
* Effettua la richiesta al domain manager per sapere se l'utente e' un amministratore del dominio o meno
* @param {*} domain
......@@ -185,4 +200,4 @@ class RequestToDomain {
}
}
export default RequestToDomain;
\ No newline at end of file
export default RequestToDomain;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment