woodpecker/cmd/drone-server/static/scripts/controllers/agents.js

38 lines
920 B
JavaScript
Raw Normal View History

2015-04-30 21:41:52 +00:00
(function () {
function AgentsCtrl($scope, $window, users, agents) {
// this is the address that agents should connect with.
$scope.addr = $window.location.origin;
// Gets the currently authenticated user
2015-04-30 21:41:52 +00:00
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Generages a remote agents.
agents.getAgents().then(function(payload){
$scope.agents = payload.data;
2015-04-30 21:41:52 +00:00
});
$scope.onDelete = function(agent) {
console.log("delete agent", agent)
agents.deleteAgent(agent).then(function(payload){
var index = $scope.agents.indexOf(agent);
$scope.agents.splice(index, 1);
});
}
$scope.newAgent={address: ""};
$scope.onAdd = function(agent) {
agents.postAgent(agent).then(function(payload){
$scope.agents.push(payload.data);
$scope.newAgent={address: ""};
});
}
2015-04-30 21:41:52 +00:00
}
angular
.module('drone')
.controller('AgentsCtrl', AgentsCtrl);
})();