修复不同请求错误

This commit is contained in:
lili 2018-04-18 23:59:44 +08:00
parent 4e26bc1f8e
commit f5d6b60ed8
5 changed files with 50 additions and 29 deletions

View File

@ -7,6 +7,6 @@ declare module Configs {
*/ */
function deepCopy(object: any): any; function deepCopy(object: any): any;
function downloadFile($scope: any, $http: any, url: any, fileName: any): void; function downloadFile($scope: any, $http: any, url: any, fileName: any, fn?: any): void;
function FileInputPlugin(fn: Function, isMultiple?: boolean): void; function FileInputPlugin(fn: Function, isMultiple?: boolean): void;
} }

File diff suppressed because one or more lines are too long

View File

@ -173,7 +173,7 @@ gulp.task('connect', ['watch'], function() {
localProxies.push({ localProxies.push({
proto: "http", proto: "http",
port: "8080", port: "8080",
hostname: "localhost", //hostname:localhost hostname: "localhost", //hostname:localhost
path: '/api/v1/proxy/namespaces/default/services/fabric8-forge', path: '/api/v1/proxy/namespaces/default/services/fabric8-forge',
targetPath: "/" targetPath: "/"
}); });
@ -249,7 +249,7 @@ gulp.task('connect', ['watch'], function() {
}, { }, {
proto: "http", proto: "http",
port: "9001", port: "9001",
hostname: "192.168.191.102", //hostname:"127.0.0.1" hostname: "192.168.191.102", //hostname:"127.0.0.1"
path: '/java/console/api', path: '/java/console/api',
targetPath: "/" targetPath: "/"
}]; }];
@ -355,4 +355,4 @@ gulp.task('site', ['clean', 'build'], function() {
}); });
}); });
gulp.task('default', ['connect']); gulp.task('default', ['connect']);

View File

@ -48,9 +48,9 @@ module Configs {
return object; return object;
} }
} }
export function downloadFile($scope, $http, url, fileName) { export function downloadFile($scope, $http, url, fileName, fn ? ) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', url, false); xhr.open('GET', url, true);
xhr.responseType = "blob"; xhr.responseType = "blob";
xhr.onload = function() { xhr.onload = function() {
if (this.status == 200) { if (this.status == 200) {
@ -80,10 +80,11 @@ module Configs {
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event); link.dispatchEvent(event);
console.log("Download link method with simulated click succeeded"); console.log("Download link method with simulated click succeeded");
Configs.customAlert("提示", "文件下载完成", '', null, 0, "success");
} catch (ex) { } catch (ex) {
console.log("Download link method with simulated click failed with the following exception:"); console.log("Download link method with simulated click failed with the following exception:");
console.log(ex); console.log(ex);
Configs.customAlert("提示", "文件下载失败", '', null, 0, "error");
} }
} }
} else { } else {
@ -93,6 +94,8 @@ module Configs {
Configs.customAlert("提示", "文件下载失败", '', null, 0, "error"); Configs.customAlert("提示", "文件下载失败", '', null, 0, "error");
} }
} }
if (angular.isFunction(fn))
fn();
} }
xhr.send(); xhr.send();
} }

View File

@ -136,20 +136,28 @@ module System {
//excel下载 //excel下载
$scope.downLoadExcelFile = () => { $scope.downLoadExcelFile = () => {
// Configs.customAlert("提示", "准备导出,请稍后", '', null, 0, "loading"); Configs.create_mask();
Configs.downloadFile($scope, $http, '/java/console/api/fileOperation/file/download', "export.xls"); Kubernetes.create_locadEffect("正在导出excel文件,请稍等...");
Configs.customAlert("提示", "导出成功,文件下载完成", '', null, 0, "success"); var target = document.getElementById('loading');
var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
Configs.downloadFile($scope, $http, '/java/console/api/fileOperation/file/download', "export.xls", () => {
$("#load").remove();
Kubernetes.removeMask();
});
} }
$scope.downloadFilePackage = () => { $scope.downloadFilePackage = () => {
Configs.create_mask(); Configs.create_mask();
Kubernetes.create_locadEffect("正在下载文件,请稍等..."); Kubernetes.create_locadEffect("正在下载文件,请稍等...");
var target = document.getElementById('loading'); var target = document.getElementById('loading');
var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target); var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
Configs.downloadFile($scope, $http, '/java/console/api/filePackage/download', "package.zip");
$("#load").remove(); Configs.downloadFile($scope, $http, '/java/console/api/filePackage/download', "package.zip", () => {
Kubernetes.removeMask(); $("#load").remove();
Kubernetes.removeMask();
});
} }