partkeepr

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

commit 82220847803e28da84d0f8083f086ca1c12a06ab
parent 2fe0aecd37cf1b6e964b34c6901420d31374911c
Author: Felicitus <felicitus@felicitus.org>
Date:   Sun, 14 Aug 2011 07:54:32 +0200

Added system information panel

Diffstat:
Mfrontend/js/Components/MenuBar.js | 18++++++++++++++++++
Afrontend/js/Components/SystemInformation/SystemInformationGrid.js | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afrontend/js/Models/SystemInformationRecord.js | 18++++++++++++++++++
Asrc/de/RaumZeitLabor/PartKeepr/System/SystemInformationRecord.php | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/de/RaumZeitLabor/PartKeepr/System/SystemService.php | 46++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 240 insertions(+), 0 deletions(-)

diff --git a/frontend/js/Components/MenuBar.js b/frontend/js/Components/MenuBar.js @@ -37,6 +37,10 @@ Ext.define('PartKeepr.MenuBar', { text: i18n("Units"), handler: this.editUnits, icon: 'resources/icons/unit.png' + },{ + text: i18n("System Information"), + handler: this.showSystemInformation, + icon: 'resources/fugue-icons/icons/system-monitor.png' }] }); @@ -49,6 +53,20 @@ Ext.define('PartKeepr.MenuBar', { this.callParent(); }, + /** + * Shows the system information window + */ + showSystemInformation: function () { + var j = Ext.create("PartKeepr.SystemInformationGrid", { + title: i18n("System Information"), + closable: true, + padding: "5 5 5 5" + }); + + + PartKeepr.getApplication().addItem(j); + j.show(); + }, showStatistics: function () { var j = Ext.create("PartKeepr.CurrentStatisticsPanel", { closable: true diff --git a/frontend/js/Components/SystemInformation/SystemInformationGrid.js b/frontend/js/Components/SystemInformation/SystemInformationGrid.js @@ -0,0 +1,101 @@ +/** + * This class represents a list of all system information records. + */ +Ext.define('PartKeepr.SystemInformationGrid', { + extend: 'Ext.grid.Panel', + + /* Define the columns */ + columns: [ + { + header: 'Name', + dataIndex: 'name', + width: 200 + },{ + header: 'Value', + dataIndex: 'value', + 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' + } + }); + + + /* 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); + + } + } +});+ \ No newline at end of file diff --git a/frontend/js/Models/SystemInformationRecord.js b/frontend/js/Models/SystemInformationRecord.js @@ -0,0 +1,17 @@ +/** + * Defines a system information record + */ +Ext.define("PartKeepr.SystemInformationRecord", { + extend: "Ext.data.Model", + fields: [ + /* Defines the name of the property */ + { name: 'name', type: 'string' }, + /* Defines the value of the property */ + { name: 'value', type: 'string' }, + /* Defines the category of the property */ + { name: 'category', type: 'string' }, + /* Defines the ID of the */ + //{ name: 'id', id: 'id', type: 'integer' } + + ] +});+ \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/System/SystemInformationRecord.php b/src/de/RaumZeitLabor/PartKeepr/System/SystemInformationRecord.php @@ -0,0 +1,55 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\System; + +/** + * This class represents a system information record. + * + * This is basically a category, a name and a value. No logic included within + * the class. + * + * For example, records could hold: + * + * Name Value Category + * ===================================================================================== + * Doctrine ORM 2.1.0 Libraries + * Doctrine DBAL 2.1.0 Libraries + * Doctrine Migrations git-f87afe9223dbfecaaddb Libraries + * + * PHP Version 5.3.2 Server Software + * Operating System Linux (Funtoo Linux - baselayout 2.1.8) Server Software + + * @author felicitus + * + */ +class SystemInformationRecord { + /** + * Holds the category name + * @var string + */ + public $category; + + /** + * Holds the name + * @var string + */ + public $name; + + /** + * Holds the value + * @var mixed + */ + public $value; + + /** + * Creates a new system information record. + * + * @param string $name + * @param mixed $value + * @param string $category + */ + public function __construct ($name, $value, $category) { + $this->name = $name; + $this->value = $value; + $this->category = $category; + } +}+ \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/System/SystemService.php b/src/de/RaumZeitLabor/PartKeepr/System/SystemService.php @@ -0,0 +1,45 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\System; +use de\RaumZeitLabor\PartKeepr\Service\RestfulService; + +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartKeepr\Service\Service; +use de\RaumZeitLabor\PartKeepr\PartKeepr; + +class SystemService extends Service { + /** + * Returns a list of system information records. + * + * Please note that it is not defined which information is returned; the result + * should be seen as "informational" to the system operator, not for automated purposes. + */ + public function getSystemInformation () { + $aData = array(); + + + $aData[] = new SystemInformationRecord("Doctrine ORM", \Doctrine\ORM\Version::VERSION, "Libraries"); + $aData[] = new SystemInformationRecord("Doctrine DBAL", \Doctrine\DBAL\Version::VERSION, "Libraries"); + + $aData[] = new SystemInformationRecord("PHP", phpversion(), "System"); + $aData[] = new SystemInformationRecord("Operating System", php_uname(), "System"); + + if (file_exists("/etc/lsb-release")) { + // Quick'n'dirty extract of the release information + $aReleaseData = explode("\n", file_get_contents("/etc/lsb-release")); + + foreach ($aReleaseData as $releaseData) { + if (strpos($releaseData, "DISTRIB_ID") !== false) { + $data = explode("\"", $releaseData); + $aData[] = new SystemInformationRecord("Distribution", $data[1], "System"); + } + } + + + } + + + return array("data" => $aData); + } + +}+ \ No newline at end of file