修复数据分页显示bug

Web_Manager_Develope
wu ming 8 years ago
parent 92e5814d5c
commit 7efdc5d699

@ -1,14 +1,45 @@
/// <reference path="../../includes.d.ts" />
declare module Developer {
type LabelResolver = () => string;
interface BreadcrumbConfig {
href?: string;
label?: string | LabelResolver;
title?: string;
class?: string;
isValid?: () => boolean;
isActive?: (subTab, path) => boolean;
}
function workspaceLink(): string;
function projectLink(projectId: any): string;
function createWorkspacesBreadcrumbs(developPerspective: any): any[];
function createWorkspacesBreadcrumbs(developPerspective?: any): BreadcrumbConfig[];
function createWorkspacesSubNavBars(developPerspective: any): any;
function createWorkspaceBreadcrumbs(children?: any, workspaceName?: any): any;
function createEnvironmentBreadcrumbs($scope: any, $location: any, $routeParams: any): any;
function createProjectBreadcrumbs(projectName?: any, children?: any, workspaceName?: any): any;
function createProjectBreadcrumbs(projectName?: any, children?: Array<BreadcrumbConfig>, workspaceName?: any): any;
function createProjectSettingsBreadcrumbs(projectName: any, workspaceName?: any): any;
function createWorkspaceSubNavBars(): any;
function namespaceRuntimeLink(workspaceName?: any): string;
/**
* Creates a routing function that loads a template and inject the needed directives to properly
* display/update the Developer module managed tabs and bread crumbs for when the route is active.
*
* Example Usage:
*
* var route = Developer.createTabRoutingFunction("/app/somedir");
* $routeProvider.when('/profiles', route('view.html', false, [{
* label: "Profiles",
* title: "Browse the profiles of this project"
* }]
* ));
*
* @param baseURL
* @returns {function(string, boolean=, Array<Developer.BreadcrumbConfig>=): {template: string, reloadOnSearch: boolean, controller: string|string|(function(any, ng.route.IRouteParamsService): undefined)[]}}
*/
function createTabRoutingFunction(baseURL: string): (templateName: string, reloadOnSearch?: boolean, children?: BreadcrumbConfig[]) => {
template: string;
reloadOnSearch: boolean;
controller: (string | (($scope: any, $routeParams: ng.route.IRouteParamsService) => void))[];
};
function createProjectSubNavBars(projectName: any, jenkinsJobId?: any, $scope?: any): any;
function createProjectSettingsSubNavBars(projectName: any, jenkinsJobId?: any): any;
function forgeProjectHasBuilder(name: any): any;
@ -20,9 +51,13 @@ declare module Developer {
function projectSecretsLink(workspaceName: any, projectName: any): string;
function secretsNamespaceLink(workspaceName: any, projectName: any, secretsNamespace: any): string;
function projectWorkspaceLink(workspaceName: any, projectName: any, path: any, ignoreBlankProject?: boolean): string;
function environmentsLink(workspaceName?: any): string;
function environmentLink(workspaceName: any, environmentNamespace: any, path?: string, ignoreBlankProject?: boolean): string;
var customProjectSubTabFactories: any[];
function createJenkinsBreadcrumbs(projectName: any, jobId: any, buildId: any): any;
function createJenkinsSubNavBars(projectName: any, jenkinsJobId: any, buildId: any, extraOption?: any): any;
function createEnvironmentSubNavBars($scope: any, $location: any, $routeParams: any): any;
function environmentInstanceLink(env: any, projectName?: any): string;
function namespaceLink($scope: any, $routeParams: any, path?: any): string;
function normalizeHref(href: string): string;
}

@ -2,7 +2,8 @@
/// <reference path="../../kubernetes/ts/kubernetesHelpers.d.ts" />
/// <reference path="developerEnrichers.d.ts" />
/// <reference path="developerHelpers.d.ts" />
/// <reference path="developerNavigation.d.ts" />
/// <reference path="dataManagerHelper.d.ts" />
/// <reference path="dataManagerModel.d.ts" />
declare module Developer {
var WorkspacesController: ng.IModule;
}

@ -209,4 +209,5 @@ declare module Kubernetes {
function getOracleName(name: string): string;
function extractDataToOracle($http: any, selectedReplicationControllers: any, targetReplicationController: any): void;
function checkoutOracleRCIsRunning(rc: any): boolean;
function replicasIsCreated(replicationcontrollers: Array<any>, name: string): boolean;
}

@ -24,6 +24,7 @@ declare module Kubernetes {
"isExtract": string;
"isTarget": any;
};
"annotations": any;
};
"spec": {
replicas: any;

2
defs.d.ts vendored

@ -5,7 +5,9 @@
/// <reference path="d.ts/developer/ts/developerHelpers.d.ts"/>
/// <reference path="d.ts/developer/ts/developerNavigation.d.ts"/>
/// <reference path="d.ts/developer/ts/FileMode.d.ts"/>
/// <reference path="d.ts/developer/ts/dataManagerHelper.d.ts"/>
/// <reference path="d.ts/developer/ts/developerPlugin.d.ts"/>
/// <reference path="d.ts/developer/ts/dataManagerModel.d.ts"/>
/// <reference path="d.ts/developer/ts/environmentPanel.d.ts"/>
/// <reference path="d.ts/developer/ts/home.d.ts"/>
/// <reference path="d.ts/developer/ts/jenkinsJob.d.ts"/>

@ -686,6 +686,73 @@ a:hover.data_file_btn {
background: url(../img/icons2.gif) -6px 9px no-repeat;
}
.layout-pf.layout-pf-fixed .container-pf-nav-pf-vertical {
margin-left: 170px;
}
.nav-pf-vertical {
width: auto;
min-width: 170px;
}
.nav-pf-vertical .list-group > .list-group-item > a {
width: auto;
}
.nav-pf-vertical > .list-group > .list-group-item > a .fa,
.nav-pf-vertical > .list-group > .list-group-item > a .glyphicon,
.nav-pf-vertical > .list-group > .list-group-item > a .pficon {
line-height: 25px;
margin-right: 3px;
}
.nav-pf-vertical > .list-group > .list-group-item > a img {
max-height: 16px;
max-width: 16px;
margin-right: 10px;
}
.navbar-tab-vertical {
height: 70px;
width: 100%;
display: block;
background: #1d1d1d;
border-color: #1d1d1d;
}
.navbar-tab-horizontal {
height: 100%;
width: 100px;
display: block;
background: #1d1d1d;
border-color: #1d1d1d;
}
.gesture {
cursor: pointer;
}
.navbar-lf {
width: 200px;
min-height: 800px;
background: #1d1d1d;
position: absolute;
left: 0;
top: 0px;
}
.navbar-lf-menu {
display: block;
text-decoration: none;
}
.log-img {
width: "66";
height: "21";
alt: "logo";
}
.fl {
float: left;
}
a.logo {
display: block;
width: 130px;
padding: 20px 0 0 40px;
}
.content-margin {
margin-left: 170px;
}
/* This is for the 'Overview' page with all the rows of boxes */
.service-view-rectangle {
position: relative;

File diff suppressed because one or more lines are too long

@ -11,29 +11,10 @@ var gulp = require('gulp'),
stringifyObject = require('stringify-object'),
hawtio = require('hawtio-node-backend'),
argv = require('yargs').argv,
del = require('del'),
xml2js = require('xml2js'),
multipart = require('connect-multiparty'),
resumable = require('./app/resumable-node.js')(__dirname + '/uploads'),
app = hawtio.app,
shellprocess = require('child_process'),
xmloperation = require('./app/xmloperation'),
K8s = require('k8s'),
crontab = require('node-crontab'),
async = require('async'),
myjs=require('./app/my.js');
del = require('del');
var oracledb = require('oracledb');
var plugins = gulpLoadPlugins({});
var pkg = require('./package.json');
var time =0;
var schedule = [];
var allDataPath = process.env.ALL_DATA || '/home/all_data';
var rootdir = allDataPath + "/collecting_data/";
var kubectl = K8s.kubectl({
endpoint: process.env.KUBERNETES_MASTER,
binary: '/usr/bin/kubectl'
});
var config = {
main: '.',
@ -75,7 +56,8 @@ gulp.task('tsc', ['clean-defs'], function() {
.pipe(plugins.sourcemaps.init())
.pipe(plugins.typescript(config.tsProject))
.on('error', plugins.notify.onError({
message: '<%= error.message =>',
onLast: true,
message: '<%= error.message %>',
title: 'Typescript compilation error'
}));
@ -101,6 +83,7 @@ gulp.task('less', function () {
paths: [path.join(__dirname, 'less', 'includes')]
}))
.on('error', plugins.notify.onError({
onLast: true,
message: '<%= error.message %>',
title: 'less file compilation error'
}))
@ -153,6 +136,7 @@ gulp.task('connect', ['watch'], function() {
var kubeBase = process.env.KUBERNETES_MASTER || 'https://localhost:8443';
console.log("==== using KUBERNETES URL: " + kubeBase);
var kube = uri(urljoin(kubeBase, 'api'));
var kubeapis = uri(urljoin(kubeBase, 'apis'));
var oapi = uri(urljoin(kubeBase, 'oapi'));
console.log("Connecting to Kubernetes on: " + kube);
@ -207,15 +191,43 @@ gulp.task('connect', ['watch'], function() {
path: '/kubernetes/api/v1/proxy/services/gogs-http-service',
targetPath: "/"
});
console.log("because of LOCAL_GOGS_HOST being set we are using a local proxy for /kubernetes/api/v1/proxy/services/gogs-http-service to point to http://"
+ process.env.LOCAL_GOGS_HOST + ":" + gogsPort);
console.log("because of LOCAL_GOGS_HOST being set we are using a local proxy for /kubernetes/api/v1/proxy/services/gogs-http-service to point to http://" + process.env.LOCAL_GOGS_HOST + ":" + gogsPort);
}
if (process.env.LOCAL_JENKINSHIFT) {
var jenkinshiftPort = process.env.LOCAL_JENKINSHIFT_PORT || "9090";
var jenkinshiftHost = process.env.LOCAL_JENKINSHIFT;
console.log("Using jenkinshift host: " + jenkinshiftHost);
var proxyPath = '/api/v1/proxy/namespaces/default/services/templates/oapi/v1';
console.log("Using jenkinshift host: " + jenkinshiftHost);
localProxies.push({
proto: "http",
port: jenkinshiftPort,
hostname: jenkinshiftHost,
path: proxyPath,
targetPath: "/oapi/v1"
});
localProxies.push({
proto: "http",
port: jenkinshiftPort,
hostname: jenkinshiftHost,
path: "/oapi/v1",
targetPath: "/oapi/v1"
});
console.log("because of LOCAL_JENKINSHIFT being set we are using a local proxy for " + proxyPath + " to point to http://" + jenkinshiftHost + ":" + jenkinshiftPort);
}
var defaultProxies = [{
proto: kube.protocol(),
port: kube.port(),
hostname: kube.hostname(),
path: '/kubernetes/api',
targetPath: kube.path()
}, {
proto: kubeapis.protocol(),
port: kubeapis.port(),
hostname: kubeapis.hostname(),
path: '/apis',
targetPath: kubeapis.path()
}, {
proto: oapi.protocol(),
port: oapi.port(),
@ -234,6 +246,12 @@ gulp.task('connect', ['watch'], function() {
port: kube.port(),
path: '/git',
targetPath: '/hawtio/git'
}, {
proto: "http",
port: "8080",
hostname: "192.168.0.102",
path: '/java/console/api',
targetPath: "/"
}];
var staticProxies = localProxies.concat(defaultProxies);
@ -286,16 +304,12 @@ gulp.task('connect', ['watch'], function() {
oauth_client_id: 'fabric8'
};
}
var answer = "window.OPENSHIFT_CONFIG = " + stringifyObject(config);
var answer = "window.OPENSHIFT_CONFIG = window.HAWTIO_OAUTH_CONFIG = " + stringifyObject(config);
res.set('Content-Type', 'application/javascript');
res.send(answer);
});
app.use(multipart());
hawtio.use('/', function(req, res, next) {
// console.log(req.connection.remoteAddress);
var path = req.originalUrl;
// avoid returning these files, they should get pulled from js
if (s.startsWith(path, '/plugins/') && s.endsWith(path, 'html')) {
@ -309,525 +323,6 @@ gulp.task('connect', ['watch'], function() {
next();
}
});
hawtio.use('/xmlformserver',function(req,res,next){
if(req.method=='POST') {
var data = [];
var parser = new xml2js.Parser();
fs.readFile(rootdir + '/data.xml', function(err, xml) {
parser.parseString(xml, function (err, result) {
myjs.Recursion(result.node);
data.push(result.node);
res.send(data);
});
});
}
});
hawtio.use("/oracleAppPath",function(req,res){
var dataPath = allDataPath + "/tabulate_data/";
var tmpPath = allDataPath + "/tmp_data/app";
var appSource=allDataPath + "/template/app";
if(req.method="POST"){
var timestamp=new Date();
if((timestamp.getTime() - time) >= 2*60*1000){
time = timestamp.getTime();
var id =fs.readFileSync("./app/version.txt");
var dirName= "huizongshuju-" +id;
dataPath = dataPath + dirName+"/";
fs.mkdirSync(dataPath);
//path.exists(tmpPath,function(exists){if(exists) console.log("exists");});
fs.renameSync(tmpPath, dataPath+"app");
console.log("move '" + tmpPath + "' to " + dataPath);
xmloperation.savehuizong(timestamp.Format('yyyy-MM-dd hh:mm:ss'), '10', id, "汇总数据库("+ id +")", dataPath, dirName);
fs.writeFileSync('./app/version.txt', 2);
res.send(200,{path: dataPath+"app/", name: dirName});
res.end();
shellprocess.exec("cp -rp " + appSource + " " + tmpPath);
}else{
res.send(403,{});
res.end();
}
}
//}
});
hawtio.use('/oracleExtractLog', function(req,res){
var path = allDataPath + "/tabulate_logs/" + req.query.rcName;
if(fs.existsSync(path)){
var log = fs.readFileSync(path, 'utf-8');
res.send(200,{logContent: log.toString()});
res.end();
}else{
res.send(200,{logContent: "当前没有日志可以查看!"});
res.end();
}
});
hawtio.use('/uploadfiles',function(req,res){
if(req.method==="POST"){
var relativePath = req.body.resumableRelativePath;
var fileName = req.body.resumableFilename;
var rootpath = req.body.resumableRootPath;
console.log("--------------------------req.body-----------------");
if(req.body.resumableTotalSize == "0"){
fs.writeFile("uploads/"+fileName,"");
// 去掉系统路径(地区及系统编号)eg: 321100_1/
relativePath = relativePath.replace(/^\w*\/*[0-9_]+\//, "");
console.log("*************-----clean------*****************");
var serverRelativePath = rootdir + rootpath + relativePath;
console.log(serverRelativePath);
fileName = "uploads/"+fileName;
console.log(fileName);
changefilename(fileName, serverRelativePath);
}
resumable.post(req, function(status, filename, original_filename, identifier){
if (status === 'done') {
var stream = fs.createWriteStream('./uploads/' + filename);
console.log("//ºÏ²¢Îļþ");
//ºÏ²¢Îļþ
resumable.write(identifier, stream);
stream.on('data', function(data){});
stream.on('end', function(){});
//ɾ³ý·Ö¿é
//µÈ´ýÁ÷½áÊø
stream.on('finish', function() {
console.log("*************-----clean------*****************");
// 去掉系统路径(地区及系统编号)eg: 321100_1/
relativePath = relativePath.replace(/^\w*\/*[0-9_]+\//, "");
relativePath = rootdir+ rootpath + relativePath;
console.log(relativePath);
fileName = "uploads/"+fileName;
console.log(fileName);
changefilename(fileName, relativePath);
resumable.clean(identifier);
});
}
console.log(status + "---------------------");
res.send(200, {
// NOTE: Uncomment this funciton to enable cross-domain request.
//'Access-Control-Allow-Origin': '*'
});
});
}
if(req.method==="GET"){
resumable.get(req, function(status, filename, original_filename, identifier){
console.log('GET',status);
res.send((status == 'found' ? 200 : 404), status);
});
}
//next();
});
hawtio.use('/download/:identifier', function(req, res){
resumable.write(req.params.identifier, res);
});
app.get('/getclientip', function(req, res){
var ip = req.connection.remoteAddress;
ip = ip.replace(/\./gim, "");
ip = ip.replace(/\:/gim, "");
res.send(ip);
});
app.get('/getversion', function(req, res){
var version = req.query;
var objid = version.id;
var realversion = xmloperation.getVersionPath(objid);
res.send(200, {id:realversion});
});
app.get('/sendDateMessage', function(req, res){
var jsonobj = req.query;
console.log("---------------------------------------------------");
console.log(jsonobj);
var objid = jsonobj.id;
var objname = jsonobj.name;
var objcity = jsonobj.city;
var objcounty = jsonobj.county;
var objsystem = jsonobj.system;
var objtype = jsonobj.type;
var objbatch = jsonobj.batch;
var province = jsonobj.province;
var code = jsonobj.code;
var character_set = jsonobj.character_set;
var sys_name_code = jsonobj.sys_name_code;
var contact = jsonobj.contact;
var phone = jsonobj.phone;
var collecttime = jsonobj.date;
var realversion = xmloperation.getVersionPath(objid);
var realpath = objtype+"/"+objbatch+"/"+objid+"/"+realversion+"/"
realpath = rootdir + realpath;
//saveByIdToXml("001001", "B", "321200_0", "泰州市_绩效管理系统2","江苏" , "泰州2", "市本级", "绩效管理系统", "321200_0", "0000", "lim", "13323225656",5);
xmloperation.saveByIdToXml(collecttime, objtype, objbatch, objid, objname, province, objcity, objcounty, objsystem, code, sys_name_code, contact, phone, realversion, realpath)
xmloperation.mkdataForPage(collecttime, objtype, realpath, objbatch, objid, objname, realversion);
res.send(200);
});
// 路径必须存在
function changefilename(oldfilepath, newfilepath){
fs.stat(oldfilepath,function(err,stats){
if(err){
changefilename(oldfilepath, newfilepath);
}
else{
//console.log("-------------------------------changefilename----");
if(stats.isFile()){
// 修改文件名
fs.rename(oldfilepath,newfilepath, function(err){
if(err){
var dirs = newfilepath.split("/");
var dirLength = dirs.length;
var dirpath = "";
//var isSuccess = "false";
for(var i=0; i < dirLength-1; i++){
dirpath = dirpath + dirs[i] + "/";
fs.mkdir(dirpath, 0777, function(err){
if(err){
//console.log("creat dir fail: "+dirpath);
}
});
}
changefilename(oldfilepath, newfilepath)
}
});
}else if(stats.isDirectory()){
var dirs = newfilepath.split("/");
var dirLength = dirs.length;
var dirpath = "";
for(var i=0; i < dirLength; i++){
dirpath = dirpath + dirs[i] + "/";
fs.mkdir(dirpath, 0777, function(err){
if(err){
//console.log("creat dir fail: "+dirpath);
}
});
}
console.log(" fail: this is Directory");
}else{
console.log("unknow type of file");
}
}
});
}
app.get('/setchmod2dir', function(req, res){
console.log("----------- setchmod2dir -------------------")
console.log(req.query);
var path = rootdir + req.query.path;
var tempfilesNum = req.query.filenum;
var realfilesnum = geFileList(path);
if(tempfilesNum <= realfilesnum){
shellprocess.exec("chmod -R 777 " + path);
console.log("------------------------------------------ "+path);
console.log(realfilesnum);
res.send(200,"chmod");
}
else{
console.log(realfilesnum);
res.send(200,"fail");
}
});
hawtio.use('/resumable.js',function(req,res){
res.setHeader("content-type", "text/javascript");
fs.createReadStream("./app/resumable.js").pipe(res);
});
/*hawtio.use('/style.css',function(req,res){
res.setHeader("content-type", "text/css");
fs.createReadStream("./app/style.css").pipe(res);
});*/
hawtio.use('/connectToOracle',function(req,res){
var rcName = req.query.oracleName;
cancelOracleConectionTask(rcName);
kubectl.rc.get(rcName,function(err, rc){
//console.log(rc);
if(err){
console.log(err);
return
}
if(rc && rc.status.replicas === 1 && rc.metadata.labels.hasOwnProperty("style") && rc.metadata.labels.style === "oracle"){
var selector = rc.spec.selector;
var task = {
taskName: rcName,
taskTime: 0,
taskCrontab: crontab.scheduleJob("*/1 * * * *", function(){ //This will call this function every 2 minutes
//console.log(rcName + "it's been 1 minutes!");
if(task.taskTime === 9){
kubectl.rc.command("label --overwrite rc " + task.taskName + " status=1", function(err, data){
if(err)
console.log(err);
crontab.cancelJob(task.taskCrontab);
cancelOracleConectionTask(task.rcName);
return;
});
}
var selectorPods = [];
kubectl.pod.list(function(err, pods){
if(!err){
pods.items.forEach(function(item){
if(myjs.selectorMatches(selector, item.metadata.labels))
selectorPods.push(item);
});
if(selectorPods.length === 0)
return;
var host = selectorPods[0].status.hostIP
var port = selectorPods[0].spec.containers[0].ports[0].hostPort;
if(host && port){
oracledb.getConnection(
{
user : "system",
password : "oracle",
connectString : host + ":" + port + "/orcl"
},function(err, connection){
if (err) {
console.log("connection failed! message" + err.message);
return;
}
kubectl.rc.command("label --overwrite rc " + task.taskName + " status=2", function(err, data){
if(err){
console.log(err);
}
console.log("update replicationControllers " + rcName + " success");
if(connection !== null){
connection.close(function(err){
if (err){
console.error(err.message);
}
console.log(rcName + "connect success!");
crontab.cancelJob(task.taskCrontab);
cancelOracleConectionTask(task.rcName);
console.log(rcName + "connection closed!");
});
}
});
});
}
}
});
task.taskTime++;
})
}
schedule.push(task);
}
res.send(200,"Ok");
res.end();
});
});
hawtio.use('/cancelOracleConection', function(req,res){
var rcName = req.query.oracleName;
var operation = req.query.operation;
if(operation !== 'stop')
cancelOracleConectionTask(rcName);
else{
kubectl.rc.command("label --overwrite rc " + rcName + " status=0", function(err, data){
if(err)
console.error(err.message);
console.log("update replicationControllers " + rcName + " success");
cancelOracleConectionTask(rcName);
});
}
res.send(200,"Ok");
res.end();
});
hawtio.use('/extractOracleData', function(req,res){
var data = req.query.param;
var poolOracle;
var collectOracle = [];
data.forEach(function(item){
var obj = JSON.parse(item);
if(obj.isTarget)
poolOracle = obj;
else{
var names = obj.OracleName.split("-");
kubectl.rc.command("label --overwrite rc " + obj.OracleName + " isExtract=1", function(err, data){
if(err)
console.error(err);
console.log("update replicationControllers " + obj.OracleName + " success");
});
obj["name"] = "J" + names[0] + "_" + names[1];
collectOracle.push(obj);
}
});
var poolOracleParam = poolOracle.connectHost + ":" +poolOracle.connectPort;
var logMessage = "";
oracledb.getConnection({
user : "system",
password : "oracle",
connectString : poolOracleParam + "/orcl"
}, function(err, connection){
if (err) {
console.error(err.message);
return;
}
var logPath = allDataPath + "/tabulate_logs/";
async.eachSeries(collectOracle, function(item, callback){
var strTUser = item.name + "_20152016";
var message = "-------------------------------------------采集库:" + item.name + "执行汇总-------------------------------------------";
console.log(message);
fs.appendFileSync(logPath + poolOracle.OracleName, message + "\n\n");
async.waterfall([
function(cb){
var dbLinkSql = "create public database link linkTo" + item.name + " connect to system IDENTIFIED BY oracle using "
+"'(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = "
+ item.connectHost + ")(PORT = " + item.connectPort + ")))(CONNECT_DATA = (SERVICE_NAME = orcl)))'";
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + dbLinkSql + "\n\n");
connection.execute(dbLinkSql, function(err, result){
if(err){
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
cb(null);
return;
}
fs.appendFileSync(logPath + poolOracle.OracleName, "数据库链接已创建。" + "\n\n");
cb(null);
});
},
function(cb){
connection.execute("select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME = 'TS_JSSJBS'", function(err, result){
if(err){
console.log(err);
return;
}
if(result.rows.length !== 0)
cb(null, false);
else
cb(null, true);
});
},
function(arg, cb){
if(!arg){
cb(null);
return;
}
var sql = "create tablespace TS_JSSJBS datafile '/opt/oracle/app/oradata/orcl/ts_jssjbs.dbf' size 512M autoextend on next 512M maxsize unlimited";
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
connection.execute(sql, function(err, result){
if (err){
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
cb(null);
return;
}
fs.appendFileSync(logPath + poolOracle.OracleName, "表空间已创建。" + "\n\n");
cb(null);
});
},
function(cb){
var sql = "Create user " + strTUser + " default tablespace TS_JSSJBS identified by 1";
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
connection.execute(sql, function(err, result){
if (err){
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
cb(null);
return;
}
fs.appendFileSync(logPath + poolOracle.OracleName, "用户已创建。" + "\n\n");
//console.log("create us");
cb(null);
});
},
function(cb){
var sql = "grant connect, resource, dba to " + strTUser;
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
connection.execute(sql, function(err, result){
if(err)
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
fs.appendFileSync(logPath + poolOracle.OracleName, "授权成功。" + "\n\n");
//console.log("grant dba");
cb(null);
});
},
function(cb){
var sql = "SELECT 'create table " + strTUser + ".J'|| substr(t.OWNER||'_'||t.TABLE_NAME,0,29)||' as select * from '||t.OWNER||'.'||t.TABLE_NAME||"
+"'@linkTo" + item.name + ";' FROM dba_tables@linkTo" + item.name + " t WHERE t.TABLESPACE_NAME NOT IN ('SYSTEM','SYSAUX')"
+ " and t.owner||t.table_name not in (select owner||table_name from dba_tables@linkTo" + item.name + " where 'data_type'='CLOB')";
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
connection.execute(sql, function(err, result){
if(err){
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
return;
}
preSql = [];
result.rows.forEach(function(row){
row.forEach(function(it){
preSql.push(it.replace(/;$/, ""));
fs.appendFileSync(logPath + poolOracle.OracleName, it + "\n");
});
});
fs.appendFileSync(logPath + poolOracle.OracleName, "\n");
cb(null, preSql);
});
},
function(arg, cb){
async.eachSeries(arg, function(sql, cback){
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
connection.execute(sql, function(err, result){
if(err){
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
cback(null, !err);
return;
}
fs.appendFileSync(logPath + poolOracle.OracleName, "表已创建。" + "\n\n");
cback(null, !err);
});
}, function(err, result){
cb(null);
});
}
], function(err, result){
if(err)
console.error(err);
kubectl.rc.command("label --overwrite rc " + item.OracleName + " isExtract=2", function(err, data){
if(err)
console.err(err);
console.log("update replicationControllers " + item.OracleName + " success");
callback(null);
});
});
}, function(err, result){
if(err)
console.error(err);
connection.close(function(err){
if(err)
console.log(err);
});
});
});
res.send(200,"Ok");
res.end();
});
hawtio.listen(function(server) {
var host = server.address().address;
var port = server.address().port;
@ -861,54 +356,3 @@ gulp.task('site', ['clean', 'build'], function() {
});
gulp.task('default', ['connect']);
function cancelOracleConectionTask(taskName){
var taskIndex = -1;
for(var index in schedule){
var connectionTask = schedule[index];
if(connectionTask.hasOwnProperty("taskName") && connectionTask.taskName === taskName){
crontab.cancelJob(connectionTask.taskCrontab);
console.log("Connection Task(taskName: " + taskName + ")" + " Canceled!");
taskIndex = index;
break;
}
}
if(taskIndex !== -1){
schedule.splice(taskIndex,1);
console.log("Remove task(taskName: " + taskName + ") from schedule");
}else{
console.log("There Are No Connection Task(taskName: " + taskName + ")" + " Can be Canceled!");
}
}
function geFileList(path)
{
var filesList = [];
  readFile(path,filesList);
return filesList.length;
}
//遍历读取文件
function readFile(path,filesList)
{
files = fs.readdirSync(path);//需要用到同步读取
files.forEach(walk);
function walk(file)
{
states = fs.statSync(path+'/'+file);  
   if(states.isDirectory())
   {
   readFile(path+'/'+file,filesList);
   }
else{
   //创建一个对象保存信息
    var obj = new Object();
    obj.size = states.size;//文件大小,以字节为单位
    obj.name = file;//文件名
    obj.path = path+'/'+file; //文件绝对路径
    filesList.push(obj);
   }
  }
}

@ -14,7 +14,6 @@
<link rel="stylesheet" href="libs/nvd3/build/nv.d3.css" />
<link rel="stylesheet" href="libs/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="libs/toastr/toastr.css" />
<link rel="stylesheet" href="libs/angular-patternfly/dist/styles/angular-patternfly.css" />
<link rel="stylesheet" href="libs/hawtio-ui/dist/OpenSans.css" />
<link rel="stylesheet" href="libs/hawtio-ui/dist/DroidSansMono.css" />
<link rel="stylesheet" href="libs/hawtio-ui/dist/ui.dynatree.css" />
@ -54,7 +53,6 @@
<script src="libs/dagre/dist/dagre.core.min.js"></script>
<script src="libs/zeroclipboard/dist/ZeroClipboard.js"></script>
<script src="libs/toastr/toastr.js"></script>
<script src="libs/angular-patternfly/dist/angular-patternfly.js"></script>
<script src="libs/hawtio-ui/dist/jquery-ui.custom.js"></script>
<script src="libs/hawtio-ui/dist/ui-bootstrap.js"></script>
<script src="libs/hawtio-ui/dist/ui-bootstrap-tpls.js"></script>
@ -67,12 +65,13 @@
<script src="libs/hawtio-ui/dist/d3.js"></script>
<script src="libs/hawtio-ui/dist/tabbable.js"></script>
<script src="libs/hawtio-ui/dist/hawtio-ui.js"></script>
<script src="libs/hawtio-forms/dist/jsdiff.js"></script>
<script src="libs/hawtio-forms/dist/hawtio-forms.js"></script>
<script src="libs/hawtio-forms/dist/bootstrap-combobox.js"></script>
<script src="libs/hawtio-template-cache/dist/hawtio-template-cache.js"></script>
<script src="libs/keycloak/dist/keycloak.js"></script>
<script src="libs/ng-idle/angular-idle.js"></script>
<script src="libs/hawtio-oauth/dist/hawtio-oauth.js"></script>
<script src="libs/hawtio-template-cache/dist/hawtio-template-cache.js"></script>
<script src="libs/term.js/src/term.js"></script>
<script src="libs/kubernetes-container-terminal/dist/container-terminal.js"></script>
<script src="libs/hawtio-kubernetes-api/dist/smokesignals.unminified.js"></script>
@ -135,34 +134,17 @@
</head>
<body style="padding-top: 75px;">
<nav class="navbar navbar-default navbar-fixed-top navbar-pf" role="navigation">
<div class="navbar-header" hawtio-extension name="hawtio-header">
<div class="navbar-brand" href="/"><img /></div>
</div>
<!--<ul class="nav navbar-nav navbar-utility">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="pficon pficon-user"></span>
User <b class="caret"></b>
</a>
<ul class="dropdown-menu" hawtio-extension name="hawtio-user">
</ul>
</li>
</ul>-->
<nav class="navbar navbar-fixed-top navbar-pf" role="navigation">
<a href="/" class="log fl"><img src="/" class="log-img"></a>
<ul class="nav navbar-nav navbar-primary" hawtio-main-nav></ul>
<ul class="nav navbar-nav navbar-persistent" hawtio-sub-tabs></ul>
</nav>
<div id="main" class="container-fluid ng-cloak" ng-controller="HawtioNav.ViewController">
<div class="row" style="margin-left: -20px; margin-right: -20px">
<div hawtio-main-outlet ng-class="getClass()"><br><br>
<!-- <hawtio-breadcrumbs-outlet></hawtio-breadcrumbs-outlet> -->
<platform-sub-tabs-outlet></platform-sub-tabs-outlet>
<div id="main" class="container-fluid container-pf-nav-pf-vertical container-pf-nav-pf-vertical-with-secondary content-margin" ng-controller="HawtioNav.ViewController" hawtio-main-outlet>
<div class="row" ng-class="getClass()">
<hawtio-breadcrumbs-outlet></hawtio-breadcrumbs-outlet>
<div ng-include src="viewPartial"></div>
</div>
<!-- <hawtio-tabs-outlet></hawtio-tabs-outlet> -->
</div>
</div>
<script src="dist/hawtio-kubernetes.js"></script>
</body>
</html>

Binary file not shown.

@ -1,75 +1,46 @@
<div ng-controller="Developer.WorkspacesController"><div class="row">
<div ng-controller="Developer.WorkspacesController" hawtio-card-bg>
<div hawtio-breadcrumbs></div>
<div hawtio-tabs></div>
<div class="container-content">
<div class="container-fluid">
<div class="row nav-content">
<ul class="nav nav-tabs" ng-show="navbarItems.length">
<li role="presentation" ng-repeat="item in navbarItems" class="{{item.class}}"><a href="#" ng-click="selectBatchItem(item)">{{item.label}}</a></li>
</ul>
</div>
<div ng-hide="model.data.length" class="align-center">
<p class="alert alert-info">当前没有可以查看的数据.</p>
</div>
<div ng-show="model.data.length">
<table class="table table-striped table-bordered" hawtio-simple-table="tableConfig"></table>
<div class="row">
<div hawtio-tabs></div>
<div class="col-xs-6 col-sm-2">
<button ng-show="true" class="btn btn-danger pull-right" ng-disabled="!id && tableConfig.selectedItems.length == 0" ng-click="deletePrompt(id || tableConfig.selectedItems)">
<i class="fa fa-remove"></i> 删除数据
</button>
<span class="pull-right">&nbsp;</span>
<button ng-show="id" class="btn btn-primary pull-right" ng-click="id = undefined"><i class="fa fa-list"></i></button>
<span class="pull-right">&nbsp;</span>
<a class="btn btn-default pull-right" title="启动oracle服务" href="/kubernetes/replicationControllers" ng-disabled="!id && tableConfig.selectedItems.length == 0" ng-click="createOracleService(id || tableConfig.selectedItems)"><i class="fa fa-plus"></i> 启动服务</a>
<span class="pull-right">&nbsp;</span>
</div>
<div class="col-md-6 col-md-offset-9">
每页显示&nbsp
<select ng-options="value for value in pageSizeChoses" ng-change="selectAction()" ng-model="options.currentTableSize"></select>
&nbsp&nbsp当前页码
<div class="hawtio-pager clearfix">
<label>{{options.currentPageNum}} / {{options.getPageSizeNum()}}</label>
<div class=btn-group>
<button class="btn" ng-disabled="isEmptyOrFirst()" ng-click="first()"><i class="fa fa-fast-backward"></i></button>
<button class="btn" ng-disabled="isEmptyOrFirst()" ng-click="previous()"><i class="fa fa-step-backward"></i></button>
<button class="btn" ng-disabled="isEmptyOrLast()" ng-click="next()"><i class="fa fa-step-forward"></i></button>
<button class="btn" ng-disabled="isEmptyOrLast()" ng-click="last()"><i class="fa fa-fast-forward"></i></button>
</div>
<header class="data_heaer">
<h2 >江苏省审计厅数据汇总平台</h2>
</header>
<div class="data_content">
<div class="data_leftside fl">
<h3 class="data_h3">本地文件列表</h3>
<ul class="fl data_leftside_files">
<li class=" data_title data_title_w">文件名</li>
<div treecontrol class="tree-classic"
tree-model="dataForTheTreeLocal"
options="treeOptionss"
on-selection="showSelectedLocal(node,selected)"
selected-nodes="selectedNodes">
{{node.name}}
</div>
</ul>
<ul class="fl data_leftside_files ">
<li class=" data_title data_title_w">已选数据文件</li>
<li ng-repeat="node in model.selectednodes" >{{node.name}}</li>
</ul>
<ul class="fl data_leftside_files " style="border-right:none;">
<li class=" data_title data_title_w">采集时间</li>
<li ng-repeat="node in model.selectednodes" >{{node.date}}&nbsp&nbsp
<span ng-show="model.uploadprocess[node.id]" style="font-size:larger; font-weight:bold; font-family:serif; color:red;">{{model.uploadprocess[node.id]}}%</span></li>
</ul>
<div class="cl"></div>
<div class="date_btns">
<a class="data_file_btn fl" >导入到服务器</a><input type="file" name="file-upload[]" id="file-uploads" onchange="angular.element(this).scope().upLoadXMLFile(this.files)" multiple webkitdirectory="" />
<a ng-click="upLoadFiles()" class="data_file_btn fl" >导入到服务器</a>
</div>
<div class="cl"></div>
</div><!--data_leftside end-->
<div class="data_rightside fr">
<h3 class="data_h3">服务器文件列表</h3>
<div style="width: 259px; overflow-x:scroll; overflow-y:auto;" class="data_rightside_tree fl" >
<div treecontrol class="tree-classic" style="width: 459px; overflow-x:visible;"
tree-model="dataForTheTree"
options="treeOptions"
on-selection="showSelected(node,selected)"
selected-node="node1">
{{node.name}}
</div>
</div><!--data_rightside_tree end-->
<div class="data_leftside fl data_rightside_w" style="width: 407px; border-right:none;">
<ul class="fl data_leftside_files" style="width: 250px; border-right:1;">
<li class=" data_title data_title_w" style="width: 250px; border-right:1;" >文件名</li>
<li ng-repeat="item in model.serveritems" style="width: 235px; overflow-x:visible;" >{{item.name}}<input type="checkbox" ng-click="isSelected(item)" class="fr"/></li>
</ul>
<ul class="fl data_leftside_files " style="width: 150px; border-right:none;" >
<li class=" data_title data_title_w" style="width: 130px; border-right:none;" >采集时间</li>
<li ng-repeat="item in model.serveritems" style="width: 158px;">{{item.time}}</li>
</ul>
</div><!--data_leftside end-->
<div class="cl"></div>
<div class="date_btns date_btns_w">
<!--<a ng-click="getServerXML()" class="data_file_btn fl">查看服务数据</a>-->
<a ng-click="downLoadFiles()" class="data_file_btn fl" >下载服务数据</a>
<!--<input type="file" name="file-upload[]" id="file-uploads" onchange="angular.element(this).scope().downLoadFiles(this.files)" multiple webkitdirectory="" />-->
<a ng-click="startOracle()" class="data_file_btn fl" >启动oracle服务</a>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
<div class="prettify"></div>
</div>

@ -1,23 +1,30 @@
/// <reference path="../../includes.ts"/>
module Developer {
/*
function homeBreadcrumb() {
return {
href: "/home",
label: "Home",
title: "Go to the home page"
}
var log = Logger.get('developer-navigation');
export type LabelResolver = () => string;
export interface BreadcrumbConfig {
href?: string;
label?: string | LabelResolver;
title?: string;
class?: string;
isValid?: () => boolean;
isActive?: (subTab, path) => boolean;
}
*/
function developBreadcrumb() {
function developBreadcrumb() : BreadcrumbConfig {
return {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces"),
label: "Develop",
title: "View all the apps for a project"
label: "Teams",
title: "View all the available teams",
isActive: (subTab, path) => false
};
}
function operateBreadcrumb() {
function operateBreadcrumb() : BreadcrumbConfig {
return {
href: UrlHelpers.join(HawtioCore.documentBase(), "/namespaces"),
label: "Manage",
@ -38,21 +45,8 @@ module Developer {
}
}
export function createWorkspacesBreadcrumbs(developPerspective) {
/*
if (developPerspective) {
return [
//homeBreadcrumb(),
developBreadcrumb()
];
} else {
return [
//homeBreadcrumb(),
operateBreadcrumb()
];
}
*/
return [];
export function createWorkspacesBreadcrumbs(developPerspective?) {
return [developBreadcrumb()];
}
@ -64,10 +58,7 @@ module Developer {
}
export function createWorkspaceBreadcrumbs(children = null, workspaceName = null) {
var answer = [
//homeBreadcrumb(),
developBreadcrumb()
];
var answer = createWorkspacesBreadcrumbs(true);
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
@ -76,7 +67,8 @@ module Developer {
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces/", workspaceName),
label: workspaceName,
title: "View the project: " + workspaceName
title: "View the project: " + workspaceName,
isActive: (subTab, path) => false
}
);
return processChildren(answer, children);
@ -90,26 +82,13 @@ module Developer {
var namespacesLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/namespace");
var workspaceName = $routeParams.workspace;
var project = $routeParams.project;
var environment = $routeParams.namespace;
if (workspaceName && project) {
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", project);
$scope.$projectLink = projectLink;
$scope.$projectNamespaceLink = UrlHelpers.join(projectLink, "namespace", ns);
namespacesLink = UrlHelpers.join(projectLink, "namespace");
// TODO use the logical name?
var envName = ns;
var buildConfig = null;
if ($scope.model) {
buildConfig = $scope.model.getProject(project, workspaceName);
if (buildConfig) {
// lets find the label for the namespace
var env = _.find(buildConfig.environments, { namespace: ns});
if (env) {
envName = env['label'] || envName;
}
log.info("env found: " + env + " for nameppace " + ns + " on buildConfig: " + buildConfig);
}
}
var children = [
var children: Array<BreadcrumbConfig> = [
{
href: UrlHelpers.join(projectLink, "environments"),
label: "Environments",
@ -117,28 +96,50 @@ module Developer {
},
{
href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: envName,
label: () => environmentName(workspaceName, ns),
title: "View the runtime of the workspace: " + ns
}
];
return createProjectBreadcrumbs(project, children, workspaceName);
} else {
if (!workspaceName) {
} else if (workspaceName && environment && workspaceName != environment) {
// find label for namespace environment
var children: Array<BreadcrumbConfig> = [
{
href: environmentsLink(workspaceName),
label: "Environments",
title: "View the environments for this project"
},
{
href: environmentLink(workspaceName, environment),
label: () => environmentName(workspaceName, environment),
title: "View this environment"
}
];
return createProjectBreadcrumbs(project, children, workspaceName);
} else if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
return activateCurrent([
//homeBreadcrumb(),
operateBreadcrumb(),
{
href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: workspaceName,
var answer = createWorkspaceBreadcrumbs(workspaceName);
answer.push({
href: UrlHelpers.join(HawtioCore.documentBase(), "workspaces", workspaceName, "namespace", ns, "apps"),
label: 'Runtime',
title: "View the runtime of the workspace: " + ns
});
return activateCurrent(answer);
}
]);
/**
* Returns the name of the given environment namespace
*/
function environmentName(workspaceName, environment) {
var model = Kubernetes.getKubernetesModel();
if (model) {
return model.environmentName(workspaceName, environment);
}
return environment;
}
export function createProjectBreadcrumbs(projectName = null, children = null, workspaceName = null) {
export function createProjectBreadcrumbs(projectName = null, children: Array<BreadcrumbConfig> = null, workspaceName = null) {
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
@ -168,12 +169,9 @@ module Developer {
export function createProjectSettingsBreadcrumbs(projectName, workspaceName = null) {
var children = [{
label: "Settings",
title: "View the settings of this app"
}];
var children = [];
if (!projectName) {
var children = [{
children = [{
label: "New App",
title: "Lets make a new app"
}];
@ -186,6 +184,12 @@ module Developer {
return activateCurrent([
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName),
label: "Dashboard",
class: "fa fa-tachometer",
title: "View the dashboard for the apps, environments and pipelines in this project"
},
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "apps"),
label: "Apps",
class: "fa fa-rocket",
title: "View the apps in this project"
@ -198,25 +202,78 @@ module Developer {
title: "View the builds in this project"
},
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/namespace", workspaceName, "apps"),
label: "Runtime",
class: "fa fa-gears",
title: "View the runtime resources in this project"
href: environmentsLink(),
label: "Environments",
class: "fa fa-cubes",
title: "View the environments for this project"
},
{
href: namespaceRuntimeLink(workspaceName),
label: "Runtime",
class: "fa fa-cube",
title: "View the Runtime perspective for this project"
}
/*
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "detail"),
label: "Details",
class: "fa fa-gear",
title: "View the project details"
}
*/
]);
}
export function namespaceRuntimeLink(workspaceName = null) {
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
return UrlHelpers.join(HawtioCore.documentBase(), "workspaces", workspaceName, "namespace", workspaceName, "apps");
}
function createBuildsLink(workspaceName, projectName, jenkinsJobId) {
workspaceName = workspaceName || Kubernetes.currentKubernetesNamespace();
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "jenkinsJob", jenkinsJobId);
}
/**
* Creates a routing function that loads a template and inject the needed directives to properly
* display/update the Developer module managed tabs and bread crumbs for when the route is active.
*
* Example Usage:
*
* var route = Developer.createTabRoutingFunction("/app/somedir");
* $routeProvider.when('/profiles', route('view.html', false, [{
* label: "Profiles",
* title: "Browse the profiles of this project"
* }]
* ));
*
* @param baseURL
* @returns {function(string, boolean=, Array<Developer.BreadcrumbConfig>=): {template: string, reloadOnSearch: boolean, controller: string|string|(function(any, ng.route.IRouteParamsService): undefined)[]}}
*/
export function createTabRoutingFunction(baseURL:string) {
return (templateName:string, reloadOnSearch:boolean = true, children?: Array<Developer.BreadcrumbConfig>) => {
return {
template: "<div hawtio-breadcrumbs></div><div hawtio-tabs></div><ng-include src='contentTemplateUrl'></ng-include>",
reloadOnSearch: reloadOnSearch,
controller: ["$scope", "$routeParams", ($scope, $routeParams:ng.route.IRouteParamsService) => {
if( $routeParams["namespace"]==null ) {
log.error("The :namespace route parameter was not defined for the route.");
}
if( $routeParams["projectId"] == null ) {
log.error("The :projectId route parameter was not defined for the route.");
}
$scope.namespace = $routeParams["namespace"];
$scope.projectId = $routeParams["projectId"];
$scope.contentTemplateUrl = UrlHelpers.join(baseURL, templateName);
$scope.breadcrumbConfig = Developer.createProjectBreadcrumbs($scope.projectId, children);
$scope.subTabConfig = Developer.createProjectSubNavBars($scope.projectId);
}]
};
}
}
export function createProjectSubNavBars(projectName, jenkinsJobId = null, $scope = null) {
var workspaceName = Kubernetes.currentKubernetesNamespace();
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName);
@ -243,6 +300,7 @@ module Developer {
}
var answer = [
/*
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName),
label: "All Apps",
@ -252,20 +310,22 @@ module Developer {
{
template: `<div ng-include="'plugins/developer/html/projectSelector.html'"></div>`
},
*/
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "environments"),
isActive: (subTab, path) => {
var href = normalizeHref(subTab.href);
//console.log("subTab: ", subTab, " path: ", path);
if (path === subTab.href) {
if (path === href) {
return true;
}
var rootPath = subTab.href.replace(/\/environments/, '');
var rootPath = href.replace(/\/environments/, '');
if (path === rootPath) {
return true;
}
return false;
},
//href: UrlHelpers.join("/workspaces", workspaceName, "projects", projectName),
//href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName),
label: "Dashboard",
class: "fa fa-tachometer",
title: "View the app dashboard for the activity, environments and pipelines"
@ -287,6 +347,15 @@ module Developer {
},
{
isValid: () => isJenkinsBuild(),
isActive: (item, path) => {
if (path.indexOf('/log/') > 0) {
return false;
}
if (path.indexOf('/jenkinsJob/') > 0) {
return true;
}
return false;
},
id: "builds",
href: jenkinsBuildLink,
label: "Builds",
@ -302,7 +371,7 @@ module Developer {
},
/*
{
href: UrlHelpers.join("/workspaces", workspaceName, "projects", projectName, "tools"),
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "tools"),
label: "Tools",
title: "View the tools for this project"
},
@ -441,6 +510,23 @@ module Developer {
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, path);
}
export function environmentsLink(workspaceName = null) {
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "environments")
}
export function environmentLink(workspaceName, environmentNamespace, path = "", ignoreBlankProject = true) {
if (ignoreBlankProject && !environmentNamespace) {
return "";
}
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "namespace", environmentNamespace, path);
}
export var customProjectSubTabFactories = [];
export function createJenkinsBreadcrumbs(projectName, jobId, buildId) {
@ -467,7 +553,7 @@ module Developer {
export function createJenkinsSubNavBars(projectName, jenkinsJobId, buildId, extraOption: any = null) {
var answer = createProjectSubNavBars(projectName, jenkinsJobId);
if (extraOption) {
extraOption.active = true;
// extraOption.active = true;
answer.push(extraOption);
}
return answer;
@ -478,75 +564,53 @@ module Developer {
var ns = Kubernetes.currentKubernetesNamespace();
var workspaceName = $routeParams.workspace;
var project = $routeParams.project;
var environment = $routeParams.namespace;
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes");
/*console.log("=====================")
console.log(projectLink);
if (workspaceName && project) {
projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", project);
}
projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes", workspaceName, "projects", project);
} else {
projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes", workspaceName || ns);
}*/
var namespacesLink = UrlHelpers.join(projectLink, "namespace");
return activateCurrent([
{
href: UrlHelpers.join(projectLink, "environments"),
label: "<< Back To App",
title: "Go back to the Dashboard for this App",
isValid: () => project
},
{
href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: "Overview",
class: "fa fa-list",
title: "Overview of all the apps for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "services"),
label: "Services",
class: "fa fa-plug",
title: "View the apps for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "replicationControllers"),
label: "Controllers",
label: "服务管理",
class: "fa fa-clone",
title: "View the Replication Controllers for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "pods"),
label: "Pods",
class: "fa fa-puzzle-piece",
title: "View the pods for this project"
title: "View the Replicas for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "events"),
label: "Events",
label: "日志信息",
class: "fa fa-newspaper-o",
title: "View the events for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "secrets"),
label: "Secrets",
class: "fa fa-key",
title: "View the secrets for this project"
},
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/hosts"),
label: "Nodes",
href: UrlHelpers.join(projectLink, "hosts"),
label: "集群节点",
class: "fa fa-server",
title: "View the nodes for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "overview"),
label: "Diagram",
class: "fa fa-sitemap",
title: "View all the objects in this project and their relationship"
},
{
href: UrlHelpers.join(namespacesLink, ns, "angryPods"),
label: "Angry Pods",
class: "fa fa-gamepad",
title: "Try the Angry Pods game!"
},
}
]);
}
export function environmentInstanceLink(env, projectName = null) {
if (env) {
var envNamespace = env["namespace"];
if (envNamespace) {
if (projectName) {
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", Kubernetes.currentKubernetesNamespace(), "projects", projectName, "namespace", envNamespace);
} else {
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", Kubernetes.currentKubernetesNamespace(), "namespace", envNamespace);
}
}
}
return "";
}
export function namespaceLink($scope, $routeParams, path = null) {
var ns = Kubernetes.currentKubernetesNamespace();
@ -572,32 +636,68 @@ module Developer {
return text;
}
// Cater for the app running at some weird document base
export function normalizeHref(href:string) {
if (!href) {
return null;
}
var regex = new RegExp('^' + HawtioCore.documentBase().replace('/', '\\/'));
return href.replace(regex, '/');
}
function activateCurrent(navBarItems) {
navBarItems = _.compact(navBarItems);
var injector = HawtioCore.injector;
var $location = injector ? injector.get<ng.ILocationService>("$location") : null;
if ($location) {
var path = trimQuery($location.path());
var path = normalizeHref(trimQuery($location.path()));
var found = false;
function makeActive(item) {
item.active = true;
found = true;
}
function getHref(item) {
var href = item.href;
var trimHref = trimQuery(href);
return normalizeHref(trimHref);
}
angular.forEach(navBarItems, (item) => {
if (item) {
if (!found && item) {
if (angular.isFunction(item.isActive)) {
if (!found && item.isActive(item, path)) {
if (item.isActive(item, path)) {
makeActive(item);
}
} else {
var href = item.href;
var trimHref = trimQuery(href);
if (!found && trimHref && trimHref === path) {
var trimHref = getHref(item);
if (!trimHref) {
return;
}
if (trimHref === path) {
makeActive(item);
}
}
}
});
// Maybe it's a sub-item of a tab, let's fall back to that maybe
if (!found) {
angular.forEach(navBarItems, (item) => {
if (!found) {
if (!angular.isFunction(item.isActive)) {
var trimHref = getHref(item);
if (!trimHref) {
return;
}
if (_.startsWith(path, trimHref)) {
makeActive(item);
}
}
}
});
}
// still not found, let's log it
if (!found) {
log.debug("No navigation tab found for path:", path);
}
}
return navBarItems;
}

@ -3,66 +3,37 @@
module Developer {
export var _module = angular.module(pluginName, ['hawtio-core', 'hawtio-ui', 'ui.codemirror', 'nvd3', 'treeControl']);
export var _module = angular.module(pluginName, ['hawtio-core', 'hawtio-ui', 'ui.codemirror', 'nvd3']);
export var controller = PluginHelpers.createControllerFunction(_module, pluginName);
export var route = PluginHelpers.createRoutingFunction(templatePath);
_module.config(['$routeProvider', ($routeProvider:ng.route.IRouteProvider) => {
$routeProvider.when(context, route('workspaces.html', false))
.when("/namespaces", route('workspaces.html', false))
//.when("/home", route('home.html', false))
.when(UrlHelpers.join(context, '/:namespace'), route('projects.html', false))
.when(UrlHelpers.join(context, '/:namespace/detail'), route('workspace.html', false))
.when(UrlHelpers.join(context, '/:namespace/jenkinsJob'), route('jenkinsJobs.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects'), route('projects.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id'), route('environments.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/detail'), Kubernetes.route('buildConfig.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/builds'), Kubernetes.route('builds.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/environments'), route('environments.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsJob/:job'), route('jenkinsJob.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsJob/:job/log/:build'), route('jenkinsLog.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsJob/:job/pipelines'), route('pipelines.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsJob/:job/pipeline/:build'), route('pipeline.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsJob/:job/metrics'), route('jenkinsMetrics.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/jenkinsMetrics'), route('jenkinsMetrics.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects/:id/tools'), route('tools.html', false))
.when(UrlHelpers.join(context, '/:workspace/projects/:project/environments/:namespace'), route('environment.html', false))
.when(UrlHelpers.join(context, '/:workspace/projects/:project/environments/:namespace'), route('environment.html', false))
.when(UrlHelpers.join(context, '/Aggregate/overview'), route('addDataFile.html', false))
.otherwise("/workspaces");
.when("/data-manager", route('workspaces.html', false))
.when(UrlHelpers.join(context, 'Overview/data-type/all'), route('workspaces.html', false))
.when(UrlHelpers.join(context, 'Overview/data-type/financial'), route('workspaces.html', false))
.when(UrlHelpers.join(context, 'Overview/data-type/social-security'), route('workspaces.html', false))
.when(UrlHelpers.join(context, 'task'), route('apps.html', false))
.otherwise(context);
}]);
_module.run(['viewRegistry', 'ServiceRegistry', 'HawtioNav', 'KubernetesModel', '$templateCache', 'DataInfoModel',(viewRegistry, ServiceRegistry, HawtioNav, KubernetesModel, $templateCache, DataInfoModel) => {
_module.run(['viewRegistry', 'ServiceRegistry', 'HawtioNav', 'KubernetesModel', '$templateCache', (viewRegistry, ServiceRegistry, HawtioNav, KubernetesModel, $templateCache) => {
log.debug("Running");
viewRegistry['workspaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';
viewRegistry['namespaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';
var builder = HawtioNav.builder();
var workspaces = builder.id('workspaces')
.href(() => context)
.title(() => '查看')
.build();
/*
var workspaceOverview = builder.id('workspaces')
.href(() => UrlHelpers.join(context, 'overview'))
.title(() => 'Workspace')
.build();
*/
/* var dataadd = builder.id('dataadd')
.href(() => context)
.title(() => '汇总')
.build();
*/
var Aggregate = builder.id('Aggregate;')
var dmanagerTab = builder.id('dmanager')
.rank(200)
.href(() => context)
.title(() => '数据汇总')
.title(() => '数据管理')
//.isValid(() => !Core.isRemoteConnection())
.tabs(workspaces)
.build();
HawtioNav.add(Aggregate);
HawtioNav.add(dmanagerTab);
}]);
_module.filter('asTrustedHtml', ['$sce', function ($sce) {

@ -2,472 +2,210 @@
/// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/>
/// <reference path="developerEnrichers.ts"/>
/// <reference path="developerHelpers.ts"/>
/// <reference path="developerNavigation.ts"/>
/// <reference path="dataManagerHelper.ts"/>
/// <reference path="dataManagerModel.ts"/>
module Developer {
export var WorkspacesController = controller("WorkspacesController",
["$scope", "KubernetesModel", "KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "DataInfoModel", "$interval",
($scope, KubernetesModel:Kubernetes.KubernetesModelService, KubernetesState, $templateCache:ng.ITemplateCacheService, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL, DataInfoModel,$interval) => {
$scope.model = DataInfoModel;
$scope.items=[];
$scope.localitems=[];
var rootPath="";
var FilterList ={
length:0
};
update();
$scope.treeOptions = {
nodeChildren: "children",
dirSelectable: true,
multiSelection: false,
injectClasses: {
ul: "a1",
li: "a2",
liSelected: "a7",
iExpanded: "a3",
iCollapsed: "a4",
iLeaf: "a5",
label: "a6",
labelSelected: "a8"
}
};
$scope.treeOptionss = {
nodeChildren: "children",
dirSelectable: true,
multiSelection: true,
injectClasses: {
ul: "a1",
li: "a2",
liSelected: "a7",
iExpanded: "a3",
iCollapsed: "a4",
iLeaf: "a5",
label: "a6",
labelSelected: "a8"
}
};
$scope.showSelected = (node,selected)=>{
$scope.model.serveritems = [];
var array = new Array();
if(selected){
if(node.children.length > 0){
array.unshift(node);
while(array.length > 0){
var childNode=array.pop();
if(childNode.children.length>0){
for(var i=0;i<childNode.children.length;i++)
array.unshift(childNode.children[i]);
}else{
if(childNode.hasOwnProperty("path"))
$scope.model.serveritems.push(childNode);
}
}
}else{
if(node.hasOwnProperty("path"))
$scope.model.serveritems.push(node);
export var WorkspacesController = controller("WorkspacesController", ["$scope", "KubernetesModel", "DataModel","KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "$element",
($scope, KubernetesModel:Kubernetes.KubernetesModelService, DataModel:Developer.DataModelService, KubernetesState, $templateCache:ng.ITemplateCacheService, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL, $element) => {
init($scope,location,$routeParams);
$scope.model=DataModel;
$scope.model.initParamOptions();
$scope.options = DataModel.paramOptions;
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
$scope.options.dataType = getDataType($location);
$scope.model.updateModel();
//配置数据表格需要显示的内容及显示格式
$scope.tableConfig = {
data: 'model.data',
enableRowClickSelection: true,
showSelectionCheckbox: true,
multiSelect: true,
selectedItems: [],
filterOptions: {
filterText: $location.search()["q"] || ''
},
columnDefs: [
{
field: "_key",
displayName: '编码',
customSortField: (field) =>{
return field.id;
//console.log(field);
}
},
{
field: "name",
displayName: '市-区/县'
},
{
field: "systemName",
displayName: '系统名称'
},
{
field: "collectingTime",
displayName: '采集时间'
},
{
field: "collectorName",
displayName: '汇总状态'
},
{
field: "collectorContacts",
displayName: '联系方式'
}
]
};
$scope.dataForTheTree = $scope.model.serverdata;
$scope.dataForTheTreeLocal = $scope.model.localdata;
$scope.$watch('model.serverdata', function(newValue,oldValue){
if(newValue){
$scope.dataForTheTree = $scope.model.serverdata;
}
});
$scope.$watch('model.localdata', function(newValue,oldValue){
if(newValue){
$scope.dataForTheTreeLocal = $scope.model.localdata;
}
$scope.selectBatchItem = (item)=> {
$scope.navbarItems.forEach((nav) =>{
nav.class="";
});
$scope.upLoadXMLFile = (files) => {
FilterList.length=0;
if(files.length>0){
var j=0;
for(var i=0;i<files.length;i++){
if(files[i].name.indexOf("data.xml")!=-1){
//console.log(files[i]);
rootPath=files[i].webkitRelativePath.replace(/\/data.xml$/,"");
var reader= new FileReader();
var resultString = "{\"name\": \"数据\", \"children\":[";
reader.onload = function(){
var str = event.target.result;
// alert(str);
var item = "<Data>";
var itemEnd = "</Data>";
// ´ý·µ»ØµÄ½á¹û£º
if(str != undefined){
// Õû¸öxml ÍêÕûÊý¾Ý£ºxmldata
var xmldata = str.toString();
// °´¶ÔÏó·ÖµÄÊý¾Ý£º
var itemArray = xmldata.split(item);
var itemsize = itemArray.length;
for(var k = 1; k < itemsize; k++){
var itemvalue = itemArray[k].split(itemEnd);
// province
var provinceValueTemp = itemvalue[0].split("<province>");
var provinceValue = provinceValueTemp[provinceValueTemp.length-1].split("</province>")[0];
//city
var cityValueTemp = itemvalue[0].split("<city>");
var cityValue = cityValueTemp[cityValueTemp.length-1].split("</city>")[0];
// county
var countyValueTemp = itemvalue[0].split("<county>");
var countyValue = countyValueTemp[countyValueTemp.length-1].split("</county>")[0];
// <code>
var codeValueTemp = itemvalue[0].split("<code>");
var codeValue = codeValueTemp[codeValueTemp.length-1].split("</code>")[0];
// <sys_name>
var sys_nameValueTemp = itemvalue[0].split("<sys_name>");
var sys_nameValue = sys_nameValueTemp[sys_nameValueTemp.length-1].split("</sys_name>")[0];
// <character_set>
var character_setValueTemp = itemvalue[0].split("<character_set>");
var character_setValue = character_setValueTemp[character_setValueTemp.length-1].split("</character_set>")[0];
// <sys_name_code>
var sys_name_codeValueTemp = itemvalue[0].split("<sys_name_code>");
var sys_name_codeValue = sys_name_codeValueTemp[sys_name_codeValueTemp.length-1].split("</sys_name_code>")[0];
// <contact>
var contactValueTemp = itemvalue[0].split("<contact>");
var contactValue = contactValueTemp[contactValueTemp.length-1].split("</contact>")[0];
// <phone>
var phoneValueTemp = itemvalue[0].split("<phone>");
var phoneValue = phoneValueTemp[phoneValueTemp.length-1].split("</phone>")[0];
// <date>
var dateValueTemp = itemvalue[0].split("<date>");
var dateValue = dateValueTemp[dateValueTemp.length-1].split("</date>")[0];
//id :
var itemId = codeValue + "_" + sys_name_codeValue;
// http get version
var rid = itemId//.replace(/\"/g, "");
// TODO typeValue 通过前端页面获取或者财政01或社保02
var typeValue = "01";
// TODO batchValue 通过前端页面获取或者批次A 大写的A批次B 大写的B
var batchValue = "A";
var itemname = cityValue + countyValue + sys_nameValue;
var versionid = 1;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
versionid = xhr.responseText;
}
}
item.class="active";
if(item.label === "全部")
$scope.model.updateParamOption("dataBatch", null);
else
$scope.model.updateParamOption("dataBatch", item.alias);
}
xhr.open("get","/getversion?id="+rid, false);
xhr.send(null);
var jsobj = JSON.parse(versionid);
var xmlversion = jsobj.id;
var properValue = "{\"id\":\""+itemId+"\", \"name\":\""+itemname+"\", \"city\":\""+
cityValue + "\", \"county\":\""+countyValue+"\", \"system\":\""+
sys_nameValue+"\", \"type\":\"" + typeValue + "\",\"batch\":\""+
batchValue+"\",\"version\":\""+xmlversion+"\", \"province\":\""+
provinceValue +"\", \"code\":\""+
codeValue +"\", \"character_set\":\""+
character_setValue +"\", \"sys_name_code\":\""+
sys_name_codeValue +"\", \"contact\":\""+
contactValue +"\", \"phone\":\""+
phoneValue +"\", \"date\":\""+
dateValue +"\"}";
resultString = resultString + properValue;
if(k < itemsize-1){
resultString =resultString+", "
}
}
resultString = resultString+"]}";
$scope.isEmptyOrFirst = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length <= 0 || idx <= 1;
}
$scope.$apply(function(){
$scope.model.localdata = JSON.parse(resultString.toString());
});
}
reader.readAsText(files[i],"utf-8");
}
else{
FilterList.length+=1;
var file_id=files[i].name.replace(/\.\w*$/,'');
// var file_id=file[i].webkitRelativePath.replace(/^[a-z]*\/$/,'');
// file_id = file_id.replace(/\/\w+$/,'');
FilterList[j++]=files[i];
}
}
}
$scope.model.uploadprocess = {};
$scope.isEmptyOrLast = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length < 1 || idx >= length;
}
$scope.upLoadFiles = ()=>{
if($scope.model.uploadedStatus == "once"){
return;
}
$scope.model.uploadedStatus = "once";
$scope.model.createFolderList(FilterList,rootPath);
if($scope.model.folderList.length >0 && $scope.model.selectednodes.length >0){
var isNotExited = [];
var isExited = [];
for(var node in $scope.model.selectednodes){
if(!$scope.model.folderList.hasOwnProperty($scope.model.selectednodes[node].id)){
isNotExited.push($scope.model.selectednodes[node]);
}else{
if($scope.model.uploadprocess[$scope.model.selectednodes[node].id] === 'undefined' || $scope.model.uploadprocess[$scope.model.selectednodes[node].id] === 0)
isExited.push($scope.model.selectednodes[node]);
$scope.first = () => {
var idx = $scope.model.getParamOption("currentPageNum");
if(idx >1)
$scope.model.updateParamOption("currentPageNum", 1);
}
}
if(isNotExited.length >0 ){
var str = "以下数据文件不存在:\n\r文件名:\n";
for(var item in isNotExited)
str += isNotExited[item].id+"\n";
alert(str);
}
if(isExited.length <=0){
alert("数据文件中没有可用上传的文件!");
}else{
var isuploaad = 1,i = 0;
var timerForUpload = $interval(function(){
if(i >= isExited.length){
// clearInterval(timerForUpload);
$interval.cancel(timerForUpload);
$scope.last = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx < length)
$scope.model.updateParamOption("currentPageNum", length);
}
if(isuploaad == 1){
var r = new Resumable({
target:'/uploadfiles',
chunkSize:50*1024*1024,
simultaneousUploads:400,
testChunks:true,
throttleProgressCallbacks:1
});
var xhr = new XMLHttpRequest();
xhr.open("GET","/getclientip",true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
r.setip(xhr.responseText);
}
}
$scope.previous = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx > 1)
$scope.model.updateParamOption("currentPageNum", idx-1);
}
xhr.send(null);
r.on('fileAdded', function(file){
r.upload();
update();
});
$scope.model.resumablejs.push({
dirname : isExited[i].id,
resumable : r
});
r.setRootPath(isExited[i].type+"/"+isExited[i].batch+"/"+isExited[i].id+"/"+isExited[i].version+"/");
r.myLoadFiles($scope.model.folderList[isExited[i].id]);
r.upload();
r.on('fileProgress',function(file){
var file_id=file.relativePath.replace(/^[a-z]*\/$/,'');
var filestr = "";
var reg = /\/[0-9]*_*[0-9]*\//g;
var resultstr;
while( (resultstr = reg.exec(file_id)) != null){
filestr = resultstr[0];
$scope.next = () =>{
var length =$scope.options.getPageSizeNum();
var idx = $scope.model.getParamOption("currentPageNum");
if(idx < length)
$scope.model.updateParamOption("currentPageNum", idx+1);
}
file_id = filestr.replace(/\/*/g,'');
r.setFileId(file_id);
// $scope.$apply(function(){
$scope.model.uploadprocess[file_id] = Math.floor(r.progress()*98);
// });
});
r.on('complete', function(){
var timerForchmod = setInterval(function(){
var pathjson = "\"path\":\""+r.getrootPath()+"\""
var datamessage = {"path":r.getrootPath(),"filenum":$scope.model.folderList[isExited[i-1].id].length};
$scope.model.uploadprocess[r.getFileId()] = Math.round(r.progress()*99);
$scope.$watch('options', (newValue, oldValue) => {
if(newValue && newValue !== oldValue){
if(newValue.currentTableSize !== oldValue.currentTableSize)
$scope.options.priorTableSize = oldValue.currentTableSize;
else
$scope.options.priorTableSize = newValue.currentTableSize;
$http({
url:'/setchmod2dir',
method:'GET',
params:datamessage
}).success(function(data,header,config,status){
if(data){
//console.log(data);
var clientdata = data;
if(clientdata == "chmod"){
sendDateMessage(isExited[i-1]);
r.setisnowcheck("1");
r.mkRetfileUploadSucceed();
clearInterval(timerForchmod);
}
DataModel.updateModel();
}
}).error(function(data,header,config,status){
console.log("-----sendDateMessage-------------"+status);
});
}, true);
},5000);
$scope.deletePrompt = (items) =>{
var idColl = [];
angular.forEach(items,(item) => {
idColl.push(item.id);
console.log(item.id);
});
i++;
isuploaad = 0;
r.on('fileuploadendsucceed', function(){
$scope.model.uploadprocess[r.getFileId()] = Math.floor(r.progress()*100);
$timeout(() => {
$http({
url:'/xmlformserver',
method:'Post'
}).success(function(data,header,config,status){
if(data){
$scope.model.serverdata = data;
}
}).error(function(data,header,config,status){
console.log("error");
});
},2000);
isuploaad = 1;
});
}
},2000);
}
}else{
alert("您没有选择需要上传的数据文件,或你选择的文件中不存在指定格式的数据文件!");
}
}
function sendDateMessage(datamessage){
$http({
url:'/sendDateMessage',
method:'GET',
params:datamessage
}).success(function(data,header,config,status){
if(data)
var clientdata = data;
}).error(function(data,header,config,status){
method: "POST",
url: "/java/console/api/delete/data",
params: {"data": idColl}
}).success(function(data, status, headers, config) {
//成功之后做一些事情
DataModel.updateModel();
}).error(function(data, status, headers, config) {
});
}
$scope.createOracleService = (items) =>{
angular.forEach(items,(item)=>{
console.log(item);
Kubernetes.createRC({
name: item._key,
labels: {
system: item.systemCode.toString(),
version: item.dataVersion.toString(),
region: item.regionalismCode.toString()
},
annotations: {
cityName: item.cityName,
districtName: item.districtName,
systemName: item.systemName
},
path: item.dataPath+"app/",
isTarget: "false"
}, (rc) =>{
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "create", Kubernetes.getName(rc), 0);
});
}
$scope.downLoadFiles = ()=>{
//Kubernetes.connectOracle($http, $timeout, "192.168.0.103:64182", "320614-54-1", 500);
}
$scope.isSelected= (node)=>{
var index = $scope.model.findItemIndex(node);
if(index !== -1){
$scope.model.selecteditems.splice(index,1);
}
else{
$scope.model.selecteditems.push(node);
}
}
$scope.showSelectedLocal = (node,selected) => {
var index = $scope.model.findNodes(node);
if(index !== "-1"){
if($scope.model.uploadprocess[node.id] ===0)
$scope.model.selectednodes.splice(index,1);
}else{
$scope.model.uploadprocess[node.id] =0;
$scope.model.selectednodes.push(node);
}
}
$scope.startOracle = ()=> {
if($scope.model.selecteditems.length >0){
for(var id in $scope.model.selecteditems){
var Obj = createRCObj($scope.model.selecteditems[id]);
if(!checkIsRunning(KubernetesModel.replicationControllers,Obj)){
Kubernetes.createRC(Obj, (rc) =>{
console.log(rc);
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "create", rc.metadata.name, 0);
});
}
}
}
}
function checkIsRunning(replicationControllers,item){
for(var rc in replicationControllers){
if(item.name === replicationControllers[rc].metadata.name)
return true;
}
return false;
}
function createRCObj(item: Object){
var array =item.id.split("_");
if(array[0] === "10"){
//console.log(item);
return {
"name": item.fakename,
"labels": {
"name": item.fakename
function init($scope,$location,$routeParams){
//创建二级菜单
$scope.subTabConfig = Developer.createCurrentSubNavBar($scope, $location, $routeParams);
$scope.navbarItems =[{
herf: "",
label: "全部",
title: "查看全部数据",
class: "active",
alias: null
},
"path": item.path +"app/",
"isTarget" : "true"
}
}else{
return {
"name": array[2] + "-" + array[3] + "-" + array[4],
"labels": {
"type": array[0],
"batch": array[1],
"region": array[2],
"system": array[3],
"version": array[4]
{
herf: "",
label: "批次A",
title: "查看批次A的数据",
class: "",
alias: "A"
},
"path": item.path +"app/",
"isTarget": "false"
}
}
}
function setchmod2dir(datamessage){
$http({
url:'/setchmod2dir',
method:'GET',
params:datamessage
}).success(function(data,header,config,status){
if(data)
var clientdata = data;
}).error(function(data,header,config,status){
console.log("-----sendDateMessage-------------"+status);
});
}
function update(){
for(var i=0; i<$scope.model.resumablejs.length; i++){
var dirId = $scope.model.resumablejs[i].dirname;
var r = $scope.model.resumablejs[i].resumable;
r.on('fileProgress', (file) =>{
if(r.getisnowcheck().indexOf("0") == -1){
$scope.$apply(function(){
$scope.model.uploadprocess[dirId] = Math.floor(r.progress()*100);
});
}
else{
$scope.$apply(function(){
$scope.model.uploadprocess[dirId] = Math.floor(r.progress()*98);
});
}
});
}
{
herf: "",
label: "批次B",
title: "查看批次B的数据",
class: "",
alias: "B"
}]
}
function getDataType($location){
var path = $location.path();
var result;
var subPath = path.split("/");
switch (subPath[subPath.length -1]) {
case "financial":
result = "财政"
break;
case "social-security":
result = "社保"
break;
default:
result = null;
break;
}
return result;
}
}]);
}

@ -1737,9 +1737,9 @@ module Kubernetes {
var client = Kubernetes.createKubernetesClient('replicationcontrollers','default');
var RCTemplate = new resourceRCTemplate();
var rcTemplate = RCTemplate.createRC(obj);
//console.log(rcTemplate);
console.log(JSON.stringify(rcTemplate));
client.put(rcTemplate, function(obj) {
//console.log("Created: ", obj);
console.log("Created: ", obj);
if (angular.isFunction(onCompleteFn)) {
onCompleteFn(obj);
}
@ -1847,4 +1847,17 @@ module Kubernetes {
return false;
}
}
export function replicasIsCreated (replicationcontrollers:Array<any>, name:string){
var result = false;
if( replicationcontrollers !=null || replicationcontrollers.length<=0){
for(var i=0; i<replicationcontrollers.length;i++){
if(getName(replicationcontrollers[i]) === name){
result = true;
break;
}
}
}
return result;
}
}

@ -26,7 +26,8 @@ module Kubernetes {
.when(UrlHelpers.join(context, 'pipelines'), route('pipelines.html', false))
.when(UrlHelpers.join(context, 'overview'), route('overview.html', true))
.when(context, {redirectTo: UrlHelpers.join(context, 'replicationControllers')});
console.log("===================");
console.log(context);
angular.forEach([context, "/workspaces/:workspace/projects/:project"], (context) => {
$routeProvider

@ -84,16 +84,12 @@ module Kubernetes {
if (result) {
function deleteSelected(selected:Array<KubePod>, next:KubePod) {
if (next) {
log.debug("deleting: ", getName(next));
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
log.debug("updated number of replicas");
KubernetesReplicationControllers.delete({
id: getName(next)
}, undefined, () => {
log.debug("deleted: ", getName(next));
if(next.metadata.labels.style === "oracle"){
console.log("delete " + next.metadata.name);
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "delete", getName(next), 0);
Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "delete", getName(next), 0);
}
deleteSelected(selected, selected.shift());
}, (error) => {
@ -101,16 +97,6 @@ module Kubernetes {
deleteSelected(selected, selected.shift());
});
});
/*KubernetesReplicationControllers.delete({
id: getName(next)
}, undefined, () => {
log.debug("deleted: ", getName(next));
deleteSelected(selected, selected.shift());
}, (error) => {
log.debug("Error deleting: ", error);
deleteSelected(selected, selected.shift());
});*/
}
}
deleteSelected(selected, selected.shift());
@ -127,44 +113,16 @@ module Kubernetes {
}
$scope.createRCs= () => {
var xhr= new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {//4表示数据已经调用完成
if (xhr.status == 200) {//HTTP的状态码
var obj=JSON.parse(xhr.responseText);
//console.log(obj.path);
var name = obj.name;
//console.log(name + "=====" +port);
var object = {
"name": name,
"labels": {
"name" : name
},
"path": obj.path,
"isTarget": "true"
}
console.log(object);
Kubernetes.createRC(object, (rc) =>{
$http({
url:'/xmlformserver',
method:'Post'
url: '/java/console/api/cancelOracleConection',
dataType: 'json',
method:'POST',
params:{param: "data"}
}).success(function(data,header,config,status){
if(data){
DataInfoModel.serverdata = data;
}
console.log("success");
}).error(function(data,header,config,status){
console.log("error");
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
});
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "create", getName(rc), 0);
});
}else if(xhr.status == 403){
alert("两次创建oracle服务时间间隔需要超过2分钟!");
}else{
}
}
};
xhr.open("POST", "/oracleAppPath", false);//与服务器连接并发送
xhr.send(null);
}
$scope.stopPrompt = (selected) =>{
@ -183,8 +141,7 @@ module Kubernetes {
if (next) {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
if(next.metadata.labels.style === "oracle"){
console.log("stop " + next.metadata.name);
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "stop", getName(next), 0);
Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "stop", getName(next), 0);
}
stopSelected(selected, selected.shift());
});
@ -209,7 +166,7 @@ module Kubernetes {
if(next.$replicas === 0)
Kubernetes.resizeController($http, KubernetesApiURL, next, 1, () => {
console.log("restart " + next.metadata.name);
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "reStart", getName(next), 0);
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "reStart", getName(next), 0);
startSelected(selected, selected.shift());
});
}

@ -46,7 +46,7 @@ module Kubernetes {
export class resourceRCTemplate{
public image="s1:latest";
public image="oracle:utf8";
public names = ["admin","cfgtoollogs","checkpoints","diag","flash-recovery-area","oradata"];
public createRC(Obj){
@ -64,7 +64,8 @@ module Kubernetes {
"kind" : "ReplicationController",
"metadata" : {
"name" : Obj.name,
"labels" : labels
"labels" : labels,
"annotations": Obj.annotations
},
"spec" : {
replicas : Obj.replicas || 1,

@ -40,6 +40,18 @@ module Navigation {
return self;
});
_module.directive('hawtioRelativeHref', ['$location', ($location) => {
return {
restrict: 'A',
link: (scope, element, attr) => {
var targetPath = attr['hawtioRelativeHref'];
var targetHref = new URI($location.url());
targetHref.segment(targetPath);
element.attr('href', targetHref.toString());
}
}
}]);
_module.directive('viewportHeight', ['$window', '$document', ($window, $document) => {
return {
restrict: 'A',
@ -68,15 +80,15 @@ module Navigation {
return {
restrict: 'A',
link: (scope, element, attrs) => {
scope.HawtioSubTabs = HawtioSubTabs;
scope.$watchCollection('HawtioSubTabs.get()', (subTabConfig) => {
scope.tabs = HawtioSubTabs;
scope.$watchCollection('tabs.get()', (tabs) => {
// log.debug("subTabConfig: ", subTabConfig);
if (subTabConfig && subTabConfig.length > 0) {
if (tabs && tabs.length > 0) {
element.removeClass('hidden-nav');
//element.css({ 'margin-left': '' });
element.css({ 'margin-left': '' });
} else {
element.addClass('hidden-nav');
//element.css({ 'margin-left': 'auto' });
element.css({ 'margin-left': 'auto' });
}
});
}
@ -91,30 +103,31 @@ module Navigation {
replace: true,
template: `
<div class="nav-pf-vertical nav-pf-vertical-with-secondary-nav" ng-controller="Developer.NavBarController" ng-class="getClass()">
<ul class="list-group">
<li ng-repeat="subTab in subTabConfig" ng-show="isValid(subTab)"
<div class="list-group">
<div ng-repeat="subTab in subTabConfig" ng-show="true"
class="list-group-item {{subTab.active ? 'active' : ''}}"
title="{{subTab.title}}">
<a ng-hide="subTab.template" href="{{subTab.href}}">
<span ng-show="subTab.class" ng-class="subTab.class"></span>
<img ng-show="subTab.icon" ng-src="{{subTab.icon}}" style="max-width: 16px; margin-right: 13px;">
<img ng-show="subTab.icon" ng-src="{{subTab.icon}}">
{{subTab.label}}
</a>
<div ng-show="subTab.template" compile="subTab.template"></div>
</li>
</ul>
</div>
</>
</div>
`,
link: (scope, element, attrs) => {
if (!initialized) {
try {
(<any>$)().setupVerticalNavigation(false);
//(<any>$)().setupVerticalNavigation(false);
} catch (err) {
// ignore if we haven't loaded patternfly
}
initialized = true;
}
scope.HawtioSubTabs = HawtioSubTabs;
var collapsed = false;
scope.getClass = () => {
//log.debug("My class: ", element.attr('class'));
@ -131,32 +144,105 @@ module Navigation {
});
scope.$watch('HawtioSubTabs.get()', (subTabConfig) => {
scope.subTabConfig = subTabConfig;
});
}
};
}]);
_module.directive('hawtioBreadcrumbsOutlet', ['HawtioBreadcrumbs', (HawtioBreadcrumbs) => {
_module.directive('hawtioBreadcrumbsOutlet', ['HawtioBreadcrumbs', 'HawtioSubTabs', (HawtioBreadcrumbs, HawtioSubTabs) => {
return {
restrict: 'E',
scope: {},
template: `
<div ng-show="breadcrumbConfig" ng-controller="Developer.NavBarController">
<div class="nav navbar-nav nav-breadcrumb nav-breadcrumbs" ng-show="breadcrumbConfig" ng-controller="Developer.NavBarController">
<ol class="breadcrumb">
<div class = 'br'><br></div>
<li ng-repeat="breadcrumb in breadcrumbConfig" ng-show="isValid(breadcrumb)"
<li ng-repeat="breadcrumb in breadcrumbConfig" ng-show="isValid(breadcrumb) && label(breadcrumb)"
class="{{breadcrumb.active ? 'active' : ''}}"
ng-class="$last ? 'dropdown' : ''"
title="{{breadcrumb.title}}">
<a ng-show="breadcrumb.href && !breadcrumb.active" href="{{breadcrumb.href}}">{{breadcrumb.label}}</a>
<span ng-hide="breadcrumb.href && !breadcrumb.active">{{breadcrumb.label}}</span>
<a ng-show="breadcrumb.href" href="{{breadcrumb.href}}">{{label(breadcrumb)}}</a>
<span ng-hide="breadcrumb.href">{{label(breadcrumb)}}</span>
</li>
<li ng-show="pageTitle">
<span ng-bind="pageTitle"></span>
</li>
</ol>
</div>
`,
link: (scope, element, attrs) => {
scope.breadcrumbs = HawtioBreadcrumbs;
scope.tabs = HawtioSubTabs;
scope.$watchCollection('breadcrumbs.get()', (breadcrumbConfig) => {
scope.breadcrumbConfig = breadcrumbConfig;
});
scope.$watchCollection('tabs.get()', (tabs) => {
var active = _.find(tabs, (tab:any) => tab.active);
if (active) {
scope.pageTitle = active.label;
} else {
scope.pageTitle = undefined;
}
});
}
};
}]);
_module.directive('platformSubTabsOutlet', ['HawtioSubTabs', (HawtioSubTabs) => {
var initialized = false;
return {
restrict: 'AE',
replace: true,
template: `
<div class="nav-pf-vertical nav-pf-vertical-with-secondary-nav" ng-controller="Developer.NavBarController" ng-class="getClass()">
<ul class="navbar-lf-menu">
<li ng-repeat="subTab in subTabConfig">
<div class="expandable closed" ng-show="subTab.items.length">
<div title="The title" class="title">
<i class="expandable-indicator"><span style="font-size:12px;color:red">{{subTab.label}}</i>
</div>
<ul class="expandable-body well">
<li ng-repeat="item in subTab.items">
<a href="{{item.href}}">{{item.label}}</a>
</li>
</ul>
</div>
<div ng-hide="subTab.items.length">
<a href="{{subTab.href}}">{{subTab.label}}</a>
</div>
</li>
</ul>
</div>
`,
link: (scope, element, attrs) => {
if (!initialized) {
try {
//(<any>$)().setupVerticalNavigation(false);
} catch (err) {
// ignore if we haven't loaded patternfly
}
initialized = true;
}
scope.HawtioSubTabs = HawtioSubTabs;
var collapsed = false;
scope.getClass = () => {
//log.debug("My class: ", element.attr('class'));
if (!scope.subTabConfig || !scope.subTabConfig.length) {
return 'hidden';
}
if (collapsed) {
return 'collapsed';
}
return '';
}
scope.$on('hawtioCollapseNav', () => {
collapsed = !collapsed;
});
scope.$watch('HawtioSubTabs.get()', (subTabConfig) => {
scope.subTabConfig = subTabConfig;
});
}
};
}]);

Loading…
Cancel
Save