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.

346 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);
  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, function(provider, response){
  248. if( response.type == "exception" ){
  249. Ext.Msg.alert( gettext("Error"), response.message );
  250. }
  251. });
  252. }
  253. }, this);
  254. }
  255. }, {
  256. scope: this,
  257. text: gettext("Submit name/description"),
  258. handler: function(btn){
  259. f = btn.ownerCt.ownerCt.getForm().getValues();
  260. Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description, function(provider, response){
  261. if( response.type == "exception" ){
  262. Ext.Msg.alert( gettext("Error"), response.message );
  263. }
  264. });
  265. }
  266. }, {
  267. text: gettext('Delete channel'),
  268. scope: this,
  269. handler: function(btn){
  270. Ext.Msg.confirm(
  271. gettext('Confirm channel deletion'),
  272. interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
  273. function(btn){
  274. if( btn == 'yes' ){
  275. Mumble.removeChannel( this.serverid, this.chandata.id );
  276. }
  277. }, this);
  278. }
  279. }]
  280. });
  281. tabitems.push({
  282. xtype: "form",
  283. border: false,
  284. title: gettext("Send message"),
  285. defaults: { "anchor": "-20px" },
  286. items: [{
  287. xtype: "checkbox",
  288. fieldLabel: gettext('Cascade to subchannels'),
  289. name: 'tree'
  290. }, {
  291. xtype: "htmleditor",
  292. fieldLabel: 'x',
  293. hideLabel: true,
  294. name: "message"
  295. }],
  296. fbar: [{
  297. scope: this,
  298. text: gettext("Send message"),
  299. handler: function(btn){
  300. f = btn.ownerCt.ownerCt.getForm().getValues();
  301. Mumble.sendMessageChannel(this.serverid, this.chandata.id, (f.tree || false), f.message);
  302. }
  303. }]
  304. });
  305. }
  306. this.wnd = new Ext.Window({
  307. title: this.windowTitle || gettext("Channel details"),
  308. layout: 'fit',
  309. items: [{
  310. xtype: "tabpanel",
  311. activeTab: 0,
  312. items: tabitems
  313. }],
  314. width: 500,
  315. height: 300,
  316. scope: this,
  317. listeners: {
  318. beforeclose: function(){
  319. this.owner.wnd = null;
  320. }
  321. },
  322. });
  323. this.wnd.owner = this;
  324. }
  325. if( !this.wnd.isVisible() ){
  326. this.wnd.show();
  327. mypos = this.tree.getPosition();
  328. mysize = this.tree.getSize();
  329. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  330. }
  331. else{
  332. this.wnd.close();
  333. }
  334. },
  335. } );