//////////////////////////////////////////////////////////////////////////// // Rev: 2010.1 (P4JsApi 1.0 Example) // // NOTE: This is an example only, and should be modified to work in // a production environment! No warranty is expressed or implied. // Scripts should be tested thoroughly on a test server before // using in a production environment. // //////////////////////////////////////////////////////////////////////////// // Copyright (c) 2010, Perforce Software, Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////////// var P4 = P4 || {}; P4.createProcessesWidget = function() { try { var reader = new Ext.data.ArrayReader({}, [ { name: 'command' }, { name: 'arguments' }, { name: 'user' }, { name: 'time' } ]); var processData = []; var loading = false; var store = new Ext.data.GroupingStore({ reader: reader, proxy: new Ext.data.MemoryProxy(processData), sortInfo: { field: 'command', direction: "ASC" }, groupField: 'command' }); var processMarkup = [ '<b>Full command</b>: {command} {arguments}<br/>', '<b>User</b>: {user}<br/>', '<b>Elapsed Time</b>: {time}<br/>' ]; var processTpl = new Ext.Template(processMarkup); var loaded = false; function fetchProcesses() { if (loading) { return; } loading = true; P4JsApi.p4("monitor show -a -l", function(processes) { while (processData.length > 0) { processData.pop(); } var item = 0; while (processes.data[item]) { var process = processes.data[item]; var data = []; data.push(process.command); data.push(process.args); data.push(process.user); data.push(process.time); if (process.time != '00:00:00' || process.user != P4JsApi.getUser()) { processData.push(data); } item++; } if (loaded) { store.reload(); var detailPanel = Ext.getCmp('detailPanel'); processTpl.overwrite(detailPanel.body, {}); } else { loaded = true; store.load(); } loading = false; }); } fetchProcesses(); var grid = new Ext.grid.GridPanel({ store: store, columns: [ { id: 'command', header: "Command", width: 50, sortable: true, dataIndex: 'command' }, { header: "User", width: 20, sortable: true, dataIndex: 'user' }, { header: "Time", width: 20, sortable: true, dataIndex: 'time' }, { header: "Arguments", width: 40, sortable: true, dataIndex: 'arguments' } ], view: new Ext.grid.GroupingView({ forceFit: true, groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' }), split: true, height: 175, region: 'north', autoScroll: true, autoshow: true, loadMask: true, iconCls: 'icon-grid', }); grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r) { var detailPanel = Ext.getCmp('detailPanel'); processTpl.overwrite(detailPanel.body, r.data); }); var loadId = setInterval(fetchProcesses, 30 * 1000); return new Ext.Panel({ frame: true, baseCls: 'x-grid-pane', height: 250, layout: 'border', items: [ grid, { id: 'detailPanel', region: 'center', bodyStyle: { background: '#ffffff', padding: '5px' }, html: 'Select a command.' } ] }); } catch(e) { alert(e); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 7663 | dscheirer | Rollback //public/perforce/p4jsapi to changelist 7643 | ||
#3 | 7660 | jhalbig |
As per meeting to resolve issue with sync calls made from within async calls hanging P4V (job039138) pulling example code from Public Depot until it can be re-worked and confirmed to function correctly with pending P4JsApi changes. |
||
#2 | 7643 | jhalbig |
Cleaned up any remaining discrepancies in the code. Removed all internal references and debugging code. Cleaned up formatting, added more commenting for submit dialog code. Ready for 2010.1 Beta. |
||
#1 | 7638 | jhalbig | Initial Addition of P4JsApi samples for 2010.1 Beta |