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.

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