Fixed ringing schedule

This commit is contained in:
Martin Schröder 2015-05-27 17:29:40 +02:00 committed by Martin Schröder
parent 7f3929d5e3
commit e023512d0a
5 changed files with 30 additions and 10 deletions

View file

@ -42,7 +42,7 @@
async.series([
function(next){
scope.UBUS.$init().done(function(){
if(!scope.UBUS.router && !scope.UBUS.router.info){
if(!scope.UBUS.router || !scope.UBUS.router.info){
alert("Questd must have crashed or is not running. Restart it on the router!");
}
}).fail(function(){

View file

@ -6,10 +6,10 @@
<p>This page is not done yet. Waiting for voice API. </p>
<luci-config-lines>
<luci-config-line title="{{'Ringing Schedule'|translate}}">
<switch id="enabled" name="enabled" ng-model="settings.scheduling.value" class="green"></switch>
<switch id="enabled" name="enabled" ng-model="settings.enabled.value" class="green"></switch>
</luci-config-line>
</luci-config-lines>
<table class="table" ng-show="settings.scheduling.value">
<table class="table">
<thead>
<th translate>Day</th>
<th translate>Time</th>
@ -22,7 +22,7 @@
<tr ng-repeat="item in schedules">
<td>{{ item.days.value.join(",") }}</td>
<td>{{ item.time.value }}</td>
<td>{{ item.number.value }}</td>
<td>{{ allSipAccountsMap[item.sip_service_provider.value].name.value }}</td>
<!--<td>{{ item.enabled.value }}</td>-->
<td style="width: 1%"><button class="btn btn-default" ng-click="onEditSchedule(item)"><i class="fa fa-pencil" style="{{editColor}}"></i></button></td>
<td style="width: 1%"><button class="btn btn-default" ng-click="onDeleteSchedule(item)"><i class="fa fa-trash-o"></i></button></td>
@ -39,7 +39,7 @@
on-dismiss="onDismissSchedule()" dismiss-label="Cancel" accept-label="Save">
<luci-config-lines>
<luci-config-line title="Phone Number">
<luci-select ng-model="schedule.number.value" ng-items="allSipAccounts" placeholder="Pick Phone Number"/>
<luci-select ng-model="schedule.sip_service_provider.value" ng-items="allSipAccounts" placeholder="Pick Phone Number"/>
</luci-config-line>
</luci-config-line>
<uci-wireless-schedule-edit ng-model="schedule" schedule="schedule" valid="scheduleValid"></uci-wireless-schedule-edit>

View file

@ -22,10 +22,21 @@
$juci.module("phone")
.controller("PhoneRingingScheduleCtrl", function($scope, $uci){
$scope.allSipAccountsMap = {};
$uci.sync(["voice_client"]).done(function(){
// TODO add config for phone
if($uci.voice_client && $uci.voice_client.settings) $scope.settings = $uci.voice_client.settings;
$scope.schedules = $uci.voice_client["@schedule"];
$scope.settings = $uci.voice_client.RINGING_STATUS;
$scope.schedules = $uci.voice_client["@ringing_schedule"];
$scope.allSipAccountsMap = {};
$scope.allSipAccounts = $uci.voice_client["@sip_service_provider"].map(function(x){
var i = {
label: x.name.value,
value: x[".name"]
};
$scope.allSipAccountsMap[x[".name"]] = x;
return i;
});
});
$scope.onAcceptSchedule = function(){
@ -53,7 +64,7 @@ $juci.module("phone")
}
$scope.onAddSchedule = function(){
$uci.voice_client.create({".type": "schedule"}).done(function(item){
$uci.voice_client.create({".type": "ringing_schedule"}).done(function(item){
$scope.schedule = item;
$scope.schedule[".new"] = true;
$scope.showScheduleDialog = 1;

View file

@ -154,8 +154,14 @@ UCI.voice_client.$registerSectionType("speed_dial", {
"tone": { dvalue: 1, type: Number },
"number": { dvalue: "", type: String }
});
UCI.voice_client.$registerSectionType("schedule", {
UCI.voice_client.$registerSectionType("ringing_status", {
"enabled": { dvalue: false, type: Boolean },
"status": { dvalue: 0, type: Number }
});
UCI.voice_client.$registerSectionType("ringing_schedule", {
"days": { dvalue: [], type: Array, allow: ["mon", "tue", "wed", "thu", "fri", "sat", "sun"], validator: UCI.validators.WeekDayListValidator},
"time": { dvalue: "", type: String, validator: UCI.validators.TimespanValidator},
"number": { dvalue: "", type: String }
"sip_service_provider": { dvalue: "", type: String }
});

View file

@ -12,4 +12,7 @@ describe("Phone", function(){
it("should be completed", function(){
expect(Object.keys(completed).filter(function(x){ return completed[x] == 0; })).to.be.empty();
});
it("should have a ringing_status section in the config", function(){
expect($uci.voice_client.ringing_status).to.be.ok();
});
});