WIP Domain listing app with automatic status checking. Buitl with AngularJS.

domainsList.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. /**
  3. * @ngdoc function
  4. * @name domainManagerApp.controller:AboutCtrl
  5. * @description
  6. * # AboutCtrl
  7. * Controller of the domainManagerApp
  8. */
  9. angular.module('domainManagerApp.domains', ['ui.bootstrap', 'firebase'])
  10. .controller('DomainsListController',['$scope', '$firebase', function ($scope, $firebase) {
  11. // $http({
  12. // method: 'GET',
  13. // url: '/scripts/data.json'
  14. // }).success(function(data) {
  15. // $scope.domains = data.domains;
  16. // });
  17. $scope.domains = [];
  18. // Get domain list from firebase
  19. var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains");
  20. ref.on("child_added", function(data) {
  21. if(!$scope.$$phase) {
  22. $scope.$apply(function(){
  23. $scope.domains.push(data.val());
  24. });
  25. }
  26. }, function (errorObject) {
  27. console.log("The read failed: " + errorObject.code);
  28. });
  29. $scope.oneAtATime = false;
  30. $scope.isOpen = false;
  31. $scope.labelColor = function(status) {
  32. if (status == "OK"){
  33. var color = "label-success";
  34. } else if (status == "DEAD") {
  35. var color = "label-danger";
  36. } else {
  37. var color = "label-default";
  38. }
  39. return color;
  40. }
  41. }]);