mirror of
				https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
				synced 2025-10-31 02:27:48 +00:00 
			
		
		
		
	Updated create/update profile datasource
This commit is contained in:
		| @@ -208,30 +208,39 @@ export class API extends RESTDataSource { | ||||
|       ...profile, | ||||
|     }); | ||||
|  | ||||
|     if (profile.profileType === 'passpoint') { | ||||
|     if (profile.profileType === 'ssid') { | ||||
|       const { | ||||
|         id, | ||||
|         details: { associatedAccessSsidProfileIds, osuSsidProfileId }, | ||||
|       } = newProfile; | ||||
|         details: { passpointProfileId, passpointConfig }, | ||||
|       } = profile; | ||||
|  | ||||
|       if (passpointConfig === 'accessSSID') { | ||||
|         this.get('portal/profile', { | ||||
|         profileId: osuSsidProfileId, | ||||
|           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], | ||||
|             }, | ||||
|           }); | ||||
|         }); | ||||
|       associatedAccessSsidProfileIds.forEach((profileId) => { | ||||
|       } else if (passpointConfig === 'osuSSID') { | ||||
|         this.get('portal/profile', { | ||||
|           profileId, | ||||
|           profileId: passpointProfileId.value, | ||||
|         }).then((profile) => { | ||||
|           this.put('portal/profile', { | ||||
|             ...profile, | ||||
|             childProfileIds: [...profile.childProfileIds, id], | ||||
|           }); | ||||
|             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; | ||||
|  | ||||
|       if (passpointConfig === 'accessSSID') { | ||||
|         this.get('portal/profile', { | ||||
|         profileId: osuSsidProfileId, | ||||
|           profileId: passpointProfileId.value, | ||||
|         }).then((profile) => { | ||||
|         if (!profile.childProfileIds.includes(parseInt(id, 10))) { | ||||
|           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, | ||||
|               childProfileIds: [...profile.childProfileIds, id], | ||||
|             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', { | ||||
|               ...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
	 irtiza-h30
					irtiza-h30