-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathsave-or-send-torrent.js
40 lines (38 loc) · 1.51 KB
/
save-or-send-torrent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
angular
.module('nzbhydraApp')
.directive('saveOrSendFile', saveOrSendFile);
function saveOrSendFile() {
return {
templateUrl: 'static/html/directives/save-or-send-file.html',
scope: {
searchResultId: "<",
isFile: "<",
type: "<"
},
controller: controller
};
function controller($scope, $http, growl, ConfigService) {
$scope.cssClass = "glyphicon-save-file";
var endpoint;
if ($scope.type === "TORRENT") {
$scope.enableButton = !_.isNullOrEmpty(ConfigService.getSafe().downloading.saveTorrentsTo) || ConfigService.getSafe().downloading.sendMagnetLinks;
$scope.tooltip = "Save torrent to black hole or send magnet link";
endpoint = "internalapi/saveOrSendTorrent";
} else {
$scope.tooltip = "Save NZB to black hole";
$scope.enableButton = !_.isNullOrEmpty(ConfigService.getSafe().downloading.saveNzbsTo);
endpoint = "internalapi/saveNzbToBlackhole";
}
$scope.add = function () {
$scope.cssClass = "nzb-spinning";
$http.put(endpoint, $scope.searchResultId).then(function (response) {
if (response.data.successful) {
$scope.cssClass = "glyphicon-ok";
} else {
$scope.cssClass = "glyphicon-remove";
growl.error(response.data.message);
}
});
};
}
}