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.

274 lines
12 KiB

15 years ago
  1. // kate: space-indent on; indent-width 4; replace-tabs on;
  2. Ext.namespace('Ext.ux');
  3. Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, {
  4. clickHandler: function( node, ev ){
  5. if( typeof node.attributes.userdata != "undefined" ){
  6. this.activate(node.attributes.userdata);
  7. }
  8. },
  9. init: function( tree ){
  10. this.tree = tree;
  11. tree.on("click", this.clickHandler, this);
  12. },
  13. activate: function( userdata ){
  14. if( !this.wnd ){
  15. this.userdata = userdata;
  16. this.wnd = new Ext.Window({
  17. title: this.windowTitle || gettext("User details"),
  18. layout: 'fit',
  19. items: [{
  20. xtype: "tabpanel",
  21. activeTab: 0,
  22. border: false,
  23. items: [{
  24. xtype: "form",
  25. border: false,
  26. title: gettext("User comment"),
  27. items: [{
  28. xtype: "htmleditor",
  29. fieldLabel: 'x',
  30. hideLabel: true,
  31. name: "comment",
  32. value: userdata.comment,
  33. }],
  34. }, {
  35. title: gettext("Avatar"),
  36. scope: this,
  37. listeners: {
  38. afterrender: function( panel ){
  39. Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){
  40. if( response.result.has ){
  41. panel.el.dom.children[0].children[0].innerHTML = String.format(
  42. '<img src="{0}" alt="avatar" />', response.result.url
  43. );
  44. }
  45. else{
  46. panel.el.dom.children[0].children[0].innerHTML =
  47. gettext("This user does not have an Avatar.");
  48. }
  49. } );
  50. }
  51. },
  52. html: gettext("Loading..."),
  53. }, {
  54. title: gettext("Infos"),
  55. xtype: "form",
  56. border: false,
  57. items: [{
  58. xtype: "checkbox",
  59. fieldLabel: gettext("Authenticated"),
  60. name: "a",
  61. checked: (this.userdata.userid != -1)
  62. }, {
  63. xtype: "checkbox",
  64. fieldLabel: gettext("Self-Deafened"),
  65. name: "sd",
  66. checked: this.userdata.selfDeaf
  67. }, {
  68. xtype: "checkbox",
  69. fieldLabel: gettext("Deafened"),
  70. name: "d",
  71. checked: this.userdata.deaf
  72. }, {
  73. xtype: "checkbox",
  74. fieldLabel: gettext("Self-Muted"),
  75. name: "sm",
  76. checked: this.userdata.selfMute
  77. }, {
  78. xtype: "checkbox",
  79. fieldLabel: gettext("Muted"),
  80. name: "m",
  81. checked: this.userdata.mute
  82. }, {
  83. xtype: "checkbox",
  84. fieldLabel: gettext("Suppressed"),
  85. name: "s",
  86. checked: this.userdata.suppress
  87. }, {
  88. xtype: "checkbox",
  89. fieldLabel: gettext("Priority Speaker"),
  90. name: "p",
  91. checked: this.userdata.prioritySpeaker
  92. }, {
  93. xtype: "checkbox",
  94. fieldLabel: gettext("Recording"),
  95. name: "r",
  96. checked: this.userdata.recording
  97. }]
  98. }, {
  99. xtype: "form",
  100. border: false,
  101. title: gettext("Administration"),
  102. items: [{
  103. xtype: "checkbox",
  104. fieldLabel: gettext("Ban"),
  105. name: "ban"
  106. }, {
  107. xtype: "numberfield",
  108. fieldLabel: gettext("Ban duration"),
  109. value: 3600,
  110. name: "duration"
  111. }, {
  112. xtype: "label",
  113. text: gettext("Only if banning. Set to 0 for permanent ban, any other value for the ban duration in seconds."),
  114. cls: "form_hint_label",
  115. }, {
  116. xtype: "textfield",
  117. fieldLabel: gettext("Reason"),
  118. name: "reason"
  119. }],
  120. fbar: [{
  121. scope: this,
  122. text: gettext("Kick"),
  123. handler: function(btn){
  124. f = btn.ownerCt.ownerCt.getForm().getValues();
  125. Mumble.kickUser(
  126. this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration)
  127. );
  128. }
  129. }, {
  130. text: gettext("Mute"),
  131. enableToggle: true,
  132. scope: this,
  133. ref: '../mutebutton',
  134. pressed: this.userdata.mute,
  135. disabled: this.userdata.deaf,
  136. toggleHandler: function(btn, state){
  137. Mumble.muteUser(this.serverid, this.userdata.session, state);
  138. }
  139. }, {
  140. text: gettext("Deafen"),
  141. enableToggle: true,
  142. scope: this,
  143. ref: '../deafenbutton',
  144. pressed: this.userdata.deaf,
  145. toggleHandler: function(btn, state){
  146. Mumble.deafenUser(this.serverid, this.userdata.session, state);
  147. if( state )
  148. btn.refOwner.mutebutton.toggle(true, true);
  149. btn.refOwner.mutebutton.setDisabled(state);
  150. }
  151. }],
  152. }],
  153. }],
  154. width: 500,
  155. height: 300,
  156. scope: this,
  157. listeners: {
  158. beforeclose: function(){
  159. this.owner.wnd = null;
  160. }
  161. },
  162. });
  163. this.wnd.owner = this;
  164. }
  165. if( !this.wnd.isVisible() ){
  166. this.wnd.show();
  167. mypos = this.tree.getPosition();
  168. mysize = this.tree.getSize();
  169. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  170. }
  171. else{
  172. this.wnd.close();
  173. }
  174. },
  175. } );
  176. Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
  177. clickHandler: function( node, ev ){
  178. if( typeof node.attributes.chandata != "undefined" ){
  179. this.activate(node.attributes.chandata);
  180. }
  181. },
  182. init: function( tree ){
  183. this.tree = tree;
  184. tree.on("click", this.clickHandler, this);
  185. },
  186. activate: function( chandata ){
  187. if( !this.wnd ){
  188. this.chandata = chandata;
  189. this.wnd = new Ext.Window({
  190. title: this.windowTitle || gettext("Channel details"),
  191. layout: 'fit',
  192. items: [{
  193. xtype: "tabpanel",
  194. activeTab: 0,
  195. items: [{
  196. xtype: "form",
  197. border: false,
  198. title: gettext("Channel description"),
  199. defaults: { "anchor": "-20px" },
  200. items: [{
  201. xtype: "textfield",
  202. fieldLabel: "x",
  203. hideLabel: true,
  204. name: "name",
  205. value: chandata.name
  206. }, {
  207. xtype: "htmleditor",
  208. fieldLabel: 'x',
  209. hideLabel: true,
  210. name: "description",
  211. value: chandata.description
  212. }],
  213. fbar: [{
  214. text: gettext('Add subchannel...'),
  215. scope: this,
  216. handler: function(btn){
  217. Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
  218. if (btn == 'ok'){
  219. Mumble.addChannel( this.serverid, text, this.chandata.id );
  220. }
  221. }, this);
  222. }
  223. }, {
  224. scope: this,
  225. text: gettext("Submit name/description"),
  226. handler: function(btn){
  227. f = btn.ownerCt.ownerCt.getForm().getValues();
  228. Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description);
  229. }
  230. }, {
  231. text: gettext('Delete channel'),
  232. scope: this,
  233. handler: function(btn){
  234. Ext.Msg.confirm(
  235. gettext('Confirm channel deletion'),
  236. interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
  237. function(btn){
  238. if( btn == 'yes' ){
  239. Mumble.removeChannel( this.serverid, this.chandata.id );
  240. }
  241. }, this);
  242. }
  243. }]
  244. }],
  245. }],
  246. width: 500,
  247. height: 300,
  248. scope: this,
  249. listeners: {
  250. beforeclose: function(){
  251. this.owner.wnd = null;
  252. }
  253. },
  254. });
  255. this.wnd.owner = this;
  256. }
  257. if( !this.wnd.isVisible() ){
  258. this.wnd.show();
  259. mypos = this.tree.getPosition();
  260. mysize = this.tree.getSize();
  261. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  262. }
  263. else{
  264. this.wnd.close();
  265. }
  266. },
  267. } );