|
Lines 38-54
var App = Ember.Application.create({
Link Here
|
| 38 |
$.get("/txtapi/status", function(data){ |
38 |
$.get("/txtapi/status", function(data){ |
| 39 |
$('#serverStatus').html("<pre>" + data + "</pre>"); |
39 |
$('#serverStatus').html("<pre>" + data + "</pre>"); |
| 40 |
}); |
40 |
}); |
| 41 |
} |
41 |
$('#container').on('submit', '#portal-create-user', function(event) { |
| 42 |
}); |
42 |
event.preventDefault(); |
| 43 |
|
43 |
var form = this; |
| 44 |
App.ApplicationRoute = Ember.Route.extend({ |
44 |
var id = $(form).find('input').val(); |
| 45 |
setupController: function(controller) { |
45 |
var button = $(form).find('button'); |
| 46 |
// alert("setupController"); |
46 |
var result = $('#portal-user-result'); |
| 47 |
}, |
47 |
if (button.prop('disabled')) return; |
| 48 |
actions: { |
48 |
button.prop('disabled', true); |
| 49 |
newUser: function() { |
49 |
result.text('Creating user…'); |
| 50 |
return Bootstrap.ModalManager.show('newUserForm'); |
50 |
$.ajax({ |
| 51 |
} |
51 |
type: 'POST', |
|
|
52 |
url: '/txtapi/lua?portal/create_user.lua%20' + encodeURIComponent(id), |
| 53 |
headers: {'X-FreeSWITCH-Portal-Write': '1'}, |
| 54 |
dataType: 'text' |
| 55 |
}).done(function(data) { |
| 56 |
var created = /^\+OK ([a-f0-9]{32})$/.exec($.trim(data)); |
| 57 |
if (created) { |
| 58 |
result.text('User ' + id + ' created. SIP password: ' + created[1]); |
| 59 |
form.reset(); |
| 60 |
App.usersController.load(); |
| 61 |
} else { |
| 62 |
result.text($.trim(data) || 'FreeSWITCH returned no result.'); |
| 63 |
} |
| 64 |
}).fail(function() { |
| 65 |
result.text('Could not reach FreeSWITCH. Check the Users list before trying again.'); |
| 66 |
}).always(function() { |
| 67 |
button.prop('disabled', false); |
| 68 |
}); |
| 69 |
}); |
| 52 |
} |
70 |
} |
| 53 |
}); |
71 |
}); |
| 54 |
|
72 |
|
|
Lines 207-223
App.UsersRoute = Ember.Route.extend({
Link Here
|
| 207 |
} |
225 |
} |
| 208 |
}); |
226 |
}); |
| 209 |
|
227 |
|
| 210 |
App.newUserRoute = Ember.Route.extend({ |
|
|
| 211 |
setupController: function(Controller) { |
| 212 |
alert("auto_update_calls"); |
| 213 |
}, |
| 214 |
actions: { |
| 215 |
show: function(controller) { |
| 216 |
App.newUserController.show(); |
| 217 |
} |
| 218 |
} |
| 219 |
}); |
| 220 |
|
| 221 |
App.SofiaStatusRoute = Ember.Route.extend({ |
228 |
App.SofiaStatusRoute = Ember.Route.extend({ |
| 222 |
setupController: function(controller) { |
229 |
setupController: function(controller) { |
| 223 |
App.sofiaStatusController.load(); |
230 |
App.sofiaStatusController.load(); |
|
Lines 246-252
App.Router.map(function(){
Link Here
|
| 246 |
this.route("showLimits"); |
253 |
this.route("showLimits"); |
| 247 |
this.route("show"); |
254 |
this.route("show"); |
| 248 |
this.route("users"); |
255 |
this.route("users"); |
| 249 |
this.route("newUser"); |
|
|
| 250 |
this.route("sofiaStatus"); |
256 |
this.route("sofiaStatus"); |
| 251 |
this.route("about", { path: "/about" }); |
257 |
this.route("about", { path: "/about" }); |
| 252 |
}); |
258 |
}); |
|
Lines 273-286
App.Channel = Em.Object.extend({
Link Here
|
| 273 |
|
279 |
|
| 274 |
}); |
280 |
}); |
| 275 |
|
281 |
|
| 276 |
App.ApplicationController = Ember.ObjectController.extend({ |
|
|
| 277 |
actions: { |
| 278 |
newUser: function() { |
| 279 |
alert("ApplicationController"); |
| 280 |
} |
| 281 |
} |
| 282 |
}); |
| 283 |
|
| 284 |
App.callsController = Ember.ArrayController.create({ |
282 |
App.callsController = Ember.ArrayController.create({ |
| 285 |
content: [], |
283 |
content: [], |
| 286 |
init: function(){ |
284 |
init: function(){ |
|
Lines 753-790
App.usersController = Ember.ArrayController.create({
Link Here
|
| 753 |
}); |
751 |
}); |
| 754 |
|
752 |
|
| 755 |
|
753 |
|
| 756 |
App.UsersController = Ember.ObjectController.extend({ |
|
|
| 757 |
newUserButtons: [ |
| 758 |
Ember.Object.create({title: 'Create', clicked:"submit", type:"primary"}), |
| 759 |
Ember.Object.create({title: 'Cancel', clicked: "cancel", dismiss: 'modal'}) |
| 760 |
], |
| 761 |
|
| 762 |
actions: { |
| 763 |
//Submit the modal |
| 764 |
submit: function() { |
| 765 |
$.post("/txtapi/lua?portal/create_user.lua%20" + $("#user_id").val(), { |
| 766 |
data: "user_id=xxxx", |
| 767 |
success: function() { }, |
| 768 |
error: function(e) { } |
| 769 |
}); |
| 770 |
|
| 771 |
// Bootstrap.NM.push('Successfully submitted modal', 'success'); |
| 772 |
return Bootstrap.ModalManager.hide('newUserForm'); |
| 773 |
}, |
| 774 |
|
| 775 |
//Cancel the modal, we don't need to hide the model manually because we set {..., dismiss: 'modal'} on the button meta data |
| 776 |
cancel: function() { |
| 777 |
Bootstrap.ModalManager.hide('newUserForm'); |
| 778 |
return Bootstrap.NM.push('Modal was cancelled', 'info'); |
| 779 |
}, |
| 780 |
|
| 781 |
//Show the modal |
| 782 |
newUser: function() { |
| 783 |
return Bootstrap.ModalManager.show('newUserForm'); |
| 784 |
} |
| 785 |
} |
| 786 |
}); |
| 787 |
|
| 788 |
App.sofiaStatusController = Ember.ArrayController.create({ |
754 |
App.sofiaStatusController = Ember.ArrayController.create({ |
| 789 |
content: [], |
755 |
content: [], |
| 790 |
init: function(){ |
756 |
init: function(){ |