feat(core): Code optimization with file download

This commit is contained in:
OldHawk
2017-10-16 11:46:54 +08:00
parent 03769208a0
commit 94f7ca5f3c
27 changed files with 105 additions and 313 deletions

View File

@@ -13,6 +13,7 @@
marked, ModalConfirmService, $stateParams, TopicsService, localStorageService, $compile, RepliesService, $filter, Upload, DownloadService,
mtDebug) {
var vm = this;
vm.DLS = DownloadService
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
vm.scoreConfig = MeanTorrentConfig.meanTorrentConfig.score;
@@ -529,26 +530,5 @@
}
});
};
/**
* downloadAttach
* @param t
* @param r
* @param af
*/
vm.downloadAttach = function (t, r, af) {
var url = '/api/attach/' + vm.topic._id.toString();
url += r ? '/' + r._id.toString() : '';
url += '?attachId=' + af._id.toString();
DownloadService.downloadFile(url, null, function (status) {
if (status === 200) {
NotifycationService.showSuccessNotify('FORUMS.ATTACHE_DOWNLOAD_SUCCESSFULLY');
}
}, function (err) {
mtDebug.info(err);
NotifycationService.showErrorNotify(err.data.message, 'FORUMS.ATTACHE_DOWNLOAD_FAILED');
});
};
}
}());