rbrindley: branch rbrindley/welcome_revamp r4273 - in /team/rbrindley/welcome...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Wed Dec 3 15:57:51 CST 2008


Author: rbrindley
Date: Wed Dec  3 15:57:51 2008
New Revision: 4273

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4273
Log:

- implemented loadQueues function
- removed queues from extensions list
- added template class for agents to override display
- removed div.clear in div.agents as it was redundant and messing with jQuery appends


Modified:
    team/rbrindley/welcome_revamp/config/js/welcome2.js
    team/rbrindley/welcome_revamp/config/welcome2.html

Modified: team/rbrindley/welcome_revamp/config/js/welcome2.js
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/js/welcome2.js?view=diff&rev=4273&r1=4272&r2=4273
==============================================================================
--- team/rbrindley/welcome_revamp/config/js/welcome2.js (original)
+++ team/rbrindley/welcome_revamp/config/js/welcome2.js Wed Dec  3 15:57:51 2008
@@ -155,30 +155,6 @@
 		//);
 	});
 
-	(function(){ // List all Queue Extensions
-		var QUEUES_CONF = config2json({filename:'queues.conf', usf:1});
-		var m = parent.sessionData.pbxinfo.queues ;
-		for( l in m ){
-			if( m.hasOwnProperty(l) ){
-				if( m[l]['configLine'].contains(',1,agentlogin()') ){
-					var exten = "<b>Agent Login</b>";
-				}else if( m[l]['configLine'].contains(',1,agentcallbacklogin()') ){
-					var exten = "<b>Agent CallBack Login</b>";
-				}else{
-					var exten = "Call Queue";
-				}
-
-				pushRow(exten_tbody, [
-					$("<td></td>").html(''),
-					$("<td></td>").html(l),
-					$("<td></td>").html( QUEUES_CONF[l] && QUEUES_CONF[l]['fullname'] || '--' ),
-					$("<td></td>").html(''),
-					$("<td></td>").html( exten )
-				]);
-			}
-		}
-	})();
-
 	(function(){ // List all RingGroup Extensions
 		var c = parent.sessionData.pbxinfo.ringgroups ;
 		for(var d in c){if(c.hasOwnProperty(d)){
@@ -273,7 +249,171 @@
 };
 
 var loadQueues = function() {
-
+	var queue_template = $('#queue_left_container > div.template');
+	var queue_conts = {}; //queue containers array
+	queue_conts[0] = $('#queue_left_container');
+	queue_conts[1] = $('#queue_right_container');
+	var cont_index = 0;
+
+	var queue_status = ASTGUI.cliCommand('show queues');
+	queue_status = parent.ASTGUI.parseCLIResponse(queue_status);
+	//ast-gui*CLI> show queues
+	//6501         has 1 calls (max unlimited) in 'ringall' strategy (0s holdtime), W:0, C:0, A:4, SL:0.0% within 0s
+	//   Members: 
+	//      Agent/6000 (Busy) has taken no calls yet
+	//   Callers: 
+	//      1. IAX2/6000-453 (wait: 0:03, prio: 0)
+	//
+	//6500         has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime), W:0, C:0, A:2, SL:0.0% within 0s
+	//   No Members
+	//   No Callers
+
+	queue_status = queue_status.split('\n\n');
+	queue_status.each( function(q) { 
+		q = q.trim();
+		if (q.length == 0) {
+			return;
+		}
+
+		var queue = queue_template.clone();
+		var agent_cnt = 0;
+		var call_cnt = 0;
+		lines = q.split('\n');
+		var line_index = 0;
+
+		//the following will always be the first line.
+		//6501         has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
+		var line = lines[line_index].split(' ');
+		line_index++;
+		var q_name = line[0]; //6501
+
+		for (var i=0; i<line.length; i++) {
+			if (line[i].contains('strategy')) {
+				var strategy = line[i-1].replace(/'/g,'');
+			} else if (line[i].contains('W:')) {
+			} else if (line[i].contains('C:')) {
+				var calls_completed = line[i].match('\\d\\d*').toString();
+			} else if (line[i].contains('A:')) {
+				var calls_abandoned = line[i].match('\\d\\d*').toString();
+			} else if (line[i].contains('SL:')) {
+				var service_level = line[i].concat(' ',line[i+1],' ',line[i+2]);
+			}
+		}
+
+		//line #2 (index=1) will either be 'Members:' or 'No Members'
+		if (lines[line_index].contains('Members:')) {
+			line_index++;
+			var agents = queue.contents().find('.agents');
+			var agent_template = $('#agent_template');
+
+			//traverse through all the members til the Callers line appears
+			//Callers line will either be 'Callers:' or 'No Callers'
+			while (!lines[line_index].contains('Callers')) {
+				var agent = agent_template.clone();
+				agent_cnt++;
+
+				//      Agent/6000 (Busy) has taken no calls yet
+				line = lines[line_index].trim();
+				var a_exten = line.split(' ')[0].split('/')[1];
+				var a_status = line.match('[\\s\\w][\\s\\w]*(?=\\))').toString();
+
+				switch(a_status.toLowerCase()) {
+					case 'busy':
+						var a_status_img = 'images/agent_loggedout.png';
+						break;
+					case 'available':
+						var a_status_img = 'images/agent_loggedin.png';
+						break;
+					case 'not in use':
+						var a_status_img = 'images/agent_loggedin.png';
+						break;
+					default:
+						var a_status_img = 'images/agent_loggedout.png';
+						break;
+				}
+
+				agent.children('span.extension').html(a_exten);
+				agent.children('img.status_icon').attr('src',a_status_img);
+
+				agent.removeClass('template');
+				agent.removeAttr('id');
+				agents.append(agent);
+
+				line_index++;
+			}
+		} else if (lines[line_index].contains('No Members')) {
+			queue.contents().find('.agents').html('No Agents');	
+			line_index++;
+		}
+
+		//next line will either be 'Callers:' or 'No Callers'
+		if (lines[line_index].contains('Callers:')) {
+			line_index++;
+			var calls = queue.contents().find('.calls > table > tbody');
+			var call_template = $('<tr></tr>').addClass('call');
+
+			//The remaining lines of the queue should be calls
+			while ( lines[line_index] ) {
+				call_cnt++;
+				var call = call_template.clone();
+
+				//      1. IAX2/6000-453 (wait: 0:03, prio: 0)
+				line = lines[line_index].trim();
+				var sections = line.split(' ');
+
+				//'1.'
+				var order = sections[0];
+				
+				//find '6000' in 'IAX2/6000-453'
+				var cid = sections[1].match('\\d\\d*(?=-\\d*)').toString();
+
+				for (var i=2; i<sections.length; i++) {
+					if (sections[i].contains('wait')) {
+						//'0:03'
+						var waittime = sections[i+1].replace(/,/,'');
+
+						var wt_tmp = waittime.split(':');
+						var secs = (parseInt(wt_tmp[0]) * 60) + parseInt(wt_tmp[1]);
+						if (secs > 30) {
+							var call_class = 'old';
+						} else if (secs > 120) {
+							var call_class = 'average';
+						} else {
+							var call_class = 'new';
+						}
+						i++; //no need to check for the next section as we know its '0:03'
+						continue;
+					} else if (sections[i].contains('prio')) {
+						//'0'
+						var priority = sections[i+1].replace(/\)/,'');
+						i++; //no need to check for the next section as we know its '0'
+						continue;
+					}
+				}
+
+				$('<td></td>').html(order).appendTo(call);
+				$('<td></td>').html(cid).appendTo(call);
+				$('<td></td>').html(waittime).appendTo(call);
+
+				call.addClass(call_class);
+				calls.append(call);
+				line_index++;
+			}
+		} else if (lines[line_index].contains('No Callers')) {
+			queue.contents().find('.calls > table.list > tbody').html('<tr><td>No Calls</td></tr>');
+			line_index++;
+		}
+
+		queue.contents().find('.name').html(q_name);
+		queue.contents().find('.strategy').html(strategy);
+		queue.contents().find('.users_agents').html(call_cnt + " calls, " + agent_cnt + " agents");
+		queue.contents().find('.service_level').html(service_level);
+		queue.contents().find('.calls_complete').html(calls_completed);
+		queue.contents().find('.calls_abandoned').html(calls_abandoned);
+		queue.removeClass('template');
+		queue_conts[cont_index].append(queue);
+		cont_index = cont_index == 1 ? 0 : 1;
+	});
 };
 
 var loadAgents = function() {

Modified: team/rbrindley/welcome_revamp/config/welcome2.html
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/welcome2.html?view=diff&rev=4273&r1=4272&r2=4273
==============================================================================
--- team/rbrindley/welcome_revamp/config/welcome2.html (original)
+++ team/rbrindley/welcome_revamp/config/welcome2.html Wed Dec  3 15:57:51 2008
@@ -217,6 +217,9 @@
 	text-align: center;
 }
 
+div.queue div.body div.agents div.template {
+	display: none;
+}
 div.queue div.body div.stats {
 	-moz-border-radius-bottomleft: 4px;
 	-moz-border-radius-bottomright: 4px;
@@ -495,11 +498,10 @@
 										</table>
 									</div>
 									<div class="agents">
-										<div class="agent">
+										<div id="agent_template" class="template agent">
 											<img class="status_icon" src="" border="0" /> 
 											<span class="extension"></span>
 										</div>
-										<div class="clear"></div>
 									</div>
 									<div class="clear"></div>
 									<div class="stats">




More information about the asterisk-gui-commits mailing list