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.

338 lines
13 KiB

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