/********************************************* * Copyright (c) 2014 AnsibleWorks, Inc. * * ObjectCount.js * * Dashboard widget showing object counts and license availability. * */ 'use strict'; angular.module('ObjectCountWidget', ['RestServices', 'Utilities']) .factory('ObjectCount', ['$rootScope', '$compile', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function ($rootScope, $compile) { return function (params) { var scope = params.scope, target = params.target, dashboard = params.dashboard, keys = ['organizations', 'users', 'teams', 'credentials', 'projects', 'inventories', 'groups', 'hosts', 'job_templates', 'jobs' ], i, html, element; html = "
\n"; html += "
System Summary
\n"; html += "
\n"; html += "\n"; html += "\n"; html += "\n"; html += "\n"; html += "\n"; html += "\n"; html += "\n"; html += "\n"; function makeRow(params) { var html = '', label = params.label, link = params.link, count = params.count; html += "\n"; html += "\n"; html += "\n"; return html; } for (i = 0; i < keys.length; i++) { html += makeRow({ label: keys[i], link: '/#/' + ((keys[i] === 'hosts' || keys[i] === 'groups') ? 'home/' + keys[i] : keys[i]), count: (dashboard[keys[i]] && dashboard[keys[i]].total) ? dashboard[keys[i]].total : 0 }); } html += "\n"; html += "
Total
"; html += "" + count + ""; html += "
\n"; html += "
\n"; html += "
\n"; element = angular.element(document.getElementById(target)); element.html(html); $compile(element)(scope); scope.$emit('WidgetLoaded'); }; } ]);