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.

369 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. layout: 'border',
  235. items: [{
  236. xtype: "textfield",
  237. fieldLabel: "x",
  238. hideLabel: true,
  239. name: "name",
  240. region: "north",
  241. value: chandata.name
  242. }, {
  243. xtype: "htmleditor",
  244. fieldLabel: 'x',
  245. hideLabel: true,
  246. name: "description",
  247. region: "center",
  248. value: chandata.description
  249. }],
  250. }];
  251. if( this.is_admin ){
  252. Ext.apply( tabitems[0], {
  253. fbar: [{
  254. text: gettext('Add subchannel...'),
  255. scope: this,
  256. handler: function(btn){
  257. Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
  258. if (btn == 'ok'){
  259. Mumble.addChannel( this.serverid, text, this.chandata.id, function(provider, response){
  260. if( response.type == "exception" ){
  261. Ext.Msg.alert( gettext("Error"), response.message );
  262. }
  263. });
  264. }
  265. }, this);
  266. }
  267. }, {
  268. scope: this,
  269. text: gettext("Submit name/description"),
  270. handler: function(btn){
  271. f = btn.ownerCt.ownerCt.getForm().getValues();
  272. Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description, function(provider, response){
  273. if( response.type == "exception" ){
  274. Ext.Msg.alert( gettext("Error"), response.message );
  275. }
  276. });
  277. }
  278. }, {
  279. text: gettext('Delete channel'),
  280. scope: this,
  281. handler: function(btn){
  282. Ext.Msg.confirm(
  283. gettext('Confirm channel deletion'),
  284. interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
  285. function(btn){
  286. if( btn == 'yes' ){
  287. Mumble.removeChannel( this.serverid, this.chandata.id );
  288. }
  289. }, this);
  290. }
  291. }]
  292. });
  293. tabitems.push({
  294. xtype: "form",
  295. border: false,
  296. title: gettext("Send message"),
  297. defaults: { "anchor": "-20px" },
  298. items: [{
  299. xtype: "checkbox",
  300. fieldLabel: gettext('Cascade to subchannels'),
  301. name: 'tree'
  302. }, {
  303. xtype: "htmleditor",
  304. fieldLabel: 'x',
  305. hideLabel: true,
  306. name: "message"
  307. }],
  308. fbar: [{
  309. scope: this,
  310. text: gettext("Send message"),
  311. handler: function(btn){
  312. f = btn.ownerCt.ownerCt.getForm().getValues();
  313. Mumble.sendMessageChannel(this.serverid, this.chandata.id,
  314. (f.tree || false), f.message,
  315. function(provider, response){
  316. if( response.type == "exception" ){
  317. Ext.Msg.alert( gettext("Error"), response.message );
  318. }
  319. else{
  320. Ext.Msg.alert( gettext("Success"), gettext("Message sent successfully.") );
  321. }
  322. });
  323. }
  324. }]
  325. });
  326. }
  327. this.wnd = new Ext.Window({
  328. title: this.windowTitle || ( this.is_admin
  329. ? interpolate( gettext("Channel %s (%s)"), [chandata.name, chandata.id] )
  330. : interpolate( gettext("Channel %s"), [chandata.name] ) ),
  331. layout: 'fit',
  332. items: [{
  333. xtype: "tabpanel",
  334. activeTab: 0,
  335. items: tabitems
  336. }],
  337. width: 500,
  338. height: 300,
  339. scope: this,
  340. listeners: {
  341. beforeclose: function(){
  342. this.owner.wnd = null;
  343. }
  344. },
  345. });
  346. this.wnd.owner = this;
  347. }
  348. if( !this.wnd.isVisible() ){
  349. this.wnd.show();
  350. mypos = this.tree.getPosition();
  351. mysize = this.tree.getSize();
  352. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  353. }
  354. else{
  355. this.wnd.close();
  356. }
  357. },
  358. } );