diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/images.js b/src/sunstone/public/app/tabs/datastores-tab/panels/images.js index 38b069a503..91078dc2e6 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/panels/images.js +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/images.js @@ -4,7 +4,9 @@ define(function(require){ */ var Locale = require('utils/locale'); + var OpenNebulaDatastore = require('opennebula/datastore'); var ImagesTable = require('tabs/images-tab/datatable'); + var FilesTable = require('tabs/files-tab/datatable'); /* CONSTANTS @@ -23,7 +25,6 @@ define(function(require){ this.icon = "fa-upload"; this.element = info[RESOURCE.toUpperCase()]; - this.imagesDataTable = new ImagesTable(IMAGES_TABLE_ID, {info: true}); return this; }; @@ -39,13 +40,37 @@ define(function(require){ */ function _html() { + var imgs = []; + + if (this.element.IMAGES.ID != undefined){ + imgs = this.element.IMAGES.ID; + + if (!$.isArray(imgs)){ + imgs = [imgs]; + } + } + + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: imgs + } + }; + + if (this.element.TYPE == OpenNebulaDatastore.TYPES.FILE_DS){ + this.imagesDataTable = new FilesTable(IMAGES_TABLE_ID, opts); + } else { + this.imagesDataTable = new ImagesTable(IMAGES_TABLE_ID, opts); + } + return this.imagesDataTable.dataTableHTML; } function _setup(context) { this.imagesDataTable.initialize(); - this.imagesDataTable.filter(this.element.NAME, ImagesTable.COLUMN_IDS.DATASTORE); - this.imagesDataTable.list(); + this.imagesDataTable.refreshResourceTableSelect(); return false; } diff --git a/src/sunstone/public/app/tabs/files-tab/datatable.js b/src/sunstone/public/app/tabs/files-tab/datatable.js index b042927ef3..78ad1919d5 100644 --- a/src/sunstone/public/app/tabs/files-tab/datatable.js +++ b/src/sunstone/public/app/tabs/files-tab/datatable.js @@ -17,10 +17,6 @@ define(function(require) { var RESOURCE = "File"; var XML_ROOT = "IMAGE"; var TAB_NAME = require('./tabId'); - var COLUMN_IDS = { - "DATASTORE": 5, - "TYPE": 7 - }; /* CONSTRUCTOR @@ -76,7 +72,6 @@ define(function(require) { Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; - Table.COLUMN_IDS = COLUMN_IDS; return Table; diff --git a/src/sunstone/public/app/tabs/images-tab/datatable.js b/src/sunstone/public/app/tabs/images-tab/datatable.js index c6e3e7232e..f68d02616e 100644 --- a/src/sunstone/public/app/tabs/images-tab/datatable.js +++ b/src/sunstone/public/app/tabs/images-tab/datatable.js @@ -17,9 +17,7 @@ define(function(require) { var RESOURCE = "Image" var XML_ROOT = "IMAGE" var TAB_NAME = require('./tabId'); - var COLUMN_IDS = { - "DATASTORE": 5 - } + /* CONSTRUCTOR */ @@ -79,7 +77,6 @@ define(function(require) { Table.prototype.elementArray = _elementArray; Table.prototype.preUpdateView = _preUpdateView; Table.prototype.postUpdateView = _postUpdateView; - Table.COLUMN_IDS = COLUMN_IDS; return Table;