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

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

@ -1,15 +1,16 @@
<div class="terminal-window pod-log-window" pod-log-window ng-mousedown="raise()">
<div class="resize-dot" ng-mousedown="startResize($event)" ng-hide="docked"></div>
<div class="centered scroll-indicator" ng-hide="atBottom" ng-click="atBottom = true">
<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>
<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>
</div>
<!--<div class="terminal-body" scroll-glue ng-model="atBottom" style="overflow-y:hidden"> -->
<div class="resize-dot" ng-mousedown="startResize($event)" ng-hide="docked"></div>
<div class="centered scroll-indicator" ng-hide="atBottom" ng-click="atBottom = true">
<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" 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>
</div>
<!--<div class="terminal-body" scroll-glue ng-model="atBottom" style="overflow-y:hidden"> -->
<textarea style="height:100%; width:100%" disabled="disabled">{{logs}}</textarea>
<!--</div>-->
</div>
<!--</div>-->
</div>

View File

@ -3,325 +3,329 @@
module Kubernetes {
var log = Logger.get("kubernetes-term-windows");
var log = Logger.get("kubernetes-term-windows");
_module.config((kubernetesContainerSocketProvider) => {
kubernetesContainerSocketProvider.WebSocketFactory = "CustomWebSockets";
});
_module.config((kubernetesContainerSocketProvider) => {
kubernetesContainerSocketProvider.WebSocketFactory = "CustomWebSockets";
});
_module.factory('CustomWebSockets', (userDetails:any) => {
return function CustomWebSocket(url, protocols) {
var paths = url.split('?');
if (!_.startsWith(paths[0], masterApiUrl())) {
paths[0] = UrlHelpers.join(masterApiUrl(), paths[0]);
}
url = KubernetesAPI.wsUrl(paths[0]);
url.search(paths[1] + '&access_token=' + userDetails.token);
log.debug("Using ws url: ", url.toString());
return new WebSocket(url.toString(), protocols);
};
});
_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;
var position = 5;
angular.forEach(terminals, (value, key) => {
if (!value.scope.docked) {
return;
}
value.el.css('left', position + 'px');
position = position + dist;
});
}
var defaultTemplate = $templateCache.get(UrlHelpers.join(templatePath, 'termShell.html'));
var self = {
positionTerminals: () => {
positionTerminals(self.terminals);
},
terminals: {},
httpTask: {},
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);
self.raiseTerminal(terminalId);
return terminalId;
}
var scope = $rootScope.$new();
getLogs(entity, scope, url);
scope.podLink = podLink;
scope.containerName = containerName;
scope.id = terminalId;
scope.docked = true;
if(terminalId in self.httpTask){
self.raiseTerminal(terminalId);
return terminalId;
}else{
self.httpTask[terminalId] = $interval(() =>{
getLogs(entity, scope, url);
},2000);
}
var el = $($compile(template)(scope));
var term = {
scope: scope,
el: el
_module.factory('CustomWebSockets', (userDetails: any) => {
return function CustomWebSocket(url, protocols) {
var paths = url.split('?');
if (!_.startsWith(paths[0], masterApiUrl())) {
paths[0] = UrlHelpers.join(masterApiUrl(), paths[0]);
}
url = KubernetesAPI.wsUrl(paths[0]);
url.search(paths[1] + '&access_token=' + userDetails.token);
log.debug("Using ws url: ", url.toString());
return new WebSocket(url.toString(), protocols);
};
body.append(el);
self.terminals[terminalId] = term;
positionTerminals(self.terminals);
return terminalId;
},
closeTerminal: (id) => {
var term = self.terminals[id];
var timer = self.httpTask[id];
if(timer){
$interval.cancel(timer);
delete self.httpTask[id];
}
if (term) {
term.el.remove();
delete self.terminals[id];
positionTerminals(self.terminals);
}
},
raiseTerminal: (id) => {
angular.forEach(self.terminals, (value, key) => {
if (key === id) {
value.el.css('z-index', '4000');
value.el.find('.terminal').focus();
} else {
value.el.css('z-index', '3000');
}
});
}
};
return self;
});
export function addWindowActions(scope, element, TerminalService) {
var moved = false;
var lastX = 0;
var lastY = 0;
var header = element.find('.terminal-title');
var body = element.find('.terminal-body');
element.on('$destroy', () => {
$('#main').css({ display: 'inherit' });
});
var HEIGHT = 348;
var WIDTH = 600;
var TITLE_HEIGHT = 35;
var NAV_OFFSET = 46;
_module.service('TerminalService', ($rootScope, $document, $compile, $interval, $templateCache) => {
var body = $document.find('body');
element.css({
height: HEIGHT,
width: WIDTH
});
header.css({
height: TITLE_HEIGHT
});
body.css({
position: 'absolute',
top: 35,
left: 0,
right: 0,
bottom: 0
});
scope.close = () => {
TerminalService.closeTerminal(scope.id);
};
scope.raise = () => {
TerminalService.raiseTerminal(scope.id);
};
scope.$watch('docked', (docked) => {
if (docked) {
element.width(WIDTH);
if (!element.hasClass('minimized')) {
element.height(HEIGHT);
}
}
});
scope.startResize = (e) => {
e.preventDefault();
log.debug("Start resize");
scope.resizing = true;
element.on('mouseup', scope.stopResize);
$(document).on('mousemove', scope.doResize);
$(document).on('mouseleave', scope.stopResize);
};
scope.doResize = (e) => {
if (scope.resizing) {
log.debug("Resizing, e: ", e);
if (!moved) {
lastX = e.clientX;
lastY = e.clientY;
moved = true;
return;
}
var height = element.height();
var width = element.width();
var deltaX = e.clientX - lastX;
var deltaY = e.clientY - lastY;
var newHeight = height + deltaY;
var newWidth = width + deltaX;
if (newHeight > 35 && newWidth > 80) {
element.height(height + deltaY);
element.width(width + deltaX);
}
lastX = e.clientX;
lastY = e.clientY;
}
};
scope.stopResize = (e) => {
scope.resizing = false;
moved = false;
element.off('mouseup', scope.stopResize);
$(document).off('mousemove', scope.doResize);
$(document).off('mouseleave', scope.stopResize);
}
scope.mouseDown = (e) => {
e.preventDefault();
if (element.hasClass('minimized') || element.hasClass('maximized')) {
return;
}
scope.dragging = true;
element.on('mouseup', scope.mouseUp);
$(document).on('mousemove', scope.mouseMove);
$(document).on('mouseleave', scope.mouseUp);
};
scope.mouseUp = (e) => {
e.preventDefault();
scope.dragging = false;
moved = false;
var height = element.height();
var offset = element.offset();
var winHeight = $(window).height();
if (offset.top > (winHeight - height - 20)) {
element.css({ top: "inherit", left: "inherit" });
scope.docked = true;
TerminalService.positionTerminals();
} else {
scope.docked = false;
}
element.off('mouseup', scope.mouseUp);
$(document).off('mousemove', scope.mouseMove);
$(document).off('mouseleave', scope.mouseUp);
};
scope.mouseMove = (e) => {
if (scope.dragging) {
if (!moved) {
lastX = e.clientX;
lastY = e.clientY;
moved = true;
return;
}
var deltaX = e.clientX - lastX;
var deltaY = e.clientY - lastY;
var elOffset = element.offset();
element.offset({ top: elOffset.top + deltaY, left: elOffset.left + deltaX });
lastX = e.clientX;
lastY = e.clientY;
}
}
function restoreWindow(scope, element) {
if (scope.offset) {
element.offset(scope.offset);
scope.docked = false;
}
if (scope.height) {
element.height(scope.height);
}
if (scope.width) {
element.width(scope.width);
}
}
function saveWindow(scope, element) {
scope.offset = element.offset();
scope.height = element.height();
scope.width = element.width();
}
scope.maximized = () => {
return element.hasClass('maximized');
}
scope.maximize = ($e) => {
$e.preventDefault();
if (element.hasClass('minimized')) {
scope.minimize();
}
if (element.hasClass('maximized')) {
restoreWindow(scope, element);
$('#main').css({ display: 'inherit' });
} else {
saveWindow(scope, element);
$('#main').css({ display: 'none' });
element.css({
height: 'inherit',
bottom: 0,
width: '100%',
top: NAV_OFFSET,
left: 0
});
}
element.toggleClass('maximized');
}
scope.minimize = ($e) => {
$e.preventDefault();
if (element.hasClass('maximized')) {
scope.maximize();
}
if (element.hasClass('minimized')) {
restoreWindow(scope, element);
} else {
saveWindow(scope, element);
scope.docked = true;
element.css({ height: TITLE_HEIGHT, top: "inherit", left: "inherit" });
TerminalService.positionTerminals();
}
element.toggleClass('minimized');
};
}
_module.directive('terminalWindow', ($compile, TerminalService) => {
return {
restrict: 'A',
scope: false,
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));
}
};
});
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){
var logObject = JSON.parse(xhr.responseText);
scope.logs = logObject[getName(rc)];
}else{
scope.logs = "当前没有可以查看的日志信息";
function positionTerminals(terminals) {
var total = _.keys(terminals).length;
var dist = (body.width() - 225) / total;
var position = 5;
angular.forEach(terminals, (value, key) => {
if (!value.scope.docked) {
return;
}
//return ({text: "aaaaaa"});
}else{
//log = "当前没有可以查看的日志!";
}
value.el.css('left', position + 'px');
position = position + dist;
});
}
}
xhr.open("POST", url, false);
//xhr.open("POST", "/java/console/api/oracle/extract/log?rcName=" + getName(rc),false);
xhr.send(null);
}
}
var defaultTemplate = $templateCache.get(UrlHelpers.join(templatePath, 'termShell.html'));
var self = {
positionTerminals: () => {
positionTerminals(self.terminals);
},
terminals: {},
httpTask: {},
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);
self.raiseTerminal(terminalId);
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) {
self.raiseTerminal(terminalId);
return terminalId;
} else {
self.httpTask[terminalId] = $interval(() => {
getLogs(entity, scope, url);
}, 2000);
}
var el = $($compile(template)(scope));
var term = {
scope: scope,
el: el
};
body.append(el);
self.terminals[terminalId] = term;
positionTerminals(self.terminals);
return terminalId;
},
closeTerminal: (id) => {
var term = self.terminals[id];
var timer = self.httpTask[id];
if (timer) {
$interval.cancel(timer);
delete self.httpTask[id];
}
if (term) {
term.el.remove();
delete self.terminals[id];
positionTerminals(self.terminals);
}
},
raiseTerminal: (id) => {
angular.forEach(self.terminals, (value, key) => {
if (key === id) {
value.el.css('z-index', '4000');
value.el.find('.terminal').focus();
} else {
value.el.css('z-index', '3000');
}
});
}
};
return self;
});
export function addWindowActions(scope, element, TerminalService) {
var moved = false;
var lastX = 0;
var lastY = 0;
var header = element.find('.terminal-title');
var body = element.find('.terminal-body');
element.on('$destroy', () => {
$('#main').css({ display: 'inherit' });
});
var HEIGHT = 348;
var WIDTH = 600;
var TITLE_HEIGHT = 35;
var NAV_OFFSET = 46;
element.css({
height: HEIGHT,
width: WIDTH
});
header.css({
height: TITLE_HEIGHT
});
body.css({
position: 'absolute',
top: 35,
left: 0,
right: 0,
bottom: 0
});
scope.close = () => {
TerminalService.closeTerminal(scope.id);
};
scope.raise = () => {
TerminalService.raiseTerminal(scope.id);
};
scope.$watch('docked', (docked) => {
if (docked) {
element.width(WIDTH);
if (!element.hasClass('minimized')) {
element.height(HEIGHT);
}
}
});
scope.startResize = (e) => {
e.preventDefault();
log.debug("Start resize");
scope.resizing = true;
element.on('mouseup', scope.stopResize);
$(document).on('mousemove', scope.doResize);
$(document).on('mouseleave', scope.stopResize);
};
scope.doResize = (e) => {
if (scope.resizing) {
log.debug("Resizing, e: ", e);
if (!moved) {
lastX = e.clientX;
lastY = e.clientY;
moved = true;
return;
}
var height = element.height();
var width = element.width();
var deltaX = e.clientX - lastX;
var deltaY = e.clientY - lastY;
var newHeight = height + deltaY;
var newWidth = width + deltaX;
if (newHeight > 35 && newWidth > 80) {
element.height(height + deltaY);
element.width(width + deltaX);
}
lastX = e.clientX;
lastY = e.clientY;
}
};
scope.stopResize = (e) => {
scope.resizing = false;
moved = false;
element.off('mouseup', scope.stopResize);
$(document).off('mousemove', scope.doResize);
$(document).off('mouseleave', scope.stopResize);
}
scope.mouseDown = (e) => {
e.preventDefault();
if (element.hasClass('minimized') || element.hasClass('maximized')) {
return;
}
scope.dragging = true;
element.on('mouseup', scope.mouseUp);
$(document).on('mousemove', scope.mouseMove);
$(document).on('mouseleave', scope.mouseUp);
};
scope.mouseUp = (e) => {
e.preventDefault();
scope.dragging = false;
moved = false;
var height = element.height();
var offset = element.offset();
var winHeight = $(window).height();
if (offset.top > (winHeight - height - 20)) {
element.css({ top: "inherit", left: "inherit" });
scope.docked = true;
TerminalService.positionTerminals();
} else {
scope.docked = false;
}
element.off('mouseup', scope.mouseUp);
$(document).off('mousemove', scope.mouseMove);
$(document).off('mouseleave', scope.mouseUp);
};
scope.mouseMove = (e) => {
if (scope.dragging) {
if (!moved) {
lastX = e.clientX;
lastY = e.clientY;
moved = true;
return;
}
var deltaX = e.clientX - lastX;
var deltaY = e.clientY - lastY;
var elOffset = element.offset();
element.offset({ top: elOffset.top + deltaY, left: elOffset.left + deltaX });
lastX = e.clientX;
lastY = e.clientY;
}
}
function restoreWindow(scope, element) {
if (scope.offset) {
element.offset(scope.offset);
scope.docked = false;
}
if (scope.height) {
element.height(scope.height);
}
if (scope.width) {
element.width(scope.width);
}
}
function saveWindow(scope, element) {
scope.offset = element.offset();
scope.height = element.height();
scope.width = element.width();
}
scope.maximized = () => {
return element.hasClass('maximized');
}
scope.maximize = ($e) => {
$e.preventDefault();
if (element.hasClass('minimized')) {
scope.minimize();
}
if (element.hasClass('maximized')) {
restoreWindow(scope, element);
$('#main').css({ display: 'inherit' });
} else {
saveWindow(scope, element);
$('#main').css({ display: 'none' });
element.css({
height: 'inherit',
bottom: 0,
width: '100%',
top: NAV_OFFSET,
left: 0
});
}
element.toggleClass('maximized');
}
scope.minimize = ($e) => {
$e.preventDefault();
if (element.hasClass('maximized')) {
scope.maximize();
}
if (element.hasClass('minimized')) {
restoreWindow(scope, element);
} else {
saveWindow(scope, element);
scope.docked = true;
element.css({ height: TITLE_HEIGHT, top: "inherit", left: "inherit" });
TerminalService.positionTerminals();
}
element.toggleClass('minimized');
};
}
_module.directive('terminalWindow', ($compile, TerminalService) => {
return {
restrict: 'A',
scope: false,
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));
}
};
});
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) {
var logObject = JSON.parse(xhr.responseText);
scope.logs = logObject[getName(rc)];
} else {
scope.logs = "当前没有可以查看的日志信息";
}
//return ({text: "aaaaaa"});
} else {
//log = "当前没有可以查看的日志!";
}
}
}
xhr.open("POST", url, false);
//xhr.open("POST", "/java/console/api/oracle/extract/log?rcName=" + getName(rc),false);
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,8 +165,11 @@ 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() {
return [{ id: '是', title: '是' }, { id: '否', title: '否' }];