mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-10-29 17:52:24 +00:00
Merge pull request #22 from Telecominfraproject/bugfix/NETEXP-1335
bugfix/NETEXP-1335: Passpoint profile childProfileIds fix
This commit is contained in:
@@ -204,9 +204,36 @@ export class API extends RESTDataSource {
|
||||
}
|
||||
|
||||
async createProfile(profile) {
|
||||
return this.post('portal/profile', {
|
||||
const newProfile = await this.post('portal/profile', {
|
||||
...profile,
|
||||
});
|
||||
|
||||
if (profile.profileType === 'passpoint') {
|
||||
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) => {
|
||||
this.get('portal/profile', {
|
||||
profileId,
|
||||
}).then((profile) => {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return newProfile;
|
||||
}
|
||||
async getProfile(profileId) {
|
||||
return this.get('portal/profile', {
|
||||
@@ -214,6 +241,35 @@ export class API extends RESTDataSource {
|
||||
});
|
||||
}
|
||||
async updateProfile(profile) {
|
||||
if (profile.profileType === 'passpoint') {
|
||||
const {
|
||||
id,
|
||||
details: { associatedAccessSsidProfileIds, osuSsidProfileId },
|
||||
} = profile;
|
||||
this.get('portal/profile', {
|
||||
profileId: osuSsidProfileId,
|
||||
}).then((profile) => {
|
||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
});
|
||||
}
|
||||
});
|
||||
associatedAccessSsidProfileIds.forEach((profileId) => {
|
||||
this.get('portal/profile', {
|
||||
profileId,
|
||||
}).then((profile) => {
|
||||
if (!profile.childProfileIds.includes(parseInt(id, 10))) {
|
||||
this.put('portal/profile', {
|
||||
...profile,
|
||||
childProfileIds: [...profile.childProfileIds, id],
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return this.put('portal/profile', {
|
||||
...profile,
|
||||
});
|
||||
|
||||
@@ -521,6 +521,18 @@ const resolvers = {
|
||||
|
||||
return result && result.value2;
|
||||
},
|
||||
associatedSsidProfiles: ({ details }, args, { dataSources }) => {
|
||||
return (
|
||||
details &&
|
||||
details.associatedAccessSsidProfileIds &&
|
||||
dataSources.api.getProfilesById(details.associatedAccessSsidProfileIds)
|
||||
);
|
||||
},
|
||||
osuSsidProfile: ({ details }, args, { dataSources }) => {
|
||||
return (
|
||||
details && details.osuSsidProfileId && dataSources.api.getProfile(details.osuSsidProfileId)
|
||||
);
|
||||
},
|
||||
},
|
||||
ClientSession: {
|
||||
id: ({ macAddress }) => macAddress.addressAsString,
|
||||
|
||||
@@ -231,6 +231,8 @@ const typeDefs = gql`
|
||||
lastModifiedTimestamp: String
|
||||
equipmentCount: Int
|
||||
details: JSONObject
|
||||
associatedSsidProfiles: [Profile]
|
||||
osuSsidProfile: Profile
|
||||
}
|
||||
|
||||
type ProfilePagination {
|
||||
|
||||
Reference in New Issue
Block a user