Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class pivot.ConfigPanel
  9. * @extends Ext.Panel
  10. * A configuration panel used for modifying the properties of a PivotGrid.
  11. */
  12. pivot.ConfigPanel = Ext.extend(Ext.Panel, {
  13. title: 'Configure',
  14. layout: {
  15. type: 'vbox',
  16. align: 'stretch'
  17. },
  18. /**
  19. * @cfg {Ext.data.Record} record The Ext.data.Record to extract the field list from. Required
  20. */
  21. initComponent: function() {
  22. var fields = this.getRecordFields();
  23. /**
  24. * @property form
  25. * @type Ext.form.FormPanel
  26. * Used to set the measure and aggregation function
  27. */
  28. this.form = new Ext.Container({
  29. layout: 'form',
  30. style: 'padding: 7px',
  31. items: [{
  32. xtype: 'combo',
  33. mode: 'local',
  34. triggerAction: 'all',
  35. forceSelection: true,
  36. editable: false,
  37. anchor: "0",
  38. fieldLabel: 'Measure',
  39. ref: '/measure',
  40. name: 'measure',
  41. displayField: 'name',
  42. valueField: 'name',
  43. value: this.measure || this.measures[0],
  44. store: this.getMeasureStore()
  45. }, { xtype: 'combo',
  46. mode: 'local',
  47. triggerAction: 'all', forceSelection: true, editable: false, anchor: "0", fieldLabel: 'Aggregator', ref: '/aggregator',
  48. name: 'aggregator',
  49. displayField: 'name', valueField: 'value', value: this.aggregator,
  50. store: new Ext.data.JsonStore({
  51. fields : ['name', 'value'],
  52. data : [
  53. {name : 'Sum', value: 'sum'},
  54. {name : 'Count', value: 'count'},
  55. {name : 'Min', value: 'min'},
  56. {name : 'Max', value: 'max'},
  57. {name : 'Average', value: 'avg'}
  58. ]
  59. })
  60. }]
  61. });
  62. /**
  63. * @property leftAxisGrid
  64. * @type pivot.AxisGrid
  65. */
  66. this.leftAxisGrid = new pivot.AxisGrid({
  67. title : 'Left Axis',
  68. fields: fields,
  69. dimensionData: this.leftAxisDimensions || [],
  70. hasWidthField: true
  71. });
  72. /**
  73. * @property topAxisGrid
  74. * @type pivot.AxisGrid
  75. */
  76. this.topAxisGrid = new pivot.AxisGrid({
  77. title : 'Top Axis',
  78. fields: fields,
  79. dimensionData: this.topAxisDimensions || []
  80. });
  81. Ext.applyIf(this, {
  82. items: [
  83. this.form,
  84. this.topAxisGrid,
  85. this.leftAxisGrid
  86. ],
  87. fbar: {
  88. buttonAlign: 'left',
  89. items: [{
  90. icon : '../shared/icons/fam/accept.png',
  91. text : 'Update',
  92. scope : this,
  93. handler: this.updateGrid
  94. }]
  95. }
  96. });
  97. pivot.ConfigPanel.superclass.initComponent.apply(this, arguments);
  98. },
  99. /**
  100. * @private
  101. * Retrieves the configured axis dimensions for the top and left grids and updates the PivotGrid accordingly
  102. */
  103. updateGrid: function() {
  104. var leftDimensions = [],
  105. topDimensions = [],
  106. leftGridItems = this.leftAxisGrid.store.data.items,
  107. topGridItems = this.topAxisGrid.store.data.items,
  108. i;
  109. for (i = 0; i < leftGridItems.length; i++) {
  110. leftDimensions.push({
  111. dataIndex: leftGridItems[i].get('field'),
  112. direction: leftGridItems[i].get('direction'),
  113. width : leftGridItems[i].get('width')
  114. });
  115. }
  116. for (i = 0; i < topGridItems.length; i++) {
  117. topDimensions.push({
  118. dataIndex: topGridItems[i].get('field'),
  119. direction: topGridItems[i].get('direction')
  120. });
  121. }
  122. this.fireEvent('update', {
  123. leftDimensions: leftDimensions,
  124. topDimensions : topDimensions,
  125. aggregator : this.aggregator.getValue(),
  126. measure : this.measure.getValue()
  127. });
  128. },
  129. /**
  130. * Extracts the field names from the configured record
  131. * @return {Array} The set of Record fields
  132. */
  133. getRecordFields: function() {
  134. return Ext.pluck(this.record.prototype.fields.items, 'name');
  135. },
  136. /**
  137. * @private
  138. * @return {Ext.data.Store} The store
  139. */
  140. getMeasureStore: function() {
  141. /**
  142. * @property measureStore
  143. * @type Ext.data.JsonStore
  144. * The store bound to the combo for selecting the field
  145. */
  146. if (this.measureStore == undefined) {
  147. var fields = [],
  148. measures = this.measures,
  149. length = measures.length,
  150. i;
  151. for (i = 0; i < length; i++) {
  152. fields[i] = [measures[i]];
  153. }
  154. this.measureStore = new Ext.data.ArrayStore({
  155. fields: ['name'],
  156. data : fields
  157. });
  158. }
  159. return this.measureStore;
  160. }
  161. });
  162. Ext.reg('pivotconfig', pivot.ConfigPanel);