修复数据分页显示bug

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

@ -1,14 +1,45 @@
/// <reference path="../../includes.d.ts" /> /// <reference path="../../includes.d.ts" />
declare module Developer { 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 workspaceLink(): string;
function projectLink(projectId: any): string; function projectLink(projectId: any): string;
function createWorkspacesBreadcrumbs(developPerspective: any): any[]; function createWorkspacesBreadcrumbs(developPerspective?: any): BreadcrumbConfig[];
function createWorkspacesSubNavBars(developPerspective: any): any; function createWorkspacesSubNavBars(developPerspective: any): any;
function createWorkspaceBreadcrumbs(children?: any, workspaceName?: any): any; function createWorkspaceBreadcrumbs(children?: any, workspaceName?: any): any;
function createEnvironmentBreadcrumbs($scope: any, $location: any, $routeParams: 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 createProjectSettingsBreadcrumbs(projectName: any, workspaceName?: any): any;
function createWorkspaceSubNavBars(): 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 createProjectSubNavBars(projectName: any, jenkinsJobId?: any, $scope?: any): any;
function createProjectSettingsSubNavBars(projectName: any, jenkinsJobId?: any): any; function createProjectSettingsSubNavBars(projectName: any, jenkinsJobId?: any): any;
function forgeProjectHasBuilder(name: any): any; function forgeProjectHasBuilder(name: any): any;
@ -20,9 +51,13 @@ declare module Developer {
function projectSecretsLink(workspaceName: any, projectName: any): string; function projectSecretsLink(workspaceName: any, projectName: any): string;
function secretsNamespaceLink(workspaceName: any, projectName: any, secretsNamespace: any): string; function secretsNamespaceLink(workspaceName: any, projectName: any, secretsNamespace: any): string;
function projectWorkspaceLink(workspaceName: any, projectName: any, path: any, ignoreBlankProject?: boolean): 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[]; var customProjectSubTabFactories: any[];
function createJenkinsBreadcrumbs(projectName: any, jobId: any, buildId: any): any; function createJenkinsBreadcrumbs(projectName: any, jobId: any, buildId: any): any;
function createJenkinsSubNavBars(projectName: any, jenkinsJobId: any, buildId: any, extraOption?: any): any; function createJenkinsSubNavBars(projectName: any, jenkinsJobId: any, buildId: any, extraOption?: any): any;
function createEnvironmentSubNavBars($scope: any, $location: any, $routeParams: 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 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="../../kubernetes/ts/kubernetesHelpers.d.ts" />
/// <reference path="developerEnrichers.d.ts" /> /// <reference path="developerEnrichers.d.ts" />
/// <reference path="developerHelpers.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 { declare module Developer {
var WorkspacesController: ng.IModule; var WorkspacesController: ng.IModule;
} }

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

@ -24,6 +24,7 @@ declare module Kubernetes {
"isExtract": string; "isExtract": string;
"isTarget": any; "isTarget": any;
}; };
"annotations": any;
}; };
"spec": { "spec": {
replicas: any; 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/developerHelpers.d.ts"/>
/// <reference path="d.ts/developer/ts/developerNavigation.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/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/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/environmentPanel.d.ts"/>
/// <reference path="d.ts/developer/ts/home.d.ts"/> /// <reference path="d.ts/developer/ts/home.d.ts"/>
/// <reference path="d.ts/developer/ts/jenkinsJob.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; 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 */ /* This is for the 'Overview' page with all the rows of boxes */
.service-view-rectangle { .service-view-rectangle {
position: relative; position: relative;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -14,7 +14,6 @@
<link rel="stylesheet" href="libs/nvd3/build/nv.d3.css" /> <link rel="stylesheet" href="libs/nvd3/build/nv.d3.css" />
<link rel="stylesheet" href="libs/codemirror/lib/codemirror.css" /> <link rel="stylesheet" href="libs/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="libs/toastr/toastr.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/OpenSans.css" />
<link rel="stylesheet" href="libs/hawtio-ui/dist/DroidSansMono.css" /> <link rel="stylesheet" href="libs/hawtio-ui/dist/DroidSansMono.css" />
<link rel="stylesheet" href="libs/hawtio-ui/dist/ui.dynatree.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/dagre/dist/dagre.core.min.js"></script>
<script src="libs/zeroclipboard/dist/ZeroClipboard.js"></script> <script src="libs/zeroclipboard/dist/ZeroClipboard.js"></script>
<script src="libs/toastr/toastr.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/jquery-ui.custom.js"></script>
<script src="libs/hawtio-ui/dist/ui-bootstrap.js"></script> <script src="libs/hawtio-ui/dist/ui-bootstrap.js"></script>
<script src="libs/hawtio-ui/dist/ui-bootstrap-tpls.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/d3.js"></script>
<script src="libs/hawtio-ui/dist/tabbable.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-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/hawtio-forms.js"></script>
<script src="libs/hawtio-forms/dist/bootstrap-combobox.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/keycloak/dist/keycloak.js"></script>
<script src="libs/ng-idle/angular-idle.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-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/term.js/src/term.js"></script>
<script src="libs/kubernetes-container-terminal/dist/container-terminal.js"></script> <script src="libs/kubernetes-container-terminal/dist/container-terminal.js"></script>
<script src="libs/hawtio-kubernetes-api/dist/smokesignals.unminified.js"></script> <script src="libs/hawtio-kubernetes-api/dist/smokesignals.unminified.js"></script>
@ -135,34 +134,17 @@
</head> </head>
<body style="padding-top: 75px;"> <body style="padding-top: 75px;">
<nav class="navbar navbar-default navbar-fixed-top navbar-pf" role="navigation"> <nav class="navbar navbar-fixed-top navbar-pf" role="navigation">
<div class="navbar-header" hawtio-extension name="hawtio-header"> <a href="/" class="log fl"><img src="/" class="log-img"></a>
<div class="navbar-brand" href="/"><img /></div> <ul class="nav navbar-nav navbar-primary" hawtio-main-nav></ul>
</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> </nav>
<platform-sub-tabs-outlet></platform-sub-tabs-outlet>
<div id="main" class="container-fluid ng-cloak" ng-controller="HawtioNav.ViewController"> <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" style="margin-left: -20px; margin-right: -20px"> <div class="row" ng-class="getClass()">
<div hawtio-main-outlet ng-class="getClass()"><br><br> <hawtio-breadcrumbs-outlet></hawtio-breadcrumbs-outlet>
<!-- <hawtio-breadcrumbs-outlet></hawtio-breadcrumbs-outlet> --> <div ng-include src="viewPartial"></div>
<div ng-include src="viewPartial"></div>
</div> </div>
<!-- <hawtio-tabs-outlet></hawtio-tabs-outlet> -->
</div>
</div> </div>
<script src="dist/hawtio-kubernetes.js"></script> <script src="dist/hawtio-kubernetes.js"></script>
</body> </body>
</html> </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-breadcrumbs></div>
</div>
<div class="row">
<div hawtio-tabs></div> <div hawtio-tabs></div>
</div> <div class="container-content">
<header class="data_heaer"> <div class="container-fluid">
<h2 >江苏省审计厅数据汇总平台</h2> <div class="row nav-content">
</header> <ul class="nav nav-tabs" ng-show="navbarItems.length">
<div class="data_content"> <li role="presentation" ng-repeat="item in navbarItems" class="{{item.class}}"><a href="#" ng-click="selectBatchItem(item)">{{item.label}}</a></li>
<div class="data_leftside fl"> </ul>
<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> </div>
</ul> <div ng-hide="model.data.length" class="align-center">
<ul class="fl data_leftside_files "> <p class="alert alert-info">当前没有可以查看的数据.</p>
<li class=" data_title data_title_w">已选数据文件</li> </div>
<li ng-repeat="node in model.selectednodes" >{{node.name}}</li> <div ng-show="model.data.length">
<table class="table table-striped table-bordered" hawtio-simple-table="tableConfig"></table>
</ul> <div class="row">
<ul class="fl data_leftside_files " style="border-right:none;"> <div class="col-xs-6 col-sm-2">
<li class=" data_title data_title_w">采集时间</li> <button ng-show="true" class="btn btn-danger pull-right" ng-disabled="!id && tableConfig.selectedItems.length == 0" ng-click="deletePrompt(id || tableConfig.selectedItems)">
<li ng-repeat="node in model.selectednodes" >{{node.date}}&nbsp&nbsp <i class="fa fa-remove"></i> 删除数据
<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> </button>
</ul> <span class="pull-right">&nbsp;</span>
<div class="cl"></div> <button ng-show="id" class="btn btn-primary pull-right" ng-click="id = undefined"><i class="fa fa-list"></i></button>
<div class="date_btns"> <span class="pull-right">&nbsp;</span>
<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 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>
<a ng-click="upLoadFiles()" class="data_file_btn fl" >导入到服务器</a> <span class="pull-right">&nbsp;</span>
</div> </div>
<div class="cl"></div> <div class="col-md-6 col-md-offset-9">
</div><!--data_leftside end--> 每页显示&nbsp
<div class="data_rightside fr"> <select ng-options="value for value in pageSizeChoses" ng-change="selectAction()" ng-model="options.currentTableSize"></select>
<h3 class="data_h3">服务器文件列表</h3> &nbsp&nbsp当前页码
<div style="width: 259px; overflow-x:scroll; overflow-y:auto;" class="data_rightside_tree fl" > <div class="hawtio-pager clearfix">
<div treecontrol class="tree-classic" style="width: 459px; overflow-x:visible;" <label>{{options.currentPageNum}} / {{options.getPageSizeNum()}}</label>
tree-model="dataForTheTree" <div class=btn-group>
options="treeOptions" <button class="btn" ng-disabled="isEmptyOrFirst()" ng-click="first()"><i class="fa fa-fast-backward"></i></button>
on-selection="showSelected(node,selected)" <button class="btn" ng-disabled="isEmptyOrFirst()" ng-click="previous()"><i class="fa fa-step-backward"></i></button>
selected-node="node1"> <button class="btn" ng-disabled="isEmptyOrLast()" ng-click="next()"><i class="fa fa-step-forward"></i></button>
{{node.name}} <button class="btn" ng-disabled="isEmptyOrLast()" ng-click="last()"><i class="fa fa-fast-forward"></i></button>
</div>
</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>
<div class="cl"></div>
</div> </div>
<div class="cl"></div> <div class="prettify"></div>
</div>
</div> </div>

@ -1,23 +1,30 @@
/// <reference path="../../includes.ts"/> /// <reference path="../../includes.ts"/>
module Developer { module Developer {
/* var log = Logger.get('developer-navigation');
function homeBreadcrumb() {
return { export type LabelResolver = () => string;
href: "/home",
label: "Home", export interface BreadcrumbConfig {
title: "Go to the home page" href?: string;
} label?: string | LabelResolver;
title?: string;
class?: string;
isValid?: () => boolean;
isActive?: (subTab, path) => boolean;
} }
*/
function developBreadcrumb() {
function developBreadcrumb() : BreadcrumbConfig {
return { return {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces"), href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces"),
label: "Develop", label: "Teams",
title: "View all the apps for a project" title: "View all the available teams",
isActive: (subTab, path) => false
}; };
} }
function operateBreadcrumb() {
function operateBreadcrumb() : BreadcrumbConfig {
return { return {
href: UrlHelpers.join(HawtioCore.documentBase(), "/namespaces"), href: UrlHelpers.join(HawtioCore.documentBase(), "/namespaces"),
label: "Manage", label: "Manage",
@ -38,21 +45,8 @@ module Developer {
} }
} }
export function createWorkspacesBreadcrumbs(developPerspective) { export function createWorkspacesBreadcrumbs(developPerspective?) {
/* return [developBreadcrumb()];
if (developPerspective) {
return [
//homeBreadcrumb(),
developBreadcrumb()
];
} else {
return [
//homeBreadcrumb(),
operateBreadcrumb()
];
}
*/
return [];
} }
@ -64,10 +58,7 @@ module Developer {
} }
export function createWorkspaceBreadcrumbs(children = null, workspaceName = null) { export function createWorkspaceBreadcrumbs(children = null, workspaceName = null) {
var answer = [ var answer = createWorkspacesBreadcrumbs(true);
//homeBreadcrumb(),
developBreadcrumb()
];
if (!workspaceName) { if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace(); workspaceName = Kubernetes.currentKubernetesNamespace();
} }
@ -76,7 +67,8 @@ module Developer {
{ {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces/", workspaceName), href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces/", workspaceName),
label: workspaceName, label: workspaceName,
title: "View the project: " + workspaceName title: "View the project: " + workspaceName,
isActive: (subTab, path) => false
} }
); );
return processChildren(answer, children); return processChildren(answer, children);
@ -90,55 +82,64 @@ module Developer {
var namespacesLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/namespace"); var namespacesLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/namespace");
var workspaceName = $routeParams.workspace; var workspaceName = $routeParams.workspace;
var project = $routeParams.project; var project = $routeParams.project;
var environment = $routeParams.namespace;
if (workspaceName && project) { if (workspaceName && project) {
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", project); var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", project);
$scope.$projectLink = projectLink; $scope.$projectLink = projectLink;
$scope.$projectNamespaceLink = UrlHelpers.join(projectLink, "namespace", ns); $scope.$projectNamespaceLink = UrlHelpers.join(projectLink, "namespace", ns);
namespacesLink = UrlHelpers.join(projectLink, "namespace"); namespacesLink = UrlHelpers.join(projectLink, "namespace");
// TODO use the logical name? var children: Array<BreadcrumbConfig> = [
var envName = ns; {
var buildConfig = null; href: UrlHelpers.join(projectLink, "environments"),
if ($scope.model) { label: "Environments",
buildConfig = $scope.model.getProject(project, workspaceName); title: "View the environments for this project"
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(),
{ {
href: UrlHelpers.join(namespacesLink, ns, "apps"), href: UrlHelpers.join(namespacesLink, ns, "apps"),
label: workspaceName, label: () => environmentName(workspaceName, ns),
title: "View the runtime of the workspace: " + 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);
}
/**
* 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) { if (!workspaceName) {
workspaceName = Kubernetes.currentKubernetesNamespace(); workspaceName = Kubernetes.currentKubernetesNamespace();
} }
@ -168,12 +169,9 @@ module Developer {
export function createProjectSettingsBreadcrumbs(projectName, workspaceName = null) { export function createProjectSettingsBreadcrumbs(projectName, workspaceName = null) {
var children = [{ var children = [];
label: "Settings",
title: "View the settings of this app"
}];
if (!projectName) { if (!projectName) {
var children = [{ children = [{
label: "New App", label: "New App",
title: "Lets make a new app" title: "Lets make a new app"
}]; }];
@ -186,6 +184,12 @@ module Developer {
return activateCurrent([ return activateCurrent([
{ {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName), 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", label: "Apps",
class: "fa fa-rocket", class: "fa fa-rocket",
title: "View the apps in this project" title: "View the apps in this project"
@ -198,25 +202,78 @@ module Developer {
title: "View the builds in this project" title: "View the builds in this project"
}, },
{ {
href: UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/namespace", workspaceName, "apps"), href: environmentsLink(),
label: "Runtime", label: "Environments",
class: "fa fa-gears", class: "fa fa-cubes",
title: "View the runtime resources in this project" 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"), href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "detail"),
label: "Details", label: "Details",
class: "fa fa-gear", class: "fa fa-gear",
title: "View the project details" 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) { function createBuildsLink(workspaceName, projectName, jenkinsJobId) {
workspaceName = workspaceName || Kubernetes.currentKubernetesNamespace(); workspaceName = workspaceName || Kubernetes.currentKubernetesNamespace();
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "jenkinsJob", jenkinsJobId); 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) { export function createProjectSubNavBars(projectName, jenkinsJobId = null, $scope = null) {
var workspaceName = Kubernetes.currentKubernetesNamespace(); var workspaceName = Kubernetes.currentKubernetesNamespace();
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName); var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName);
@ -243,6 +300,7 @@ module Developer {
} }
var answer = [ var answer = [
/*
{ {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName), href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName),
label: "All Apps", label: "All Apps",
@ -252,20 +310,22 @@ module Developer {
{ {
template: `<div ng-include="'plugins/developer/html/projectSelector.html'"></div>` template: `<div ng-include="'plugins/developer/html/projectSelector.html'"></div>`
}, },
*/
{ {
href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "environments"), href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, "environments"),
isActive: (subTab, path) => { isActive: (subTab, path) => {
var href = normalizeHref(subTab.href);
//console.log("subTab: ", subTab, " path: ", path); //console.log("subTab: ", subTab, " path: ", path);
if (path === subTab.href) { if (path === href) {
return true; return true;
} }
var rootPath = subTab.href.replace(/\/environments/, ''); var rootPath = href.replace(/\/environments/, '');
if (path === rootPath) { if (path === rootPath) {
return true; return true;
} }
return false; return false;
}, },
//href: UrlHelpers.join("/workspaces", workspaceName, "projects", projectName), //href: UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName),
label: "Dashboard", label: "Dashboard",
class: "fa fa-tachometer", class: "fa fa-tachometer",
title: "View the app dashboard for the activity, environments and pipelines" title: "View the app dashboard for the activity, environments and pipelines"
@ -287,6 +347,15 @@ module Developer {
}, },
{ {
isValid: () => isJenkinsBuild(), isValid: () => isJenkinsBuild(),
isActive: (item, path) => {
if (path.indexOf('/log/') > 0) {
return false;
}
if (path.indexOf('/jenkinsJob/') > 0) {
return true;
}
return false;
},
id: "builds", id: "builds",
href: jenkinsBuildLink, href: jenkinsBuildLink,
label: "Builds", 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", label: "Tools",
title: "View the tools for this project" title: "View the tools for this project"
}, },
@ -441,6 +510,23 @@ module Developer {
return UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", projectName, path); 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 var customProjectSubTabFactories = [];
export function createJenkinsBreadcrumbs(projectName, jobId, buildId) { export function createJenkinsBreadcrumbs(projectName, jobId, buildId) {
@ -467,7 +553,7 @@ module Developer {
export function createJenkinsSubNavBars(projectName, jenkinsJobId, buildId, extraOption: any = null) { export function createJenkinsSubNavBars(projectName, jenkinsJobId, buildId, extraOption: any = null) {
var answer = createProjectSubNavBars(projectName, jenkinsJobId); var answer = createProjectSubNavBars(projectName, jenkinsJobId);
if (extraOption) { if (extraOption) {
extraOption.active = true; // extraOption.active = true;
answer.push(extraOption); answer.push(extraOption);
} }
return answer; return answer;
@ -478,75 +564,53 @@ module Developer {
var ns = Kubernetes.currentKubernetesNamespace(); var ns = Kubernetes.currentKubernetesNamespace();
var workspaceName = $routeParams.workspace; var workspaceName = $routeParams.workspace;
var project = $routeParams.project; var project = $routeParams.project;
var environment = $routeParams.namespace;
var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes"); var projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes");
/*console.log("=====================")
console.log(projectLink);
if (workspaceName && project) { if (workspaceName && project) {
projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/workspaces", workspaceName, "projects", project); projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes", workspaceName, "projects", project);
} } else {
var namespacesLink = UrlHelpers.join(projectLink, "namespace"); projectLink = UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes", workspaceName || ns);
return activateCurrent([ }*/
{ var namespacesLink = UrlHelpers.join(projectLink, "namespace");
href: UrlHelpers.join(projectLink, "environments"), return activateCurrent([
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"), href: UrlHelpers.join(namespacesLink, ns, "replicationControllers"),
label: "Controllers", label: "服务管理",
class: "fa fa-clone", class: "fa fa-clone",
title: "View the Replication Controllers for this project" title: "View the Replicas for this project"
}, },
{
href: UrlHelpers.join(namespacesLink, ns, "pods"),
label: "Pods",
class: "fa fa-puzzle-piece",
title: "View the pods for this project"
},
{ {
href: UrlHelpers.join(namespacesLink, ns, "events"), href: UrlHelpers.join(namespacesLink, ns, "events"),
label: "Events", label: "日志信息",
class: "fa fa-newspaper-o", class: "fa fa-newspaper-o",
title: "View the events for this project" title: "View the events for this project"
}, },
{ {
href: UrlHelpers.join(namespacesLink, ns, "secrets"), href: UrlHelpers.join(projectLink, "hosts"),
label: "Secrets", label: "集群节点",
class: "fa fa-key",
title: "View the secrets for this project"
},
{
href: UrlHelpers.join(HawtioCore.documentBase(), "/kubernetes/hosts"),
label: "Nodes",
class: "fa fa-server", class: "fa fa-server",
title: "View the nodes for this project" 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) { export function namespaceLink($scope, $routeParams, path = null) {
var ns = Kubernetes.currentKubernetesNamespace(); var ns = Kubernetes.currentKubernetesNamespace();
@ -572,32 +636,68 @@ module Developer {
return text; 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) { function activateCurrent(navBarItems) {
navBarItems = _.compact(navBarItems); navBarItems = _.compact(navBarItems);
var injector = HawtioCore.injector; var injector = HawtioCore.injector;
var $location = injector ? injector.get<ng.ILocationService>("$location") : null; var $location = injector ? injector.get<ng.ILocationService>("$location") : null;
if ($location) { if ($location) {
var path = trimQuery($location.path()); var path = normalizeHref(trimQuery($location.path()));
var found = false; var found = false;
function makeActive(item) { function makeActive(item) {
item.active = true; item.active = true;
found = true; found = true;
} }
function getHref(item) {
var href = item.href;
var trimHref = trimQuery(href);
return normalizeHref(trimHref);
}
angular.forEach(navBarItems, (item) => { angular.forEach(navBarItems, (item) => {
if (item) { if (!found && item) {
if (angular.isFunction(item.isActive)) { if (angular.isFunction(item.isActive)) {
if (!found && item.isActive(item, path)) { if (item.isActive(item, path)) {
makeActive(item); makeActive(item);
} }
} else { } else {
var href = item.href; var trimHref = getHref(item);
var trimHref = trimQuery(href); if (!trimHref) {
if (!found && trimHref && trimHref === path) { return;
}
if (trimHref === path) {
makeActive(item); 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; return navBarItems;
} }

@ -3,66 +3,37 @@
module Developer { 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 controller = PluginHelpers.createControllerFunction(_module, pluginName);
export var route = PluginHelpers.createRoutingFunction(templatePath); 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)) $routeProvider.when(context, route('workspaces.html', false))
.when("/namespaces", route('workspaces.html', false)) .when("/data-manager", route('workspaces.html', false))
//.when("/home", route('home.html', false)) .when(UrlHelpers.join(context, 'Overview/data-type/all'), route('workspaces.html', false))
.when(UrlHelpers.join(context, '/:namespace'), route('projects.html', false)) .when(UrlHelpers.join(context, 'Overview/data-type/financial'), route('workspaces.html', false))
.when(UrlHelpers.join(context, '/:namespace/detail'), route('workspace.html', false)) .when(UrlHelpers.join(context, 'Overview/data-type/social-security'), route('workspaces.html', false))
.when(UrlHelpers.join(context, '/:namespace/jenkinsJob'), route('jenkinsJobs.html', false)) .when(UrlHelpers.join(context, 'task'), route('apps.html', false))
.when(UrlHelpers.join(context, '/:namespace/projects'), route('projects.html', false)) .otherwise(context);
.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");
}]); }]);
_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"); log.debug("Running");
viewRegistry['workspaces'] = Kubernetes.templatePath + 'layoutKubernetes.html'; viewRegistry['workspaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';
viewRegistry['namespaces'] = Kubernetes.templatePath + 'layoutKubernetes.html'; viewRegistry['namespaces'] = Kubernetes.templatePath + 'layoutKubernetes.html';
var builder = HawtioNav.builder(); var builder = HawtioNav.builder();
var workspaces = builder.id('workspaces')
.href(() => context) var dmanagerTab = builder.id('dmanager')
.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;')
.rank(200) .rank(200)
.href(() => context) .href(() => context)
.title(() => '数据汇总') .title(() => '数据管理')
//.isValid(() => !Core.isRemoteConnection()) //.isValid(() => !Core.isRemoteConnection())
.tabs(workspaces)
.build(); .build();
HawtioNav.add(Aggregate); HawtioNav.add(dmanagerTab);
}]); }]);
_module.filter('asTrustedHtml', ['$sce', function ($sce) { _module.filter('asTrustedHtml', ['$sce', function ($sce) {

@ -2,472 +2,210 @@
/// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/> /// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/>
/// <reference path="developerEnrichers.ts"/> /// <reference path="developerEnrichers.ts"/>
/// <reference path="developerHelpers.ts"/> /// <reference path="developerHelpers.ts"/>
/// <reference path="developerNavigation.ts"/> /// <reference path="dataManagerHelper.ts"/>
/// <reference path="dataManagerModel.ts"/>
module Developer { module Developer {
export var WorkspacesController = controller("WorkspacesController", ["$scope", "KubernetesModel", "DataModel","KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "$element",
export var WorkspacesController = controller("WorkspacesController", ($scope, KubernetesModel:Kubernetes.KubernetesModelService, DataModel:Developer.DataModelService, KubernetesState, $templateCache:ng.ITemplateCacheService, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL, $element) => {
["$scope", "KubernetesModel", "KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "DataInfoModel", "$interval", init($scope,location,$routeParams);
($scope, KubernetesModel:Kubernetes.KubernetesModelService, KubernetesState, $templateCache:ng.ITemplateCacheService, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL, DataInfoModel,$interval) => {
$scope.model = DataInfoModel; $scope.model=DataModel;
$scope.items=[]; $scope.model.initParamOptions();
$scope.options = DataModel.paramOptions;
$scope.localitems=[]; $scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
var rootPath=""; $scope.options.dataType = getDataType($location);
var FilterList ={
length:0 $scope.model.updateModel();
};
update(); //配置数据表格需要显示的内容及显示格式
$scope.tableConfig = {
$scope.treeOptions = { data: 'model.data',
nodeChildren: "children", enableRowClickSelection: true,
dirSelectable: true, showSelectionCheckbox: true,
multiSelection: false, multiSelect: true,
injectClasses: { selectedItems: [],
ul: "a1", filterOptions: {
li: "a2", filterText: $location.search()["q"] || ''
liSelected: "a7", },
iExpanded: "a3", columnDefs: [
iCollapsed: "a4", {
iLeaf: "a5", field: "_key",
label: "a6", displayName: '编码',
labelSelected: "a8" customSortField: (field) =>{
} return field.id;
}; //console.log(field);
}
$scope.treeOptionss = { },
nodeChildren: "children", {
dirSelectable: true, field: "name",
multiSelection: true, displayName: '市-区/县'
injectClasses: { },
ul: "a1", {
li: "a2", field: "systemName",
liSelected: "a7", displayName: '系统名称'
iExpanded: "a3", },
iCollapsed: "a4", {
iLeaf: "a5", field: "collectingTime",
label: "a6", displayName: '采集时间'
labelSelected: "a8" },
} {
}; field: "collectorName",
displayName: '汇总状态'
$scope.showSelected = (node,selected)=>{ },
{
$scope.model.serveritems = []; field: "collectorContacts",
var array = new Array(); displayName: '联系方式'
if(selected){ }
if(node.children.length > 0){ ]
array.unshift(node); };
while(array.length > 0){
var childNode=array.pop(); $scope.selectBatchItem = (item)=> {
if(childNode.children.length>0){ $scope.navbarItems.forEach((nav) =>{
for(var i=0;i<childNode.children.length;i++) nav.class="";
array.unshift(childNode.children[i]); });
}else{ item.class="active";
if(childNode.hasOwnProperty("path")) if(item.label === "全部")
$scope.model.serveritems.push(childNode); $scope.model.updateParamOption("dataBatch", null);
} else
} $scope.model.updateParamOption("dataBatch", item.alias);
}else{ }
if(node.hasOwnProperty("path"))
$scope.model.serveritems.push(node); $scope.isEmptyOrFirst = () => {
} var idx = $scope.model.getParamOption("currentPageNum");
} var length =$scope.options.getPageSizeNum();
}; return length <= 0 || idx <= 1;
}
$scope.dataForTheTree = $scope.model.serverdata;
$scope.dataForTheTreeLocal = $scope.model.localdata; $scope.isEmptyOrLast = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
$scope.$watch('model.serverdata', function(newValue,oldValue){ var length =$scope.options.getPageSizeNum();
if(newValue){ return length < 1 || idx >= length;
$scope.dataForTheTree = $scope.model.serverdata; }
}
}); $scope.first = () => {
var idx = $scope.model.getParamOption("currentPageNum");
$scope.$watch('model.localdata', function(newValue,oldValue){ if(idx >1)
if(newValue){ $scope.model.updateParamOption("currentPageNum", 1);
$scope.dataForTheTreeLocal = $scope.model.localdata; }
}
}); $scope.last = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
$scope.upLoadXMLFile = (files) => { var length =$scope.options.getPageSizeNum();
FilterList.length=0; if(idx < length)
if(files.length>0){ $scope.model.updateParamOption("currentPageNum", length);
var j=0; }
for(var i=0;i<files.length;i++){
if(files[i].name.indexOf("data.xml")!=-1){ $scope.previous = () => {
//console.log(files[i]); var idx = $scope.model.getParamOption("currentPageNum");
rootPath=files[i].webkitRelativePath.replace(/\/data.xml$/,""); var length =$scope.options.getPageSizeNum();
var reader= new FileReader(); if(idx > 1)
var resultString = "{\"name\": \"数据\", \"children\":["; $scope.model.updateParamOption("currentPageNum", idx-1);
reader.onload = function(){ }
var str = event.target.result;
// alert(str); $scope.next = () =>{
var item = "<Data>"; var length =$scope.options.getPageSizeNum();
var itemEnd = "</Data>"; var idx = $scope.model.getParamOption("currentPageNum");
// ´ý·µ»ØµÄ½á¹û£º if(idx < length)
if(str != undefined){ $scope.model.updateParamOption("currentPageNum", idx+1);
// Õû¸öxml ÍêÕûÊý¾Ý£ºxmldata }
var xmldata = str.toString();
// °´¶ÔÏó·ÖµÄÊý¾Ý£º $scope.$watch('options', (newValue, oldValue) => {
var itemArray = xmldata.split(item); if(newValue && newValue !== oldValue){
var itemsize = itemArray.length; if(newValue.currentTableSize !== oldValue.currentTableSize)
for(var k = 1; k < itemsize; k++){ $scope.options.priorTableSize = oldValue.currentTableSize;
var itemvalue = itemArray[k].split(itemEnd); else
$scope.options.priorTableSize = newValue.currentTableSize;
// province
var provinceValueTemp = itemvalue[0].split("<province>"); DataModel.updateModel();
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("您没有选择需要上传的数据文件,或你选择的文件中不存在指定格式的数据文件!");
}
}
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.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
},
"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);
});
}
});
}
} }
}, true);
$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);
});
});
}
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"
}]
}
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;
}
}]); }]);
} }

@ -942,7 +942,7 @@ module Kubernetes {
var url = kubernetesUrlForKind(KubernetesApiURL, "ReplicationController", namespace, id); var url = kubernetesUrlForKind(KubernetesApiURL, "ReplicationController", namespace, id);
$http.get(url). $http.get(url).
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
if (data) { if (data) {
var desiredState = data.spec; var desiredState = data.spec;
if (!desiredState) { if (!desiredState) {
desiredState = {}; desiredState = {};
@ -1737,16 +1737,16 @@ module Kubernetes {
var client = Kubernetes.createKubernetesClient('replicationcontrollers','default'); var client = Kubernetes.createKubernetesClient('replicationcontrollers','default');
var RCTemplate = new resourceRCTemplate(); var RCTemplate = new resourceRCTemplate();
var rcTemplate = RCTemplate.createRC(obj); var rcTemplate = RCTemplate.createRC(obj);
//console.log(rcTemplate); console.log(JSON.stringify(rcTemplate));
client.put(rcTemplate, function(obj) { client.put(rcTemplate, function(obj) {
//console.log("Created: ", obj); console.log("Created: ", obj);
if (angular.isFunction(onCompleteFn)) { if (angular.isFunction(onCompleteFn)) {
onCompleteFn(obj); onCompleteFn(obj);
} }
}); });
} }
export function connectOracle($http, $timeout, url, operation, rcName, delayTime){ export function connectOracle($http, $timeout, url, operation, rcName, delayTime){
$timeout(() => { $timeout(() => {
$http({ $http({
url: url, url: url,
@ -1847,4 +1847,17 @@ module Kubernetes {
return false; 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,9 +26,10 @@ module Kubernetes {
.when(UrlHelpers.join(context, 'pipelines'), route('pipelines.html', false)) .when(UrlHelpers.join(context, 'pipelines'), route('pipelines.html', false))
.when(UrlHelpers.join(context, 'overview'), route('overview.html', true)) .when(UrlHelpers.join(context, 'overview'), route('overview.html', true))
.when(context, {redirectTo: UrlHelpers.join(context, 'replicationControllers')}); .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 $routeProvider
.when(UrlHelpers.join(context, '/namespace/:namespace/podCreate'), route('podCreate.html', false)) .when(UrlHelpers.join(context, '/namespace/:namespace/podCreate'), route('podCreate.html', false))
.when(UrlHelpers.join(context, '/namespace/:namespace/podEdit/:id'), route('podEdit.html', false)) .when(UrlHelpers.join(context, '/namespace/:namespace/podEdit/:id'), route('podEdit.html', false))

@ -83,34 +83,20 @@ module Kubernetes {
onClose: (result:boolean) => { onClose: (result:boolean) => {
if (result) { if (result) {
function deleteSelected(selected:Array<KubePod>, next:KubePod) { function deleteSelected(selected:Array<KubePod>, next:KubePod) {
if (next) { if (next) {
log.debug("deleting: ", getName(next)); Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
log.debug("updated number of replicas");
KubernetesReplicationControllers.delete({ KubernetesReplicationControllers.delete({
id: getName(next) id: getName(next)
}, undefined, () => { }, undefined, () => {
log.debug("deleted: ", getName(next)); if(next.metadata.labels.style === "oracle"){
if(next.metadata.labels.style === "oracle"){ Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "delete", getName(next), 0);
console.log("delete " + next.metadata.name); }
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "delete", getName(next), 0);
}
deleteSelected(selected, selected.shift()); deleteSelected(selected, selected.shift());
}, (error) => { }, (error) => {
log.debug("Error deleting: ", error); log.debug("Error deleting: ", error);
deleteSelected(selected, selected.shift()); 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()); deleteSelected(selected, selected.shift());
@ -126,45 +112,17 @@ module Kubernetes {
}).open(); }).open();
} }
$scope.createRCs= () => { $scope.createRCs= () => {
var xhr= new XMLHttpRequest(); $http({
xhr.onreadystatechange = () => { url: '/java/console/api/cancelOracleConection',
if (xhr.readyState == 4) {//4表示数据已经调用完成 dataType: 'json',
if (xhr.status == 200) {//HTTP的状态码 method:'POST',
var obj=JSON.parse(xhr.responseText); params:{param: "data"}
//console.log(obj.path); }).success(function(data,header,config,status){
var name = obj.name; console.log("success");
//console.log(name + "=====" +port); }).error(function(data,header,config,status){
var object = { //log.warn("Failed to connect " + connectParam + " " + data + " " + status);
"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.stopPrompt = (selected) =>{ $scope.stopPrompt = (selected) =>{
@ -182,9 +140,8 @@ module Kubernetes {
function stopSelected(selected:Array<KubePod>, next:KubePod) { function stopSelected(selected:Array<KubePod>, next:KubePod) {
if (next) { if (next) {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => { Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
if(next.metadata.labels.style === "oracle"){ if(next.metadata.labels.style === "oracle"){
console.log("stop " + next.metadata.name); Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "stop", getName(next), 0);
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "stop", getName(next), 0);
} }
stopSelected(selected, selected.shift()); stopSelected(selected, selected.shift());
}); });
@ -209,7 +166,7 @@ module Kubernetes {
if(next.$replicas === 0) if(next.$replicas === 0)
Kubernetes.resizeController($http, KubernetesApiURL, next, 1, () => { Kubernetes.resizeController($http, KubernetesApiURL, next, 1, () => {
console.log("restart " + next.metadata.name); 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()); startSelected(selected, selected.shift());
}); });
} }

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

@ -40,6 +40,18 @@ module Navigation {
return self; 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) => { _module.directive('viewportHeight', ['$window', '$document', ($window, $document) => {
return { return {
restrict: 'A', restrict: 'A',
@ -68,15 +80,15 @@ module Navigation {
return { return {
restrict: 'A', restrict: 'A',
link: (scope, element, attrs) => { link: (scope, element, attrs) => {
scope.HawtioSubTabs = HawtioSubTabs; scope.tabs = HawtioSubTabs;
scope.$watchCollection('HawtioSubTabs.get()', (subTabConfig) => { scope.$watchCollection('tabs.get()', (tabs) => {
// log.debug("subTabConfig: ", subTabConfig); // log.debug("subTabConfig: ", subTabConfig);
if (subTabConfig && subTabConfig.length > 0) { if (tabs && tabs.length > 0) {
element.removeClass('hidden-nav'); element.removeClass('hidden-nav');
//element.css({ 'margin-left': '' }); element.css({ 'margin-left': '' });
} else { } else {
element.addClass('hidden-nav'); element.addClass('hidden-nav');
//element.css({ 'margin-left': 'auto' }); element.css({ 'margin-left': 'auto' });
} }
}); });
} }
@ -91,30 +103,31 @@ module Navigation {
replace: true, replace: true,
template: ` template: `
<div class="nav-pf-vertical nav-pf-vertical-with-secondary-nav" ng-controller="Developer.NavBarController" ng-class="getClass()"> <div class="nav-pf-vertical nav-pf-vertical-with-secondary-nav" ng-controller="Developer.NavBarController" ng-class="getClass()">
<ul class="list-group"> <div class="list-group">
<li ng-repeat="subTab in subTabConfig" ng-show="isValid(subTab)" <div ng-repeat="subTab in subTabConfig" ng-show="true"
class="list-group-item {{subTab.active ? 'active' : ''}}" class="list-group-item {{subTab.active ? 'active' : ''}}"
title="{{subTab.title}}"> title="{{subTab.title}}">
<a ng-hide="subTab.template" href="{{subTab.href}}"> <a ng-hide="subTab.template" href="{{subTab.href}}">
<span ng-show="subTab.class" ng-class="subTab.class"></span> <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}} {{subTab.label}}
</a> </a>
<div ng-show="subTab.template" compile="subTab.template"></div> <div ng-show="subTab.template" compile="subTab.template"></div>
</li> </div>
</ul> </>
</div> </div>
`, `,
link: (scope, element, attrs) => { link: (scope, element, attrs) => {
if (!initialized) { if (!initialized) {
try { try {
(<any>$)().setupVerticalNavigation(false); //(<any>$)().setupVerticalNavigation(false);
} catch (err) { } catch (err) {
// ignore if we haven't loaded patternfly // ignore if we haven't loaded patternfly
} }
initialized = true; initialized = true;
} }
scope.HawtioSubTabs = HawtioSubTabs; scope.HawtioSubTabs = HawtioSubTabs;
var collapsed = false; var collapsed = false;
scope.getClass = () => { scope.getClass = () => {
//log.debug("My class: ", element.attr('class')); //log.debug("My class: ", element.attr('class'));
@ -131,31 +144,104 @@ module Navigation {
}); });
scope.$watch('HawtioSubTabs.get()', (subTabConfig) => { scope.$watch('HawtioSubTabs.get()', (subTabConfig) => {
scope.subTabConfig = subTabConfig; scope.subTabConfig = subTabConfig;
}); });
} }
}; };
}]); }]);
_module.directive('hawtioBreadcrumbsOutlet', ['HawtioBreadcrumbs', (HawtioBreadcrumbs) => { _module.directive('hawtioBreadcrumbsOutlet', ['HawtioBreadcrumbs', 'HawtioSubTabs', (HawtioBreadcrumbs, HawtioSubTabs) => {
return { return {
restrict: 'E', restrict: 'E',
scope: {}, scope: {},
template: ` 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"> <ol class="breadcrumb">
<div class = 'br'><br></div> <li ng-repeat="breadcrumb in breadcrumbConfig" ng-show="isValid(breadcrumb) && label(breadcrumb)"
<li ng-repeat="breadcrumb in breadcrumbConfig" ng-show="isValid(breadcrumb)"
class="{{breadcrumb.active ? 'active' : ''}}" class="{{breadcrumb.active ? 'active' : ''}}"
ng-class="$last ? 'dropdown' : ''"
title="{{breadcrumb.title}}"> title="{{breadcrumb.title}}">
<a ng-show="breadcrumb.href && !breadcrumb.active" href="{{breadcrumb.href}}">{{breadcrumb.label}}</a> <a ng-show="breadcrumb.href" href="{{breadcrumb.href}}">{{label(breadcrumb)}}</a>
<span ng-hide="breadcrumb.href && !breadcrumb.active">{{breadcrumb.label}}</span> <span ng-hide="breadcrumb.href">{{label(breadcrumb)}}</span>
</li>
<li ng-show="pageTitle">
<span ng-bind="pageTitle"></span>
</li>
</ol> </ol>
</div> </div>
`, `,
link: (scope, element, attrs) => { link: (scope, element, attrs) => {
scope.breadcrumbs = HawtioBreadcrumbs; scope.breadcrumbs = HawtioBreadcrumbs;
scope.tabs = HawtioSubTabs;
scope.$watchCollection('breadcrumbs.get()', (breadcrumbConfig) => { 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;
}); });
} }
}; };

Loading…
Cancel
Save