diff --git a/src/app/components/dashboard-apps-dock/dashboard-apps-dock.coffee b/src/app/components/dashboard-apps-dock/dashboard-apps-dock.coffee index 7af155cc..3a3275e5 100644 --- a/src/app/components/dashboard-apps-dock/dashboard-apps-dock.coffee +++ b/src/app/components/dashboard-apps-dock/dashboard-apps-dock.coffee @@ -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) diff --git a/src/app/components/mnoe-api/app-instances.svc.coffee b/src/app/components/mnoe-api/app-instances.svc.coffee index 88b142c1..c757dff0 100644 --- a/src/app/components/mnoe-api/app-instances.svc.coffee +++ b/src/app/components/mnoe-api/app-instances.svc.coffee @@ -6,7 +6,9 @@ angular.module 'mnoEnterpriseAngular' @appInstances = [] appInstancesPromise = null - @getAppInstances = -> + + # If unscoped and no cache, retrieve app instances irrespective of tenant + @getAppInstances = (unscoped = false) -> return appInstancesPromise if appInstancesPromise? deferred = $q.defer() @@ -15,14 +17,14 @@ angular.module 'mnoEnterpriseAngular' cache = MnoLocalStorage.getObject(MnoeCurrentUser.user.id + "_" + LOCALSTORAGE.appInstancesKey) if cache? # Refresh the cache content asynchronously - fetchAppInstances() + fetchAppInstances(unscoped) # 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(unscoped).then((response) -> deferred.resolve(response)) return appInstancesPromise = deferred.promise @@ -33,14 +35,16 @@ angular.module 'mnoEnterpriseAngular' fetchAppInstances() # Retrieve app instances from the backend - fetchAppInstances = -> + # If unscoped, retrieve app instances irrespective of tenant + fetchAppInstances = (unscoped) -> # 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 unscoped then {unscoped: true} else {} + _self.appInstancesPromise = MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances').get(params).then( (response) -> response = response.plain() # Save the app instances in the local storage