passpoint profile childProfileIds fix

This commit is contained in:
irtiza-h30
2021-03-19 17:15:03 -04:00
parent dd7c24d0dc
commit 5213719292
3 changed files with 65 additions and 1 deletions

View File

@@ -204,9 +204,36 @@ export class API extends RESTDataSource {
} }
async createProfile(profile) { async createProfile(profile) {
return this.post('portal/profile', { const newProfile = await this.post('portal/profile', {
...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) { async getProfile(profileId) {
return this.get('portal/profile', { return this.get('portal/profile', {
@@ -214,6 +241,35 @@ export class API extends RESTDataSource {
}); });
} }
async updateProfile(profile) { 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', { return this.put('portal/profile', {
...profile, ...profile,
}); });

View File

@@ -521,6 +521,13 @@ const resolvers = {
return result && result.value2; return result && result.value2;
}, },
associatedSsidProfiles: ({ details }, args, { dataSources }) => {
const { associatedAccessSsidProfileIds, osuSsidProfileId } = details;
return (
associatedAccessSsidProfileIds &&
dataSources.api.getProfilesById([...associatedAccessSsidProfileIds, osuSsidProfileId])
);
},
}, },
ClientSession: { ClientSession: {
id: ({ macAddress }) => macAddress.addressAsString, id: ({ macAddress }) => macAddress.addressAsString,

View File

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