partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit a53662c4dd6da863d2e6ee97f614b115dec67294
parent 6633f412d2d5ee94b37d78b221a3cbba6add81c8
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu, 10 Sep 2015 15:01:04 +0200

Added service for retrieving the system information, refactored component to display the system information properly

Diffstat:
Msrc/PartKeepr/CoreBundle/Controller/DefaultController.php | 14+++++++++++++-
Msrc/PartKeepr/CoreBundle/Services/SystemService.php | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js | 158+++++++++++++++++++++++++++++++------------------------------------------------
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js | 18++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 1+
5 files changed, 95 insertions(+), 98 deletions(-)

diff --git a/src/PartKeepr/CoreBundle/Controller/DefaultController.php b/src/PartKeepr/CoreBundle/Controller/DefaultController.php @@ -8,7 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration as Routing; class DefaultController extends FOSRestController { /** - * Returns system information + * Returns system status * * @Routing\Route("/api/system_status", defaults={"method" = "get","_format" = "json"}) * @View() @@ -19,4 +19,16 @@ class DefaultController extends FOSRestController { return $this->get("partkeepr_systemservice")->getSystemStatus(); } + + /** + * Returns system information + * + * @Routing\Route("/api/system_information", defaults={"method" = "get","_format" = "json"}) + * @View() + * + * @return array + */ + public function getSystemInformationAction () { + return $this->get("partkeepr_systemservice")->getSystemInformation(); + } } diff --git a/src/PartKeepr/CoreBundle/Services/SystemService.php b/src/PartKeepr/CoreBundle/Services/SystemService.php @@ -74,7 +74,7 @@ class SystemService extends ContainerAware $aData[] = new SystemInformationRecord($key, $value, "PartKeepr Configuration Information"); } - return array("data" => $aData); + return $aData; } /** diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js @@ -2,101 +2,67 @@ * This class represents a list of all system information records. */ Ext.define('PartKeepr.SystemInformationGrid', { - extend: 'PartKeepr.BaseGrid', - - /* Define the columns */ - columns: [ - { - header: 'Name', - dataIndex: 'name', - width: 200 - },{ - header: 'Value', - dataIndex: 'value', - renderer: 'htmlEncode', - flex:1 - },{ - header: 'Category', - dataIndex: 'category', - hidden: true - } - ], - - /** - * Initializes the component - */ - initComponent: function () { - - /* Add grouping */ - var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{ - groupHeaderTpl: '{name}' - }); - - this.features = [groupingFeature]; - - /* Create the store using an in-memory proxy */ - this.store = Ext.create("Ext.data.Store", { - model: 'PartKeepr.SystemInformationRecord', - sorters: ['category','name'], - groupField: 'category', - proxy: { - type: 'memory' - } - }); - + extend: 'PartKeepr.BaseGrid', - /* Add the refresh button */ - this.refreshButton = Ext.create("Ext.button.Button", { - handler: this.requestSystemInformation, - scope: this, - text: i18n("Refresh") - }); - - this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", { - dock: 'bottom', - ui: 'footer', - items: [ this.refreshButton ] - }); - - this.dockedItems = [ this.bottomToolbar ]; - - // Initialize the panel - this.callParent(); - - // Retrieve the system information - this.requestSystemInformation(); - - }, - /** - * Requests the system information from the server. - */ - requestSystemInformation: function () { - var call = new PartKeepr.ServiceCall("System", "getSystemInformation"); - call.setHandler(Ext.bind(this.processSystemInformationRecords, this)); - call.doCall(); - }, - /** - * Processes the response given by the getSystemInformation call. - * - * Removes all records from the store and re-creates the records. - * - * @param response The response record - */ - processSystemInformationRecords: function (response) { - this.store.removeAll(); - - // Workaround for removeAll Bug - see http://www.sencha.com/forum/showthread.php?136673-4.0.2-store.removeAll()-does-not-perform-view.all.clear() - this.view.all.clear(); - - for (var i=0;i<response.data.length;i++) { - var rec = new PartKeepr.SystemInformationRecord({ - category: response.data[i].category, - name: response.data[i].name, - value: response.data[i].value - }); - - this.store.insert(0, rec); - - } - } + /* Define the columns */ + columns: [ + { + header: 'Name', + dataIndex: 'name', + width: 200 + }, { + header: 'Value', + dataIndex: 'value', + renderer: Ext.util.Format.htmlEncode, + flex: 1 + }, { + header: 'Category', + dataIndex: 'category', + hidden: true + } + ], + + /** + * Initializes the component + */ + initComponent: function () + { + + /* Add grouping */ + var groupingFeature = Ext.create('Ext.grid.feature.Grouping', { + groupHeaderTpl: '{name}' + }); + + this.features = [groupingFeature]; + + /* Create the store using an in-memory proxy */ + this.store = Ext.create("Ext.data.Store", { + model: 'PartKeepr.SystemInformationRecord', + sorters: ['category', 'name'], + groupField: 'category' + }); + + + /* Add the refresh button */ + this.refreshButton = Ext.create("Ext.button.Button", { + handler: this.requestSystemInformation, + scope: this, + text: i18n("Refresh") + }); + + this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", { + dock: 'bottom', + ui: 'footer', + items: [this.refreshButton] + }); + + this.dockedItems = [this.bottomToolbar]; + + // Initialize the panel + this.callParent(); + + // Retrieve the system information + this.store.load(); + + } }); \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js @@ -0,0 +1,17 @@ +Ext.define('PartKeepr.SystemInformationRecord', { + extend: 'PartKeepr.data.HydraModel', + alias: 'schema.PartKeepr.SystemInformationRecord', + + fields: [ + { name: 'name', type: 'string'}, + { name: 'category', type: 'string'}, + { name: 'value', type: 'string'}, + ], + + + + proxy: { + type: "Hydra", + url: '/api/system_information' + } +});+ \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -52,6 +52,7 @@ {% endfor %} {% javascripts output='js/compiled/main2.js' + '@PartKeeprFrontendBundle/Resources/public/js/Models/SystemInformationRecord.js' '@PartKeeprFrontendBundle/Resources/public/js/Util/Crypto/isaac.js' '@PartKeeprFrontendBundle/Resources/public/js/Util/Crypto/bcrypt.js' '@PartKeeprFrontendBundle/Resources/public/js/Util/Crypto/core.js'