Merge pull request #22 from Telecominfraproject/bugfix/NETEXP-1335

bugfix/NETEXP-1335: Passpoint profile childProfileIds fix
This commit is contained in:
Sean Macfarlane
2021-03-23 10:51:25 -04:00
committed by GitHub
3 changed files with 71 additions and 1 deletions

View File

@@ -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,
});

View File

@@ -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,

View File

@@ -231,6 +231,8 @@ const typeDefs = gql`
lastModifiedTimestamp: String
equipmentCount: Int
details: JSONObject
associatedSsidProfiles: [Profile]
osuSsidProfile: Profile
}
type ProfilePagination {