show sofia status on portal

This commit is contained in:
Seven Du 2014-03-11 23:55:58 +08:00
parent f80404c777
commit f5a2346e4f
2 changed files with 158 additions and 0 deletions

View File

@ -218,6 +218,12 @@ App.newUserRoute = Ember.Route.extend({
}
});
App.SofiaStatusRoute = Ember.Route.extend({
setupController: function(controller) {
App.sofiaStatusController.load();
}
});
App.Router.map(function(){
this.route("calls");
this.route("channels");
@ -241,6 +247,8 @@ App.Router.map(function(){
this.route("show");
this.route("users");
this.route("newUser");
this.route("sofiaStatus");
this.route("addGateway");
this.route("about", { path: "/about" });
});
@ -778,6 +786,95 @@ App.UsersController = Ember.ObjectController.extend({
}
});
App.sofiaStatusController = Ember.ArrayController.create({
content: [],
init: function(){
},
load: function() {
var me = this;
$.get("/xmlapi/sofia?xmlstatus", function(data){
console.log(data);
var row_count = 0;
var aliases = data.getElementsByTagName("alias");
var profiles = data.getElementsByTagName("profile");
var gateways = data.getElementsByTagName("gateway");
me.content.clear();
for (var i=0; i<aliases.length; i++) {
var row = {};
row.name = aliases[i].getElementsByTagName("name")[0].textContent;
row.type = aliases[i].getElementsByTagName("type")[0].textContent;
row.data = aliases[i].getElementsByTagName("data")[0].textContent;
row.state = aliases[i].getElementsByTagName("state")[0].textContent;
console.log(row)
row_count++;
me.pushObject(row);
}
for (var i=0; i<profiles.length; i++) {
var row = {};
row.name = profiles[i].getElementsByTagName("name")[0].textContent;
row.type = profiles[i].getElementsByTagName("type")[0].textContent;
row.data = profiles[i].getElementsByTagName("data")[0].textContent;
row.state = profiles[i].getElementsByTagName("state")[0].textContent;
row.actions = "Start | Stop | Restart | More ...";
console.log(row)
row_count++;
me.pushObject(row);
}
for (var i=0; i<gateways.length; i++) {
var row = {};
row.name = gateways[i].getElementsByTagName("name")[0].textContent;
row.type = gateways[i].getElementsByTagName("type")[0].textContent;
row.data = gateways[i].getElementsByTagName("data")[0].textContent;
row.state = gateways[i].getElementsByTagName("state")[0].textContent;
row.actions = "Reg | UnReg | Delete";
console.log(row)
row_count++;
me.pushObject(row);
}
me.set('total', row_count);
});
}
});
App.SofiaStatusController = Ember.ObjectController.extend({
newGatewayButtons: [
{title: 'Submit', clicked: "submit"},
{title: 'Cancel', clicked: "cancel", dismiss: 'modal'}
],
actions: {
//Submit the modal
submit: function() {
alert("Not implemented");
return false;
$.post("/txtapi/lua?create_gw.lua%20" + $("#gateway_name").val(), {
success: function() { },
error: function(e) { }
});
// Bootstrap.NM.push('Successfully submitted modal', 'success');
return Bootstrap.ModalManager.hide('newUserForm');
},
//Cancel the modal, we don't need to hide the model manually because we set {..., dismiss: 'modal'} on the button meta data
cancel: function() {
Bootstrap.ModalManager.hide('newUserForm');
return Bootstrap.NM.push('Modal was cancelled', 'info');
},
//Show the modal
addGateway: function() {
return Bootstrap.ModalManager.show('newUserForm');
}
}
});
// App.initialize();
var global_debug_event = false;
var global_background_job = false;

View File

@ -92,6 +92,7 @@
<li><a id="menu-calls" href="#calls">Calls</a></li>
<li><a id="menu-channels" href="#channels">Channels</a></li>
<li><a href="#show">Show</a></li>
<li><a href="#sofiaStatus">Sofia</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
@ -640,6 +641,66 @@
</div>
</script>
<script type="text/x-handlebars" data-template-name="sofiaStatus">
<div class="pull-right">
{{#bs-button type="primary" clicked="addGateway"}}Add Gateway{{/bs-button}}
</div>
{{#bs-modal name="newUserForm" fade="true" footerButtonsBinding="addGatewayButtons" title="Add Gateway"}}
<div class="control-group">
<label class="control-label" for="gateway_name">Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="gateway_name" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="gateway_realm">Realm</label>
<div class="controls">
<input type="text" class="input-xlarge" name="gateway_realm" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="gateway_name">Username</label>
<div class="controls">
<input type="text" class="input-xlarge" name="gateway_username" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="gateway_name">Password</label>
<div class="controls">
<input type="text" class="input-xlarge" name="gateway_password" value="">
</div>
</div>
<div class="modal-footer">
{{#bs-button type="primary" clicked="submit"}}Add{{/bs-button}}
{{#bs-button clicked="cancel"}}Cancel{{/bs-button}}
</div>
{{/bs-modal}}
<h1>Sofia Status</h1>
<div>
<table class="table">
<tr>
<th>Type</th>
<th>Name</th>
<th>Data</th>
<th>State</th>
<th>Action</th>
</tr>
{{#each App.sofiaStatusController.content}}
<tr>
<td>{{ type }}</td>
<td>{{ name }}</td>
<td>{{ data }}</td>
<td>{{ state }}</td>
<td>{{ actions }}</td>
</tr>
{{/each}}
</table>
</div>
</script>
<script type="text/x-handlebars" data-template-name="calls">
<div class="pull-right">
<label><input type="checkbox" id="auto_update_calls" value="1" onclick="auto_update_calls();">Auto Update</label>