修复数据分页显示bug

This commit is contained in:
wu ming 2016-09-03 15:03:40 +08:00
parent 92e5814d5c
commit 7efdc5d699
19 changed files with 1810 additions and 2363 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

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

2
defs.d.ts vendored
View File

@ -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"/>

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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>-->
<ul class="nav navbar-nav navbar-primary" hawtio-main-nav></ul>
<ul class="nav navbar-nav navbar-persistent" hawtio-sub-tabs></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>
</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> -->
<div ng-include src="viewPartial"></div>
<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>
</body>
</html>

Binary file not shown.

View File

@ -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>
<div class="row">
<div hawtio-tabs></div>
</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 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>
</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 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 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>
</div>
</div>
</div>
</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>

View File

@ -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,55 +82,64 @@ 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 = [
{
href: UrlHelpers.join(projectLink, "environments"),
label: "Environments",
title: "View the environments for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: envName,
title: "View the runtime of the workspace: " + ns
}
];
return createProjectBreadcrumbs(project, children, workspaceName);
} else {
if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace();
}
return activateCurrent([
//homeBreadcrumb(),
operateBreadcrumb(),
var children: Array<BreadcrumbConfig> = [
{
href: UrlHelpers.join(projectLink, "environments"),
label: "Environments",
title: "View the environments for this project"
},
{
href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: workspaceName,
label: () => environmentName(workspaceName, ns),
title: "View the runtime of the workspace: " + ns
}
]);
];
return createProjectBreadcrumbs(project, children, 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();
}
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);
}
export function createProjectBreadcrumbs(projectName = null, children = null, workspaceName = null) {
/**
* 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: 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);
}
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"
},
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(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;
}

View File

@ -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) => {
_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(() => '数据汇总')
//.isValid(() => !Core.isRemoteConnection())
.tabs(workspaces)
.title(() => '数据管理')
//.isValid(() => !Core.isRemoteConnection())
.build();
HawtioNav.add(Aggregate);
HawtioNav.add(dmanagerTab);
}]);
_module.filter('asTrustedHtml', ['$sce', function ($sce) {

View File

@ -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", "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);
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.model=DataModel;
$scope.model.initParamOptions();
$scope.options = DataModel.paramOptions;
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
$scope.options.dataType = getDataType($location);
$scope.localitems=[];
var rootPath="";
var FilterList ={
length:0
};
$scope.model.updateModel();
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.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.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.selectBatchItem = (item)=> {
$scope.navbarItems.forEach((nav) =>{
nav.class="";
});
item.class="active";
if(item.label === "全部")
$scope.model.updateParamOption("dataBatch", null);
else
$scope.model.updateParamOption("dataBatch", item.alias);
}
$scope.showSelected = (node,selected)=>{
$scope.isEmptyOrFirst = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length <= 0 || idx <= 1;
}
$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);
}
}
};
$scope.isEmptyOrLast = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length < 1 || idx >= length;
}
$scope.dataForTheTree = $scope.model.serverdata;
$scope.dataForTheTreeLocal = $scope.model.localdata;
$scope.first = () => {
var idx = $scope.model.getParamOption("currentPageNum");
if(idx >1)
$scope.model.updateParamOption("currentPageNum", 1);
}
$scope.$watch('model.serverdata', function(newValue,oldValue){
if(newValue){
$scope.dataForTheTree = $scope.model.serverdata;
}
});
$scope.last = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx < length)
$scope.model.updateParamOption("currentPageNum", length);
}
$scope.$watch('model.localdata', function(newValue,oldValue){
if(newValue){
$scope.dataForTheTreeLocal = $scope.model.localdata;
}
});
$scope.previous = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx > 1)
$scope.model.updateParamOption("currentPageNum", idx-1);
}
$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);
$scope.next = () =>{
var length =$scope.options.getPageSizeNum();
var idx = $scope.model.getParamOption("currentPageNum");
if(idx < length)
$scope.model.updateParamOption("currentPageNum", idx+1);
}
// 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;
}
}
}
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.$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.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]);
}
}
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);
}
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);
}
}
}
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];
}
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);
$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);
}
}
}).error(function(data,header,config,status){
console.log("-----sendDateMessage-------------"+status);
});
},5000);
});
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("您没有选择需要上传的数据文件,或你选择的文件中不存在指定格式的数据文件!");
}
$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;
DataModel.updateModel();
}
}, true);
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){
$scope.deletePrompt = (items) =>{
var idColl = [];
angular.forEach(items,(item) => {
idColl.push(item.id);
console.log(item.id);
});
$http({
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);
}
function init($scope,$location,$routeParams){
//创建二级菜单
$scope.subTabConfig = Developer.createCurrentSubNavBar($scope, $location, $routeParams);
$scope.navbarItems =[{
herf: "",
label: "全部",
title: "查看全部数据",
class: "active",
alias: null
},
{
herf: "",
label: "批次A",
title: "查看批次A的数据",
class: "",
alias: "A"
},
{
herf: "",
label: "批次B",
title: "查看批次B的数据",
class: "",
alias: "B"
}]
}
$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
},
"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]
},
"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);
});
}
});
}
}
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;
}
}]);
}

View File

@ -942,7 +942,7 @@ module Kubernetes {
var url = kubernetesUrlForKind(KubernetesApiURL, "ReplicationController", namespace, id);
$http.get(url).
success(function (data, status, headers, config) {
if (data) {
if (data) {
var desiredState = data.spec;
if (!desiredState) {
desiredState = {};
@ -1737,16 +1737,16 @@ 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);
}
});
}
export function connectOracle($http, $timeout, url, operation, rcName, delayTime){
export function connectOracle($http, $timeout, url, operation, rcName, delayTime){
$timeout(() => {
$http({
url: url,
@ -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;
}
}

View File

@ -26,9 +26,10 @@ 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) => {
angular.forEach([context, "/workspaces/:workspace/projects/:project"], (context) => {
$routeProvider
.when(UrlHelpers.join(context, '/namespace/:namespace/podCreate'), route('podCreate.html', false))
.when(UrlHelpers.join(context, '/namespace/:namespace/podEdit/:id'), route('podEdit.html', false))

View File

@ -83,34 +83,20 @@ module Kubernetes {
onClose: (result:boolean) => {
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");
if (next) {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
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);
}
}, undefined, () => {
if(next.metadata.labels.style === "oracle"){
Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "delete", getName(next), 0);
}
deleteSelected(selected, selected.shift());
}, (error) => {
log.debug("Error deleting: ", error);
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());
@ -126,45 +112,17 @@ module Kubernetes {
}).open();
}
$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'
}).success(function(data,header,config,status){
if(data){
DataInfoModel.serverdata = data;
}
}).error(function(data,header,config,status){
console.log("error");
});
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.createRCs= () => {
$http({
url: '/java/console/api/cancelOracleConection',
dataType: 'json',
method:'POST',
params:{param: "data"}
}).success(function(data,header,config,status){
console.log("success");
}).error(function(data,header,config,status){
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
});
}
$scope.stopPrompt = (selected) =>{
@ -182,9 +140,8 @@ module Kubernetes {
function stopSelected(selected:Array<KubePod>, next:KubePod) {
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);
if(next.metadata.labels.style === "oracle"){
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());
});
}

View File

@ -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,

View File

@ -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,31 +144,104 @@ 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) => {
link: (scope, element, attrs) => {
scope.breadcrumbs = HawtioBreadcrumbs;
scope.tabs = HawtioSubTabs;
scope.$watchCollection('breadcrumbs.get()', (breadcrumbConfig) => {
scope.breadcrumbConfig = 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;
});
}
};