完成导出功能以及导出日志查看功能

This commit is contained in:
lili 2018-04-03 17:26:04 +08:00
parent 3ac9da8ad2
commit 30c70fba37
8 changed files with 648 additions and 552 deletions

2
defs.d.ts vendored
View File

@ -77,6 +77,7 @@
/// <reference path="d.ts/kubernetes/ts/sharedControllers.d.ts"/>
/// <reference path="d.ts/kubernetes/ts/tabs.d.ts"/>
/// <reference path="d.ts/kubernetes/ts/templates.d.ts"/>
/// <reference path="d.ts/navigation/ts/navigationPlugin.d.ts"/>
/// <reference path="d.ts/system/ts/systemHelpers.d.ts"/>
/// <reference path="d.ts/system/ts/systemPlugin.d.ts"/>
/// <reference path="d.ts/system/ts/regionalismCodeSearch.d.ts"/>
@ -85,4 +86,3 @@
/// <reference path="d.ts/system/ts/systemCodeSearch.d.ts"/>
/// <reference path="d.ts/system/ts/systemList.d.ts"/>
/// <reference path="d.ts/system/ts/systemVerification.d.ts"/>
/// <reference path="d.ts/navigation/ts/navigationPlugin.d.ts"/>

File diff suppressed because one or more lines are too long

View File

@ -444,9 +444,9 @@
<span class="ml5 mt5 fl sj_over_hid">全选</span>
</label>
</li>
<li class="cl export-li" ng-repeat="item in data">
<li class="cl export-li" ng-repeat="item in uniqueData">
<label class="export-label">
<input type="checkbox" id={{item.id}} ng-checked="ischeckedId(item.id) " ng-click="selectId(item.id,$event,idList) " class="fl " />
<input type="checkbox" id={{item.id}} ng-checked="ischeckedId(item.id) " ng-click="selectId(item.id,$event) " class="fl " />
<span class="ml5 mt5 fl sj_over_hid ">{{item.cityName}}_{{item.districtName}}_{{item.systemName}}_{{item.endYear}}_{{item.submittedBatch}}_{{item.dataVersion}}</span>
</label>
</li>
@ -457,15 +457,17 @@
<ul class="mb10 " style="height:400px;overflow-y:auto; ">
<li class="cl export-li " ng-repeat="item in export ">
<label class="export-label">
<input type="checkbox" id={{item.type}} ng-checked="ischeckedType(item.type) " ng-click="selectType(item.type,$event,typeList) " class="fl " />
<span class="ml5 mt5 fl sj_over_hid " style="width: 150px;">{{item.exportName}}</span>
<select class="ml5 mt5 fl sj_over_hid" style="width: 200px;" ng-show="item.exportName=='汇总库' " ng-init="selectGatherOracleName=gatherOracles[0].name" ng-model="selectGatherOracleName" ng-options="one.name for one in gatherOracles">
<input type="checkbox" id={{item.type}} ng-checked="ischeckedType(item.type) " ng-click="selectType(item.type,$event) " class="fl " />
<span class="ml5 mt5 fl sj_over_hid " style="width: 100px;">{{item.exportName}}</span>
<span class="ml5 mt5 fl sj_over_hid " style="width:100px;" ng-show="item.exportName=='汇总库' && gatherOracleSelected">请选择汇总库</span>
<select class="ml5 mt5 fl sj_over_hid" style="width: 150px;" ng-show="item.exportName=='汇总库' && gatherOracleSelected" ng-model="$parent.selectGatherOracleName">
<option ng-repeat="one in gatherOracles " value="{{one.id}} ">{{one.name}}</option>
</select>
</label>
</li>
</ul>
</div>
<button class="sj_btn_blue mt20 fr " ng-click="onsubmit(idList,typeList) ">保存</button>
<button class="sj_btn_blue mt20 fr " ng-click="onsubmit(idList,typeList,selectGatherOracleName) ">保存</button>
<button class="sj_btn_grey mt20 mr5 fr " ng-click="cancel() ">取消</button>
</div>
</script>

View File

