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.

316 lines
14 KiB

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