Guest User

Untitled

a guest
Jun 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. export class AssaysTableComponent implements OnInit{
  2. //private rowData;
  3. private gridApi;
  4. private gridColumnApi;
  5. private columnDefs;
  6. private rowModelType;
  7. private paginationPageSize;
  8. private components;
  9. private rowData: any[];
  10. private cacheBlockSize;
  11. private infiniteInitialRowCount;
  12. allTableData : any[];
  13.  
  14. constructor(private http:HttpClient, private appServices:AppServices) {
  15. this.columnDefs = [
  16. {
  17. headerName: "Date/Time",
  18. field: "createdDate",
  19. headerCheckboxSelection: true,
  20. headerCheckboxSelectionFilteredOnly: true,
  21. checkboxSelection: true,
  22. width: 250,
  23. cellRenderer: "loadingRenderer"
  24. },
  25. {headerName: 'Assay Name', field: 'assayName', width: 200},
  26. {headerName: 'Samples', field: 'sampleCount', width: 100}
  27.  
  28. ];
  29.  
  30. this.components = {
  31. loadingRenderer: function(params) {
  32. if (params.value !== undefined) {
  33. return params.value;
  34. } else {
  35. return '<img src="../images/loading.gif">';
  36. }
  37. }
  38. };
  39. this.rowModelType = "infinite";
  40. //this.paginationPageSize = 10;
  41. this.cacheBlockSize = 10;
  42. this.infiniteInitialRowCount = 1;
  43.  
  44. //this.rowData = this.appServices.assayData;
  45. }
  46.  
  47. ngOnInit(){
  48. }
  49.  
  50. onGridReady(params) {
  51. this.gridApi = params.api;
  52. this.gridColumnApi = params.columnApi;
  53. //const allTableData:string[] = [];
  54.  
  55. //const apiCount = 0;
  56. //apiCount++;
  57. console.log("assayApiCall>>",this.appServices.assayApiCall);
  58. const assaysObj = new Assays();
  59. assaysObj.sortBy = 'CREATED_DATE';
  60. assaysObj.sortOder = 'desc';
  61. assaysObj.count = "50";
  62.  
  63. if(this.appServices.assayApiCall>0){
  64. console.log("this.allTableData >> ",this.allTableData);
  65. assaysObj.startEvalulationKey = {
  66. }
  67. }
  68.  
  69. this.appServices.downloadAssayFiles(assaysObj).subscribe(
  70. (response) => {
  71. if (response.length > 0) {
  72. var dataSource = {
  73.  
  74. rowCount: null,
  75. getRows: function (params) {
  76. console.log("asking for " + params.startRow + " to " + params.endRow);
  77. setTimeout(function () {
  78. console.log("response>>",response);
  79. if(this.allTableData == undefined){
  80. this.allTableData = response;
  81. }
  82. else{
  83. this.allTableData = this.allTableData.concat(response);
  84. }
  85. var rowsThisPage = response.slice(params.startRow, params.endRow);
  86. var lastRow = -1;
  87. if (response.length <= params.endRow) {
  88. lastRow = response.length;
  89. }
  90. params.successCallback(rowsThisPage, lastRow);
  91. }, 500);
  92. }
  93. }
  94. params.api.setDatasource(dataSource);
  95. this.appServices.setIsAssaysAvailable(true);
  96. this.appServices.assayApiCall +=1;
  97. }
  98. else{
  99. this.appServices.setIsAssaysAvailable(false)
  100. }
  101. }
  102. )
  103. }
  104. }
Add Comment
Please, Sign In to add comment