TestResultPanel.js (4189B)
1 /** 2 * Provides a simple panel where tests can be displayed including their status. 3 */ 4 Ext.define('PartKeeprSetup.TestResultPanel', { 5 extend: 'Ext.grid.Panel', 6 7 hideHeaders: true, 8 9 store: { 10 fields: [ 11 { 12 name: 'name', 13 type: 'string' 14 }, { 15 name: 'success', 16 type: 'boolean' 17 18 }, { 19 name: 'message', 20 type: 'string' 21 }, { 22 name: 'errors', 23 type: 'string' 24 }, { 25 name: 'warnings', 26 type: 'string' 27 }, { 28 name: 'noWarning', 29 type: 'boolean' 30 }, { 31 name: 'waiting', 32 type: 'boolean' 33 } 34 ] 35 }, 36 columns: [ 37 { 38 flex: 1, 39 dataIndex: 'name' 40 }, { 41 width: 30, 42 dataIndex: 'success', 43 renderer: function (val, metaData, record) 44 { 45 if (record.get("waiting")) { 46 return '<span title="Waiting" style="vertical-align: top;" class="web-icon cog"></span>'; 47 } 48 49 if (val) { 50 if (record.get("warnings").length > 0) { 51 return '<span title="OK" style="vertical-align: top;" class="web-icon error"></span>'; 52 } else { 53 return '<span title="OK" style="vertical-align: top;" class="web-icon accept"></span>'; 54 } 55 56 } else { 57 return '<span title="Error" style="vertical-align: top;" class="web-icon cancel"></span>'; 58 } 59 } 60 }, { 61 flex: 2, 62 dataIndex: 'message' 63 }, { 64 width: 130, 65 xtype: 'widgetcolumn', 66 dataIndex: 'success', 67 widget: { 68 hidden: false, 69 xtype: 'button', 70 defaultBindProperty: "disabled", 71 text: "Show Errors", 72 handler: function (widgetColumn) 73 { 74 var record = widgetColumn.getWidgetRecord(); 75 Ext.Msg.alert("Error Details", record.get("errors")); 76 } 77 } 78 },{ 79 width: 130, 80 xtype: 'widgetcolumn', 81 dataIndex: 'noWarning', 82 widget: { 83 hidden: false, 84 xtype: 'button', 85 defaultBindProperty: "disabled", 86 text: "Show Warnings", 87 handler: function (widgetColumn) 88 { 89 var record = widgetColumn.getWidgetRecord(); 90 Ext.Msg.alert("Warning Details", record.get("warnings")); 91 } 92 } 93 } 94 ], 95 /** 96 * Initializes the component. 97 */ 98 initComponent: function () 99 { 100 this.callParent(); 101 }, 102 103 /** 104 * Clears the result output panel. 105 */ 106 clear: function () 107 { 108 109 this.store.removeAll(); 110 }, 111 112 outputTestMessage: function (test) 113 { 114 this.store.add({ 115 name: test.message, 116 success: true, 117 waiting: true, 118 noWarning: true 119 }); 120 }, 121 /** 122 * Appends the specific test to the output panel, 123 * and fires the error event if an error occured. 124 * 125 * @param test PartKeeprSetup.AbstractTest 126 */ 127 appendTestResult: function (test) 128 { 129 var rec = this.store.findRecord("name", test.message); 130 131 if (rec !== null) { 132 rec.set("success", test.success); 133 rec.set("message", test.resultMessage); 134 rec.set("errors", test.errors.join("<br/>")); 135 136 if (test.warnings.length > 0) { 137 rec.set("warnings", test.warnings.join("<br/>")); 138 rec.set("noWarning", false); 139 } else { 140 rec.set("noWarning", true); 141 } 142 143 rec.set("waiting", false); 144 rec.commit(); 145 } 146 147 if (!test.success) { 148 this.fireEvent("test-error"); 149 } 150 } 151 });