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.

360 lines
14 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, function(provider, response){
  172. if( response.type == "exception" ){
  173. Ext.Msg.alert( gettext("Error"), response.message );
  174. }
  175. else{
  176. Ext.Msg.alert( gettext("Success"), gettext("Message sent successfully.") );
  177. }
  178. });
  179. }
  180. }]
  181. });
  182. }
  183. this.wnd = new Ext.Window({
  184. title: this.windowTitle || gettext("User details"),
  185. layout: 'fit',
  186. items: {
  187. xtype: "tabpanel",
  188. activeTab: 0,
  189. border: false,
  190. items: tabitems,
  191. },
  192. width: 500,
  193. height: 300,
  194. scope: this,
  195. listeners: {
  196. beforeclose: function(){
  197. this.owner.wnd = null;
  198. }
  199. },
  200. });
  201. this.wnd.owner = this;
  202. }
  203. if( !this.wnd.isVisible() ){
  204. this.wnd.show();
  205. mypos = this.tree.getPosition();
  206. mysize = this.tree.getSize();
  207. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  208. }
  209. else{
  210. this.wnd.close();
  211. }
  212. },
  213. } );
  214. Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
  215. clickHandler: function( node, ev ){
  216. if( typeof node.attributes.chandata != "undefined" ){
  217. this.activate(node.attributes.chandata);
  218. }
  219. },
  220. init: function( tree ){
  221. this.tree = tree;
  222. tree.on("click", this.clickHandler, this);
  223. },
  224. activate: function( chandata ){
  225. if( !this.wnd ){
  226. this.chandata = chandata;
  227. tabitems = [{
  228. xtype: "form",
  229. border: false,
  230. title: gettext("Channel description"),
  231. defaults: { "anchor": "-20px" },
  232. items: [{
  233. xtype: "textfield",
  234. fieldLabel: "x",
  235. hideLabel: true,
  236. name: "name",
  237. value: chandata.name
  238. }, {
  239. xtype: "htmleditor",
  240. fieldLabel: 'x',
  241. hideLabel: true,
  242. name: "description",
  243. value: chandata.description
  244. }],
  245. }];
  246. if( this.is_admin ){
  247. Ext.apply( tabitems[0], {
  248. fbar: [{
  249. text: gettext('Add subchannel...'),
  250. scope: this,
  251. handler: function(btn){
  252. Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
  253. if (btn == 'ok'){
  254. Mumble.addChannel( this.serverid, text, this.chandata.id, function(provider, response){
  255. if( response.type == "exception" ){
  256. Ext.Msg.alert( gettext("Error"), response.message );
  257. }
  258. });
  259. }
  260. }, this);
  261. }
  262. }, {
  263. scope: this,
  264. text: gettext("Submit name/description"),
  265. handler: function(btn){
  266. f = btn.ownerCt.ownerCt.getForm().getValues();
  267. Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description, function(provider, response){
  268. if( response.type == "exception" ){
  269. Ext.Msg.alert( gettext("Error"), response.message );
  270. }
  271. });
  272. }
  273. }, {
  274. text: gettext('Delete channel'),
  275. scope: this,
  276. handler: function(btn){
  277. Ext.Msg.confirm(
  278. gettext('Confirm channel deletion'),
  279. interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
  280. function(btn){
  281. if( btn == 'yes' ){
  282. Mumble.removeChannel( this.serverid, this.chandata.id );
  283. }
  284. }, this);
  285. }
  286. }]
  287. });
  288. tabitems.push({
  289. xtype: "form",
  290. border: false,
  291. title: gettext("Send message"),
  292. defaults: { "anchor": "-20px" },
  293. items: [{
  294. xtype: "checkbox",
  295. fieldLabel: gettext('Cascade to subchannels'),
  296. name: 'tree'
  297. }, {
  298. xtype: "htmleditor",
  299. fieldLabel: 'x',
  300. hideLabel: true,
  301. name: "message"
  302. }],
  303. fbar: [{
  304. scope: this,
  305. text: gettext("Send message"),
  306. handler: function(btn){
  307. f = btn.ownerCt.ownerCt.getForm().getValues();
  308. Mumble.sendMessageChannel(this.serverid, this.chandata.id, (f.tree || false), f.message, function(provider, response){
  309. if( response.type == "exception" ){
  310. Ext.Msg.alert( gettext("Error"), response.message );
  311. }
  312. else{
  313. Ext.Msg.alert( gettext("Success"), gettext("Message sent successfully.") );
  314. }
  315. });
  316. }
  317. }]
  318. });
  319. }
  320. this.wnd = new Ext.Window({
  321. title: this.windowTitle || gettext("Channel details"),
  322. layout: 'fit',
  323. items: [{
  324. xtype: "tabpanel",
  325. activeTab: 0,
  326. items: tabitems
  327. }],
  328. width: 500,
  329. height: 300,
  330. scope: this,
  331. listeners: {
  332. beforeclose: function(){
  333. this.owner.wnd = null;
  334. }
  335. },
  336. });
  337. this.wnd.owner = this;
  338. }
  339. if( !this.wnd.isVisible() ){
  340. this.wnd.show();
  341. mypos = this.tree.getPosition();
  342. mysize = this.tree.getSize();
  343. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  344. }
  345. else{
  346. this.wnd.close();
  347. }
  348. },
  349. } );