mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-10-29 17:52:24 +00:00
Updated create/update profile datasource
This commit is contained in:
@@ -208,29 +208,38 @@ export class API extends RESTDataSource {
|
||||
...profile,
|
||||
});
|
||||
|
||||
if (profile.profileType === 'passpoint') {
|
||||
if (profile.profileType === 'ssid') {
|
||||
const {
|
||||
id,
|
||||
details: { associatedAccessSsidProfileIds, osuSsidProfileId },
|
||||
} = newProfile;
|
||||
this.get('portal/profile', {
|
||||
profileId: osuSsidProfileId,
|
||||
}).then((profile) => {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
});
|
||||
});
|
||||
associatedAccessSsidProfileIds.forEach((profileId) => {
|
||||
details: { passpointProfileId, passpointConfig },
|
||||
} = profile;
|
||||
|
||||
if (passpointConfig === 'accessSSID') {
|
||||
this.get('portal/profile', {
|
||||
profileId,
|
||||
profileId: passpointProfileId.value,
|
||||
}).then((profile) => {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
details: {
|
||||
...profile.details,
|
||||
associatedAccessSsidProfileIds: profile.details.associatedAccessSsidProfileIds
|
||||
? [...profile.details.associatedAccessSsidProfileIds, newProfile.id]
|
||||
: [newProfile.id],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if (passpointConfig === 'osuSSID') {
|
||||
this.get('portal/profile', {
|
||||
profileId: passpointProfileId.value,
|
||||
}).then((profile) => {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
details: {
|
||||
...profile.details,
|
||||
osuSsidProfileId: newProfile.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return newProfile;
|
||||
@@ -241,33 +250,73 @@ export class API extends RESTDataSource {
|
||||
});
|
||||
}
|
||||
async updateProfile(profile) {
|
||||
if (profile.profileType === 'passpoint') {
|
||||
if (profile.profileType === 'ssid') {
|
||||
const {
|
||||
id,
|
||||
details: { associatedAccessSsidProfileIds, osuSsidProfileId },
|
||||
details: { passpointProfileId, passpointConfig },
|
||||
} = profile;
|
||||
this.get('portal/profile', {
|
||||
profileId: osuSsidProfileId,
|
||||
}).then((profile) => {
|
||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
||||
|
||||
if (passpointConfig === 'accessSSID') {
|
||||
this.get('portal/profile', {
|
||||
profileId: passpointProfileId.value,
|
||||
}).then((profile) => {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
details: {
|
||||
...profile.details,
|
||||
...(profile.details.osuSsidProfileId === parseInt(id, 10) && {
|
||||
osuSsidProfileId: null,
|
||||
}),
|
||||
associatedAccessSsidProfileIds: profile.details.associatedAccessSsidProfileIds
|
||||
? [...profile.details.associatedAccessSsidProfileIds, id]
|
||||
: [id],
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
associatedAccessSsidProfileIds.forEach((profileId) => {
|
||||
});
|
||||
} else if (passpointConfig === 'osuSSID') {
|
||||
this.get('portal/profile', {
|
||||
profileId,
|
||||
profileId: passpointProfileId.value,
|
||||
}).then((profile) => {
|
||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
details: {
|
||||
...profile.details,
|
||||
...(profile.details.associatedAccessSsidProfileIds && {
|
||||
associatedAccessSsidProfileIds: profile.details.associatedAccessSsidProfileIds.filter(
|
||||
(i) => i !== parseInt(id, 10)
|
||||
),
|
||||
}),
|
||||
osuSsidProfileId: id,
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
const oldProfile = await this.get('portal/profile', { profileId: id });
|
||||
if (oldProfile.childProfileIds.length) {
|
||||
const childProfiles = await this.get('portal/profile/inSet', {
|
||||
profileIdSet: oldProfile.childProfileIds,
|
||||
});
|
||||
const passpointProfile = childProfiles.find(
|
||||
(profile) => profile.profileType === 'passpoint'
|
||||
);
|
||||
if (passpointProfile) {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
...passpointProfile,
|
||||
details: {
|
||||
...passpointProfile.details,
|
||||
...(passpointProfile.details.osuSsidProfileId === parseInt(id, 10) && {
|
||||
osuSsidProfileId: null,
|
||||
}),
|
||||
...(passpointProfile.details.associatedAccessSsidProfileIds && {
|
||||
associatedAccessSsidProfileIds: passpointProfile.details.associatedAccessSsidProfileIds.filter(
|
||||
(i) => i !== parseInt(id, 10)
|
||||
),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.put('portal/profile', {
|
||||
|
||||
Reference in New Issue
Block a user