Shout: Display digit details on the dialpad
authorBen Klang <ben@alkaloid.net>
Tue, 9 Mar 2010 04:13:15 +0000 (23:13 -0500)
committerBen Klang <ben@alkaloid.net>
Tue, 9 Mar 2010 04:13:53 +0000 (23:13 -0500)
shout/dialplan.php
shout/lib/Shout.php
shout/templates/dialplan/edit.inc
shout/themes/screen.css

index 3350215..de4134d 100644 (file)
@@ -55,6 +55,11 @@ case 'edit':
         break;
     }
     $menu = $menus[$menu];
+    try {
+        $destinations = $shout->extensions->getExtensions($curaccount);
+    } catch (Exception $e) {
+        $notification->push(_("Problem getting destination information."));
+    }
     break;
 case 'list':
 default:
index 626dc3a..9ed2fff 100644 (file)
@@ -155,7 +155,7 @@ class Shout
                 )
             ),
             'ringexten' => array(
-                'description' => _("Ring an extension."),
+                'description' => _("Ring extension"),
                 'args' => array(
                     'exten' => array(
                         'name' => _("Extension"),
@@ -166,18 +166,18 @@ class Shout
                 )
             ),
             'leave_message' => array(
-                'description' => _("Leave a message."),
+                'description' => _("Go to voicemail"),
                 'args' => array(
                     'mailbox' => array(
                         'name' => _("Mailbox"),
                         'type' => 'enum',
                         'required' => true,
                         'params' => array(self::getNames($shout->extensions->getExtensions($account)))
-                        )
+                    )
                 )
             ),
             'conference' => array(
-                'description' => _("Enter conference room"),
+                'description' => _("Enter conference"),
                 'args' => array(
                     'roomno' => array(
                         'name' => _("Room Number"),
@@ -187,11 +187,11 @@ class Shout
                 )
             ),
             'directory' => array(
-                'description' => _("Enter company directory."),
+                'description' => _("Company directory"),
                 'args' => array()
             ),
             'dial' => array(
-                'description' => _("Place an outgoing call."),
+                'description' => _("Call out"),
                 'args' => array(
                     'number' => array(
                         'name' => _("Phone Number"),
@@ -201,7 +201,7 @@ class Shout
                 )
             ),
             'rewind' => array(
-                'description' => _("Restart the current menu."),
+                'description' => _("Restart menu"),
                 'args' => array()
             ),
             // TODO: Actions to implement: Queue
index e6163e2..93f8683 100644 (file)
@@ -32,6 +32,7 @@ var ajax_url = '<?php echo Horde::getServiceLink('ajax', 'shout') ?>';
 var menu = '<?php echo $menu['name']; ?>';
 var menuInfo = $H();
 var menuActions = $H(<?php echo Horde_Serialize::serialize(Shout::getMenuActions(), Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
+var destinations = $H(<?php echo Horde_Serialize::serialize($destinations, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
 var curDigit = null;
 
 function editAction(digit)
@@ -71,7 +72,6 @@ function editAction(digit)
             }
         });
         var params = $H({'action': action});
-        var actionForm;
         new Ajax.Updater('editAction', ajax_url + 'getActionForm',
         {
             method: 'post',
@@ -118,6 +118,7 @@ function refreshMenu()
 
     var meta = menuInfo.get('meta');
 
+    // Draw the menu metainfo box
     row = getMetaRow('<?php echo _("Menu Name"); ?>', meta.name);
     $('menuInfo').appendChild(row);
     row = getMetaRow('<?php echo _("Description"); ?>', meta.description);
@@ -130,7 +131,6 @@ function refreshMenu()
     text = document.createTextNode('<?php echo _("Sound file"); ?>');
     col.appendChild(text);
     row.appendChild(col);
-
     col = document.createElement('td');
     col.className='menuStatValue';
     text = document.createTextNode(meta.soundfile);
@@ -148,6 +148,65 @@ function refreshMenu()
     col.appendChild(img);
     row.appendChild(col);
     $('menuInfo').appendChild(row);
+    
+    // Fill in the actions
+    $H(menuInfo.get('actions')).each(function (pair) {
+        var text;
+        var digit = pair.key;
+        var action = pair.value.action;
+        var button = $('digit_'+digit);
+        empty(button);
+        var p = document.createElement('p');
+        p.className = 'buttonActionLabel';
+        var span = document.createElement('span');
+        span.className='digitLabel';
+        if (digit == 'star') {
+            text = document.createTextNode('*');
+        } else if (digit == 'octothorpe') {
+            text = document.createTextNode('#');
+        } else {
+            text = document.createTextNode(digit);
+        }
+        span.appendChild(text);
+        p.appendChild(span);
+        text = document.createTextNode(menuActions.get(action).description);
+        p.appendChild(text);
+        button.appendChild(p);
+
+        p = document.createElement('p');
+        p.className = 'buttonDetail';
+
+        switch(action) {
+        case 'jump':
+            var menu = pair.value.args.first()['menuName'];
+            text = document.createTextNode(destinations.get(exten).name);
+            break;
+        case 'ringexten':
+        case 'leave_message':
+            // FIXME: Why do I need first() here?
+            var exten = pair.value.args.first()['exten'];
+            text = document.createTextNode(destinations.get(exten).name);
+            break;
+        case 'conference':
+            var roomno = pair.value.args.first()['roomno'];
+            if (roomno != null) {
+                text = document.createTextNode(roomno);
+            } else {
+                text = document.createTextNode('');
+            }
+            break;
+        case 'dial':
+            var number = pair.value.args.first()['number'];
+            text = document.createTextNode(number);
+            break;
+        default:
+            text = document.createTextNode('');
+            break;
+        }
+
+        p.appendChild(text);
+        button.appendChild(p);
+    });
 }
 
 function getMetaRow(name, value)
index 9355d74..68e770c 100644 (file)
@@ -126,6 +126,7 @@ ul {
     font-weight: bold;
     font-size: 1.5em;
     color: #666;
+    float: left;
 }
 
 #editActionOverlay {
@@ -150,4 +151,10 @@ ul {
 
 #editAction {
     margin: 5px;
+}
+
+.buttonActionLabel
+{
+    text-align: right;
+    font-style: italic;
 }
\ No newline at end of file