mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-11-02 03:28:00 +00:00
Merge pull request #4 from Telecominfraproject/feature/TW-558
feature/TW-558: added Status API
This commit is contained in:
@@ -131,6 +131,15 @@ export class API extends RESTDataSource {
|
||||
});
|
||||
}
|
||||
|
||||
async getEquipmentStatus(customerId, equipmentIds, statusDataTypes) {
|
||||
return this.get('portal/status/forCustomerWithFilter', {
|
||||
customerId,
|
||||
equipmentIds,
|
||||
statusDataTypes,
|
||||
paginationContext: buildPaginationContext(),
|
||||
});
|
||||
}
|
||||
|
||||
async createProfile(profile) {
|
||||
return this.post('portal/profile', {
|
||||
...profile,
|
||||
|
||||
@@ -48,6 +48,14 @@ const resolvers = {
|
||||
return dataSources.api.filterEquipment(customerId, locationIds, equipmentType, cursor, limit);
|
||||
},
|
||||
|
||||
getEquipmentStatus: async (
|
||||
_,
|
||||
{ customerId, equipmentIds, statusDataTypes },
|
||||
{ dataSources }
|
||||
) => {
|
||||
return dataSources.api.getEquipmentStatus(customerId, equipmentIds, statusDataTypes);
|
||||
},
|
||||
|
||||
getProfile: async (_, { id }, { dataSources }) => {
|
||||
return dataSources.api.getProfile(id);
|
||||
},
|
||||
@@ -171,7 +179,7 @@ const resolvers = {
|
||||
|
||||
createProfile: async (
|
||||
_,
|
||||
{ profileType, customerId, name, childProfileIds, detailss },
|
||||
{ profileType, customerId, name, childProfileIds, details },
|
||||
{ dataSources }
|
||||
) => {
|
||||
return dataSources.api.createProfile({
|
||||
@@ -198,6 +206,42 @@ const resolvers = {
|
||||
});
|
||||
},
|
||||
},
|
||||
Equipment: {
|
||||
profile: ({ profileId }, args, { dataSources }) => {
|
||||
return dataSources.api.getProfile(profileId);
|
||||
},
|
||||
status: ({ customerId, id }, args, { dataSources }) => {
|
||||
return dataSources.api.getEquipmentStatus(
|
||||
customerId,
|
||||
[id],
|
||||
['PROTOCOL', 'OS_PERFORMANCE', 'RADIO_UTILIZATION', 'CLIENT_DETAILS']
|
||||
);
|
||||
},
|
||||
channel: ({ details }) => {
|
||||
const values = [];
|
||||
Object.keys(details.radioMap).forEach((i) => values.push(details.radioMap[i].channelNumber));
|
||||
return values;
|
||||
},
|
||||
},
|
||||
StatusPagination: {
|
||||
protocol: ({ items }) => items.find((i) => i.statusDataType === 'PROTOCOL'),
|
||||
osPerformance: ({ items }) => items.find((i) => i.statusDataType === 'OS_PERFORMANCE'),
|
||||
radioUtilization: ({ items }) => items.find((i) => i.statusDataType === 'RADIO_UTILIZATION'),
|
||||
clientDetails: ({ items }) => items.find((i) => i.statusDataType === 'CLIENT_DETAILS'),
|
||||
},
|
||||
StatusDetails: {
|
||||
reportedMacAddr: ({ reportedMacAddr }) => reportedMacAddr && reportedMacAddr.addressAsString,
|
||||
capacityDetails: ({ capacityDetails }) => {
|
||||
const values = [];
|
||||
Object.keys(capacityDetails).forEach((i) => values.push(capacityDetails[i].usedCapacity));
|
||||
return values;
|
||||
},
|
||||
noiseFloorDetails: ({ avgNoiseFloor }) => {
|
||||
const values = [];
|
||||
Object.keys(avgNoiseFloor).forEach((i) => values.push(avgNoiseFloor[i]));
|
||||
return values;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = resolvers;
|
||||
|
||||
@@ -29,6 +29,12 @@ const typeDefs = gql`
|
||||
limit: Int
|
||||
): EquipmentPagination
|
||||
|
||||
getEquipmentStatus(
|
||||
customerId: Int!
|
||||
equipmentIds: [Int]
|
||||
statusDataTypes: [String]
|
||||
): StatusPagination
|
||||
|
||||
getProfile(id: Int!): Profile
|
||||
deleteProfile(id: Int!): Profile
|
||||
getAllProfiles(customerId: Int!, cursor: String, limit: Int): ProfilePagination
|
||||
@@ -90,8 +96,10 @@ const typeDefs = gql`
|
||||
latitude: String
|
||||
longitude: String
|
||||
serial: String
|
||||
channel: [Int]
|
||||
lastModifiedTimestamp: String
|
||||
details: JSONObject
|
||||
profile: Profile
|
||||
status: StatusPagination
|
||||
}
|
||||
|
||||
type EquipmentPagination {
|
||||
@@ -99,6 +107,29 @@ const typeDefs = gql`
|
||||
context: PaginationContext
|
||||
}
|
||||
|
||||
type StatusPagination {
|
||||
protocol: Status
|
||||
radioUtilization: Status
|
||||
osPerformance: Status
|
||||
clientDetails: Status
|
||||
}
|
||||
|
||||
type Status {
|
||||
customerId: Int!
|
||||
statusDataType: String
|
||||
lastModifiedTimestamp: String
|
||||
details: StatusDetails
|
||||
}
|
||||
|
||||
type StatusDetails {
|
||||
reportedIpV4Addr: String
|
||||
reportedMacAddr: String
|
||||
uptimeInSeconds: Int
|
||||
capacityDetails: [Int]
|
||||
noiseFloorDetails: [Int]
|
||||
numClientsPerRadio: [Int]
|
||||
}
|
||||
|
||||
type Profile {
|
||||
id: Int!
|
||||
profileType: String!
|
||||
|
||||
Reference in New Issue
Block a user