2014-02-08 01:40:16 +00:00
|
|
|
var app = angular.module('gophish', ['ngTable', 'ngResource']);
|
|
|
|
|
|
|
|
app.factory('CampaignService', function($resource) {
|
2014-02-08 21:16:36 +00:00
|
|
|
return $resource('/api/campaigns/:id?api_key=' + API_KEY, {
|
|
|
|
id: "@id"
|
|
|
|
}, {
|
|
|
|
update: {
|
|
|
|
method: 'PUT'
|
|
|
|
}
|
|
|
|
});
|
2014-02-08 01:40:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.factory('GroupService', function($resource) {
|
2014-02-08 21:16:36 +00:00
|
|
|
return $resource('/api/groups/:id?api_key=' + API_KEY, {
|
|
|
|
id: "@id"
|
|
|
|
}, {
|
|
|
|
update: {
|
|
|
|
method: 'PUT'
|
|
|
|
}
|
|
|
|
});
|
2014-02-08 01:40:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.controller('CampaignCtrl', function($scope, CampaignService) {
|
2014-02-08 21:16:36 +00:00
|
|
|
CampaignService.query(function(campaigns) {
|
2014-02-08 01:40:16 +00:00
|
|
|
$scope.campaigns = campaigns
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
app.controller('GroupCtrl', function($scope, GroupService) {
|
2014-02-08 21:16:36 +00:00
|
|
|
GroupService.query(function(groups) {
|
|
|
|
$scope.groups = groups
|
|
|
|
})
|
2014-02-08 01:40:16 +00:00
|
|
|
|
|
|
|
$scope.editGroup = function(group) {
|
|
|
|
if (group === 'new') {
|
|
|
|
$scope.newGroup = true;
|
|
|
|
$scope.group = {
|
|
|
|
name: '',
|
2014-02-08 21:16:36 +00:00
|
|
|
targets: [],
|
2014-02-08 01:40:16 +00:00
|
|
|
id: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$scope.newGroup = false;
|
|
|
|
$scope.group = group;
|
|
|
|
}
|
|
|
|
};
|
2014-02-08 21:16:36 +00:00
|
|
|
|
|
|
|
$scope.addTarget = function() {
|
|
|
|
if ($scope.newTarget.email != "") {
|
|
|
|
$scope.group.targets.push({
|
|
|
|
email: $scope.newTarget.email
|
|
|
|
});
|
|
|
|
$scope.newTarget.email = ""
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$scope.removeTarget = function(target) {
|
|
|
|
$scope.group.targets.splice($scope.group.targets.indexOf(target), 1);
|
|
|
|
};
|
2014-02-08 01:40:16 +00:00
|
|
|
})
|