overview.client.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. (function (angular) {
  2. const SECTION_NAME = "overview";
  3. angular
  4. .module("BrowserSync")
  5. .controller("OverviewController", [
  6. "options",
  7. "pagesConfig",
  8. OverviewController
  9. ]);
  10. /**
  11. * @param options
  12. * @param pagesConfig
  13. */
  14. function OverviewController (options, pagesConfig) {
  15. var ctrl = this;
  16. ctrl.section = pagesConfig[SECTION_NAME];
  17. ctrl.options = options.bs;
  18. ctrl.ui = {
  19. snippet: !ctrl.options.server && !ctrl.options.proxy
  20. };
  21. }
  22. /**
  23. * Url Info - this handles rendering of each server
  24. * info item
  25. */
  26. angular
  27. .module("BrowserSync")
  28. .directive("urlInfo", function () {
  29. return {
  30. restrict: "E",
  31. replace: true,
  32. scope: {
  33. "options": "="
  34. },
  35. templateUrl: "url-info.html",
  36. controller: [
  37. "$scope",
  38. "$rootScope",
  39. "Clients",
  40. urlInfoController
  41. ]
  42. };
  43. });
  44. /**
  45. * @param $scope
  46. * @param $rootScope
  47. * @param Clients
  48. */
  49. function urlInfoController($scope, $rootScope, Clients) {
  50. var options = $scope.options;
  51. var urls = options.urls;
  52. $scope.ui = {
  53. server: false,
  54. proxy: false
  55. };
  56. if ($scope.options.mode === "server") {
  57. $scope.ui.server = true;
  58. if (!Array.isArray($scope.options.server.baseDir)) {
  59. $scope.options.server.baseDir = [$scope.options.server.baseDir];
  60. }
  61. }
  62. if ($scope.options.mode === "proxy") {
  63. $scope.ui.proxy = true;
  64. }
  65. $scope.urls = [];
  66. $scope.urls.push({
  67. title: "Local",
  68. tagline: "URL for the machine you are running BrowserSync on",
  69. url: urls.local,
  70. icon: "imac"
  71. });
  72. if (urls.external) {
  73. $scope.urls.push({
  74. title: "External",
  75. tagline: "Other devices on the same wifi network",
  76. url: urls.external,
  77. icon: "wifi"
  78. });
  79. }
  80. if (urls.tunnel) {
  81. $scope.urls.push({
  82. title: "Tunnel",
  83. tagline: "Secure HTTPS public url",
  84. url: urls.tunnel,
  85. icon: "globe"
  86. });
  87. }
  88. /**
  89. *
  90. */
  91. $scope.sendAllTo = function (path) {
  92. Clients.sendAllTo(path);
  93. $rootScope.$emit("notify:flash", {
  94. heading: "Instruction sent:",
  95. message: "Sync all Browsers to: " + path
  96. });
  97. };
  98. }
  99. /**
  100. * Display the snippet when in snippet mode
  101. */
  102. angular
  103. .module("BrowserSync")
  104. .directive("snippetInfo", function () {
  105. return {
  106. restrict: "E",
  107. replace: true,
  108. scope: {
  109. "options": "="
  110. },
  111. templateUrl: "snippet-info.html",
  112. controller: ["$scope", function snippetInfoController() {/*noop*/}]
  113. };
  114. });
  115. })(angular);