Do not expose byUUIDs and byRefs.
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'ConsoleCtrl', ($scope, $stateParams, xoObjects) ->
|
||||
{byUUIDs} = xoObjects
|
||||
{get} = xoObjects
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
->
|
||||
VM = $scope.VM = byUUIDs[$stateParams.uuid]
|
||||
VM = $scope.VM = get $stateParams.uuid
|
||||
|
||||
# If the VM or its pool cannot be found, stop here.
|
||||
return unless VM? and (pool = byUUIDs[VM.poolRef])?
|
||||
return unless VM? and (pool = get VM.poolRef)?
|
||||
|
||||
$scope.consoleUrl = do ->
|
||||
for console in VM.consoles
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'HostCtrl', ($scope, $stateParams, xoApi, xoObjects) ->
|
||||
{byUUIDs, byRefs} = xoObjects
|
||||
{get} = xoObjects
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
->
|
||||
host = $scope.host = byUUIDs[$stateParams.uuid]
|
||||
host = $scope.host = get $stateParams.uuid
|
||||
return unless host?
|
||||
$scope.pool = byRefs[host.poolRef]
|
||||
$scope.pool = get host.poolRef
|
||||
)
|
||||
|
||||
$scope.removeMessage = (UUID) ->
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'NewSrCtrl', ($scope, $stateParams, xoObjects) ->
|
||||
{byUUIDs} = xoObjects
|
||||
{get} = xoObjects
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
->
|
||||
container = $scope.container = byUUIDs[$stateParams.container]
|
||||
container = $scope.container = get $stateParams.container
|
||||
)
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'NewVmCtrl', ($scope, $stateParams, xoObjects) ->
|
||||
{byUUIDs} = xoObjects
|
||||
{get} = xoObjects
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
->
|
||||
container = $scope.container = byUUIDs[$stateParams.container]
|
||||
container = $scope.container = get $stateParams.container
|
||||
|
||||
# If the container was not found, no need to continue.
|
||||
return unless container?
|
||||
@@ -15,7 +15,7 @@ angular.module('xoWebApp')
|
||||
container.templates
|
||||
else
|
||||
# TODO: checks for the pool's existence.
|
||||
pool = byUUIDs[container.poolRef]
|
||||
pool = get container.poolRef
|
||||
|
||||
# Returns its templates.
|
||||
pool.templates
|
||||
|
||||
@@ -4,6 +4,5 @@ angular.module('xoWebApp')
|
||||
.controller 'PoolCtrl', ($scope, $stateParams, xoObjects) ->
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
-> $scope.pool = xoObjects.byUUIDs[$stateParams.uuid]
|
||||
-> $scope.pool = xoObjects.get $stateParams.uuid
|
||||
)
|
||||
$scope.oneAtATime = true;
|
||||
|
||||
@@ -4,5 +4,5 @@ angular.module('xoWebApp')
|
||||
.controller 'SrCtrl', ($scope, $stateParams, xoObjects) ->
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
-> $scope.SR = xoObjects.byUUIDs[$stateParams.uuid]
|
||||
-> $scope.SR = xoObjects.get $stateParams.uuid
|
||||
)
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'VmCtrl', ($scope, $stateParams, xoApi, xoObjects) ->
|
||||
{byUUIDs, byRefs} = xoObjects
|
||||
{get} = xoObjects
|
||||
$scope.$watch(
|
||||
-> xoObjects.revision
|
||||
->
|
||||
VM = $scope.VM = xoObjects.byUUIDs[$stateParams.uuid]
|
||||
VM = $scope.VM = get $stateParams.uuid
|
||||
|
||||
# build VDI list of this VM
|
||||
return unless VM?
|
||||
$scope.VDIs = []
|
||||
for VBD in VM.$VBDs
|
||||
VDI = byRefs[byRefs[VBD]?.VDI]
|
||||
VDI = get (get VBD)?.VDI
|
||||
$scope.VDIs.push VDI if VDI?
|
||||
)
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ angular.module('xoWebApp')
|
||||
|
||||
# Resolves links between objects.
|
||||
.filter 'resolve', (xoObjects) ->
|
||||
{byRefs} = xoObjects
|
||||
{get} = xoObjects
|
||||
|
||||
(ref) ->
|
||||
if angular.isArray ref
|
||||
refs = ref
|
||||
byRefs[ref] for ref in refs
|
||||
get ref for ref in refs
|
||||
else
|
||||
byRefs[ref]
|
||||
get ref
|
||||
|
||||
# Applies a function to a list of items.
|
||||
#
|
||||
|
||||
@@ -148,25 +148,26 @@ angular.module('xoWebApp')
|
||||
|
||||
# This service provides access to XO objects.
|
||||
.service 'xoObjects', ($timeout, xoApi) ->
|
||||
byRefs = Object.create null
|
||||
byUUIDs = Object.create null
|
||||
{
|
||||
all
|
||||
byRefs
|
||||
byTypes
|
||||
byUUIDs
|
||||
} = xoObjects = {
|
||||
revision: 0
|
||||
all: []
|
||||
byRefs: {}
|
||||
byTypes: {}
|
||||
byUUIDs: {}
|
||||
byTypes: Object.create null
|
||||
|
||||
get: (key) ->
|
||||
byUUIDs[key] ? byRefs[key]
|
||||
}
|
||||
|
||||
do helper = ->
|
||||
xoApi.call('xo.getAllObjects').then (objects) ->
|
||||
# Empty collections.
|
||||
delete byRefs[key] for key of byTypes
|
||||
delete byTypes[key] for key of byTypes
|
||||
delete byUUIDs[key] for key of byUUIDs
|
||||
byRefs = Object.create null
|
||||
byUUIDs = Object.create null
|
||||
|
||||
all = objects
|
||||
for object in all
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="flat-panel-title"><i class="fa fa-copy" style="color: #e25440;"></i> Templates</p>
|
||||
<p class="center" ng-if="!pool.templates.length">No templates</p>
|
||||
<accordion close-others="oneAtATime">
|
||||
<accordion close-others="true">
|
||||
<accordion-group heading="{{template.name_label}}" ng-repeat="template in pool.templates | resolve">
|
||||
{{template.name_description}}
|
||||
</accordion-group>
|
||||
|
||||
Reference in New Issue
Block a user