///
\n \t{{column.title}}\n | \n
---|
\n \t\t{{col.title}}\n \t | \n
" + " | "
+ content + " |
key1=value1,key2=value2,....
format
*/
function labelsToString(labels, seperatorText) {
if (seperatorText === void 0) { seperatorText = Kubernetes.labelFilterTextSeparator; }
var answer = "";
angular.forEach(labels, function (value, key) {
var separator = answer ? seperatorText : "";
answer += separator + key + "=" + value;
});
return answer;
}
Kubernetes.labelsToString = labelsToString;
function labelsFormat(replicas) {
var annotion = getAnnotations(replicas);
var lables = getLabels(replicas);
var hasChineseVersion = lables["version"].indexOf("版本") == -1 ? "版本" + lables["version"] : lables["version"];
return {
isExtract: lables["isExtract"],
isTarget: lables["isTarget"],
status: lables["status"],
style: lables["style"],
cityName: annotion["cityName"],
districtName: annotion["districtName"],
systemName: annotion["systemName"],
year: annotion["year"],
version: hasChineseVersion
};
}
Kubernetes.labelsFormat = labelsFormat;
function initShared($scope, $location, $http, $timeout, $routeParams, KubernetesModel, KubernetesState, KubernetesApiURL) {
$scope.baseUri = Core.trimTrailing(Core.url("/") || "", "/") || "";
var injector = HawtioCore.injector;
function hasService(name) {
if (injector) {
var ServiceRegistry = injector.get("ServiceRegistry");
if (ServiceRegistry) {
return ServiceRegistry.hasService(name);
}
}
return false;
}
$scope.hasServiceKibana = function () { return hasService(Kubernetes.kibanaServiceName); };
$scope.hasServiceGogs = function () { return hasService(Kubernetes.gogsServiceName); };
$scope.hasServiceForge = function () { return hasService(Kubernetes.fabric8ForgeServiceName); };
$scope.hasServiceApiman = function () { return hasService(Kubernetes.apimanServiceName); };
$scope.viewTemplates = function () {
var returnTo = $location.url();
$location.path('/kubernetes/templates').search({ 'returnTo': returnTo });
};
$scope.namespace = $routeParams.namespace || $scope.namespace || KubernetesState.selectedNamespace || Kubernetes.defaultNamespace;
if ($scope.namespace != KubernetesState.selectedNamespace) {
KubernetesState.selectedNamespace = $scope.namespace;
// lets show page is going to reload
if ($scope.model) {
$scope.model.fetched = false;
}
}
Kubernetes.setCurrentKubernetesNamespace($scope.namespace);
$scope.forgeEnabled = isForgeEnabled();
$scope.projectId = $routeParams["project"] || $scope.projectId || $scope.id;
var showProjectNavBars = false;
if ($scope.projectId && showProjectNavBars) {
$scope.breadcrumbConfig = Developer.createProjectBreadcrumbs($scope.projectId);
$scope.subTabConfig = Developer.createProjectSubNavBars($scope.projectId, null, $scope);
}
else {
$scope.breadcrumbConfig = Developer.createEnvironmentBreadcrumbs($scope, $location, $routeParams);
$scope.subTabConfig = Developer.createEnvironmentSubNavBars($scope, $location, $routeParams);
}
if ($scope.projectId) {
$scope.$projectLink = Developer.projectLink($scope.projectId);
}
$scope.link = function (href) {
if (!href) {
return href;
}
if ($scope.$projectLink) {
return Developer.namespaceLink($scope, $routeParams, href.replace(/^\/kubernetes/, ''));
}
else {
return href;
}
};
$scope.codeMirrorOptions = {
lineWrapping: true,
lineNumbers: true,
readOnly: 'nocursor',
mode: { name: "javascript", json: true }
};
$scope.resizeDialog = {
controller: null,
newReplicas: 0,
dialog: new UI.Dialog(),
onOk: function () {
var resizeDialog = $scope.resizeDialog;
resizeDialog.dialog.close();
resizeController($http, KubernetesApiURL, resizeDialog.controller, resizeDialog.newReplicas, function () { Kubernetes.log.debug("updated number of replicas"); });
},
open: function (controller) {
var resizeDialog = $scope.resizeDialog;
resizeDialog.controller = controller;
resizeDialog.newReplicas = Core.pathGet(controller, ["status", "replicas"]);
resizeDialog.dialog.open();
$timeout(function () {
$('#replicas').focus();
}, 50);
},
close: function () {
$scope.resizeDialog.dialog.close();
}
};
$scope.triggerBuild = function (buildConfig) {
var url = buildConfig.$triggerUrl;
console.log("triggering build at url: " + url);
if (url) {
//var data = {};
var data = null;
var config = {
headers: {
'Content-Type': "application/json"
}
};
var name = Core.pathGet(buildConfig, ["metadata", "name"]);
Core.notification('info', "Triggering build " + name);
$http.post(url, data, config).
success(function (data, status, headers, config) {
console.log("trigger worked! got data " + angular.toJson(data, true));
// TODO should we show some link to the build
Core.notification('info', "Building " + name);
}).
error(function (data, status, headers, config) {
Kubernetes.log.warn("Failed to load " + url + " " + data + " " + status);
Core.notification('error', "Failed to trigger build for " + name + ". Returned code: " + status + " " + data);
});
}
;
};
// update the URL if the filter is changed
$scope.$watch("tableConfig.filterOptions.filterText", function (text) {
//var filterText = Kubernetes.findValeOfLabels(text);
$location.search("q", text);
});
$scope.$on("labelFilterUpdate", function ($event, text) {
var filterOptions = ($scope.tableConfig || {}).filterOptions || {};
var currentFilter = filterOptions.filterText;
if (Core.isBlank(currentFilter)) {
filterOptions.filterText = text;
}
else {
var expressions = currentFilter.split(/\s+/);
if (expressions.indexOf(text) !== -1) {
// lets exclude this filter expression
expressions = expressions.remove(text);
filterOptions.filterText = expressions.join(" ");
}
else {
filterOptions.filterText = currentFilter + " " + text;
}
}
$scope.id = undefined;
});
}
Kubernetes.initShared = initShared;
/**
* Returns the number of pods that are ready
*/
function readyPodCount(service) {
var count = 0;
angular.forEach((service || {}).$pods, function (pod) {
if (pod.$ready) {
count++;
}
});
return count;
}
Kubernetes.readyPodCount = readyPodCount;
/**
* Returns the service link URL for either the service name or the service object
*/
function serviceLinkUrl(service, httpOnly) {
if (httpOnly === void 0) { httpOnly = false; }
if (angular.isObject(service)) {
var portalIP = service.$host;
// lets assume no custom port for now for external routes
var port = null;
var protocol = "http://";
var spec = service.spec;
if (spec) {
if (!portalIP) {
portalIP = spec.portalIP;
}
var hasHttps = false;
var hasHttp = false;
angular.forEach(spec.ports, function (portSpec) {
var p = portSpec.port;
if (p) {
if (p === 443) {
hasHttps = true;
}
else if (p === 80) {
hasHttp = true;
}
if (!port) {
port = p;
}
}
});
if (!hasHttps && !hasHttp && port) {
// lets treat 8080 as http which is a common service to export
if (port === 8080) {
hasHttp = true;
}
else if (port === 8443) {
hasHttps = true;
}
}
}
if (portalIP) {
if (hasHttps) {
return "https://" + portalIP;
}
else if (hasHttp) {
return "http://" + portalIP;
}
else if (!httpOnly) {
if (port) {
return protocol + portalIP + ":" + port + "/";
}
else {
return protocol + portalIP;
}
}
}
}
else if (service) {
var serviceId = service.toString();
if (serviceId) {
var ServiceRegistry = getServiceRegistry();
if (ServiceRegistry) {
return ServiceRegistry.serviceLink(serviceId) || "";
}
}
}
return "";
}
Kubernetes.serviceLinkUrl = serviceLinkUrl;
/**
* Returns the total number of counters for the podCounters object
*/
function podCounterTotal($podCounters) {
var answer = 0;
if ($podCounters) {
angular.forEach(["ready", "valid", "waiting", "error"], function (name) {
var value = $podCounters[name] || 0;
answer += value;
});
}
return answer;
}
Kubernetes.podCounterTotal = podCounterTotal;
/**
* Given the list of pods lets iterate through them and find all pods matching the selector
* and return counters based on the status of the pod
*/
function createPodCounters(selector, pods, outputPods, podLinkQuery, podLinkUrl) {
if (outputPods === void 0) { outputPods = []; }
if (podLinkQuery === void 0) { podLinkQuery = null; }
if (podLinkUrl === void 0) { podLinkUrl = null; }
if (!podLinkUrl) {
podLinkUrl = "/kubernetes/pods";
}
var filterFn;
if (angular.isFunction(selector)) {
filterFn = selector;
}
else {
filterFn = function (pod) { return selectorMatches(selector, getLabels(pod)); };
}
var answer = {
podsLink: "",
ready: 0,
valid: 0,
waiting: 0,
error: 0
};
if (selector) {
if (!podLinkQuery) {
podLinkQuery = Kubernetes.labelsToString(selector, " ");
}
answer.podsLink = podLinkUrl + "?q=" + encodeURIComponent(podLinkQuery);
angular.forEach(pods, function (pod) {
if (filterFn(pod)) {
outputPods.push(pod);
var status = getStatus(pod);
if (status) {
var lower = status.toLowerCase();
if (lower.startsWith("run")) {
if (isReady(pod)) {
answer.ready += 1;
}
else {
answer.valid += 1;
}
}
else if (lower.startsWith("wait") || lower.startsWith("pend")) {
answer.waiting += 1;
}
else if (lower.startsWith("term") || lower.startsWith("error") || lower.startsWith("fail")) {
answer.error += 1;
}
}
else {
answer.error += 1;
}
}
});
}
return answer;
}
Kubernetes.createPodCounters = createPodCounters;
/**
* Converts the given json into an array of items. If the json contains a nested set of items then that is sorted; so that services
* are processed first; then turned into an array. Otherwise the json is put into an array so it can be processed polymorphically
*/
function convertKubernetesJsonToItems(json) {
var items = json.items;
if (angular.isArray(items)) {
// TODO we could check for List or Config types here and warn if not
// sort the services first
var answer = [];
items.forEach(function (item) {
if (item.kind === "Service") {
answer.push(item);
}
});
items.forEach(function (item) {
if (item.kind !== "Service") {
answer.push(item);
}
});
return answer;
}
else {
return [json];
}
}
Kubernetes.convertKubernetesJsonToItems = convertKubernetesJsonToItems;
function isV1beta1Or2() {
return Kubernetes.defaultApiVersion === "v1beta1" || Kubernetes.defaultApiVersion === "v1beta2";
}
Kubernetes.isV1beta1Or2 = isV1beta1Or2;
/**
* Returns a link to the detail page for the given entity
*/
function entityPageLink(obj) {
if (obj) {
function getLink(entity) {
var viewLink = entity["$viewLink"];
if (viewLink) {
return viewLink;
}
var id = getName(entity);
var kind = getKind(entity);
if (kind && id) {
var path = kind.substring(0, 1).toLowerCase() + kind.substring(1) + "s";
var namespace = getNamespace(entity);
if (namespace && !isIgnoreNamespaceKind(kind)) {
return Core.url(UrlHelpers.join('/kubernetes/namespace', namespace, path, id));
}
else {
return Core.url(UrlHelpers.join('/kubernetes', path, id));
}
}
}
var baseLink = getLink(obj);
if (!HawtioCore.injector || !baseLink) {
return baseLink;
}
var $routeParams = HawtioCore.injector.get('$routeParams');
var projectId = $routeParams['project'] || $routeParams['project'];
if (!projectId) {
return baseLink;
}
return UrlHelpers.join(Developer.projectLink(projectId), baseLink.replace(/^\/kubernetes\//, ''));
}
return null;
}
Kubernetes.entityPageLink = entityPageLink;
function resourceKindToUriPath(kind) {
var kindPath = kind.toLowerCase() + "s";
if (kindPath === "replicationControllers" && !isV1beta1Or2()) {
kindPath = "replicationcontrollers";
}
return kindPath;
}
Kubernetes.resourceKindToUriPath = resourceKindToUriPath;
function isIgnoreNamespaceKind(kind) {
return kind === "Host" || kind === "Minion";
}
/**
* Returns the root URL for the kind
*/
function kubernetesUrlForKind(KubernetesApiURL, kind, namespace, path) {
if (namespace === void 0) { namespace = null; }
if (path === void 0) { path = null; }
var pathSegment = "";
if (path) {
pathSegment = "/" + Core.trimLeading(path, "/");
}
var kindPath = resourceKindToUriPath(kind);
var ignoreNamespace = isIgnoreNamespaceKind(kind);
if (isV1beta1Or2() || ignoreNamespace) {
var postfix = "";
if (namespace && !ignoreNamespace) {
postfix = "?namespace=" + namespace;
}
return UrlHelpers.join(KubernetesApiURL, kindPath, pathSegment, postfix);
}
else {
return UrlHelpers.join(KubernetesApiURL, "/namespaces/", namespace, kindPath, pathSegment);
}
}
Kubernetes.kubernetesUrlForKind = kubernetesUrlForKind;
;
/**
* Returns the base URL for the kind of kubernetes resource or null if it cannot be found
*/
function kubernetesUrlForItemKind(KubernetesApiURL, json) {
var kind = json.kind;
if (kind) {
return kubernetesUrlForKind(KubernetesApiURL, kind, json.namespace);
}
else {
Kubernetes.log.warn("Ignoring missing kind " + kind + " for kubernetes json: " + angular.toJson(json));
return null;
}
}
Kubernetes.kubernetesUrlForItemKind = kubernetesUrlForItemKind;
function kubernetesProxyUrlForService(KubernetesApiURL, service, path) {
if (path === void 0) { path = null; }
var pathSegment = "";
if (path) {
pathSegment = "/" + Core.trimLeading(path, "/");
}
else {
pathSegment = "/";
}
var namespace = getNamespace(service);
if (isV1beta1Or2()) {
var postfix = "?namespace=" + namespace;
return UrlHelpers.join(KubernetesApiURL, "/proxy", kubernetesNamespacePath(), "/services/" + getName(service) + pathSegment + postfix);
}
else {
return UrlHelpers.join(KubernetesApiURL, "/proxy/namespaces/", namespace, "/services/" + getName(service) + pathSegment);
}
}
Kubernetes.kubernetesProxyUrlForService = kubernetesProxyUrlForService;
function kubernetesProxyUrlForServiceCurrentNamespace(service, path) {
if (path === void 0) { path = null; }
var apiPrefix = UrlHelpers.join(kubernetesApiUrl());
return kubernetesProxyUrlForService(apiPrefix, service, path);
}
Kubernetes.kubernetesProxyUrlForServiceCurrentNamespace = kubernetesProxyUrlForServiceCurrentNamespace;
function buildConfigRestUrl(id) {
return UrlHelpers.join(buildConfigsRestURL(), id);
}
Kubernetes.buildConfigRestUrl = buildConfigRestUrl;
function deploymentConfigRestUrl(id) {
return UrlHelpers.join(deploymentConfigsRestURL(), id);
}
Kubernetes.deploymentConfigRestUrl = deploymentConfigRestUrl;
function imageRepositoryRestUrl(id) {
return UrlHelpers.join(imageRepositoriesRestURL(), id);
}
Kubernetes.imageRepositoryRestUrl = imageRepositoryRestUrl;
function buildRestUrl(id) {
return UrlHelpers.join(buildsRestURL(), id);
}
Kubernetes.buildRestUrl = buildRestUrl;
function buildLogsRestUrl(id) {
return UrlHelpers.join(buildsRestURL(), id, "log");
}
Kubernetes.buildLogsRestUrl = buildLogsRestUrl;
/**
* Runs the given application JSON
*/
function runApp($location, $scope, $http, KubernetesApiURL, json, name, onSuccessFn, namespace, onCompleteFn) {
if (name === void 0) { name = "App"; }
if (onSuccessFn === void 0) { onSuccessFn = null; }
if (namespace === void 0) { namespace = null; }
if (onCompleteFn === void 0) { onCompleteFn = null; }
if (json) {
if (angular.isString(json)) {
json = angular.fromJson(json);
}
name = name || "App";
var postfix = namespace ? " in namespace " + namespace : "";
Core.notification('info', "Running " + name + postfix);
var items = convertKubernetesJsonToItems(json);
angular.forEach(items, function (item) {
var url = kubernetesUrlForItemKind(KubernetesApiURL, item);
if (url) {
$http.post(url, item).
success(function (data, status, headers, config) {
Kubernetes.log.debug("Got status: " + status + " on url: " + url + " data: " + data + " after posting: " + angular.toJson(item));
if (angular.isFunction(onCompleteFn)) {
onCompleteFn();
}
Core.$apply($scope);
}).
error(function (data, status, headers, config) {
var message = null;
if (angular.isObject(data)) {
message = data.message;
var reason = data.reason;
if (reason === "AlreadyExists") {
// lets ignore duplicates
Kubernetes.log.debug("entity already exists at " + url);
return;
}
}
if (!message) {
message = "Failed to POST to " + url + " got status: " + status;
}
Kubernetes.log.warn("Failed to save " + url + " status: " + status + " response: " + angular.toJson(data, true));
Core.notification('error', message);
});
}
});
}
}
Kubernetes.runApp = runApp;
/**
* Returns true if the current status of the pod is running
*/
function isRunning(podCurrentState) {
var status = (podCurrentState || {}).phase;
if (status) {
var lower = status.toLowerCase();
return lower.startsWith("run");
}
else {
return false;
}
}
Kubernetes.isRunning = isRunning;
/**
* Returns true if the labels object has all of the key/value pairs from the selector
*/
function selectorMatches(selector, labels) {
if (angular.isObject(labels)) {
var answer = true;
var count = 0;
angular.forEach(selector, function (value, key) {
count++;
if (answer && labels[key] !== value) {
answer = false;
}
});
return answer && count > 0;
}
else {
return false;
}
}
Kubernetes.selectorMatches = selectorMatches;
/**
* Returns the service registry
*/
function getServiceRegistry() {
var injector = HawtioCore.injector;
return injector ? injector.get("ServiceRegistry") : null;
}
Kubernetes.getServiceRegistry = getServiceRegistry;
/**
* Returns a link to the kibana logs web application
*/
function kibanaLogsLink(ServiceRegistry) {
var link = ServiceRegistry.serviceLink(Kubernetes.kibanaServiceName);
if (link) {
if (!link.endsWith("/")) {
link += "/";
}
return link + "#/dashboard/Fabric8";
}
else {
return null;
}
}
Kubernetes.kibanaLogsLink = kibanaLogsLink;
function openLogsForPods(ServiceRegistry, $window, namespace, pods) {
var link = kibanaLogsLink(ServiceRegistry);
if (link) {
var query = "";
var count = 0;
angular.forEach(pods, function (item) {
var id = getName(item);
if (id) {
var space = query ? " OR " : "";
count++;
query += space + '"' + id + '"';
}
});
if (query) {
if (count > 1) {
query = "(" + query + ")";
}
query = 'kubernetes.namespace_name:"' + namespace + '" AND kubernetes.pod_name:' + query;
link += "?_a=(query:(query_string:(query:'" + query + "')))";
var newWindow = $window.open(link, "viewLogs");
}
}
}
Kubernetes.openLogsForPods = openLogsForPods;
function resizeController($http, KubernetesApiURL, replicationController, newReplicas, onCompleteFn) {
if (onCompleteFn === void 0) { onCompleteFn = null; }
var id = getName(replicationController);
var namespace = getNamespace(replicationController) || "";
var url = kubernetesUrlForKind(KubernetesApiURL, "ReplicationController", namespace, id);
$http.get(url).
success(function (data, status, headers, config) {
if (data) {
var desiredState = data.spec;
if (!desiredState) {
desiredState = {};
data.spec = desiredState;
}
desiredState.replicas = newReplicas;
$http.put(url, data).
success(function (data, status, headers, config) {
Kubernetes.log.debug("updated controller " + url);
if (angular.isFunction(onCompleteFn)) {
onCompleteFn();
}
}).
error(function (data, status, headers, config) {
Kubernetes.log.warn("Failed to save " + url + " " + data + " " + status);
});
}
}).
error(function (data, status, headers, config) {
Kubernetes.log.warn("Failed to load " + url + " " + data + " " + status);
});
}
Kubernetes.resizeController = resizeController;
function statusTextToCssClass(text, ready) {
if (ready === void 0) { ready = false; }
if (text) {
var lower = text.toLowerCase();
if (lower.startsWith("run") || lower.startsWith("ok")) {
if (!ready) {
return "fa fa-spinner fa-spin green";
}
return 'fa fa-play-circle green';
}
else if (lower.startsWith("wait") || lower.startsWith("pend")) {
return 'fa fa-download';
}
else if (lower.startsWith("term") || lower.startsWith("error") || lower.startsWith("fail")) {
return 'fa fa-off orange';
}
else if (lower.startsWith("succeeded")) {
return 'fa fa-check-circle-o green';
}
}
return 'fa fa-question red';
}
Kubernetes.statusTextToCssClass = statusTextToCssClass;
function podStatus(pod) {
return getStatus(pod);
}
Kubernetes.podStatus = podStatus;
function isReady(pod) {
var status = pod.status || {};
var answer = false;
angular.forEach(status.conditions, function (condition) {
var t = condition.type;
if (t && t === "Ready") {
var status = condition.status;
if (status === "True") {
answer = true;
}
}
});
return answer;
}
Kubernetes.isReady = isReady;
function createAppViewPodCounters(appView) {
var array = [];
var map = {};
var pods = appView.pods;
var lowestDate = null;
angular.forEach(pods, function (pod) {
var selector = getLabels(pod);
var selectorText = Kubernetes.labelsToString(selector, " ");
var answer = map[selector];
if (!answer) {
answer = {
labelText: selectorText,
podsLink: UrlHelpers.join("/kubernetes/namespace/", pod.metadata.namespace, "pods?q=" + encodeURIComponent(selectorText)),
valid: 0,
waiting: 0,
error: 0
};
map[selector] = answer;
array.push(answer);
}
var status = (podStatus(pod) || "Error").toLowerCase();
if (status.startsWith("run") || status.startsWith("ok")) {
answer.valid += 1;
}
else if (status.startsWith("wait") || status.startsWith("pwnd")) {
answer.waiting += 1;
}
else {
answer.error += 1;
}
var creationTimestamp = getCreationTimestamp(pod);
if (creationTimestamp) {
var d = new Date(creationTimestamp);
if (!lowestDate || d < lowestDate) {
lowestDate = d;
}
}
});
appView.$creationDate = lowestDate;
return array;
}
Kubernetes.createAppViewPodCounters = createAppViewPodCounters;
function createAppViewServiceViews(appView) {
var array = [];
var pods = appView.pods;
angular.forEach(pods, function (pod) {
var id = getName(pod);
if (id) {
var abbrev = id;
var idx = id.indexOf("-");
if (idx > 1) {
abbrev = id.substring(0, idx);
}
pod.idAbbrev = abbrev;
}
pod.statusClass = statusTextToCssClass(podStatus(pod), isReady(pod));
});
var services = appView.services || [];
var replicationControllers = appView.replicationControllers || [];
var size = Math.max(services.length, replicationControllers.length, 1);
var appName = appView.$info.name;
for (var i = 0; i < size; i++) {
var service = services[i];
var replicationController = replicationControllers[i];
var controllerId = getName(replicationController);
var name = getName(service) || controllerId;
var address = Core.pathGet(service, ["spec", "portalIP"]);
if (!name && pods.length) {
name = pods[0].idAbbrev;
}
if (!appView.$info.name) {
appView.$info.name = name;
}
if (!appView.id && pods.length) {
appView.id = getName(pods[0]);
}
if (i > 0) {
appName = name;
}
var podCount = pods.length;
var podCountText = podCount + " pod" + (podCount > 1 ? "s" : "");
var view = {
appName: appName || name,
name: name,
createdDate: appView.$creationDate,
podCount: podCount,
podCountText: podCountText,
address: address,
controllerId: controllerId,
service: service,
replicationController: replicationController,
pods: pods
};
array.push(view);
}
return array;
}
Kubernetes.createAppViewServiceViews = createAppViewServiceViews;
/**
* converts a git path into an accessible URL for the browser
*/
function gitPathToUrl(iconPath, branch) {
if (branch === void 0) { branch = "master"; }
return (HawtioCore.injector.get('AppLibraryURL') || '') + "/git/" + branch + iconPath;
}
Kubernetes.gitPathToUrl = gitPathToUrl;
function asDate(value) {
return value ? new Date(value) : null;
}
function enrichBuildConfig(buildConfig, sortedBuilds) {
if (buildConfig) {
var triggerUrl = null;
var metadata = buildConfig.metadata || {};
var name = metadata.name;
buildConfig.$name = name;
var projectLink = Developer.projectLink(name);
var ns = metadata.namespace || currentKubernetesNamespace();
buildConfig.$namespace = ns;
buildConfig.environments = [];
buildConfig.$creationDate = asDate(Kubernetes.getCreationTimestamp(buildConfig));
buildConfig.$labelsText = Kubernetes.labelsToString(getLabels(buildConfig));
if (name) {
buildConfig.$viewLink = UrlHelpers.join("workspaces", ns, "projects", name, "environments");
buildConfig.$editLink = UrlHelpers.join("workspaces", ns, "projects", name, "buildConfigEdit");
angular.forEach([false, true], function (flag) {
angular.forEach(buildConfig.triggers, function (trigger) {
if (!triggerUrl) {
var type = trigger.type;
if (type === "generic" || flag) {
var generic = trigger[type];
if (type && generic) {
var secret = generic.secret;
if (secret) {
triggerUrl = UrlHelpers.join(buildConfigHooksRestURL(), name, secret, type);
buildConfig.$triggerUrl = triggerUrl;
}
}
}
}
});
});
// lets find the latest build...
if (sortedBuilds) {
buildConfig.$lastBuild = _.find(sortedBuilds, {
metadata: {
labels: {
buildconfig: name
}
}
});
}
}
var $fabric8Views = {};
function defaultPropertiesIfNotExist(name, object, autoCreate) {
if (autoCreate === void 0) { autoCreate = false; }
var view = $fabric8Views[name];
if (autoCreate && !view) {
view = {};
$fabric8Views[name] = view;
}
if (view) {
angular.forEach(object, function (value, property) {
var current = view[property];
if (!current) {
view[property] = value;
}
});
}
}
function defaultPropertiesIfNotExistStartsWith(prefix, object, autoCreate) {
if (autoCreate === void 0) { autoCreate = false; }
angular.forEach($fabric8Views, function (view, name) {
if (view && name.startsWith(prefix)) {
angular.forEach(object, function (value, property) {
var current = view[property];
if (!current) {
view[property] = value;
}
});
}
});
}
var labels = metadata.labels || {};
var annotations = metadata.annotations || {};
// lets default the repo and user
buildConfig.$user = annotations["fabric8.jenkins/user"] || labels["user"];
buildConfig.$repo = annotations["fabric8.jenkins/repo"] || labels["repo"];
angular.forEach(annotations, function (value, key) {
var parts = key.split('/', 2);
if (parts.length > 1) {
var linkId = parts[0];
var property = parts[1];
if (linkId && property && linkId.startsWith("fabric8.link")) {
var link = $fabric8Views[linkId];
if (!link) {
link = {
class: linkId
};
$fabric8Views[linkId] = link;
}
link[property] = value;
}
}
});
if (buildConfig.$user && buildConfig.$repo) {
// browse gogs repo view
var gogsUrl = serviceLinkUrl(Kubernetes.gogsServiceName);
if (gogsUrl) {
defaultPropertiesIfNotExist("fabric8.link.browseGogs.view", {
label: "Browse...",
url: UrlHelpers.join(gogsUrl, buildConfig.$user, buildConfig.$repo),
description: "Browse the source code of this repository",
iconClass: "fa fa-external-link"
}, true);
}
// run forge commands view
defaultPropertiesIfNotExist("fabric8.link.forgeCommand.view", {
label: "Command...",
url: UrlHelpers.join(projectLink, "/forge/commands/user", buildConfig.$user, buildConfig.$repo),
description: "Perform an action on this project",
iconClass: "fa fa-play-circle"
}, true);
// configure devops view
defaultPropertiesIfNotExist("fabric8.link.forgeCommand.devops.settings", {
label: "Settings",
url: UrlHelpers.join(projectLink, "/forge/command/devops-edit/user", buildConfig.$user, buildConfig.$repo),
description: "Configure the DevOps settings for this project",
iconClass: "fa fa-pencil-square-o"
}, true);
}
// add some icons and descriptions
defaultPropertiesIfNotExist("fabric8.link.repository.browse", {
label: "Browse...",
description: "Browse the source code of this repository",
iconClass: "fa fa-external-link"
});
defaultPropertiesIfNotExist("fabric8.link.jenkins.job", {
iconClass: "fa fa-tasks",
description: "View the Jenkins Job for this build"
});
defaultPropertiesIfNotExist("fabric8.link.jenkins.monitor", {
iconClass: "fa fa-tachometer",
description: "View the Jenkins Monitor dashboard for this project"
});
defaultPropertiesIfNotExist("fabric8.link.jenkins.pipeline", {
iconClass: "fa fa-arrow-circle-o-right",
description: "View the Jenkins Pipeline for this project"
});
defaultPropertiesIfNotExist("fabric8.link.letschat.room", {
iconClass: "fa fa-comment",
description: "Chat room for this project"
});
defaultPropertiesIfNotExist("fabric8.link.letschat.room", {
iconClass: "fa fa-comment",
description: "Chat room for this project"
});
defaultPropertiesIfNotExist("fabric8.link.taiga", {
iconClass: "fa fa-check-square-o",
description: "Issue tracker for this project"
});
defaultPropertiesIfNotExist("fabric8.link.issues", {
iconClass: "fa fa-check-square-o",
description: "Issues for this project"
});
defaultPropertiesIfNotExist("fabric8.link.releases", {
iconClass: "fa fa-tag",
description: "Issues for this project"
});
defaultPropertiesIfNotExist("fabric8.link.taiga.team", {
iconClass: "fa fa-users",
description: "Team members for this project"
});
defaultPropertiesIfNotExist("fabric8.link.team", {
iconClass: "fa fa-users",
description: "Team members for this project"
});
defaultPropertiesIfNotExistStartsWith("fabric8.link.environment.", {
iconClass: "fa fa-cloud",
description: "The kubernetes namespace for this environment"
});
// lets put the views into sections...
var $fabric8CodeViews = {};
var $fabric8BuildViews = {};
var $fabric8TeamViews = {};
var $fabric8EnvironmentViews = {};
angular.forEach($fabric8Views, function (value, key) {
var view;
if (key.indexOf("taiga") > 0 || key.indexOf(".issue") > 0 || key.indexOf("letschat") > 0 || key.indexOf(".team") > 0) {
view = $fabric8TeamViews;
}
else if (key.indexOf("jenkins") > 0) {
view = $fabric8BuildViews;
}
else if (key.indexOf(".environment.") > 0) {
view = $fabric8EnvironmentViews;
}
else {
view = $fabric8CodeViews;
}
view[key] = value;
});
buildConfig.$fabric8Views = $fabric8Views;
buildConfig.$fabric8CodeViews = $fabric8CodeViews;
buildConfig.$fabric8BuildViews = $fabric8BuildViews;
buildConfig.$fabric8EnvironmentViews = $fabric8EnvironmentViews;
buildConfig.$fabric8TeamViews = $fabric8TeamViews;
var $jenkinsJob = annotations["fabric8.io/jenkins-job"];
if (!$jenkinsJob && $fabric8Views["fabric8.link.jenkins.job"]) {
$jenkinsJob = name;
}
buildConfig.$jenkinsJob = $jenkinsJob;
angular.forEach($fabric8EnvironmentViews, function (env) {
var c = env.class;
var prefix = "fabric8.link.environment.";
if (c && c.startsWith(prefix)) {
var ens = c.substring(prefix.length);
env.namespace = ens;
env.url = UrlHelpers.join("/workspaces", ns, "projects", name, "namespace", ens);
}
buildConfig.environments.push(env);
});
if (!buildConfig.environments.length) {
// lets create a single environment
var ens = ns;
var env = {
namespace: ens,
label: "Current",
description: "The environemnt that this project is built and run inside",
iconClass: "fa fa-cloud",
url: UrlHelpers.join("/workspaces", ns, "projects", name, "namespace", ens)
};
buildConfig.environments.push(env);
}
buildConfig.environments = buildConfig.environments.reverse();
buildConfig.tools = [];
angular.forEach($fabric8CodeViews, function (env) {
buildConfig.tools.push(env);
});
angular.forEach($fabric8TeamViews, function (env) {
buildConfig.tools.push(env);
});
}
}
Kubernetes.enrichBuildConfig = enrichBuildConfig;
function enrichBuildConfigs(buildConfigs, sortedBuilds) {
if (sortedBuilds === void 0) { sortedBuilds = null; }
angular.forEach(buildConfigs, function (buildConfig) {
enrichBuildConfig(buildConfig, sortedBuilds);
});
return buildConfigs;
}
Kubernetes.enrichBuildConfigs = enrichBuildConfigs;
function enrichBuilds(builds) {
angular.forEach(builds, function (build) {
enrichBuild(build);
});
return _.sortBy(builds, "$creationDate").reverse();
}
Kubernetes.enrichBuilds = enrichBuilds;
function enrichBuild(build) {
if (build) {
var metadata = build.metadata || {};
var annotations = metadata.annotations || {};
var name = getName(build);
var namespace = getNamespace(build);
build.$name = name;
build.$namespace = namespace;
var nameArray = name.split("-");
var nameArrayLength = nameArray.length;
build.$shortName = (nameArrayLength > 4) ? nameArray.slice(0, nameArrayLength - 4).join("-") : name.substring(0, 30);
var labels = getLabels(build);
var configId = labels.buildconfig;
build.$configId = configId;
if (configId) {
//build.$configLink = UrlHelpers.join("kubernetes/buildConfigs", configId);
build.$configLink = UrlHelpers.join("workspaces", currentKubernetesNamespace(), "projects", configId);
}
var creationTimestamp = getCreationTimestamp(build);
if (creationTimestamp) {
var d = new Date(creationTimestamp);
build.$creationDate = d;
}
if (name) {
//build.$viewLink = UrlHelpers.join("kubernetes/builds", name);
var projectLink = UrlHelpers.join("workspaces", currentKubernetesNamespace(), "projects", configId);
build.$viewLink = UrlHelpers.join(projectLink, "builds", name);
//build.$logsLink = UrlHelpers.join("kubernetes/buildLogs", name);
build.$logsLink = UrlHelpers.join(projectLink, "buildLogs", name);
}
build.podName = build.podName || annotations["openshift.io/build.pod-name"];
var podName = build.podName;
if (podName && namespace) {
var podNameArray = podName.split("-");
var podNameArrayLength = podNameArray.length;
build.$podShortName = (podNameArrayLength > 5) ? podNameArray[podNameArrayLength - 5] : podName.substring(0, 30);
build.$podLink = UrlHelpers.join("kubernetes/namespace", namespace, "pods", podName);
}
}
return build;
}
Kubernetes.enrichBuild = enrichBuild;
function enrichDeploymentConfig(deploymentConfig) {
if (deploymentConfig) {
var triggerUrl = null;
var name = Core.pathGet(deploymentConfig, ["metadata", "name"]);
deploymentConfig.$name = name;
var found = false;
angular.forEach(deploymentConfig.triggers, function (trigger) {
var type = trigger.type;
if (!deploymentConfig.$imageChangeParams && type === "ImageChange") {
var imageChangeParams = trigger.imageChangeParams;
if (imageChangeParams) {
var containerNames = imageChangeParams.containerNames || [];
imageChangeParams.$containerNames = containerNames.join(" ");
deploymentConfig.$imageChangeParams = imageChangeParams;
}
}
});
}
}
Kubernetes.enrichDeploymentConfig = enrichDeploymentConfig;
function enrichDeploymentConfigs(deploymentConfigs) {
angular.forEach(deploymentConfigs, function (deploymentConfig) {
enrichDeploymentConfig(deploymentConfig);
});
return deploymentConfigs;
}
Kubernetes.enrichDeploymentConfigs = enrichDeploymentConfigs;
function enrichEvent(event) {
if (event) {
var metadata = event.metadata || {};
var firstTimestamp = event.firstTimestamp;
if (firstTimestamp) {
var d = new Date(firstTimestamp);
event.$firstTimestamp = d;
}
var lastTimestamp = event.lastTimestamp;
if (lastTimestamp) {
var d = new Date(lastTimestamp);
event.$lastTimestamp = d;
}
var labels = angular.copy(event.source || {});
var involvedObject = event.involvedObject || {};
var name = involvedObject.name;
var kind = involvedObject.kind;
if (name) {
labels['name'] = name;
}
if (kind) {
labels['kind'] = kind;
}
event.$labelsText = Kubernetes.labelsToString(labels);
}
}
Kubernetes.enrichEvent = enrichEvent;
function enrichEvents(events, model) {
if (model === void 0) { model = null; }
angular.forEach(events, function (event) {
enrichEvent(event);
});
// lets update links to the events for each pod and RC
if (model) {
function clearEvents(entity) {
entity.$events = [];
entity.$eventsLink = null;
entity.$eventCount = 0;
}
function updateEvent(entity, event) {
if (entity) {
entity.$events.push(event);
if (!entity.$eventsLink) {
entity.$eventsLink = UrlHelpers.join("/kubernetes/namespace/", currentKubernetesNamespace(), "events") + "?q=kind%3D" + entity.kind + "%20name%3D" + entity.metadata.name;
}
entity.$eventCount = entity.$events.length;
}
}
var pods = model.pods || [];
var rcs = model.replicationControllers || [];
angular.forEach(pods, clearEvents);
angular.forEach(rcs, clearEvents);
angular.forEach(events, function (event) {
var involvedObject = event.involvedObject || {};
var name = involvedObject.name;
var kind = involvedObject.kind;
var ns = model.currentNamespace();
if (name && kind && ns) {
var entity = null;
if (kind === "ReplicationController") {
entity = model.getReplicationController(ns, name);
}
else if (kind === "Pod") {
entity = model.getPod(ns, name);
}
if (entity) {
updateEvent(entity, event);
}
}
});
}
return events;
}
Kubernetes.enrichEvents = enrichEvents;
function enrichImageRepository(imageRepository) {
if (imageRepository) {
var triggerUrl = null;
var name = Core.pathGet(imageRepository, ["metadata", "name"]);
imageRepository.$name = name;
}
}
Kubernetes.enrichImageRepository = enrichImageRepository;
function enrichImageRepositories(imageRepositories) {
angular.forEach(imageRepositories, function (imageRepository) {
enrichImageRepository(imageRepository);
});
return imageRepositories;
}
Kubernetes.enrichImageRepositories = enrichImageRepositories;
var labelColors = {
'region': 'k8s-badge-region',
'system': 'k8s-badge-system',
'isTarget': 'k8s-badge-target',
};
function containerLabelClass(labelType) {
if (!(labelType in labelColors)) {
return 'mouse-pointer';
}
else
return labelColors[labelType] + ' mouse-pointer';
}
Kubernetes.containerLabelClass = containerLabelClass;
/**
* Returns true if the fabric8 forge plugin is enabled
*/
function isForgeEnabled() {
// TODO should return true if the service "fabric8-forge" is valid
return true;
}
Kubernetes.isForgeEnabled = isForgeEnabled;
/**
* Returns the current kubernetes selected namespace or the default one
*/
function currentKubernetesNamespace() {
var injector = HawtioCore.injector;
if (injector) {
var KubernetesState = injector.get("KubernetesState") || {};
return KubernetesState.selectedNamespace || Kubernetes.defaultNamespace;
}
return Kubernetes.defaultNamespace;
}
Kubernetes.currentKubernetesNamespace = currentKubernetesNamespace;
function setCurrentKubernetesNamespace(ns) {
if (ns) {
var KubernetesState = inject("KubernetesState") || {};
KubernetesState.selectedNamespace = ns;
}
}
Kubernetes.setCurrentKubernetesNamespace = setCurrentKubernetesNamespace;
/**
* Configures the json schema
*/
function configureSchema() {
angular.forEach(Kubernetes.schema.definitions, function (definition, name) {
var properties = definition.properties;
if (properties) {
var hideProperties = ["creationTimestamp", "kind", "apiVersion", "annotations", "additionalProperties", "namespace", "resourceVersion", "selfLink", "uid"];
angular.forEach(hideProperties, function (propertyName) {
var property = properties[propertyName];
if (property) {
property["hidden"] = true;
}
});
angular.forEach(properties, function (property, propertyName) {
var ref = property["$ref"];
var type = property["type"];
if (ref && (!type || type === "object")) {
property["type"] = ref;
}
if (type === "array") {
var items = property["items"];
if (items) {
var ref = items["$ref"];
var type = items["type"];
if (ref && (!type || type === "object")) {
items["type"] = ref;
}
}
}
});
}
Kubernetes.schema.definitions.os_build_WebHookTrigger.properties.secret.type = "password";
});
}
Kubernetes.configureSchema = configureSchema;
/**
* Lets remove any enriched data to leave the original json intact
*/
function unenrich(item) {
var o = _.cloneDeep(item);
angular.forEach(o, function (value, key) {
if (key.startsWith("$") || key.startsWith("_")) {
delete o[key];
}
});
delete o['connectTo'];
return o;
}
Kubernetes.unenrich = unenrich;
/**
* Returns the unenriched JSON representation of an object
*/
function toRawJson(item) {
var o = unenrich(item);
return JSON.stringify(o, null, 2); // spacing level = 2
}
Kubernetes.toRawJson = toRawJson;
/**
* Returns the unenriched YAML representation of an object
*/
function toRawYaml(item) {
var o = unenrich(item);
return jsyaml.dump(o, { indent: 2 });
}
Kubernetes.toRawYaml = toRawYaml;
function watch($scope, $element, kind, ns, fn, labelSelector) {
if (labelSelector === void 0) { labelSelector = null; }
var connection = KubernetesAPI.watch({
kind: kind,
namespace: ns,
labelSelector: labelSelector,
success: function (objects) {
fn(objects);
Core.$apply($scope);
}
});
$element.on('$destroy', function () {
console.log("Static controller[" + kind + ", " + ns + "] element destroyed");
$scope.$destroy();
});
$scope.$on('$destroy', function () {
console.log("Static controller[" + kind + ", " + ns + "] scope destroyed");
connection.disconnect();
});
var oldDeleteScopeFn = $scope.deleteScope;
$scope.deleteScope = function () {
$element.remove();
if (angular.isFunction(oldDeleteScopeFn)) {
oldDeleteScopeFn();
}
};
}
Kubernetes.watch = watch;
function createKubernetesClient(kind, ns) {
if (ns === void 0) { ns = null; }
var K8SClientFactory = inject("K8SClientFactory");
if (!K8SClientFactory) {
Kubernetes.log.warn("Could not find injected K8SClientFactory!");
return null;
}
if (kind === "projects" || kind === "namespaces") {
ns = null;
}
else if (!ns) {
ns = Kubernetes.currentKubernetesNamespace();
}
return K8SClientFactory.create(kind, ns);
}
Kubernetes.createKubernetesClient = createKubernetesClient;
function currentUserName() {
var userDetails = HawtioOAuth.getUserProfile();
var answer = null;
if (userDetails) {
answer = getName(userDetails);
}
return answer || "admin";
}
Kubernetes.currentUserName = currentUserName;
function createNamespace(ns, client) {
if (!client) {
client = Kubernetes.isOpenShift ? Kubernetes.createKubernetesClient('projects') : Kubernetes.createKubernetesClient('namespaces');
}
if (ns && ns !== currentKubernetesNamespace()) {
var object = {
apiVersion: Kubernetes.defaultApiVersion,
kind: Kubernetes.isOpenShift ? 'Project' : 'Namespace',
metadata: {
name: ns,
labels: {}
}
};
client.put(object, function (data) {
Kubernetes.log.info("Created namespace: " + ns);
}, function (err) {
Kubernetes.log.warn("Failed to create namespace: " + ns + ": " + angular.toJson(err));
});
}
}
Kubernetes.createNamespace = createNamespace;
function createRC(obj, onCompleteFn) {
if (onCompleteFn === void 0) { onCompleteFn = null; }
var client = Kubernetes.createKubernetesClient('replicationcontrollers', 'default');
var RCTemplate = new Kubernetes.resourceRCTemplate();
var rcTemplate = RCTemplate.createRC(obj);
client.put(rcTemplate, function (obj) {
if (angular.isFunction(onCompleteFn)) {
onCompleteFn(obj);
}
}, function (err) {
console.log(err);
});
}
Kubernetes.createRC = createRC;
function connectOracle($http, $timeout, url, operation, replicas, delayTime) {
$timeout(function () {
$http({
url: url,
method: 'POST',
params: { oracleName: getName(replicas), operation: operation },
}).success(function (data, header, config, status) {
console.log("success");
}).error(function (data, header, config, status) {
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
});
}, delayTime);
}
Kubernetes.connectOracle = connectOracle;
function getOracleStatus(labels) {
var answer = -1;
if (typeof (labels) === 'object' && labels.hasOwnProperty("status")) {
switch (labels.status) {
case '0':
answer = 0;
break;
case '1':
answer = 1;
break;
case '2':
answer = 2;
break;
default:
answer = -1;
}
}
return answer;
}
Kubernetes.getOracleStatus = getOracleStatus;
function getExtractStatus(labels) {
if (labels.isTarget === 'false') {
return parseInt(labels.isExtract);
}
else {
return 10;
}
}
Kubernetes.getExtractStatus = getExtractStatus;
function getOracleName(replicas) {
var annotation = getAnnotations(replicas);
return annotation["cityName"] + "-" + annotation["districtName"] + "-" + annotation["systemName"];
}
Kubernetes.getOracleName = getOracleName;
function extractDataToOracle($http, url, selectedReplicationControllers, targetOracle, fn) {
//console.log(targetReplicationController.length);
var answer = targetOracle && true;
var inneedOracle = [];
selectedReplicationControllers.forEach(function (rc) {
var annotations = getAnnotations(rc);
answer = answer && checkoutOracleIsRunning(rc);
inneedOracle.push({
"name": getName(rc),
"ip": getHost(rc.$pods[0]),
"port": rc.$pods[0].spec.containers[0].ports[0].hostPort,
"dataId": annotations["id"]
});
});
if (answer) {
var data = { "name": targetOracle.id, "target": targetOracle, "inneed": inneedOracle };
var spinner;
$.ajax({
type: "POST",
url: UrlHelpers.join(url, targetOracle.id + "", "extract"),
timeout: 8000,
dataType: 'json',
//async: false,
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
beforeSend: function () {
Configs.create_mask(); //创建遮罩层
create_locadEffect("正在验证汇总库配置信息,请稍等!"); //创建数据加载效果层
var target = document.getElementById('loading');
spinner = new Spinner(loadConfigs()).spin(target);
},
complete: function (XMLHttpRequest, textStatus) {
if (XMLHttpRequest.status == 200) {
//spinner.spin();
Kubernetes.createSuccessInfo("success", "连接汇总库成功,即将执行汇总或抽取操作!");
setTimeout("Kubernetes.removeMask()", 1500);
}
else {
//spinner.spin();
Kubernetes.createSuccessInfo("error", "连接汇总库失败,请检查服务集群中的汇总库配置是否正确!");
setTimeout("Kubernetes.removeMask()", 1500);
}
},
success: function (data) {
}
});
}
else {
//alert("您选择的汇总数据库或需要汇总的数据库中存在未启动成功的数据库,导致汇总操作失败,请重新选择!");
Configs.customAlert("提示", "操作失败:需要汇总的数据库中存在未启动成功的数据库!", '', null, 0, "error");
}
}
Kubernetes.extractDataToOracle = extractDataToOracle;
function checkoutOracleIsRunning(rc) {
if (rc.$podCounters.ready && rc.$oracleStatus == 2) {
return true;
}
else {
return false;
}
}
Kubernetes.checkoutOracleIsRunning = checkoutOracleIsRunning;
function replicasIsCreated(replicationcontrollers, name) {
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;
}
Kubernetes.replicasIsCreated = replicasIsCreated;
function loadConfigs() {
return {
lines: 9,
length: 0,
width: 13,
radius: 38,
scale: 1,
corners: 1,
color: '#ffffff',
opacity: 0,
rotate: 90,
direction: 1,
speed: 0.5,
trail: 50,
zIndex: 1000000002,
className: 'spinner',
top: '40%',
left: '50%',
shadow: false,
hwaccel: false,
position: 'absolute'
};
}
Kubernetes.loadConfigs = loadConfigs;
/*
创建加载效果层
*/
function create_locadEffect(msg) {
var tmp = ""
+ "" + msg + "";
var load = document.createElement("div");
load.id = "load";
load.innerHTML = tmp;
document.body.appendChild(load);
$("#load").addClass("load-effect-msg");
}
Kubernetes.create_locadEffect = create_locadEffect;
function createSuccessInfo(icon, msg) {
$("#load").remove();
Configs.customAlert("提示", msg, '', null, 0, icon);
/*var tmp = ""
+ "" + msg +"";
var result = document.createElement("div");
result.id = "exe_result";
result.innerHTML = tmp;
document.body.appendChild(result);*/
}
Kubernetes.createSuccessInfo = createSuccessInfo;
function removeMask() {
var mask = document.getElementById("mask");
//var result = document.getElementById("exe_result");
if (null == mask)
return;
document.body.removeChild(mask);
//document.body.removeChild(result);
}
Kubernetes.removeMask = removeMask;
function checkRCIsExtracting(selected) {
var answer = false;
for (var i = 0; i < selected.length; i++) {
var label = getLabels(selected[i]);
if (label.isExtract == 1) {
answer = true;
break;
}
}
return answer;
}
Kubernetes.checkRCIsExtracting = checkRCIsExtracting;
})(Kubernetes || (Kubernetes = {}));
/// duration: ' + y + ' seconds
'; if (date) { tooltip += 'started: ' + date + '
'; } if (result) { tooltip += 'result: ' + result + '
'; } if (x) { var data = buildsSucceeded; var key = successBuildKey; if (!successBuildKey && (!result || !result.startsWith("SUCC"))) { data = buildsFailed; key = failedBuildKey; } data.push({ tooltip: tooltip, color: color, x: x, y: y }); } }); $scope.data = []; if (buildsSucceeded.length) { $scope.data.push({ key: successBuildKey, values: buildsSucceeded }); } if (buildsFailed.length) { $scope.data.push({ key: failedBuildKey, values: buildsFailed }); } $scope.api.updateWithData($scope.data); $timeout(function () { $scope.api.update(); }, 50); } function updateData() { var metricsPath = $scope.jobId ? UrlHelpers.join("job", $scope.jobId, "fabric8/metrics") : "fabric8/metrics"; var url = Kubernetes.kubernetesProxyUrlForServiceCurrentNamespace(Developer.jenkinsServiceNameAndPort, metricsPath); Developer.log.info(""); if (url && (!$scope.jenkins || Kubernetes.keepPollingModel)) { $http.get(url, Developer.jenkinsHttpConfig). success(function (data, status, headers, config) { if (data) { if (Developer.hasObjectChanged(data, $scope.entityChangedCache)) { Developer.log.info("entity has changed!"); $scope.metrics = data; updateChartData(); } } $scope.model.fetched = true; Core.$apply($scope); }). error(function (data, status, headers, config) { Developer.log.warn("Failed to load " + url + " " + data + " " + status); }); } } }]); })(Developer || (Developer = {})); ///Please wait, fetching logs...
\nView previous container logs?
\n \nThere are no tools currently available.
\r\nThere are no tools currently available.
\r\nEnvironment is a logical place where deployments happen which maps to a kubernetes / openshift namespace. You will see environments here after you add a build.
\r\n New Build\r\n当前没有可以查看的任务列表!
\n\r\n Please choose the perspective you would like to use:\r\n
\r\n\r\n \r\n \r\n  Develop »\r\n \r\n
\r\n\r\n\r\n Work on projects and source code\r\n
\r\n\r\n \r\n \r\n Operate »\r\n \r\n
\r\n\r\n\r\n Manage and run Pods and Services\r\n
\r\nThere are no builds in this job.
\r\nThere are no jobs in this jenkins.
\r\nThere are no completed builds in this job.
\r\nThere are no pipeline stages in this build.
\r\nThere are no pipelines for this job.
\r\nThere are no projects in this workspace.
\r\nThere are no tools currently available.
\r\nThere are no tools currently available.
\r\n当前没有可以查看的数据.
\n\r\n \r\n | \r\n\r\n \r\n \r\n \r\n | \r\n\r\n \r\n Pod {{pod.idAbbrev}}\r\n \r\n \r\n IP:\r\n {{pod.status.podIP}}\r\n \r\n | \r\n \r\n \r\n | \r\n
There are no apps currently available.
\r\nThere are no build configurations available.
\r\n Add Build Configuration\r\n\r\n
\r\n \r\n {{logsText}}\r\n
\r\n
\r\n \r\n There are no builds currently running.
\r\nThere are no deployment configurations available.
\r\n Create Deployment Configuration\r\nThere are no hosts currently running.
\r\nThere are no image repositories available.
\r\n Create Image Repository\r\n\r\n Create a project by entering or copy/pasting the Git URL for a repository, and give the project a name. By default the name will be based on the repository name.\r\n
\r\n\r\n \r\n\r\n \r\n\r\nPipeline is a kind of build which uses Jenkins Workflow internally which has multiple Stages. You will see the active pipelines here after you add a build to this project
\r\nThere are no build pipelines available.
\r\n Create Build Configuration\r\nThere are no pods currently running.
\r\n当前没有正在运行的oracle服务.
\r\nThere are no secrets currently available.
\r\n当前没有可以查看的数据.
\n\n {{row.code}} | \n\n {{row.cityName}} | \n\n {{row.districtName}} | \n
当前没有可以查看的数据.
\n\n {{row.code}} | \n\n {{row.systemName}} | \n
\n {{row[col.field]}}\n \n | \n
\n \n | \n\n 有缺失\n 正常\n 待归档\n 待审核\n | \n{{row.areaCode}} | \n{{row.cityName}} | \n{{row.districtName}} | \n{{row.sysName}} | \n{{row.dataBaseType}} | \n\n \n \n \n \n —\n | \n\n \n \n \n \n —\n | \n\n \n \n \n \n —\n | \n
\n \n | \n{{row.checkResult}} | \n{{row.collection}} | \n\n 未校验\n 不需校验\n 校验中\n 标准表存在\n 标准表不存在\n 待抽取\n 正在抽取\n 抽取完成\n | \n\n 未校验\n 不需校验\n 校验中\n 标准表存在\n 标准表不存在\n 待抽取\n 正在抽取\n 抽取完成\n | \n{{row.cityName}} | \n{{row.districtName}} | \n{{row.areaCode}} | \n\n \n 否\n | \n{{row.sysName}} | \n{{row.dataVersion}} | \n{{row.departmentManager}} | \n{{row.managerContacts}} | \n{{row.dataBaseType}} | \n\n 热区\n 冷区\n 无\n | \n\n \n | \n
已启用 | \n已停止 | \n\n {{volume.name}}\n | \n\n 云路径:{{volume.path}}\n | \n\n 存储类型:\n 热区\n 冷区\n | \n\n 已用 {{volume.formatUsedSize}} / 共 {{volume.formatTotalSize}}\n | \n\n \n \n | \n
---|---|---|---|---|---|---|
\n \n \n | \n\n 服务器{{$index+1}}\n | \n\n {{row.ip}}\n | \n\n 存储路径:{{row.path}}\n | \n\n | \n\n |
\n 是否删除:{{showDeleteVolume.item.name}} 云盘?\n
\n当前没有配置汇总库信息,请配置,否则汇总操作将不可用!
\n