mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 22:15:25 +00:00
update
This commit is contained in:
69
node_modules/browser-sync-ui/lib/plugins/connections/connections.client.js
generated
vendored
Normal file
69
node_modules/browser-sync-ui/lib/plugins/connections/connections.client.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
(function (angular) {
|
||||
|
||||
const SECTION_NAME = "connections";
|
||||
|
||||
angular
|
||||
.module("BrowserSync")
|
||||
.controller("ConnectionsController", [
|
||||
"pagesConfig",
|
||||
ConnectionsControllers
|
||||
]);
|
||||
|
||||
/**
|
||||
* @param pagesConfig
|
||||
* @constructor
|
||||
*/
|
||||
function ConnectionsControllers(pagesConfig) {
|
||||
var ctrl = this;
|
||||
ctrl.section = pagesConfig[SECTION_NAME];
|
||||
}
|
||||
|
||||
angular
|
||||
.module("BrowserSync")
|
||||
.directive("connectionList", function () {
|
||||
return {
|
||||
restrict: "E",
|
||||
scope: {
|
||||
options: "="
|
||||
},
|
||||
templateUrl: "connections.directive.html",
|
||||
controller: ["$scope", "Clients", "Socket", connectionListDirective],
|
||||
controllerAs: "ctrl"
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Controller for the URL sync
|
||||
* @param $scope - directive scope
|
||||
* @param Clients
|
||||
* @param Socket
|
||||
*/
|
||||
function connectionListDirective($scope, Clients, Socket) {
|
||||
|
||||
var ctrl = this;
|
||||
ctrl.connections = [];
|
||||
|
||||
ctrl.update = function (data) {
|
||||
ctrl.connections = data;
|
||||
$scope.$digest();
|
||||
};
|
||||
|
||||
// Always try to retreive the sockets first time.
|
||||
Socket.getData("clients").then(function (data) {
|
||||
ctrl.connections = data;
|
||||
});
|
||||
|
||||
// Listen to events to update the list on the fly
|
||||
Socket.on("ui:connections:update", ctrl.update);
|
||||
|
||||
$scope.$on("$destroy", function () {
|
||||
Socket.off("ui:connections:update", ctrl.update);
|
||||
});
|
||||
|
||||
ctrl.highlight = function (connection) {
|
||||
Clients.highlight(connection);
|
||||
};
|
||||
}
|
||||
|
||||
})(angular);
|
||||
|
Reference in New Issue
Block a user