@ -325,15 +325,21 @@ module Configs {
}]);
export var dataExportController = controller("dataExportController", ['$scope', '$http', 'DataModel', 'ConfigsModel', ($scope, $http, DataModel: Developer.DataModelService, ConfigsModel: Configs.ConfigsModelService) => {
$scope.model = DataModel;
$scope.data = DataModel.data;
$scope.gatherOracles=ConfigsModel.oracleParam;
$scope.export = [{ "type": 1, "exportName": "原始数据" }, { "type": 2, "exportName": "汇总库" }, { "type": 3, "exportName": "标准表抽取脚本" }];
$scope.model = DataModel;
getUniqueData($scope);
$scope.gatherOracles = ConfigsModel.oracleParam;
// $scope.gatherOracles = ["2017汇总库"];
$scope.export = [{ "type": 1, "exportName": "原始数据" }, { "type": 2, "exportName": "汇总库" }, { "type": 3, "exportName": "标准表抽取脚本" }];
$scope.gatherOracleSelected = false;
$scope.idList = [];
$scope.typeList = [];
$scope.selectGatherOracleName = "";
$scope.gatherOracleList = [];
$scope.flag = false;
$scope.ischeckedId = function(id) {
return $scope.idList.indexOf(id) >= 0;
}
@ -354,16 +360,27 @@ module Configs {
}
$scope.ischeckedType = function(type) {
return $scope.typeList.indexOf(type) >= 0;
}
$scope.selectType = function(type, event) {
var action = event.target;
if (action.checked) {
if (type == 2) {
$scope.gatherOracleSelected = true;
}
if ($scope.typeList.indexOf(type) == -1) {
$scope.typeList.push(type);
return $scope.typeList;
}
} else {
if (type == 2) {
$scope.gatherOracleSelected = false;
}
var idx = $scope.typeList.indexOf(type);
if (idx != -1) {
$scope.typeList.splice(idx, 1);
@ -375,7 +392,7 @@ module Configs {
$scope.selectAll = function(flag) {
if ($scope.flag) {
flag = false;
angular.forEach($scope.data, function(item, index) {
angular.forEach($scope.uniqueData, function(item, index) {
$scope.idList.push(item.id);
});
return $scope.idList;
@ -390,7 +407,7 @@ module Configs {
$scope.closeThisDialog();
}
$scope.onsubmit = (idList, typeList) => {
$scope.onsubmit = (idList, typeList, selectGatherOracleName) => {
if (!idList.length) {
Configs.customAlert("提示", "请选择需要导出的数据", '', null, 0, "error");
return;
@ -399,27 +416,34 @@ module Configs {
Configs.customAlert("提示", "请选择需要导出的类型", '', null, 0, "error");
return;
}
var formData = {};
formData['idList'] = idList;
formData['typeList'] = typeList;
if ((selectGatherOracleName == undefined || selectGatherOracleName == "") && $scope.gatherOracleSelected) {
Configs.customAlert("提示", "请选择汇总库汇总库", '', null, 0, "error");
return;
}
// var formData = {};
// formData['idList'] = idList;
// formData['typeList'] = typeList;
// formData['gatherOracleList']=[];
// formData['gatherOracleList'].psuh(selectGatherOracleName);
$scope.gatherOracleList.push(selectGatherOracleName);
$.ajax({
async: false,
type: "POST",
contentType: "application/x-www-form-urlencoded",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
url: UrlHelpers.join("/java/console/api/oracle/exportData"),
dataType: 'json',
data: { "idList": idList, "typeList": typeList },
data: { "idList": idList, "typeList": typeList, "gatherOracleList": $scope.gatherOracleList },
// data: { "idList": idList, "typeList": typeList },
// data: JSON.stringify(formData),
success: (data) => {
Configs.customAlert("提示", "操作成功: 本次合计新增了" + data, '', null, 0, "success");
Configs.customAlert("提示", "正在导出,查看详情请点击查看导出日志!", '', null, 0, "success");
},
error: (data) => {
Configs.customAlert("提示", "操作成功: 本次合计新增了" + data, '', null, 0, "error");
Configs.customAlert("提示", "导出失败:" + data, '', null, 0, "error");
}
});
@ -446,4 +470,25 @@ module Configs {
}
return title;
}
function getUniqueData($scope) {
var result;
$.ajax({
async: false,
type: "POST",
contentType: "application/json;charset=utf-8",
url: UrlHelpers.join("/java/console/api/getAllData"),
dataType: 'json',
success: (data) => {
$scope.uniqueData = data;
result = data;
return "success";
},
error: (data) => {
return "获取数据失败";
}
});
}
}

View File

@ -4,7 +4,8 @@
<span class="fa fa-caret-down"></span>
</div>
<div class="terminal-title" ng-mousedown="mouseDown($event)" ng-mouseup="mouseUp($event)" ng-mousemove="mouseMove($event)">
<h5 class="top-bottom-middle">{{containerName}}的抽取日志</h5>
<h5 class="top-bottom-middle" ng-hide="isExportLog">{{containerName}}的抽取日志</h5>
<h5 class="top-bottom-middle" ng-hide="!isExportLog">导出日志</h5>
<i class="fa fa-remove pull-right clickable" title="Close and exit this log" ng-click="close()"></i>
<i class="fa fa-square-o pull-right clickable" title="Maximize this log" ng-click="maximize($event)"></i>
<i class="fa fa-sort-desc pull-right clickable" ng-hide="maximized()" title="Minimize this log" ng-click="minimize($event)"></i>

View File

@ -9,7 +9,7 @@ module Kubernetes {
kubernetesContainerSocketProvider.WebSocketFactory = "CustomWebSockets";
});
_module.factory('CustomWebSockets', (userDetails:any) => {
_module.factory('CustomWebSockets', (userDetails: any) => {
return function CustomWebSocket(url, protocols) {
var paths = url.split('?');
if (!_.startsWith(paths[0], masterApiUrl())) {
@ -24,6 +24,7 @@ module Kubernetes {
_module.service('TerminalService', ($rootScope, $document, $compile, $interval, $templateCache) => {
var body = $document.find('body');
function positionTerminals(terminals) {
var total = _.keys(terminals).length;
var dist = (body.width() - 225) / total;
@ -43,7 +44,7 @@ module Kubernetes {
},
terminals: {},
httpTask: {},
newTerminal: ($interval, podLink, containerName, entity, url ,template = defaultTemplate) => {
newTerminal: ($interval, podLink, containerName, entity, url, template = defaultTemplate) => {
var terminalId = UrlHelpers.join(podLink, containerName);
if (terminalId in self.terminals) {
log.debug("Already a terminal with id: ", terminalId);
@ -51,18 +52,21 @@ module Kubernetes {
return terminalId;
}
var scope = $rootScope.$new();
if (containerName == "") {
scope.isExportLog = true;
}
getLogs(entity, scope, url);
scope.podLink = podLink;
scope.containerName = containerName;
scope.id = terminalId;
scope.docked = true;
if(terminalId in self.httpTask){
if (terminalId in self.httpTask) {
self.raiseTerminal(terminalId);
return terminalId;
}else{
self.httpTask[terminalId] = $interval(() =>{
} else {
self.httpTask[terminalId] = $interval(() => {
getLogs(entity, scope, url);
},2000);
}, 2000);
}
var el = $($compile(template)(scope));
var term = {
@ -74,10 +78,11 @@ module Kubernetes {
positionTerminals(self.terminals);
return terminalId;
},
closeTerminal: (id) => {
var term = self.terminals[id];
var timer = self.httpTask[id];
if(timer){
if (timer) {
$interval.cancel(timer);
delete self.httpTask[id];
}
@ -292,7 +297,7 @@ module Kubernetes {
return {
restrict: 'A',
scope: false,
link: (scope:any, element, attr) => {
link: (scope: any, element, attr) => {
addWindowActions(scope, element, TerminalService);
var body = element.find('.terminal-body');
body.append($compile('<kubernetes-container-terminal pod="podLink" container="containerName" command="bash"></kubernetes-container-terminal>')(scope));
@ -300,21 +305,21 @@ module Kubernetes {
};
});
function getLogs(rc, scope, url){
var xhr= new XMLHttpRequest();
function getLogs(rc, scope, url) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if(xhr.readyState == 4){
if (xhr.status == 200){
if(xhr.responseText !="" && xhr.responseText !=null){
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (xhr.responseText != "" && xhr.responseText != null) {
var logObject = JSON.parse(xhr.responseText);
scope.logs = logObject[getName(rc)];
}else{
} else {
scope.logs = "当前没有可以查看的日志信息";
}
//return ({text: "aaaaaa"});
}else{
} else {
//log = "当前没有可以查看的日志!";
}
}
@ -324,4 +329,3 @@ module Kubernetes {
xhr.send(null);
}
}

View File

@ -20,7 +20,7 @@
<div class="row clear fr mb10">
<!--<input type="checkbox" class="fl mr5 " style="margin-top: 8px;" />
<label class="fl mr5 " style="margin-top: 5px; font-style:nomal;">全选</label>-->
<button class="btn pull-right sj_btn_grey mr20" ng-click="downLoadExcelFile()">
<button class="btn pull-right sj_btn_grey mr20" ng-click="openLog()">
<i class="glyphicon glyphicon-export"></i> 导出日志查看
</button>
<span class="pull-right">&nbsp;</span>

View File

@ -7,7 +7,7 @@
/// <reference path="../../configs/ts/configsUtils.ts"/>
module System {
export var SystemListController = controller('SystemListController', ['$scope', '$location', '$http', '$templateCache', 'Upload', 'NgTableParams', 'ngDialog', 'SystemModel', ($scope, $location, $http, $templateCache, Upload, NgTableParams, ngDialog, SystemModel) => {
export var SystemListController = controller('SystemListController', ['$scope', '$interval', '$location', '$http', '$templateCache', 'Upload', 'NgTableParams', 'ngDialog', 'SystemModel', 'TerminalService', ($scope, $interval, $location, $http, $templateCache, Upload, NgTableParams, ngDialog, SystemModel, TerminalService) => {
shareInit($scope);
$scope.modelServices = SystemModel;
@ -165,7 +165,10 @@ module System {
closeByDocument: false
});
}
$scope.openLog = () => {
TerminalService.newTerminal($interval, "exportData", "", "export_data", "/java/console/api/oracle/exportData/log", $templateCache.get(UrlHelpers.join(Kubernetes.templatePath, 'logShell.html')));
}
//boolean选择条件是/否
function booleanChoose() {