PageRenderTime 20ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/scalr-2/tags/scalr-2.0.0/app/templates/en_US/farms_view.tpl

http://scalr.googlecode.com/
Smarty Template | 186 lines | 168 code | 18 blank | 0 comment | 37 complexity | 949a3dac0af8228d1416b6cabca0d230 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, GPL-3.0
  1. {include file="inc/header.tpl"}
  2. <script type="text/javascript" src="/js/ui-ng/data.js"></script>
  3. <script type="text/javascript" src="/js/ui-ng/viewers/ListView.js"></script>
  4. <div id="listview-farms-view"></div>
  5. <script type="text/javascript">
  6. {literal}
  7. Ext.onReady(function () {
  8. var store = new Scalr.data.Store({
  9. reader: new Scalr.data.JsonReader({
  10. root: 'data',
  11. successProperty: 'success',
  12. errorProperty: 'error',
  13. totalProperty: 'total',
  14. id: 'id',
  15. fields: [
  16. {name: 'id', type: 'int'},
  17. {name: 'clientid', type: 'int'},
  18. {name: 'dtadded', type: 'date'},
  19. 'name', 'status', 'region', 'servers', 'roles', 'zones','client_email','havemysqlrole','shortcuts'
  20. ]
  21. }),
  22. remoteSort: true,
  23. url: '/server/grids/farms_list.php?a=1{/literal}{$grid_query_string}{literal}'
  24. });
  25. new Scalr.Viewers.ListView({
  26. renderTo: "listview-farms-view",
  27. autoRender: true,
  28. store: store,
  29. savePagingSize: true,
  30. savePagingNumber: true,
  31. saveFilter: true,
  32. stateId: 'listview-farms-view',
  33. stateful: true,
  34. title: 'Farms',
  35. rowOptionsMenu: [
  36. //{id: "option.viewMap", text:'View map', href: "/farm_map.php?id={id}"},
  37. //new Ext.menu.Separator({id: "option.viewMapSep"}),
  38. {itemId: "option.privateKey", text: 'Download Private key', href: "/storage/keys/{id}/{name}.pem"},
  39. new Ext.menu.Separator({itemId: "option.privateKeySep"}),
  40. {itemId: "option.launchFarm", text: 'Launch', href: "/farms_control.php?farmid={id}"},
  41. {itemId: "option.terminateFarm",text: 'Terminate', href: "/farms_control.php?farmid={id}"},
  42. new Ext.menu.Separator({itemId: "option.controlSep"}),
  43. {itemId: "option.usageStats", text: 'Usage statistics', href: "/farm_usage_stats.php?farmid={id}"},
  44. {itemId: "option.loadStats", text: 'Load statistics', href: "/monitoring.php?farmid={id}"},
  45. {itemId: "option.ebs", text: 'EBS usage', href: "/ebs_manage.php?farmid={id}"},
  46. {itemId: "option.eip", text: 'Elastic IPs usage', href: "/elastic_ips.php?farmid={id}"},
  47. {itemId: "option.events", text: 'Events & Notifications', href: "/events_view.php?farmid={id}"},
  48. new Ext.menu.Separator({itemId: "option.mysqlSep"}),
  49. {itemId: "option.mysql", text: 'MySQL status', href: "/farm_mysql_info.php?farmid={id}"},
  50. {itemId: "option.script", text: 'Execute script', href: "/execute_script.php?farmid={id}"},
  51. new Ext.menu.Separator({itemId: "option.logsSep"}),
  52. {itemId: "option.logs", text: 'View log', href: "/logs_view.php?farmid={id}"},
  53. new Ext.menu.Separator({itemId: "option.editSep"}),
  54. {itemId: "option.edit", text: 'Edit', href: "/farms_add.php?id={id}"},
  55. {itemId: "option.delete", text: 'Delete', href: "/farm_delete.php?id={id}"},
  56. new Ext.menu.Separator({itemId: "option.scSep"})
  57. ],
  58. getRowOptionVisibility: function (item, record) {
  59. var data = record.data;
  60. if (item.itemId == "option.launchFarm")
  61. return (data.status == 0);
  62. if (item.itemId == "option.terminateFarm")
  63. return (data.status == 1);
  64. if (item.itemId == "option.scSep")
  65. return (data.shortcuts.length > 0);
  66. if (item.itemId == "option.viewMap" ||
  67. item.itemId == "option.viewMapSep" ||
  68. item.itemId == "option.loadStats" ||
  69. item.itemId == "option.mysqlSep" ||
  70. item.itemId == "option.mysql" ||
  71. item.itemId == "option.script"
  72. ) {
  73. if (data.status == 0)
  74. return false;
  75. else
  76. {
  77. if (item.itemId != "option.mysql")
  78. return true;
  79. else
  80. return data.havemysqlrole;
  81. }
  82. }
  83. else
  84. return true;
  85. },
  86. listViewOptions: {
  87. emptyText: "No farms found",
  88. columns: [
  89. { header: "Farm ID", width: 5, dataIndex: 'id', sortable: true, hidden: 'no' },
  90. {/literal}
  91. {if $smarty.session.uid == 0}
  92. {literal}
  93. { header: "Client", width: 10, dataIndex: 'client', tpl: '<a href="/clients_view.php?clientid={clientid}">{client_email}</a>', sortable: false, hidden: 'no' },
  94. {/literal}
  95. {/if}
  96. {literal}
  97. { header: "Farm Name", width: 10, dataIndex: 'name', sortable: true, hidden: 'no' },
  98. { header: "Location", width: 10, dataIndex: 'region', sortable: true, hidden: 'no' },
  99. { header: "Added", width: 10, dataIndex: 'dtadded', tpl: '{[values.dtadded ? values.dtadded.dateFormat("M j, Y") : ""]}', sortable: true, hidden: 'no' },
  100. { header: "Roles", width: 10, dataIndex: 'roles', tpl: '{roles} [<a href="/farm_roles_view.php?farmid={id}">View</a>]', sortable: false, hidden: 'no' },
  101. { header: "Servers", width: 10, dataIndex: 'servers', tpl: '{servers} [<a href="/servers_view.php?farmid={id}">View</a>]', sortable: false, hidden: 'no' },
  102. { header: "DNS zones", width: 10, dataIndex: 'zones', tpl: '{zones} [<a href="/dns_zones_view.php?farmid={id}">View</a>]', sortable: false, hidden: 'no' },
  103. { header: "Status", width: 5, dataIndex: 'status', tpl:
  104. new Ext.XTemplate('<span class="{[this.getClass(values.status)]}">{[this.getName(values.status)]}</span>', {
  105. getClass: function (value) {
  106. if (value == 1)
  107. return "status-ok";
  108. else if (value == 3)
  109. return "status-ok-pending";
  110. else
  111. return "status-fail";
  112. },
  113. getName: function (value) {
  114. var titles = {
  115. 1: "Running",
  116. 0: "Terminated",
  117. 2: "Terminating",
  118. 3: "Synchronizing"
  119. };
  120. return titles[value] || value;
  121. }
  122. }), sortable: true, hidden: 'no'
  123. }
  124. ]
  125. },
  126. listeners: {
  127. 'beforeshowoptions': {fn: function (grid, record, romenu, ev) {
  128. romenu.record = record;
  129. var data = record.data;
  130. romenu.items.each(function (item) {
  131. if (item.isshortcut) {
  132. item.parentMenu.remove(item);
  133. }
  134. });
  135. if (data.shortcuts.length > 0)
  136. {
  137. for (i in data.shortcuts)
  138. {
  139. if (typeof(data.shortcuts[i]) != 'function')
  140. {
  141. romenu.add({
  142. //id:'option.'+(Math.random()*100000),
  143. isshortcut:1,
  144. xmenu:romenu,
  145. text:'Execute '+data.shortcuts[i].name,
  146. href:'execute_script.php?farmid='+data.shortcuts[i].farmid+'&task=execute&script='+data.shortcuts[i].event_name
  147. });
  148. }
  149. }
  150. }
  151. /*
  152. else
  153. {
  154. var rows = romenu.items.items;
  155. for (k in rows)
  156. {
  157. if (rows[k].isshortcut == 1)
  158. romenu.remove(rows[k]);
  159. }
  160. }
  161. */
  162. }}
  163. }
  164. });
  165. });
  166. {/literal}
  167. </script>
  168. {include file="inc/footer.tpl"}