Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
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.

151 lines
5.1 KiB

  1. // kate: space-indent on; indent-width 4; replace-tabs on;
  2. Ext.namespace('Ext.ux');
  3. Ext.ux.MumbleChannelViewer = function( config ){
  4. Ext.apply( this, config );
  5. Ext.applyIf( this, {
  6. title: gettext("Channel Viewer"),
  7. root: {
  8. text: gettext("Loading..."),
  9. leaf: true
  10. },
  11. buttons: [{
  12. text: gettext("Refresh"),
  13. handler: this.refresh,
  14. scope: this
  15. }],
  16. } );
  17. Ext.ux.MumbleChannelViewer.superclass.constructor.call( this );
  18. this.refresh();
  19. }
  20. Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, {
  21. refresh: function(){
  22. var conn = new Ext.data.Connection();
  23. conn.request({
  24. url: this.source_url,
  25. scope: this,
  26. success: function( resp, opt ){
  27. respdata = Ext.decode( resp.responseText );
  28. root = {
  29. text: respdata.name,
  30. id: "mumbroot",
  31. leaf: false,
  32. icon: '/static/mumble/mumble.16x16.png',
  33. children: [],
  34. };
  35. function populateNode( node, json ){
  36. subchan_users = 0;
  37. for( var i = 0; i < json.channels.length; i++ ){
  38. child = {
  39. text: json.channels[i].name,
  40. id: ("channel_" + json.channels[i].id),
  41. leaf: false,
  42. icon: '/static/mumble/channel.png',
  43. children: [],
  44. };
  45. node.children.push( child );
  46. subchan_users += populateNode( child, json.channels[i] );
  47. }
  48. for( var i = 0; i < json.users.length; i++ ){
  49. child = {
  50. text: json.users[i].name,
  51. id: ("user_" + json.users[i].id),
  52. leaf: true,
  53. icon: '/static/mumble/talking_off.png',
  54. };
  55. node.children.push( child );
  56. }
  57. if( json.id == 0 || json.users.length > 0 || subchan_users )
  58. node.expanded = true;
  59. return subchan_users + json.users.length;
  60. }
  61. populateNode( root, respdata.root );
  62. this.setRootNode( root );
  63. },
  64. failure: function( resp, opt ){
  65. alert("fail");
  66. },
  67. });
  68. },
  69. } );
  70. Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer );
  71. function render_mumble( divname, urls ){
  72. var mainpanel = new Ext.Panel({
  73. renderTo: divname,
  74. height: 600,
  75. layout: "border",
  76. items: [{
  77. xtype: "mumblechannelviewer",
  78. region: "west",
  79. width: 350,
  80. split: true,
  81. source_url: urls.data,
  82. }, {
  83. xtype: "tabpanel",
  84. region: "center",
  85. activeTab: 0,
  86. items: [{
  87. title: gettext("Registration"),
  88. xtype: "form",
  89. items: [{
  90. name: "username",
  91. fieldLabel: gettext("User name"),
  92. xtype: "textfield",
  93. }, {
  94. name: "password",
  95. fieldLabel: gettext("Password"),
  96. xtype: "textfield",
  97. inputType: "password",
  98. }],
  99. }, {
  100. title: gettext("Administration"),
  101. xtype: "form",
  102. items: [{
  103. name: "test",
  104. fieldLabel: "testing",
  105. xtype: "textfield",
  106. }],
  107. }, {
  108. title: gettext("User texture"),
  109. layout: "border",
  110. items: [{
  111. region: "north",
  112. layout: "hbox",
  113. height: 200,
  114. items: [{
  115. flex: 1,
  116. title: gettext("Texture"),
  117. html: "texture!"
  118. }, {
  119. flex: 1,
  120. title: gettext("Gravatar"),
  121. html: "gravatar!",
  122. }],
  123. }, {
  124. region: "center",
  125. xtype: "form",
  126. items: [{
  127. name: "usegravatar",
  128. fieldLabel: gettext("Use Gravatar"),
  129. xtype: "checkbox",
  130. }, {
  131. name: "uploadpic",
  132. fieldLabel: gettext("Upload Avatar"),
  133. xtype: "textfield",
  134. inputType: "file",
  135. }],
  136. }],
  137. }, {
  138. xtype: "userEditorPanel",
  139. django_users_url: urls.django_users,
  140. mumble_users_url: urls.mumble_users,
  141. } ],
  142. }],
  143. });
  144. }