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

domainsList.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.domainsList', ['ui.bootstrap', 'firebase', 'domainManagerApp.domainsData'])
  10. .controller('DomainsListController',['$scope', '$firebase', 'Domains', '$rootScope', function ($scope, $firebase, Domains, $rootScope) {
  11. // $http({
  12. // method: 'GET',
  13. // url: '/scripts/data.json'
  14. // }).success(function(data) {
  15. // $scope.domains = data.domains;
  16. // });
  17. $scope.domains = Domains.get();
  18. $rootScope.$on('domains:loaded', function(domain) {
  19. if(!$scope.$$phase) {
  20. $scope.$apply(function(){
  21. $scope.domains = Domains.get();
  22. });
  23. }
  24. });
  25. $scope.oneAtATime = false;
  26. $scope.isOpen = false;
  27. $scope.labelColor = function(status) {
  28. if (status == "OK"){
  29. var color = "label-success";
  30. } else if (status == "DEAD") {
  31. var color = "label-danger";
  32. } else {
  33. var color = "label-default";
  34. }
  35. return color;
  36. }
  37. }]);
  38. // // Get domain list from firebase
  39. // var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains");
  40. // ref.on("child_added", function(data) {
  41. // if(!$scope.$$phase) {
  42. // $scope.$apply(function(){
  43. // $scope.domains.push(data.val());
  44. // });
  45. // }
  46. // }, function (errorObject) {
  47. // console.log("The read failed: " + errorObject.code);
  48. // });