Skip to content

Commit

Permalink
[MNOE-406] Added logic to request for unscoped data when showing dash…
Browse files Browse the repository at this point in the history
…board apps
  • Loading branch information
MAhsenArif committed Feb 1, 2018
1 parent b194700 commit a38ea4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ DashboardAppsDockCtrl = ($scope, $cookies, $uibModal, $window, $timeout, MnoeOrg
$scope.$watch MnoeOrganizations.getSelectedId, (val) ->
if val?
$scope.isLoading = true
MnoeAppInstances.getAppInstances().then(
MnoeAppInstances.getAppInstances(true).then(
(response) ->
$scope.apps = response
).finally(-> $scope.isLoading = false)
Expand Down
11 changes: 6 additions & 5 deletions src/app/components/mnoe-api/app-instances.svc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module 'mnoEnterpriseAngular'
@appInstances = []

appInstancesPromise = null
@getAppInstances = ->
@getAppInstances = (force = false) ->
return appInstancesPromise if appInstancesPromise?

deferred = $q.defer()
Expand All @@ -15,14 +15,14 @@ angular.module 'mnoEnterpriseAngular'
cache = MnoLocalStorage.getObject(MnoeCurrentUser.user.id + "_" + LOCALSTORAGE.appInstancesKey)
if cache?
# Refresh the cache content asynchronously
fetchAppInstances()
fetchAppInstances(force)
# Append response array to service array
_self.appInstances = cache
# Return the promised cache
deferred.resolve(cache)
else
# If the cache is empty return the call promise
fetchAppInstances().then((response) -> deferred.resolve(response))
fetchAppInstances(force).then((response) -> deferred.resolve(response))

return appInstancesPromise = deferred.promise

Expand All @@ -33,14 +33,15 @@ angular.module 'mnoEnterpriseAngular'
fetchAppInstances()

# Retrieve app instances from the backend
fetchAppInstances = ->
fetchAppInstances = (force) ->
# Workaround as the API is not standard (return a hash map not an array)
# (Prefix operation by '/' to avoid data extraction)
# TODO: Standard API
defer = $q.defer()
MnoeOrganizations.get().then(
->
_self.appInstancesPromise = MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances').get().then(
params = if force == true then 'unscoped' else ''
_self.appInstancesPromise = MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances?data=' + params).get().then(
(response) ->
response = response.plain()
# Save the app instances in the local storage
Expand Down

0 comments on commit a38ea4b

Please sign in to comment.