Summary.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. MWF.xApplication.BAM.summary = MWF.xApplication.BAM.summary || {};
  2. MWF.xApplication.BAM.Summary = new Class({
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default"
  6. },
  7. initialize: function(app, node, options){
  8. this.setOptions(options);
  9. this.app = app;
  10. this.css = this.app.css;
  11. this.lp = this.app.lp;
  12. this.container = $(node);
  13. this.actions = this.app.actions;
  14. this.categoryDataLoaded = false;
  15. this.organizationDataLoaded = false;
  16. this.overviewDataLoaded = false;
  17. this.load();
  18. },
  19. load: function(){
  20. this.loadSummaryLayout();
  21. this.loadSummary();
  22. //this.loadDecimal(function(){
  23. // this.loadSummary();
  24. //}.bind(this));
  25. },
  26. loadSummaryLayout: function(){
  27. this.overviewAreaNode = new Element("div", {"styles": this.css.overviewAreaNode}).inject(this.container);
  28. this.taskAreaNode = new Element("div", {"styles": this.css.taskAreaNode}).inject(this.container);
  29. this.countAreaNode = new Element("div", {"styles": this.css.countAreaNode}).inject(this.container);
  30. this.taskDashboardAreaNode = new Element("div", {"styles": this.css.taskDashboardAreaNode}).inject(this.taskAreaNode);
  31. this.taskRankAreaNode = new Element("div", {"styles": this.css.taskRankAreaNode}).inject(this.taskAreaNode);
  32. this.taskContentAreaNode = new Element("div", {"styles": this.css.taskContentAreaNode}).inject(this.countAreaNode);
  33. this.taskCompletedContentAreaNode = new Element("div", {"styles": this.css.taskCompletedContentAreaNode}).inject(this.countAreaNode);
  34. this.workContentAreaNode = new Element("div", {"styles": this.css.workContentAreaNode}).inject(this.countAreaNode);
  35. this.workCompletedContentAreaNode = new Element("div", {"styles": this.css.workCompletedContentAreaNode}).inject(this.countAreaNode);
  36. },
  37. checkLoadDataCompleted: function(){
  38. if (this.overviewDataLoaded && this.categoryDataLoaded && this.organizationDataLoaded){
  39. this.fireEvent("loaded");
  40. }
  41. },
  42. loadSummary: function(){
  43. this.loadOverviewData(function(){
  44. this.loadOverview();
  45. this.overviewDataLoaded = true;
  46. this.checkLoadDataCompleted();
  47. }.bind(this));
  48. this.loadCategoryData(function(){
  49. this.loadTaskDashboard();
  50. this.loadTaskContent();
  51. this.loadTaskCompletedContent();
  52. this.loadWorkContent();
  53. this.loadWorkCompletedContent();
  54. this.categoryDataLoaded = true;
  55. this.checkLoadDataCompleted();
  56. }.bind(this));
  57. this.loadOrganizationData(function(){
  58. this.loadTaskRank();
  59. this.organizationDataLoaded = true;
  60. this.checkLoadDataCompleted();
  61. }.bind(this));
  62. },
  63. loadOverviewData: function(callback){
  64. this.actions.summary(function(json){
  65. this.summaryData = json.data;
  66. if (callback) callback();
  67. }.bind(this));
  68. },
  69. loadOverview: function(){
  70. // this.actions.summary(function(json){
  71. // this.summaryData = json.data;
  72. MWF.xDesktop.requireApp("BAM", "summary.Overview", function(){
  73. this.summaryChart = new MWF.xApplication.BAM.summary.Overview(this, this.overviewAreaNode, this.summaryData);
  74. }.bind(this));
  75. // }.bind(this));
  76. },
  77. loadTaskRank: function(){
  78. MWF.xDesktop.requireApp("BAM", "summary.TaskRank", function(){
  79. this.rankChart = new MWF.xApplication.BAM.summary.TaskRank(this, this.taskRankAreaNode);
  80. }.bind(this));
  81. },
  82. loadTaskDashboard: function(){
  83. MWF.xDesktop.requireApp("BAM", "summary.TaskDashboard", function(){
  84. this.dashboardChart = new MWF.xApplication.BAM.summary.TaskDashboard(this, this.taskDashboardAreaNode);
  85. }.bind(this));
  86. },
  87. loadTaskContent: function(){
  88. MWF.xDesktop.requireApp("BAM", "summary.TaskContent", function(){
  89. this.taskChart = new MWF.xApplication.BAM.summary.TaskContent(this, this.taskContentAreaNode);
  90. }.bind(this));
  91. },
  92. loadTaskCompletedContent: function(){
  93. MWF.xDesktop.requireApp("BAM", "summary.TaskCompletedContent", function(){
  94. this.taskCompletedChart = new MWF.xApplication.BAM.summary.TaskCompletedContent(this, this.taskCompletedContentAreaNode, this.scalingData);
  95. }.bind(this));
  96. },
  97. loadWorkContent: function(){
  98. MWF.xDesktop.requireApp("BAM", "summary.WorkContent", function(){
  99. this.workChart = new MWF.xApplication.BAM.summary.WorkContent(this, this.workContentAreaNode, this.scalingData);
  100. }.bind(this));
  101. },
  102. loadWorkCompletedContent: function(){
  103. MWF.xDesktop.requireApp("BAM", "summary.WorkCompletedContent", function(){
  104. this.workCompletedChart = new MWF.xApplication.BAM.summary.WorkCompletedContent(this, this.workCompletedContentAreaNode, this.scalingData);
  105. }.bind(this));
  106. },
  107. loadRunningData: function(callback){
  108. if (!this.runningData){
  109. this.actions.loadRunning(function(json){
  110. this.runningData = json.data;
  111. if (callback) callback();
  112. }.bind(this));
  113. }else{
  114. if (callback) callback();
  115. }
  116. },
  117. loadOrganizationData: function(callback){
  118. this.organizationData = {};
  119. this.actions.loadOrganization(function(json){
  120. this.organizationData = json.data;
  121. if (callback) callback();
  122. }.bind(this));
  123. },
  124. loadCategoryData: function(callback){
  125. this.categoryData = {
  126. "application": [],
  127. "process": [],
  128. "activity": []
  129. };
  130. this.actions.loadCategory(function(json){
  131. this.categoryData = json.data;
  132. if (callback) callback();
  133. }.bind(this));
  134. },
  135. destroy: function(){
  136. if(this.summaryChart) this.summaryChart.destroy();
  137. if(this.rankChart) this.rankChart.destroy();
  138. if(this.dashboardChart) this.dashboardChart.destroy();
  139. if(this.taskChart) this.taskChart.destroy();
  140. if(this.taskCompletedChart) this.taskCompletedChart.destroy();
  141. if(this.workChart) this.workChart.destroy();
  142. if(this.workCompletedChart) this.workCompletedChart.destroy();
  143. this.container.empty();
  144. MWF.release(this);
  145. }
  146. });