diff --git a/forge/db/models/Team.js b/forge/db/models/Team.js index a8ec8f1525..41a2c07f8a 100644 --- a/forge/db/models/Team.js +++ b/forge/db/models/Team.js @@ -104,6 +104,15 @@ module.exports = { "members"."TeamId" = "Team"."id" )`), 'memberCount' + ], + [ + literal(`( + SELECT COUNT(*) + FROM "Devices" AS "devices" + WHERE + "devices"."TeamId" = "Team"."id" + )`), + 'deviceCount' ] ] } @@ -134,6 +143,15 @@ module.exports = { "members"."TeamId" = "Team"."id" )`), 'memberCount' + ], + [ + literal(`( + SELECT COUNT(*) + FROM "Devices" AS "devices" + WHERE + "devices"."TeamId" = "Team"."id" + )`), + 'deviceCount' ] ] } @@ -177,6 +195,15 @@ module.exports = { "members"."TeamId" = "Team"."id" )`), 'memberCount' + ], + [ + literal(`( + SELECT COUNT(*) + FROM "Devices" AS "devices" + WHERE + "devices"."TeamId" = "Team"."id" + )`), + 'deviceCount' ] ] } diff --git a/forge/db/views/Team.js b/forge/db/views/Team.js index 132f587117..0f556491da 100644 --- a/forge/db/views/Team.js +++ b/forge/db/views/Team.js @@ -33,6 +33,7 @@ module.exports = function (app) { instanceCount: { type: 'number' }, instanceCountByType: { type: 'object', additionalProperties: true }, memberCount: { type: 'number' }, + deviceCount: { type: 'number' }, createdAt: { type: 'string' }, updatedAt: { type: 'string' }, billing: { type: 'object', additionalProperties: true }, @@ -51,6 +52,7 @@ module.exports = function (app) { avatar: result.avatar, instanceCount: result.projectCount, memberCount: result.memberCount, + deviceCount: result.deviceCount, createdAt: result.createdAt, updatedAt: result.updatedAt, links: result.links diff --git a/frontend/src/api/application.js b/frontend/src/api/application.js index 6a46ff9580..e459ccdbb5 100644 --- a/frontend/src/api/application.js +++ b/frontend/src/api/application.js @@ -87,9 +87,7 @@ const getApplicationInstances = async (applicationId, cursor, limit) => { const getApplicationDevices = async (applicationId, cursor, limit) => { const url = paginateUrl(`/api/v1/applications/${applicationId}/devices`, cursor, limit) const res = await client.get(url) - if (!res?.data?.count) { - return [] - } + res.data.devices = res.data.devices.map((item) => { item.createdSince = daysSince(item.createdAt) item.updatedSince = daysSince(item.updatedAt) diff --git a/frontend/src/components/DevicesBrowser.vue b/frontend/src/components/DevicesBrowser.vue index 7054bef1cd..8a4d7e6522 100644 --- a/frontend/src/components/DevicesBrowser.vue +++ b/frontend/src/components/DevicesBrowser.vue @@ -16,6 +16,7 @@ message="Deleting Device..." />