mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-11-01 02:58:07 +00:00
Merge pull request #31 from Telecominfraproject/hotfix/ProfileDatasource
hotfix/ProfileDatasource: Updated create/update profile datasource
This commit is contained in:
@@ -208,29 +208,49 @@ export class API extends RESTDataSource {
|
|||||||
...profile,
|
...profile,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (profile.profileType === 'passpoint') {
|
if (profile.profileType === 'ssid') {
|
||||||
const {
|
const {
|
||||||
id,
|
details: { passpointProfileId, passpointConfig },
|
||||||
details: { associatedAccessSsidProfileIds, osuSsidProfileId },
|
} = profile;
|
||||||
} = newProfile;
|
|
||||||
this.get('portal/profile', {
|
if (passpointConfig === 'accessSSID') {
|
||||||
profileId: osuSsidProfileId,
|
|
||||||
}).then((profile) => {
|
|
||||||
this.put('portal/profile', {
|
|
||||||
...profile,
|
|
||||||
childProfileIds: [...profile.childProfileIds, id],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
associatedAccessSsidProfileIds.forEach((profileId) => {
|
|
||||||
this.get('portal/profile', {
|
this.get('portal/profile', {
|
||||||
profileId,
|
profileId: passpointProfileId.value,
|
||||||
}).then((profile) => {
|
}).then((profile) => {
|
||||||
this.put('portal/profile', {
|
this.put('portal/profile', {
|
||||||
...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) => {
|
||||||
|
if (profile.details.osuSsidProfileId) {
|
||||||
|
this.get('portal/profile', {
|
||||||
|
profileId: profile.details.osuSsidProfileId,
|
||||||
|
}).then((ssidProfile) => {
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...ssidProfile,
|
||||||
|
childProfileIds: ssidProfile.childProfileIds.filter((i) => i !== profile.id),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...profile,
|
||||||
|
details: {
|
||||||
|
...profile.details,
|
||||||
|
osuSsidProfileId: newProfile.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newProfile;
|
return newProfile;
|
||||||
@@ -241,33 +261,94 @@ export class API extends RESTDataSource {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async updateProfile(profile) {
|
async updateProfile(profile) {
|
||||||
if (profile.profileType === 'passpoint') {
|
if (profile.profileType === 'ssid') {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
details: { associatedAccessSsidProfileIds, osuSsidProfileId },
|
details: { passpointProfileId = {}, passpointConfig },
|
||||||
} = profile;
|
} = profile;
|
||||||
this.get('portal/profile', {
|
|
||||||
profileId: osuSsidProfileId,
|
const oldProfile = await this.get('portal/profile', { profileId: id });
|
||||||
}).then((profile) => {
|
if (oldProfile.childProfileIds.length) {
|
||||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
const childProfiles =
|
||||||
this.put('portal/profile', {
|
(await this.get('portal/profile/inSet', {
|
||||||
...profile,
|
profileIdSet: oldProfile.childProfileIds,
|
||||||
childProfileIds: [...profile.childProfileIds, id],
|
})) || [];
|
||||||
});
|
|
||||||
}
|
const passpointProfile = childProfiles.find(
|
||||||
});
|
(profile) => profile.profileType === 'passpoint'
|
||||||
associatedAccessSsidProfileIds.forEach((profileId) => {
|
);
|
||||||
this.get('portal/profile', {
|
|
||||||
profileId,
|
if (passpointProfile) {
|
||||||
}).then((profile) => {
|
if (
|
||||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
!passpointProfileId.value ||
|
||||||
|
passpointProfile.id !== parseInt(passpointProfileId.value, 10)
|
||||||
|
) {
|
||||||
this.put('portal/profile', {
|
this.put('portal/profile', {
|
||||||
...profile,
|
...passpointProfile,
|
||||||
childProfileIds: [...profile.childProfileIds, id],
|
details: {
|
||||||
|
...passpointProfile.details,
|
||||||
|
...(passpointProfile.details.osuSsidProfileId === parseInt(id, 10) && {
|
||||||
|
osuSsidProfileId: null,
|
||||||
|
}),
|
||||||
|
...(passpointProfile.details.associatedAccessSsidProfileIds && {
|
||||||
|
associatedAccessSsidProfileIds: passpointProfile.details.associatedAccessSsidProfileIds.filter(
|
||||||
|
(i) => i !== parseInt(id, 10)
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (passpointProfileId.value) {
|
||||||
|
if (passpointConfig === 'accessSSID') {
|
||||||
|
this.get('portal/profile', {
|
||||||
|
profileId: passpointProfileId.value,
|
||||||
|
}).then((profile) => {
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...profile,
|
||||||
|
details: {
|
||||||
|
...profile.details,
|
||||||
|
...(profile.details.osuSsidProfileId === parseInt(id, 10) && {
|
||||||
|
osuSsidProfileId: null,
|
||||||
|
}),
|
||||||
|
associatedAccessSsidProfileIds: profile.details.associatedAccessSsidProfileIds
|
||||||
|
? [...profile.details.associatedAccessSsidProfileIds, id]
|
||||||
|
: [id],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (passpointConfig === 'osuSSID') {
|
||||||
|
this.get('portal/profile', {
|
||||||
|
profileId: passpointProfileId.value,
|
||||||
|
}).then((profile) => {
|
||||||
|
if (profile.details.osuSsidProfileId) {
|
||||||
|
this.get('portal/profile', {
|
||||||
|
profileId: profile.details.osuSsidProfileId,
|
||||||
|
}).then((ssidProfile) => {
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...ssidProfile,
|
||||||
|
childProfileIds: ssidProfile.childProfileIds.filter((i) => i !== profile.id),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...profile,
|
||||||
|
details: {
|
||||||
|
...profile.details,
|
||||||
|
...(profile.details.associatedAccessSsidProfileIds && {
|
||||||
|
associatedAccessSsidProfileIds: profile.details.associatedAccessSsidProfileIds.filter(
|
||||||
|
(i) => i !== parseInt(id, 10)
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
osuSsidProfileId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.put('portal/profile', {
|
return this.put('portal/profile', {
|
||||||
@@ -275,9 +356,40 @@ export class API extends RESTDataSource {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async deleteProfile(profileId) {
|
async deleteProfile(profileId) {
|
||||||
return this.delete('portal/profile', {
|
const deletedProfile = await this.delete('portal/profile', {
|
||||||
profileId,
|
profileId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (deletedProfile.profileType === 'ssid') {
|
||||||
|
if (deletedProfile.childProfileIds.length) {
|
||||||
|
const childProfiles =
|
||||||
|
(await this.get('portal/profile/inSet', {
|
||||||
|
profileIdSet: deletedProfile.childProfileIds,
|
||||||
|
})) || [];
|
||||||
|
|
||||||
|
const passpointProfile = childProfiles.find(
|
||||||
|
(profile) => profile.profileType === 'passpoint'
|
||||||
|
);
|
||||||
|
if (passpointProfile) {
|
||||||
|
this.put('portal/profile', {
|
||||||
|
...passpointProfile,
|
||||||
|
details: {
|
||||||
|
...passpointProfile.details,
|
||||||
|
...(passpointProfile.details.osuSsidProfileId === parseInt(profileId, 10) && {
|
||||||
|
osuSsidProfileId: null,
|
||||||
|
}),
|
||||||
|
...(passpointProfile.details.associatedAccessSsidProfileIds && {
|
||||||
|
associatedAccessSsidProfileIds: passpointProfile.details.associatedAccessSsidProfileIds.filter(
|
||||||
|
(i) => i !== parseInt(profileId, 10)
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deletedProfile;
|
||||||
}
|
}
|
||||||
async getAllProfiles({ customerId, cursor, limit, type, context }) {
|
async getAllProfiles({ customerId, cursor, limit, type, context }) {
|
||||||
return this.get('portal/profile/forCustomer', {
|
return this.get('portal/profile/forCustomer', {
|
||||||
|
|||||||
Reference in New Issue
Block a user