Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenBW committed Jan 26, 2018
1 parent 3ce32c2 commit f6f7953
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
42 changes: 41 additions & 1 deletion client/app/components/dashboard/dashboard.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ export const DashboardComponent = {
}

/** @ngInject */
function ComponentController ($state, DashboardService, EventNotifications, lodash, Chargeback, RBAC) {
function ComponentController ($state, DashboardService, EventNotifications, lodash, Chargeback, RBAC, Polling) {
const vm = this

const retiredTitle = __('Retire Status')
const allRequestTypes = ['pending', 'approved', 'denied']

vm.$onDestroy = function onDestroy () {
Polling.stop('vmPolling')
}
vm.$onInit = function () {
vm.permissions = {
'monthlyCharges': RBAC.has(RBAC.FEATURES.DASHBOARD.VIEW.MONTHLY_CHARGES)
Expand All @@ -33,10 +36,14 @@ function ComponentController ($state, DashboardService, EventNotifications, loda
approved: 0,
denied: 0
},
chargeback: 0,
navigateToRetiringSoonServicesList: navigateToRetiringSoonServicesList,
navigateToRetiredServicesList: navigateToRetiredServicesList,
navigateToCurrentServicesList: navigateToCurrentServicesList
})

resolveServiceCounts()
resolveRequestCounts()
}

function navigateToRetiredServicesList () {
Expand Down Expand Up @@ -74,4 +81,37 @@ function ComponentController ($state, DashboardService, EventNotifications, loda
}]
})
}

function resolveServiceCounts () {
if (RBAC.has('miq_request_view')) {
Promise.all(DashboardService.allServices()).then((response) => {
let services = response[0].resources
vm.servicesCount.total = response[0].subcount
vm.servicesCount.retired = response[1].subcount
vm.servicesCount.soon = response[2].subcount
vm.servicesCount.current = vm.servicesCount.total - vm.servicesCount.retired
services.forEach(Chargeback.processReports)
vm.chargeback = {
'used_cost_sum': lodash(services).map('chargeback').map('used_cost_sum').values().sum()
}
vm.servicesFeature = true
}).catch(reason => {

})
}
}

function resolveRequestCounts () {
if (RBAC.has('service_view') && RBAC.has(RBAC.FEATURES.SERVICES.VIEW)) {
Promise.all(DashboardService.allRequests()).then((response) => {
vm.requestsCount.pending = response[0].subcount + response[1].subcount
vm.requestsCount.approved = response[2].subcount + response[3].subcount
vm.requestsCount.denied = response[5].subcount + response[4].subcount
vm.requestsCount.total = vm.requestsCount.pending + vm.requestsCount.approved + vm.requestsCount.denied
vm.requestsFeature = true
}).catch(reason => {

})
}
}
}
18 changes: 6 additions & 12 deletions client/app/components/dashboard/dashboard.component.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ export function DashboardComponentFactory (CollectionsApi) {

function resolveRequests () {
return [
[
pendingRequestsForServiceTemplateProvisionRequest(),
pendingRequestsForServiceReconfigureRequest()
],
[
approvedRequestsForServiceTemplateProvisionRequest(),
approvedRequestsForServiceReconfigureRequest()
],
[
deniedRequestsForServiceTemplateProvisionRequest(),
deniedRequestsForServiceReconfigureRequest()
]
pendingRequestsForServiceTemplateProvisionRequest(),
pendingRequestsForServiceReconfigureRequest(),
approvedRequestsForServiceTemplateProvisionRequest(),
approvedRequestsForServiceReconfigureRequest(),
deniedRequestsForServiceTemplateProvisionRequest(),
deniedRequestsForServiceReconfigureRequest()
]
}

Expand Down

0 comments on commit f6f7953

Please sign in to comment.