Commit 0c4408dd by Jon Jackson

Remove hawtio dependency

parent 9abeb9c4
......@@ -25,8 +25,6 @@
"ansi_up": false,
"c3": false,
"d3": false,
"hawtioPluginLoader": false,
"HawtioCore": false,
"Logger" : false,
"LabelSelector": false,
"ResourceGroupVersion": false,
......
......@@ -36,25 +36,51 @@ module.exports = function (grunt) {
},
concat: {
options: {
separator: ';'
separator: ';\n'
},
ui: {
src: ['src/**/*UI.module.js', 'dist/scripts/templates.js', 'src/components/**/*.js', 'src/filters/**/*.js', 'src/ui-services/**/*.js'],
src: [
'src/pluginLoader.js',
'src/*UI.module.js',
'dist/scripts/templates.js',
'src/components/**/*.js',
'src/filters/**/*.js',
'src/ui-services/**/*.js'
],
dest: 'dist/origin-web-common-ui.js'
},
services: {
src: ['src/**/*Services.module.js', 'src/services/**/*.js', 'src/constants/**/*.js'],
src: [
'src/pluginLoader.js',
'src/*Services.module.js',
'src/services/**/*.js',
'src/constants/**/*.js'
],
dest: 'dist/origin-web-common-services.js'
},
dist: {
src: ['src/**/*.module.js', 'dist/scripts/templates.js', 'src/**/*.js'],
src: [
'src/pluginLoader.js',
'src/*.module.js',
'dist/scripts/templates.js',
'src/constants/**/*.js',
'src/filters/**/*.js',
'src/services/**/*.js',
'src/ui-services/**/*.js',
'src/components/**/*.js'
],
dest: 'dist/origin-web-common.js'
}
},
copy: {
main: {
files: [
{expand: true, cwd: 'src/styles/', src: ['*'], dest: 'dist/less/'}
{
expand: true,
cwd: 'src/styles/',
src: ['*'],
dest: 'dist/less/'
}
]
}
},
......@@ -71,7 +97,10 @@ module.exports = function (grunt) {
},
options: {
cleancss: true,
paths: ['src/styles', 'bower_components/']
paths: [
'src/styles',
'bower_components/'
]
}
}
},
......@@ -129,17 +158,35 @@ module.exports = function (grunt) {
src: 'dist/origin-web-common.js',
dest: 'dist/origin-web-common.min.js'
}
}
});
// You can specify which modules to build as arguments of the build task.
grunt.registerTask('build', 'Create bootstrap build files', function () {
grunt.task.run(['clean', 'ngtemplates', 'concat', 'copy', 'ngAnnotate', 'less', 'uglify:build', 'test']);
grunt.task.run([
'clean',
'ngtemplates',
'concat',
'copy',
'ngAnnotate',
'less',
'uglify:build',
'test'
]);
});
// Runs all the tasks of build with the exception of tests
grunt.registerTask('deploy', 'Prepares the project for deployment. Does not run unit tests', function () {
grunt.task.run(['clean', 'ngtemplates', 'concat', 'copy', 'ngAnnotate', 'less', 'uglify:build']);
grunt.task.run([
'clean',
'ngtemplates',
'concat',
'copy',
'ngAnnotate',
'less',
'uglify:build'
]);
});
grunt.registerTask('default', ['build']);
......
......@@ -30,10 +30,9 @@
"angular": "~1.5.11",
"angular-sanitize": "~1.5.11",
"angular-utf8-base64": "~0.0.5",
"hawtio-core": "~2.0.37",
"hawtio-extension-service": "~2.0.2",
"hopscotch": "~0.2.7",
"jquery": "~3.2.1",
"js-logger": "~0.9.14",
"kubernetes-label-selector": "~2.1.1",
"lodash": "~4.17.4",
"patternfly": ">=3.27.2 <4.0",
......
/*
* This is a pared down version of hawtio-core in order to remove the outdated
* dependency as part the migration from bower to yarn.
*
* TODO Figure out a better strategy for API discovery so that this can be
* removed altogether.
*
*/
// log initialization
/* globals Logger window console document localStorage $ angular jQuery navigator Jolokia */
(function() {
'use strict';
Logger.setLevel(Logger.INFO);
window['LogBuffer'] = 100;
if ('localStorage' in window) {
if (!('logLevel' in window.localStorage)) {
window.localStorage['logLevel'] = JSON.stringify(Logger.INFO);
}
var logLevel = Logger.DEBUG;
try {
logLevel = JSON.parse(window.localStorage['logLevel']);
} catch (e) {
console.error("Failed to parse log level setting: ", e);
}
Logger.setLevel(logLevel);
if ('logBuffer' in window.localStorage) {
var logBuffer = window.localStorage['logBuffer'];
window['LogBuffer'] = parseInt(logBuffer, 10);
} else {
window.localStorage['logBuffer'] = window['LogBuffer'];
}
}
})();
/*
* Plugin loader and discovery mechanism
*/
var pluginLoader = (function(self) {
'use strict';
var log = Logger;
var bootstrapEl = document.documentElement;
self.log = log;
/**
* Holds all of the angular modules that need to be bootstrapped
* @type {Array}
*/
self.modules = [];
/**
* Tasks to be run before bootstrapping, tasks can be async.
* Supply a function that takes the next task to be
* executed as an argument and be sure to call the passed
* in function.
*
* @type {Array}
*/
self.tasks = [];
self.setBootstrapElement = function(el) {
log.debug("Setting bootstrap element to: ", el);
bootstrapEl = el;
}
self.getBootstrapElement = function() {
return bootstrapEl;
}
self.registerPreBootstrapTask = function(task, front) {
if (angular.isFunction(task)) {
log.debug("Adding legacy task");
task = {
task: task
};
}
if (!task.name) {
task.name = 'unnamed-task-' + (self.tasks.length + 1);
}
if (task.depends && !angular.isArray(task.depends) && task.depends !== '*') {
task.depends = [task.depends];
}
if (!front) {
self.tasks.push(task);
} else {
self.tasks.unshift(task);
}
};
self.addModule = function(module) {
log.debug("Adding module: " + module);
self.modules.push(module);
};
self.getModules = function() {
return self.modules;
};
self.loaderCallback = null;
self.setLoaderCallback = function(cb) {
self.loaderCallback = cb;
};
function intersection(search, needle) {
if (!angular.isArray(needle)) {
needle = [needle];
}
var answer = [];
needle.forEach(function(n) {
search.forEach(function(s) {
if (n === s) {
answer.push(s);
}
});
});
return answer;
}
self.loadPlugins = function(callback) {
var lcb = self.loaderCallback;
var plugins = {};
var bootstrap = function() {
var executedTasks = [];
var deferredTasks = [];
var bootstrapTask = {
name: 'Bootstrap',
depends: '*',
runs: 0,
task: function(next) {
function listTasks() {
deferredTasks.forEach(function(task) {
self.log.info(" name: " + task.name + " depends: ", task.depends);
});
}
if (deferredTasks.length > 0) {
self.log.info("tasks yet to run: ");
listTasks();
bootstrapTask.runs = bootstrapTask.runs + 1;
self.log.info("Task list restarted : ", bootstrapTask.runs, " times");
if (bootstrapTask.runs === 5) {
self.log.info("Orphaned tasks: ");
listTasks();
deferredTasks.length = 0;
} else {
deferredTasks.push(bootstrapTask);
}
}
self.log.debug("Executed tasks: ", executedTasks);
next();
}
}
self.registerPreBootstrapTask(bootstrapTask);
var executeTask = function() {
var tObj = null;
var tmp = [];
// if we've executed all of the tasks, let's drain any deferred tasks
// into the regular task queue
if (self.tasks.length === 0) {
tObj = deferredTasks.shift();
}
// first check and see what tasks have executed and see if we can pull a task
// from the deferred queue
while(!tObj && deferredTasks.length > 0) {
var task = deferredTasks.shift();
if (task.depends === '*') {
if (self.tasks.length > 0) {
tmp.push(task);
} else {
tObj = task;
}
} else {
var intersect = intersection(executedTasks, task.depends);
if (intersect.length === task.depends.length) {
tObj = task;
} else {
tmp.push(task);
}
}
}
if (tmp.length > 0) {
tmp.forEach(function(task) {
deferredTasks.push(task);
});
}
// no deferred tasks to execute, let's get a new task
if (!tObj) {
tObj = self.tasks.shift();
}
// check if task has dependencies
if (tObj && tObj.depends && self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' has dependencies: ", tObj.depends);
if (tObj.depends === '*') {
if (self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' wants to run after all other tasks, deferring");
deferredTasks.push(tObj);
executeTask();
return;
}
} else {
var intersect = intersection(executedTasks, tObj.depends);
if (intersect.length != tObj.depends.length) {
self.log.debug("Deferring task: '" + tObj.name + "'");
deferredTasks.push(tObj);
executeTask();
return;
}
}
}
if (tObj) {
self.log.debug("Executing task: '" + tObj.name + "'");
var called = false;
var next = function() {
if (next.notFired) {
next.notFired = false;
executedTasks.push(tObj.name);
setTimeout(executeTask, 1);
}
}
next.notFired = true;
tObj.task(next);
} else {
self.log.debug("All tasks executed");
setTimeout(callback, 1);
}
};
setTimeout(executeTask, 1);
};
var loadScripts = (function() {
// keep track of when scripts are loaded so we can execute the callback
var loaded = 0;
$.each(plugins, function(key, data) {
loaded = loaded + data.Scripts.length;
});
var totalScripts = loaded;
var scriptLoaded = function() {
$.ajaxSetup({async:true});
loaded = loaded - 1;
if (lcb) {
lcb.scriptLoaderCallback(lcb, totalScripts, loaded + 1);
}
if (loaded === 0) {
bootstrap();
}
};
if (loaded > 0) {
$.each(plugins, function(key, data) {
data.Scripts.forEach( function(script) {
var scriptName = data.Context + "/" + script;
log.debug("Fetching script: ", scriptName);
$.ajaxSetup({async:false});
$.getScript(scriptName)
.done(function(textStatus) {
log.debug("Loaded script: ", scriptName);
})
.fail(function(jqxhr, settings, exception) {
log.info("Failed loading script: \"", exception.message, "\" (<a href=\"", scriptName, ":", exception.lineNumber, "\">", scriptName, ":", exception.lineNumber, "</a>)");
})
.always(scriptLoaded);
});
});
} else {
// no scripts to load, so just do the callback
$.ajaxSetup({async:true});
bootstrap();
}
return this;
})();
};
self.debug = function() {
log.debug("modules");
log.debug(self.modules);
};
self.setLoaderCallback({
scriptLoaderCallback: function (self, total, remaining) {
log.debug("Total scripts: ", total, " Remaining: ", remaining);
}
});
return self;
})(pluginLoader || {}, window, undefined);
// Plugin responsible for bootstrapping the app
var BootstrapPlugin = (function () {
'use strict';
function BootstrapPluginClass(){}
/**
* The app's injector, set once bootstrap is completed
*/
Object.defineProperty(BootstrapPluginClass.prototype, "injector", {
get: function() {
return BootstrapPlugin._injector;
},
enumerable: true,
configurable: true
});
var BootstrapPlugin = new BootstrapPluginClass();
/**
* This plugin's name and angular module
*/
BootstrapPlugin.pluginName = "bootstrap-plugin";
/**
* This plugins logger instance
*/
var log = Logger.get(BootstrapPlugin.pluginName);
var _module = angular.module(BootstrapPlugin.pluginName, []);
_module.config(["$locationProvider", function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
_module.run(['documentBase', function (documentBase) {
log.debug("loaded");
}]);
BootstrapPlugin.documentBase = function() {
var base = $('head').find('base');
var answer = '/'
if (base && base.length > 0) {
answer = base.attr('href');
} else {
log.warn("Document is missing a 'base' tag, defaulting to '/'");
}
return answer;
}
// Holds the document base so plugins can easily
// figure out absolute URLs when needed
_module.factory('documentBase', function() {
return BootstrapPlugin.documentBase();
});
pluginLoader.addModule("ng");
pluginLoader.addModule("ngSanitize");
pluginLoader.addModule(BootstrapPlugin.pluginName);
// bootstrap the app
$(function () {
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if ( !jQuery.browser ) {
var matched = jQuery.uaMatch( navigator.userAgent );
var browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
}
pluginLoader.loadPlugins(function() {
if (BootstrapPlugin.injector) {
log.debug("Application already bootstrapped");
return;
}
var bootstrapEl = pluginLoader.getBootstrapElement();
log.debug("Using bootstrap element: ", bootstrapEl);
BootstrapPlugin._injector = angular.bootstrap(bootstrapEl, pluginLoader.getModules(), {
strictDi: false
});
log.debug("Bootstrapped application");
});
});
return BootstrapPlugin;
})();
// Create an alias for hawtioPluginLoader since it may still be used in other
// downstream repos.
window.hawtioPluginLoader = pluginLoader;
;
/**
* @name openshiftCommonServices
*
......@@ -25,11 +452,11 @@ angular.module('openshiftCommonServices', ['ab-base64'])
RedirectLoginServiceProvider.OAuthRedirectURI(URI(AUTH_CFG.oauth_redirect_base).segment("oauth").toString());
});
hawtioPluginLoader.addModule('openshiftCommonServices');
pluginLoader.addModule('openshiftCommonServices');
// API Discovery, this runs before the angular app is bootstrapped
// TODO we want this to be possible with a single request against the API instead of being dependent on the numbers of groups and versions
hawtioPluginLoader.registerPreBootstrapTask(function(next) {
pluginLoader.registerPreBootstrapTask(function(next) {
// Skips api discovery, needed to run spec tests
if ( _.get(window, "OPENSHIFT_CONFIG.api.k8s.resources") ) {
next();
......@@ -154,7 +581,8 @@ hawtioPluginLoader.registerPreBootstrapTask(function(next) {
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.service("AlertMessageService", function(){
......@@ -176,7 +604,8 @@ angular.module("openshiftCommonServices")
}
};
});
;'use strict';
;
'use strict';
// ResourceGroupVersion represents a fully qualified resource
function ResourceGroupVersion(resource, group, version) {
......@@ -584,7 +1013,8 @@ angular.module('openshiftCommonServices')
getPreferredVersion: getPreferredVersion
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices").
service("ApplicationsService", function(
......@@ -664,7 +1094,8 @@ service("ApplicationsService", function(
getApplications: getApplications
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
// In a config step, set the desired user store and login service. For example:
......@@ -957,7 +1388,8 @@ angular.module('openshiftCommonServices')
}
};
}]);
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.factory("AuthorizationService", function($q, $cacheFactory, Logger, $interval, APIService, DataService){
......@@ -1134,7 +1566,8 @@ angular.module("openshiftCommonServices")
getRulesForProject: getRulesForProject
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.factory('base64util', function() {
......@@ -1150,7 +1583,8 @@ angular.module('openshiftCommonServices')
}
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.service("BindingService",
......@@ -1391,7 +1825,8 @@ angular.module("openshiftCommonServices")
sortServiceInstances: sortServiceInstances
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.factory('Constants', function() {
......@@ -1400,7 +1835,8 @@ angular.module('openshiftCommonServices')
constants.VERSION = version;
return constants;
});
;'use strict';
;
'use strict';
/* jshint eqeqeq: false, unused: false, expr: true */
angular.module('openshiftCommonServices')
......@@ -2894,7 +3330,8 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
return new DataService();
});
;'use strict';
;
'use strict';
// Logout strategies
angular.module('openshiftCommonServices')
......@@ -2929,7 +3366,8 @@ angular.module('openshiftCommonServices')
};
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.service("KeywordService", function($filter) {
......@@ -3033,7 +3471,8 @@ angular.module("openshiftCommonServices")
generateKeywords: generateKeywords
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.provider('Logger', function() {
......@@ -3076,7 +3515,8 @@ angular.module('openshiftCommonServices')
return logger;
};
});
;'use strict';
;
'use strict';
/* jshint unused: false */
// UserStore objects able to remember user and tokens for the current user
......@@ -3269,7 +3709,8 @@ angular.module('openshiftCommonServices')
};
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.factory('ProjectsService',
......@@ -3453,7 +3894,8 @@ angular.module('openshiftCommonServices')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.factory('PromiseUtils', function($q) {
......@@ -3507,7 +3949,8 @@ angular.module('openshiftCommonServices')
}
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.service("RecentlyViewedProjectsService", function($filter){
......@@ -3576,7 +4019,8 @@ angular.module("openshiftCommonServices")
isRecentlyViewed: isRecentlyViewed
};
});
;'use strict';
;
'use strict';
// Login strategies
angular.module('openshiftCommonServices')
......@@ -3838,7 +4282,8 @@ angular.module('openshiftCommonServices')
};
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonServices")
.service("VersionsService", function(){
......@@ -3868,7 +4313,8 @@ angular.module("openshiftCommonServices")
},
};
});
;'use strict';
;
'use strict';
// Provide a websocket implementation that behaves like $http
// Methods:
......@@ -3947,7 +4393,8 @@ angular.module('openshiftCommonServices')
return $ws;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.constant('API_DEDUPLICATION', {
......@@ -3960,7 +4407,8 @@ angular.module('openshiftCommonServices')
{group: 'extensions', kind: 'NetworkPolicy'}
]
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonServices')
.constant('API_PREFERRED_VERSIONS', {
......
/*
* This is a pared down version of hawtio-core in order to remove the outdated
* dependency as part the migration from bower to yarn.
*
* TODO Figure out a better strategy for API discovery so that this can be
* removed altogether.
*
*/
// log initialization
/* globals Logger window console document localStorage $ angular jQuery navigator Jolokia */
(function() {
'use strict';
Logger.setLevel(Logger.INFO);
window['LogBuffer'] = 100;
if ('localStorage' in window) {
if (!('logLevel' in window.localStorage)) {
window.localStorage['logLevel'] = JSON.stringify(Logger.INFO);
}
var logLevel = Logger.DEBUG;
try {
logLevel = JSON.parse(window.localStorage['logLevel']);
} catch (e) {
console.error("Failed to parse log level setting: ", e);
}
Logger.setLevel(logLevel);
if ('logBuffer' in window.localStorage) {
var logBuffer = window.localStorage['logBuffer'];
window['LogBuffer'] = parseInt(logBuffer, 10);
} else {
window.localStorage['logBuffer'] = window['LogBuffer'];
}
}
})();
/*
* Plugin loader and discovery mechanism
*/
var pluginLoader = (function(self) {
'use strict';
var log = Logger;
var bootstrapEl = document.documentElement;
self.log = log;
/**
* Holds all of the angular modules that need to be bootstrapped
* @type {Array}
*/
self.modules = [];
/**
* Tasks to be run before bootstrapping, tasks can be async.
* Supply a function that takes the next task to be
* executed as an argument and be sure to call the passed
* in function.
*
* @type {Array}
*/
self.tasks = [];
self.setBootstrapElement = function(el) {
log.debug("Setting bootstrap element to: ", el);
bootstrapEl = el;
}
self.getBootstrapElement = function() {
return bootstrapEl;
}
self.registerPreBootstrapTask = function(task, front) {
if (angular.isFunction(task)) {
log.debug("Adding legacy task");
task = {
task: task
};
}
if (!task.name) {
task.name = 'unnamed-task-' + (self.tasks.length + 1);
}
if (task.depends && !angular.isArray(task.depends) && task.depends !== '*') {
task.depends = [task.depends];
}
if (!front) {
self.tasks.push(task);
} else {
self.tasks.unshift(task);
}
};
self.addModule = function(module) {
log.debug("Adding module: " + module);
self.modules.push(module);
};
self.getModules = function() {
return self.modules;
};
self.loaderCallback = null;
self.setLoaderCallback = function(cb) {
self.loaderCallback = cb;
};
function intersection(search, needle) {
if (!angular.isArray(needle)) {
needle = [needle];
}
var answer = [];
needle.forEach(function(n) {
search.forEach(function(s) {
if (n === s) {
answer.push(s);
}
});
});
return answer;
}
self.loadPlugins = function(callback) {
var lcb = self.loaderCallback;
var plugins = {};
var bootstrap = function() {
var executedTasks = [];
var deferredTasks = [];
var bootstrapTask = {
name: 'Bootstrap',
depends: '*',
runs: 0,
task: function(next) {
function listTasks() {
deferredTasks.forEach(function(task) {
self.log.info(" name: " + task.name + " depends: ", task.depends);
});
}
if (deferredTasks.length > 0) {
self.log.info("tasks yet to run: ");
listTasks();
bootstrapTask.runs = bootstrapTask.runs + 1;
self.log.info("Task list restarted : ", bootstrapTask.runs, " times");
if (bootstrapTask.runs === 5) {
self.log.info("Orphaned tasks: ");
listTasks();
deferredTasks.length = 0;
} else {
deferredTasks.push(bootstrapTask);
}
}
self.log.debug("Executed tasks: ", executedTasks);
next();
}
}
self.registerPreBootstrapTask(bootstrapTask);
var executeTask = function() {
var tObj = null;
var tmp = [];
// if we've executed all of the tasks, let's drain any deferred tasks
// into the regular task queue
if (self.tasks.length === 0) {
tObj = deferredTasks.shift();
}
// first check and see what tasks have executed and see if we can pull a task
// from the deferred queue
while(!tObj && deferredTasks.length > 0) {
var task = deferredTasks.shift();
if (task.depends === '*') {
if (self.tasks.length > 0) {
tmp.push(task);
} else {
tObj = task;
}
} else {
var intersect = intersection(executedTasks, task.depends);
if (intersect.length === task.depends.length) {
tObj = task;
} else {
tmp.push(task);
}
}
}
if (tmp.length > 0) {
tmp.forEach(function(task) {
deferredTasks.push(task);
});
}
// no deferred tasks to execute, let's get a new task
if (!tObj) {
tObj = self.tasks.shift();
}
// check if task has dependencies
if (tObj && tObj.depends && self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' has dependencies: ", tObj.depends);
if (tObj.depends === '*') {
if (self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' wants to run after all other tasks, deferring");
deferredTasks.push(tObj);
executeTask();
return;
}
} else {
var intersect = intersection(executedTasks, tObj.depends);
if (intersect.length != tObj.depends.length) {
self.log.debug("Deferring task: '" + tObj.name + "'");
deferredTasks.push(tObj);
executeTask();
return;
}
}
}
if (tObj) {
self.log.debug("Executing task: '" + tObj.name + "'");
var called = false;
var next = function() {
if (next.notFired) {
next.notFired = false;
executedTasks.push(tObj.name);
setTimeout(executeTask, 1);
}
}
next.notFired = true;
tObj.task(next);
} else {
self.log.debug("All tasks executed");
setTimeout(callback, 1);
}
};
setTimeout(executeTask, 1);
};
var loadScripts = (function() {
// keep track of when scripts are loaded so we can execute the callback
var loaded = 0;
$.each(plugins, function(key, data) {
loaded = loaded + data.Scripts.length;
});
var totalScripts = loaded;
var scriptLoaded = function() {
$.ajaxSetup({async:true});
loaded = loaded - 1;
if (lcb) {
lcb.scriptLoaderCallback(lcb, totalScripts, loaded + 1);
}
if (loaded === 0) {
bootstrap();
}
};
if (loaded > 0) {
$.each(plugins, function(key, data) {
data.Scripts.forEach( function(script) {
var scriptName = data.Context + "/" + script;
log.debug("Fetching script: ", scriptName);
$.ajaxSetup({async:false});
$.getScript(scriptName)
.done(function(textStatus) {
log.debug("Loaded script: ", scriptName);
})
.fail(function(jqxhr, settings, exception) {
log.info("Failed loading script: \"", exception.message, "\" (<a href=\"", scriptName, ":", exception.lineNumber, "\">", scriptName, ":", exception.lineNumber, "</a>)");
})
.always(scriptLoaded);
});
});
} else {
// no scripts to load, so just do the callback
$.ajaxSetup({async:true});
bootstrap();
}
return this;
})();
};
self.debug = function() {
log.debug("modules");
log.debug(self.modules);
};
self.setLoaderCallback({
scriptLoaderCallback: function (self, total, remaining) {
log.debug("Total scripts: ", total, " Remaining: ", remaining);
}
});
return self;
})(pluginLoader || {}, window, undefined);
// Plugin responsible for bootstrapping the app
var BootstrapPlugin = (function () {
'use strict';
function BootstrapPluginClass(){}
/**
* The app's injector, set once bootstrap is completed
*/
Object.defineProperty(BootstrapPluginClass.prototype, "injector", {
get: function() {
return BootstrapPlugin._injector;
},
enumerable: true,
configurable: true
});
var BootstrapPlugin = new BootstrapPluginClass();
/**
* This plugin's name and angular module
*/
BootstrapPlugin.pluginName = "bootstrap-plugin";
/**
* This plugins logger instance
*/
var log = Logger.get(BootstrapPlugin.pluginName);
var _module = angular.module(BootstrapPlugin.pluginName, []);
_module.config(["$locationProvider", function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
_module.run(['documentBase', function (documentBase) {
log.debug("loaded");
}]);
BootstrapPlugin.documentBase = function() {
var base = $('head').find('base');
var answer = '/'
if (base && base.length > 0) {
answer = base.attr('href');
} else {
log.warn("Document is missing a 'base' tag, defaulting to '/'");
}
return answer;
}
// Holds the document base so plugins can easily
// figure out absolute URLs when needed
_module.factory('documentBase', function() {
return BootstrapPlugin.documentBase();
});
pluginLoader.addModule("ng");
pluginLoader.addModule("ngSanitize");
pluginLoader.addModule(BootstrapPlugin.pluginName);
// bootstrap the app
$(function () {
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if ( !jQuery.browser ) {
var matched = jQuery.uaMatch( navigator.userAgent );
var browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
}
pluginLoader.loadPlugins(function() {
if (BootstrapPlugin.injector) {
log.debug("Application already bootstrapped");
return;
}
var bootstrapEl = pluginLoader.getBootstrapElement();
log.debug("Using bootstrap element: ", bootstrapEl);
BootstrapPlugin._injector = angular.bootstrap(bootstrapEl, pluginLoader.getModules(), {
strictDi: false
});
log.debug("Bootstrapped application");
});
});
return BootstrapPlugin;
})();
// Create an alias for hawtioPluginLoader since it may still be used in other
// downstream repos.
window.hawtioPluginLoader = pluginLoader;
;
/**
* @name openshiftCommonUI
*
......@@ -26,8 +453,9 @@ angular.module('openshiftCommonUI', [])
.constant('IS_IOS', /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);
hawtioPluginLoader.addModule('openshiftCommonUI');
;angular.module('openshiftCommonUI').run(['$templateCache', function($templateCache) {
pluginLoader.addModule('openshiftCommonUI');
;
angular.module('openshiftCommonUI').run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('src/components/binding/bindApplicationForm.html',
......@@ -491,7 +919,8 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
);
}]);
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI').component('bindApplicationForm', {
controllerAs: 'ctrl',
......@@ -518,7 +947,8 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
}
}
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI').component('bindResults', {
controllerAs: 'ctrl',
......@@ -533,7 +963,8 @@ angular.module('openshiftCommonUI').component('bindResults', {
},
templateUrl: 'src/components/binding/bindResults.html'
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI').component('bindServiceForm', {
controllerAs: 'ctrl',
......@@ -557,7 +988,8 @@ angular.module('openshiftCommonUI').component('bindServiceForm', {
};
}
});
;"use strict";
;
"use strict";
angular.module("openshiftCommonUI")
......@@ -631,7 +1063,8 @@ angular.module("openshiftCommonUI")
}
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonUI")
.directive("deleteProject", function($uibModal, $location, $filter, $q, hashSizeFilter, APIService, NotificationsService, ProjectsService, Logger) {
......@@ -727,7 +1160,8 @@ angular.module("openshiftCommonUI")
}
};
});
;'use strict';
;
'use strict';
/* jshint unused: false */
/**
......@@ -744,7 +1178,8 @@ angular.module('openshiftCommonUI')
$uibModalInstance.dismiss('cancel');
};
});
;"use strict";
;
"use strict";
angular.module("openshiftCommonUI")
......@@ -847,7 +1282,8 @@ angular.module("openshiftCommonUI")
},
};
});
;"use strict";
;
"use strict";
angular.module("openshiftCommonUI").component("originModalPopup", {
transclude: true,
......@@ -959,7 +1395,8 @@ angular.module("openshiftCommonUI").component("originModalPopup", {
}
}
});
;'use strict';
;
'use strict';
// oscUnique is a validation directive
// use:
// Put it on an input or other DOM node with an ng-model attribute.
......@@ -1020,7 +1457,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
// This triggers when an element has either a toggle or data-toggle attribute set on it
......@@ -1108,7 +1546,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
// The HTML5 `autofocus` attribute does not work reliably with Angular,
......@@ -1124,7 +1563,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.directive('tileClick', function() {
......@@ -1142,7 +1582,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.directive('toastNotifications', function(NotificationsService, $rootScope, $timeout) {
......@@ -1226,7 +1667,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
// Truncates text to a length, adding a tooltip and an ellipsis if truncated.
......@@ -1261,7 +1703,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter("alertStatus", function() {
......@@ -1303,7 +1746,8 @@ angular.module('openshiftCommonUI')
return 'pficon pficon-info';
};
});
;'use strict';
;
'use strict';
/* jshint unused: false */
angular.module('openshiftCommonUI')
......@@ -1394,7 +1838,8 @@ angular.module('openshiftCommonUI')
return (icon) ? icon : "fa fa-cube";
};
});
;'use strict';
;
'use strict';
angular
.module('openshiftCommonUI')
......@@ -1408,7 +1853,8 @@ angular
return AuthorizationService.canIAddToProject(namespace);
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('isNewerResource', function() {
......@@ -1472,7 +1918,8 @@ angular.module('openshiftCommonUI')
return items;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('highlightKeywords', function(KeywordService) {
......@@ -1525,7 +1972,8 @@ angular.module('openshiftCommonUI')
return result;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
// Returns an image URL for an icon class if available. Some icons we have
......@@ -1556,7 +2004,8 @@ angular.module('openshiftCommonUI')
return logoBaseUrl + logoImage;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('isAbsoluteURL', function() {
......@@ -1569,7 +2018,8 @@ angular.module('openshiftCommonUI')
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
// Usage: <span ng-bind-html="text | linkify : '_blank'"></span>
......@@ -1584,7 +2034,8 @@ angular.module('openshiftCommonUI')
return HTMLService.linkify(text, target, alreadyEscaped);
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonUI")
.filter("normalizeIconClass", function() {
......@@ -1598,7 +2049,8 @@ angular.module("openshiftCommonUI")
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('parseJSON', function() {
......@@ -1624,13 +2076,15 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('preferredVersion', function(APIService) {
return APIService.getPreferredVersion;
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('prettifyJSON', function(parseJSONFilter) {
......@@ -1645,7 +2099,8 @@ angular.module('openshiftCommonUI')
}
};
});
;'use strict';
;
'use strict';
/* jshint unused: false */
angular.module('openshiftCommonUI')
......@@ -1861,7 +2316,8 @@ angular.module('openshiftCommonUI')
};
})
;
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('camelToLower', function() {
return function(str) {
......@@ -1911,7 +2367,8 @@ angular.module('openshiftCommonUI')
return true;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter('truncate', function() {
......@@ -1943,7 +2400,8 @@ angular.module('openshiftCommonUI')
return truncated;
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI')
.filter("toArray", function() {
......@@ -2001,7 +2459,8 @@ angular.module('openshiftCommonUI')
return "";
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI').factory('GuidedTourService', function() {
var hopscotchConfig = {};
......@@ -2141,7 +2600,8 @@ angular.module('openshiftCommonUI').factory('GuidedTourService', function() {
cancelTour: cancelTour
};
});
;'use strict';
;
'use strict';
angular.module("openshiftCommonUI")
.factory("HTMLService", function(BREAKPOINTS) {
......@@ -2244,7 +2704,8 @@ angular.module("openshiftCommonUI")
}
};
});
;'use strict';
;
'use strict';
angular.module('openshiftCommonUI').provider('NotificationsService', function() {
this.dismissDelay = 8000;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,11 +2,171 @@ function ResourceGroupVersion(e, t, n) {
return this.resource = e, this.group = t, this.version = n, this;
}
angular.module("openshiftCommonServices", [ "ab-base64" ]).config([ "AuthServiceProvider", function(e) {
!function() {
"use strict";
if (Logger.setLevel(Logger.INFO), window.LogBuffer = 100, "localStorage" in window) {
"logLevel" in window.localStorage || (window.localStorage.logLevel = JSON.stringify(Logger.INFO));
var e = Logger.DEBUG;
try {
e = JSON.parse(window.localStorage.logLevel);
} catch (e) {
console.error("Failed to parse log level setting: ", e);
}
if (Logger.setLevel(e), "logBuffer" in window.localStorage) {
var t = window.localStorage.logBuffer;
window.LogBuffer = parseInt(t, 10);
} else window.localStorage.logBuffer = window.LogBuffer;
}
}();
var pluginLoader = function(e) {
"use strict";
function t(e, t) {
angular.isArray(t) || (t = [ t ]);
var n = [];
return t.forEach(function(t) {
e.forEach(function(e) {
t === e && n.push(e);
});
}), n;
}
var n = Logger, r = document.documentElement;
return e.log = n, e.modules = [], e.tasks = [], e.setBootstrapElement = function(e) {
n.debug("Setting bootstrap element to: ", e), r = e;
}, e.getBootstrapElement = function() {
return r;
}, e.registerPreBootstrapTask = function(t, r) {
angular.isFunction(t) && (n.debug("Adding legacy task"), t = {
task: t
}), t.name || (t.name = "unnamed-task-" + (e.tasks.length + 1)), t.depends && !angular.isArray(t.depends) && "*" !== t.depends && (t.depends = [ t.depends ]), r ? e.tasks.unshift(t) : e.tasks.push(t);
}, e.addModule = function(t) {
n.debug("Adding module: " + t), e.modules.push(t);
}, e.getModules = function() {
return e.modules;
}, e.loaderCallback = null, e.setLoaderCallback = function(t) {
e.loaderCallback = t;
}, e.loadPlugins = function(r) {
var o = e.loaderCallback, i = {}, a = function() {
var n = [], o = [], i = {
name: "Bootstrap",
depends: "*",
runs: 0,
task: function(t) {
function r() {
o.forEach(function(t) {
e.log.info(" name: " + t.name + " depends: ", t.depends);
});
}
o.length > 0 && (e.log.info("tasks yet to run: "), r(), i.runs = i.runs + 1, e.log.info("Task list restarted : ", i.runs, " times"), 5 === i.runs ? (e.log.info("Orphaned tasks: "), r(), o.length = 0) : o.push(i)), e.log.debug("Executed tasks: ", n), t();
}
};
e.registerPreBootstrapTask(i);
var a = function() {
var i = null, s = [];
for (0 === e.tasks.length && (i = o.shift()); !i && o.length > 0; ) {
var c = o.shift();
"*" === c.depends ? e.tasks.length > 0 ? s.push(c) : i = c : (l = t(n, c.depends)).length === c.depends.length ? i = c : s.push(c);
}
if (s.length > 0 && s.forEach(function(e) {
o.push(e);
}), i || (i = e.tasks.shift()), i && i.depends && e.tasks.length > 0) if (e.log.debug("Task '" + i.name + "' has dependencies: ", i.depends), "*" === i.depends) {
if (e.tasks.length > 0) return e.log.debug("Task '" + i.name + "' wants to run after all other tasks, deferring"), o.push(i), void a();
} else {
var l = t(n, i.depends);
if (l.length != i.depends.length) return e.log.debug("Deferring task: '" + i.name + "'"), o.push(i), void a();
}
if (i) {
e.log.debug("Executing task: '" + i.name + "'");
var u = function() {
u.notFired && (u.notFired = !1, n.push(i.name), setTimeout(a, 1));
};
u.notFired = !0, i.task(u);
} else e.log.debug("All tasks executed"), setTimeout(r, 1);
};
setTimeout(a, 1);
};
!function() {
var e = 0;
$.each(i, function(t, n) {
e += n.Scripts.length;
});
var t = e, r = function() {
$.ajaxSetup({
async: !0
}), e -= 1, o && o.scriptLoaderCallback(o, t, e + 1), 0 === e && a();
};
e > 0 ? $.each(i, function(e, t) {
t.Scripts.forEach(function(e) {
var o = t.Context + "/" + e;
n.debug("Fetching script: ", o), $.ajaxSetup({
async: !1
}), $.getScript(o).done(function(e) {
n.debug("Loaded script: ", o);
}).fail(function(e, t, r) {
n.info('Failed loading script: "', r.message, '" (<a href="', o, ":", r.lineNumber, '">', o, ":", r.lineNumber, "</a>)");
}).always(r);
});
}) : ($.ajaxSetup({
async: !0
}), a());
}();
}, e.debug = function() {
n.debug("modules"), n.debug(e.modules);
}, e.setLoaderCallback({
scriptLoaderCallback: function(e, t, r) {
n.debug("Total scripts: ", t, " Remaining: ", r);
}
}), e;
}(pluginLoader || {}, window), BootstrapPlugin = function() {
"use strict";
function e() {}
Object.defineProperty(e.prototype, "injector", {
get: function() {
return t._injector;
},
enumerable: !0,
configurable: !0
});
var t = new e();
t.pluginName = "bootstrap-plugin";
var n = Logger.get(t.pluginName), r = angular.module(t.pluginName, []);
return r.config([ "$locationProvider", function(e) {
e.html5Mode(!0);
} ]), r.run([ "documentBase", function(e) {
n.debug("loaded");
} ]), t.documentBase = function() {
var e = $("head").find("base"), t = "/";
return e && e.length > 0 ? t = e.attr("href") : n.warn("Document is missing a 'base' tag, defaulting to '/'"), t;
}, r.factory("documentBase", function() {
return t.documentBase();
}), pluginLoader.addModule("ng"), pluginLoader.addModule("ngSanitize"), pluginLoader.addModule(t.pluginName), $(function() {
if (jQuery.uaMatch = function(e) {
e = e.toLowerCase();
var t = /(chrome)[ \/]([\w.]+)/.exec(e) || /(webkit)[ \/]([\w.]+)/.exec(e) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e) || /(msie) ([\w.]+)/.exec(e) || e.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e) || [];
return {
browser: t[1] || "",
version: t[2] || "0"
};
}, !jQuery.browser) {
var e = jQuery.uaMatch(navigator.userAgent), r = {};
e.browser && (r[e.browser] = !0, r.version = e.version), r.chrome ? r.webkit = !0 : r.webkit && (r.safari = !0), jQuery.browser = r;
}
pluginLoader.loadPlugins(function() {
if (t.injector) n.debug("Application already bootstrapped"); else {
var e = pluginLoader.getBootstrapElement();
n.debug("Using bootstrap element: ", e), t._injector = angular.bootstrap(e, pluginLoader.getModules(), {
strictDi: !1
}), n.debug("Bootstrapped application");
}
});
}), t;
}();
window.hawtioPluginLoader = pluginLoader, angular.module("openshiftCommonServices", [ "ab-base64" ]).config([ "AuthServiceProvider", function(e) {
e.UserStore("MemoryUserStore");
} ]).constant("API_CFG", _.get(window.OPENSHIFT_CONFIG, "api", {})).constant("APIS_CFG", _.get(window.OPENSHIFT_CONFIG, "apis", {})).constant("AUTH_CFG", _.get(window.OPENSHIFT_CONFIG, "auth", {})).config([ "$httpProvider", "AuthServiceProvider", "RedirectLoginServiceProvider", "AUTH_CFG", function(e, t, n, r) {
e.interceptors.push("AuthInterceptor"), t.LoginService("RedirectLoginService"), t.LogoutService("DeleteTokenLogoutService"), t.UserStore("LocalStorageUserStore"), n.OAuthClientID(r.oauth_client_id), n.OAuthAuthorizeURI(r.oauth_authorize_uri), n.OAuthTokenURI(r.oauth_token_uri), n.OAuthRedirectURI(URI(r.oauth_redirect_base).segment("oauth").toString());
} ]), hawtioPluginLoader.addModule("openshiftCommonServices"), hawtioPluginLoader.registerPreBootstrapTask(function(e) {
} ]), pluginLoader.addModule("openshiftCommonServices"), pluginLoader.registerPreBootstrapTask(function(e) {
if (_.get(window, "OPENSHIFT_CONFIG.api.k8s.resources")) e(); else {
var t = {
k8s: {},
......@@ -76,7 +236,7 @@ screenXlgMin: 1600
pattern: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,
maxlength: 253,
description: "Name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or a number."
}).constant("IS_IOS", /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream), hawtioPluginLoader.addModule("openshiftCommonUI"), angular.module("openshiftCommonUI").run([ "$templateCache", function(e) {
}).constant("IS_IOS", /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream), pluginLoader.addModule("openshiftCommonUI"), angular.module("openshiftCommonUI").run([ "$templateCache", function(e) {
"use strict";
e.put("src/components/binding/bindApplicationForm.html", '<div class="bind-form">\n <form>\n <div class="form-group">\n <label>\n <h3>Create a binding for application <strong>{{ctrl.applicationName}}</strong></h3>\n </label>\n <span class="help-block">\n Bindings create a secret containing the necessary information for an application to use a service.\n </span>\n </div>\n </form>\n\n <label ng-if="!ctrl.allowNoBinding">\n Select a service:\n </label>\n <form name="ctrl.formName">\n <fieldset>\n <div class="radio">\n <div ng-if="ctrl.allowNoBinding" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="null">\n Do not bind at this time.\n </label>\n <div class="bind-description">\n <span class="help-block service-instance-name">\n Bindings can be created later from within a project.\n </span>\n </div>\n </div>\n <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances" class="bind-service-selection">\n <label>\n <input type="radio" ng-model="ctrl.serviceToBind" ng-value="serviceInstance">\n {{ctrl.serviceClasses[serviceInstance.spec.clusterServiceClassRef.name].spec.externalMetadata.displayName || serviceInstance.spec.clusterServiceClassRef.name}}\n </label>\n <div class="bind-description">\n <span class="pficon pficon-info"\n ng-if="!(serviceInstance | isServiceInstanceReady)"\n data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready."\n data-toggle="popover"\n data-trigger="hover">\n </span>\n <span class="help-block service-instance-name">\n {{serviceInstance.metadata.name}}\n </span>\n </div>\n </div>\n <h4 ng-if="!ctrl.bindableServiceInstances.length">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="help-block service-instance-name">\n There are no bindable services in this project\n </span>\n </h4>\n </div>\n </fieldset>\n </form>\n</div>\n'),
e.put("src/components/binding/bindResults.html", '<div ng-if="!ctrl.error && !(ctrl.binding | isBindingFailed)">\n <div ng-if="ctrl.binding && !(ctrl.binding | isBindingReady)" class="results-status">\n <span class="fa fa-clock-o text-muted" aria-hidden="true"></span>\n <span class="sr-only">Pending</span>\n <div class="results-message">\n <h3>\n The binding is being created.\n </h3>\n <p class="results-message-details">This may take several minutes.</p>\n </div>\n </div>\n <div ng-if="(ctrl.binding | isBindingReady)">\n <div class="results-status">\n <span class="pficon pficon-ok" aria-hidden="true"></span>\n <span class="sr-only">Success</span>\n <div class="results-message">\n <h3>\n <span ng-if="ctrl.bindType === \'application\'">\n <strong>{{ctrl.serviceToBind}}</strong> has been bound to\n <strong>{{ctrl.applicationToBind}}</strong> successfully.\n </span>\n <span ng-if="ctrl.bindType !== \'application\'">\n The binding <strong>{{ctrl.binding.metadata.name}}</strong> has been created successfully.\n </span>\n </h3>\n <p class="results-message-details">\n The binding operation created the secret\n <a ng-if="ctrl.secretHref" ng-href="{{ctrl.secretHref}}">{{ctrl.binding.spec.secretName}}</a>\n <span ng-if="!ctrl.secretHref">{{ctrl.binding.spec.secretName}}</span>\n that you may need to reference in your application.\n <span ng-if="ctrl.showPodPresets">Its data will be available to your application as environment variables.</span>\n </p>\n </div>\n </div>\n <div class="alert alert-info results-info" ng-if="ctrl.bindType === \'application\'">\n <span class="pficon pficon-info" aria-hidden="true"></span>\n <span class="sr-only">Info</span>\n The binding secret will only be available to new pods. You will need to redeploy your application.\n </div>\n </div>\n</div>\n<div ng-if="ctrl.error || (ctrl.binding | isBindingFailed)">\n <div class="results-status">\n <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>\n <span class="sr-only">Error</span>\n <div class="results-message">\n <h3>\n The binding could not be created.\n </h3>\n </div>\n </div>\n <div ng-if="ctrl.error" class="sub-title">\n <span ng-if="ctrl.error.data.message">\n {{ctrl.error.data.message | upperFirst}}\n </span>\n <span ng-if="!ctrl.error.data.message">\n An error occurred creating the binding.\n </span>\n </div>\n <div ng-if="!ctrl.error" class="sub-title">\n {{ctrl.binding | bindingFailedMessage}}\n </div>\n</div>\n'),
......@@ -86,427 +246,50 @@ e.put("src/components/delete-project/delete-project-button.html", '<div class="a
e.put("src/components/delete-project/delete-project.html", '<a href="javascript:void(0)"\n ng-click="openDeleteModal()"\n role="button"\n ng-attr-aria-disabled="{{disableDelete ? \'true\' : undefined}}"\n ng-class="{ \'disabled-link\': disableDelete }"\n>{{label || \'Delete\'}}</a>\n'), e.put("src/components/edit-project/editProject.html", '<form name="editProjectForm">\n <fieldset ng-disabled="disableInputs">\n <div class="form-group">\n <label for="displayName">Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="editableFields.displayName">\n </div>\n\n <div class="form-group">\n <label for="description">Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="editableFields.description"></textarea>\n </div>\n\n <div class="button-group">\n <button type="submit"\n class="btn btn-primary"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="update()"\n ng-disabled="editProjectForm.$invalid || disableInputs"\n value="">{{submitButtonLabel}}</button>\n <button\n class="btn btn-default"\n ng-class="{\'dialog-btn\': isDialog}"\n ng-click="cancelEditProject()">\n Cancel\n </button>\n </div>\n </fieldset>\n</form>\n'),
e.put("src/components/origin-modal-popup/origin-modal-popup.html", '<div class="origin-modal-popup tile-click-prevent" ng-if="$ctrl.shown" ng-style="$ctrl.positionStyle"\n ng-class="{\'position-above\': $ctrl.showAbove, \'position-left\': $ctrl.showLeft}">\n <h4 class="origin-modal-popup-title">\n {{$ctrl.modalTitle}}\n </h4>\n <div ng-transclude></div>\n <a href="" class="origin-modal-popup-close" ng-click="$ctrl.onClose()">\n <span class="pficon pficon-close"></span>\n </a>\n</div>\n'), e.put("src/components/toast-notifications/toast-notifications.html", '<div class="toast-notifications-list-pf">\n <div\n ng-repeat="(notificationID, notification) in notifications track by notification.trackByID"\n ng-if="!notification.hidden || notification.isHover"\n ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)">\n <div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{\'alert-dismissable\': !hideCloseButton}">\n <button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)">\n <span class="pficon pficon-close" aria-hidden="true"></span>\n <span class="sr-only">Close</span>\n </button>\n <span class="{{notification.type | alertIcon}}" aria-hidden="true"></span>\n <span class="sr-only">{{notification.type}}</span>\n <span class="toast-notification-message" ng-if="notification.message">{{notification.message}}</span>\n <div ng-if="notification.details" class="toast-notification-details">\n <truncate-long-text\n limit="200"\n content="notification.details"\n use-word-boundary="true"\n expandable="true"\n hide-collapse="true">\n </truncate-long-text>\n </div>\n <span ng-repeat="link in notification.links">\n <a ng-if="!link.href" href="" ng-click="onClick(notification, link)" role="button">{{link.label}}</a>\n <a ng-if="link.href" ng-href="{{link.href}}" ng-attr-target="{{link.target}}">{{link.label}}</a>\n <span ng-if="!$last" class="toast-action-divider">|</span>\n </span>\n </div>\n </div>\n</div>\n'),
e.put("src/components/truncate-long-text/truncateLongText.html", '\x3c!--\n Do not remove class `truncated-content` (here or below) even though it\'s not\n styled directly in origin-web-common. `truncated-content` is used by\n origin-web-console in certain contexts.\n\n highlightKeywords and linkify are mutually exclusive options\n--\x3e\n<span ng-if="!truncated">\n <span ng-if="!linkify || (highlightKeywords | size)" ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>\n <span ng-if="linkify && !(highlightKeywords | size)" ng-bind-html="content | linkify : \'_blank\'" class="truncated-content"></span>\n</span>\n\x3c!-- To avoid truncating in middle of a link, we only optionally apply linkify to expanded content --\x3e\n<span ng-if="truncated">\n <span ng-if="!toggles.expanded">\n <span ng-attr-title="{{content}}" class="truncation-block">\n <span ng-bind-html="truncatedContent | highlightKeywords : keywords" class="truncated-content"></span>&hellip;\n </span>\n <a ng-if="expandable" href="" ng-click="toggles.expanded = true" class="truncation-expand-link">See All</a>\n </span>\n <span ng-if="toggles.expanded">\n <span ng-if="!linkify || (highlightKeywords | size)"\n ng-bind-html="content | highlightKeywords : keywords"\n class="truncated-content"></span>\n <span ng-if="linkify && !(highlightKeywords | size)"\n ng-bind-html="content | linkify : \'_blank\'"\n class="truncated-content"></span>\n <a href="" ng-if="!hideCollapse" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a>\n </span>\n</span>\n');
} ]), angular.module("openshiftCommonUI").component("bindApplicationForm", {
controllerAs: "ctrl",
bindings: {
allowNoBinding: "<?",
createBinding: "=",
applicationName: "=",
formName: "=",
serviceClasses: "<",
serviceInstances: "<",
serviceToBind: "="
},
templateUrl: "src/components/binding/bindApplicationForm.html",
controller: [ "BindingService", function(e) {
function t(t) {
return e.isServiceBindable(t, n.serviceClasses);
}
var n = this;
n.$onChanges = function(e) {
(e.serviceInstances || e.serviceClasses) && (n.bindableServiceInstances = _.filter(n.serviceInstances, t));
};
} ]), angular.module("openshiftCommonServices").constant("API_DEDUPLICATION", {
groups: [ {
group: "authorization.openshift.io"
} ],
kinds: [ {
group: "extensions",
kind: "DaemonSet"
}, {
group: "extensions",
kind: "HorizontalPodAutoscaler"
}, {
group: "extensions",
kind: "NetworkPolicy"
} ]
}), angular.module("openshiftCommonUI").component("bindResults", {
controllerAs: "ctrl",
bindings: {
error: "<",
binding: "<",
serviceToBind: "<",
bindType: "@",
applicationToBind: "<",
showPodPresets: "<",
secretHref: "<"
}), angular.module("openshiftCommonServices").constant("API_PREFERRED_VERSIONS", {
appliedclusterresourcequotas: {
group: "quota.openshift.io",
version: "v1",
resource: "appliedclusterresourcequotas"
},
templateUrl: "src/components/binding/bindResults.html"
}), angular.module("openshiftCommonUI").component("bindServiceForm", {
controllerAs: "ctrl",
bindings: {
serviceClass: "<",
showPodPresets: "<",
applications: "<",
formName: "=",
allowNoBinding: "<?",
projectName: "<",
bindType: "=",
appToBind: "="
builds: {
group: "build.openshift.io",
version: "v1",
resource: "builds"
},
templateUrl: "src/components/binding/bindServiceForm.html",
controller: [ "$filter", function(e) {
var t = this, n = e("humanizeKind");
t.groupByKind = function(e) {
return n(e.kind);
};
} ]
}), angular.module("openshiftCommonUI").directive("createProject", [ "$window", function(e) {
return {
restrict: "E",
scope: {
redirectAction: "&",
onCancel: "&?",
isDialog: "@"
"builds/clone": {
group: "build.openshift.io",
version: "v1",
resource: "builds/clone"
},
templateUrl: "src/components/create-project/createProject.html",
controller: [ "$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", "Logger", function(t, n, r, o, i, a) {
t.submitButtonLabel || (t.submitButtonLabel = "Create"), t.isDialog = "true" === t.isDialog;
t.createProject = function() {
if (t.disableInputs = !0, t.createProjectForm.$valid) {
var e = t.displayName || t.name;
r.create(t.name, t.displayName, t.description).then(function(e) {
var r = t.redirectAction();
r ? r(encodeURIComponent(e.metadata.name)) : n.path("project/" + encodeURIComponent(e.metadata.name) + "/create"), o.addNotification({
type: "success",
message: "Project '" + i(e) + "' was successfully created."
});
}, function(n) {
t.disableInputs = !1;
var r = n.data || {};
if ("AlreadyExists" === r.reason) t.nameTaken = !0; else {
var i = r.message || "An error occurred creating project '" + e + "'.";
o.addNotification({
type: "error",
message: i
}), a.error("Project '" + e + "' could not be created.", n);
}
});
}
}, t.cancelCreateProject = function() {
if (t.onCancel) {
var n = t.onCancel();
n && n();
} else e.history.back();
}, t.$on("$destroy", function() {
o.hideNotification("create-project-error");
});
} ]
};
} ]), angular.module("openshiftCommonUI").directive("deleteProject", [ "$uibModal", "$location", "$filter", "$q", "hashSizeFilter", "APIService", "NotificationsService", "ProjectsService", "Logger", function(e, t, n, r, o, i, a, s, c) {
return {
restrict: "E",
scope: {
project: "=",
disableDelete: "=?",
typeNameToConfirm: "=?",
label: "@?",
buttonOnly: "@",
stayOnCurrentPage: "=?",
success: "=?",
redirectUrl: "@?"
"builds/log": {
group: "build.openshift.io",
version: "v1",
resource: "builds/log"
},
templateUrl: function(e, t) {
return angular.isDefined(t.buttonOnly) ? "src/components/delete-project/delete-project-button.html" : "src/components/delete-project/delete-project.html";
"buildconfigs/instantiate": {
group: "build.openshift.io",
version: "v1",
resource: "buildconfigs/instantiate"
},
replace: !0,
link: function(r, o, i) {
var l = n("displayName"), u = function() {
if (!r.stayOnCurrentPage) if (r.redirectUrl) t.url(r.redirectUrl); else if ("/" !== t.path()) {
var e = URI("/");
t.url(e);
} else r.$emit("deleteProject");
};
r.openDeleteModal = function() {
r.disableDelete || e.open({
templateUrl: "src/components/delete-project/delete-project-modal.html",
controller: "DeleteProjectModalController",
scope: r
}).result.then(function() {
var e = "Project '" + l(r.project) + "'";
s.delete(r.project).then(function() {
a.addNotification({
type: "success",
message: e + " was marked for deletion."
}), r.success && r.success(), u();
}).catch(function(t) {
a.addNotification({
type: "error",
message: e + " could not be deleted.",
details: n("getErrorDetails")(t)
}), c.error(e + " could not be deleted.", t);
});
});
};
}
};
} ]), angular.module("openshiftCommonUI").controller("DeleteProjectModalController", [ "$scope", "$uibModalInstance", function(e, t) {
e.delete = function() {
t.close("delete");
}, e.cancel = function() {
t.dismiss("cancel");
};
} ]), angular.module("openshiftCommonUI").directive("editProject", [ "$window", function(e) {
return {
restrict: "E",
scope: {
project: "=",
submitButtonLabel: "@",
redirectAction: "&",
onCancel: "&",
isDialog: "@"
},
templateUrl: "src/components/edit-project/editProject.html",
controller: [ "$scope", "$filter", "$location", "Logger", "NotificationsService", "ProjectsService", "annotationNameFilter", "displayNameFilter", function(t, n, r, o, i, a, s, c) {
t.submitButtonLabel || (t.submitButtonLabel = "Save"), t.isDialog = "true" === t.isDialog;
var l = n("annotation"), u = n("annotationName"), d = function(e) {
return {
description: l(e, "description"),
displayName: l(e, "displayName")
};
}, p = function(e, t) {
var n = angular.copy(e);
return n.metadata.annotations[u("description")] = t.description, n.metadata.annotations[u("displayName")] = t.displayName, n;
}, f = function(e) {
var t = [ s("description"), s("displayName") ];
return _.each(t, function(t) {
e.metadata.annotations[t] || delete e.metadata.annotations[t];
}), e;
};
t.editableFields = d(t.project), t.update = function() {
t.disableInputs = !0, t.editProjectForm.$valid && a.update(t.project.metadata.name, f(p(t.project, t.editableFields))).then(function(e) {
var n = t.redirectAction();
n && n(encodeURIComponent(t.project.metadata.name)), i.addNotification({
type: "success",
message: "Project '" + c(e) + "' was successfully updated."
});
}, function(e) {
t.disableInputs = !1, t.editableFields = d(t.project), i.addNotification({
type: "error",
message: "An error occurred while updating project '" + c(t.project) + "'.",
details: n("getErrorDetails")(e)
}), o.error("Project '" + c(t.project) + "' could not be updated.", e);
});
}, t.cancelEditProject = function() {
var n = t.onCancel();
n ? n() : e.history.back();
};
} ]
};
} ]), angular.module("openshiftCommonUI").component("originModalPopup", {
transclude: !0,
bindings: {
modalTitle: "@",
shown: "<",
position: "@",
referenceElement: "<?",
onClose: "<"
},
templateUrl: "src/components/origin-modal-popup/origin-modal-popup.html",
controller: [ "$scope", "HTMLService", "$element", "$window", function(e, t, n, r) {
function o() {
var e = d.referenceElement || n[0].parentNode;
if (e && t.isWindowAboveBreakpoint(t.WINDOW_SIZE_SM)) {
var o, i, a = d.position && d.position.indexOf("top") > -1, s = d.position && d.position.indexOf("left") > -1, c = e.getBoundingClientRect(), l = r.innerHeight, u = n[0].children[0], p = _.get(u, "offsetHeight", 0), f = _.get(u, "offsetWidth", 0);
c.top < p ? a = !1 : c.bottom + p > l && (a = !0), o = a ? c.top - p + "px" : c.bottom + "px", i = s ? c.left + "px" : c.right - f + "px", d.showAbove = a, d.showLeft = s, d.positionStyle = {
left: i,
top: o
};
} else d.positionStyle = {};
}
function i() {
var e = d.referenceElement ? d.referenceElement.parentNode : n[0].parentNode;
$(e).append('<div class="origin-modal-popup-backdrop modal-backdrop fade in tile-click-prevent"></div>');
}
function a() {
$(".origin-modal-popup-backdrop").remove();
}
function s() {
e.$evalAsync(o);
}
function c() {
i(), u = _.debounce(s, 50, {
maxWait: 250
}), angular.element(r).on("resize", u);
}
function l() {
a(), u && (angular.element(r).off("resize", u), u = null);
}
var u, d = this;
d.$onChanges = function(e) {
e.shown && (d.shown ? c() : l()), (e.shown || e.referenceElement) && d.shown && o();
}, d.$onDestroy = function() {
d.shown && l();
};
} ]
}), angular.module("openshiftCommonUI").directive("oscUnique", function() {
return {
restrict: "A",
scope: {
oscUnique: "=",
oscUniqueDisabled: "="
},
require: "ngModel",
link: function(e, t, n, r) {
var o = [], i = !0;
e.$watchCollection("oscUnique", function(e) {
o = _.isArray(e) ? e : _.keys(e);
});
var a = function() {
r.$setValidity("oscUnique", e.oscUniqueDisabled || i);
};
e.$watch("oscUniqueDisabled", a), r.$parsers.unshift(function(e) {
return i = !_.includes(o, e), a(), e;
});
}
};
}), angular.module("openshiftCommonUI").directive("toggle", [ "IS_IOS", function(e) {
var t = function(e) {
$("body").css("cursor", e);
}, n = _.partial(t, "pointer"), r = _.partial(t, "auto");
return e && ($(document).on("shown.bs.popover", n), $(document).on("shown.bs.tooltip", n), $(document).on("hide.bs.popover", r), $(document).on("hide.bs.tooltip", r)), {
restrict: "A",
scope: {
dynamicContent: "@?"
},
link: function(e, t, n) {
var r = {
container: n.container || "body",
placement: n.placement || "auto"
};
if (n) switch (n.toggle) {
case "popover":
(n.dynamicContent || "" === n.dynamicContent) && e.$watch("dynamicContent", function() {
$(t).popover("destroy"), setTimeout(function() {
$(t).attr("data-content", e.dynamicContent).popover(r);
}, 200);
}), $(t).popover(r), e.$on("$destroy", function() {
$(t).popover("destroy");
});
break;
case "tooltip":
(n.dynamicContent || "" === n.dynamicContent) && e.$watch("dynamicContent", function() {
$(t).tooltip("destroy"), setTimeout(function() {
$(t).attr("title", e.dynamicContent).tooltip(r);
}, 200);
}), $(t).tooltip(r), e.$on("$destroy", function() {
$(t).tooltip("destroy");
});
break;
case "dropdown":
"dropdown" === n.hover && ($(t).dropdownHover({
delay: 200
}), $(t).dropdown());
}
}
};
} ]), angular.module("openshiftCommonUI").directive("takeFocus", [ "$timeout", function(e) {
return {
restrict: "A",
link: function(t, n) {
e(function() {
$(n).focus();
}, 300);
}
};
} ]), angular.module("openshiftCommonUI").directive("tileClick", function() {
return {
restrict: "AC",
link: function(e, t) {
$(t).click(function(e) {
var n = $(e.target);
n && (n.closest("a", t).length || n.closest("button", t).length) || n.closest(".tile-click-prevent", t).length || angular.element($("a.tile-target", t))[0].click();
});
}
};
}), angular.module("openshiftCommonUI").directive("toastNotifications", [ "NotificationsService", "$rootScope", "$timeout", function(e, t, n) {
return {
restrict: "E",
scope: {},
templateUrl: "src/components/toast-notifications/toast-notifications.html",
link: function(r) {
r.notifications = [];
var o = function(e) {
return e.hidden && !e.isHover;
}, i = function(e) {
e.isHover = !1, e.hidden = !0;
}, a = function() {
r.notifications = _.reject(r.notifications, o);
};
r.close = function(e) {
i(e), _.isFunction(e.onClose) && e.onClose();
}, r.onClick = function(e, t) {
_.isFunction(t.onClick) && t.onClick() && i(e);
}, r.setHover = function(e, t) {
o(e) || (e.isHover = t);
};
var s = t.$on("NotificationsService.onNotificationAdded", function(t, o) {
o.skipToast || r.$evalAsync(function() {
r.notifications.push(o), e.isAutoDismiss(o) && n(function() {
o.hidden = !0;
}, e.dismissDelay), a();
});
});
r.$on("$destroy", function() {
s && (s(), s = null);
});
}
};
} ]), angular.module("openshiftCommonUI").directive("truncateLongText", [ "truncateFilter", function(e) {
return {
restrict: "E",
scope: {
content: "=",
limit: "=",
newlineLimit: "=",
useWordBoundary: "=",
expandable: "=",
hideCollapse: "=",
keywords: "=highlightKeywords",
linkify: "=?"
},
templateUrl: "src/components/truncate-long-text/truncateLongText.html",
link: function(t) {
t.toggles = {
expanded: !1
}, t.$watch("content", function(n) {
n ? (t.truncatedContent = e(n, t.limit, t.useWordBoundary, t.newlineLimit), t.truncated = t.truncatedContent.length !== n.length) : (t.truncatedContent = null, t.truncated = !1);
});
}
};
} ]), angular.module("openshiftCommonServices").constant("API_DEDUPLICATION", {
groups: [ {
group: "authorization.openshift.io"
} ],
kinds: [ {
group: "extensions",
kind: "DaemonSet"
}, {
group: "extensions",
kind: "HorizontalPodAutoscaler"
}, {
group: "extensions",
kind: "NetworkPolicy"
} ]
}), angular.module("openshiftCommonServices").constant("API_PREFERRED_VERSIONS", {
appliedclusterresourcequotas: {
group: "quota.openshift.io",
version: "v1",
resource: "appliedclusterresourcequotas"
},
builds: {
group: "build.openshift.io",
version: "v1",
resource: "builds"
},
"builds/clone": {
group: "build.openshift.io",
version: "v1",
resource: "builds/clone"
},
"builds/log": {
group: "build.openshift.io",
version: "v1",
resource: "builds/log"
},
"buildconfigs/instantiate": {
group: "build.openshift.io",
version: "v1",
resource: "buildconfigs/instantiate"
},
buildconfigs: {
group: "build.openshift.io",
version: "v1",
resource: "buildconfigs"
buildconfigs: {
group: "build.openshift.io",
version: "v1",
resource: "buildconfigs"
},
configmaps: {
version: "v1",
......@@ -1085,7 +868,7 @@ extensions: "v1beta1"
if (e instanceof ResourceGroupVersion) return e;
var n, r, o;
return angular.isString(e) ? (n = d(e), o = f[r = ""]) : e && e.resource && (n = d(e.resource), r = e.group || "", o = e.version || f[r] || _.get(t, [ "groups", r, "preferredVersion" ])), new ResourceGroupVersion(n, r, o);
}, h = function(e) {
}, m = function(e) {
if (e) {
var t = e.split("/");
return 1 === t.length ? "v1" === t[0] ? {
......@@ -1099,7 +882,7 @@ group: t[0],
version: t[1]
} : void a.warn('Invalid apiVersion "' + e + '"');
}
}, m = function(e, t) {
}, h = function(e, t) {
return !(!_.find(r.kinds, {
group: e,
kind: t
......@@ -1134,7 +917,7 @@ _.each(e.versions[t].resources, function(t) {
_.includes(t.name, "/") || _.find(o, {
kind: t.kind,
group: e.name
}) || m(e.name, t.kind) || (t.namespaced || n) && r.push({
}) || h(e.name, t.kind) || (t.namespaced || n) && r.push({
kind: t.kind,
group: e.name
});
......@@ -1148,19 +931,19 @@ toAPIVersion: function(e) {
return e.group ? e.group + "/" + e.version : e.version;
},
toResourceGroupVersion: g,
parseGroupVersion: h,
parseGroupVersion: m,
objectToResourceGroupVersion: function(e) {
if (e && e.kind && e.apiVersion) {
var t = p(e.kind);
if (t) {
var n = h(e.apiVersion);
var n = m(e.apiVersion);
if (n) return new ResourceGroupVersion(t, n.group, n.version);
}
}
},
deriveTargetResource: function(e, t) {
if (e && t) {
var n = p(t.kind), r = h(t.apiVersion), o = g(e);
var n = p(t.kind), r = m(t.apiVersion), o = g(e);
if (n && r && o) return angular.isString(e) ? (o.equals(n) && (o.group = r.group, o.version = r.version), o) : (o.equals(n, r.group) && (o.version = r.version), o);
}
},
......@@ -1277,24 +1060,24 @@ throw n + " not set";
this.$get = [ "$q", "$injector", "$log", "$rootScope", "Logger", "base64", function(o, i, a, s, c, l) {
var u = c.get("auth");
u.log("AuthServiceProvider.$get", arguments);
var d = $.Callbacks(), p = $.Callbacks(), f = $.Callbacks(), g = null, h = null, m = r(i, e, "AuthServiceProvider.UserStore()");
m.available() || c.error("AuthServiceProvider.$get user store " + e + " not available");
var d = $.Callbacks(), p = $.Callbacks(), f = $.Callbacks(), g = null, m = null, h = r(i, e, "AuthServiceProvider.UserStore()");
h.available() || c.error("AuthServiceProvider.$get user store " + e + " not available");
var v = r(i, t, "AuthServiceProvider.LoginService()"), b = r(i, n, "AuthServiceProvider.LogoutService()");
return {
UserStore: function() {
return m;
return h;
},
isLoggedIn: function() {
return !!m.getUser();
return !!h.getUser();
},
withUser: function() {
var e = m.getUser();
var e = h.getUser();
return e ? (s.user = e, u.log("AuthService.withUser()", e), o.when(e)) : (u.log("AuthService.withUser(), calling startLogin()"), this.startLogin());
},
setUser: function(e, t, n) {
u.log("AuthService.setUser()", e, t, n);
var r = m.getUser();
m.setUser(e, n), m.setToken(t, n), s.user = e, (r && r.metadata && r.metadata.name) !== (e && e.metadata && e.metadata.name) && (u.log("AuthService.setUser(), user changed", r, e), f.fire(e));
var r = h.getUser();
h.setUser(e, n), h.setToken(t, n), s.user = e, (r && r.metadata && r.metadata.name) !== (e && e.metadata && e.metadata.name) && (u.log("AuthService.setUser(), user changed", r, e), f.fire(e));
},
requestRequiresAuth: function(e) {
var t = !!e.auth;
......@@ -1302,7 +1085,7 @@ return u.log("AuthService.requestRequiresAuth()", e.url.toString(), t), t;
},
addAuthToRequest: function(e) {
var t = "";
return e && e.auth && e.auth.token ? (t = e.auth.token, u.log("AuthService.addAuthToRequest(), using token from request config", t)) : (t = m.getToken(), u.log("AuthService.addAuthToRequest(), using token from user store", t)), t ? ("WATCH" === e.method ? (e.protocols = e.protocols || [], _.isArray(e.protocols) || (e.protocols = [ e.protocols ]), 0 == e.protocols.length && e.protocols.unshift("undefined"), e.protocols.unshift("base64url.bearer.authorization.k8s.io." + l.urlencode(t)), u.log("AuthService.addAuthToRequest(), added token protocol", e.protocols)) : (e.headers.Authorization = "Bearer " + t, u.log("AuthService.addAuthToRequest(), added token header", e.headers.Authorization)), !0) : (u.log("AuthService.addAuthToRequest(), no token available"), !1);
return e && e.auth && e.auth.token ? (t = e.auth.token, u.log("AuthService.addAuthToRequest(), using token from request config", t)) : (t = h.getToken(), u.log("AuthService.addAuthToRequest(), using token from user store", t)), t ? ("WATCH" === e.method ? (e.protocols = e.protocols || [], _.isArray(e.protocols) || (e.protocols = [ e.protocols ]), 0 == e.protocols.length && e.protocols.unshift("undefined"), e.protocols.unshift("base64url.bearer.authorization.k8s.io." + l.urlencode(t)), u.log("AuthService.addAuthToRequest(), added token protocol", e.protocols)) : (e.headers.Authorization = "Bearer " + t, u.log("AuthService.addAuthToRequest(), added token header", e.headers.Authorization)), !0) : (u.log("AuthService.addAuthToRequest(), no token available"), !1);
},
startLogin: function() {
if (g) return u.log("Login already in progress"), g;
......@@ -1316,16 +1099,16 @@ g = null;
});
},
startLogout: function() {
if (h) return u.log("Logout already in progress"), h;
var e = this, t = m.getUser(), n = m.getToken(), r = this.isLoggedIn();
return h = b.logout(t, n).then(function() {
if (m) return u.log("Logout already in progress"), m;
var e = this, t = h.getUser(), n = h.getToken(), r = this.isLoggedIn();
return m = b.logout(t, n).then(function() {
u.log("Logout service success");
}).catch(function(e) {
u.error("Logout service error", e);
}).finally(function() {
e.setUser(null, null);
var t = e.isLoggedIn();
r && !t && p.fire(), h = null;
r && !t && p.fire(), m = null;
});
},
onLogin: function(e) {
......@@ -1385,7 +1168,7 @@ return d(t) && !_.isEmpty(_.intersection(e.verbs, [ "*", "create", "update" ]));
});
}, f = {}, g = function(e) {
return _.get(s.get(e || a), [ "rules" ]);
}, h = function(e, t, n, r) {
}, m = function(e, t, n, r) {
var o = e[n];
if (!o) return !1;
var i = o[r];
......@@ -1426,7 +1209,7 @@ canI: function(e, t, n) {
if (c) return !0;
if (!e) return !1;
var r = o.toResourceGroupVersion(e), i = g(n || a);
return !!i && (h(i, t, r.group, r.resource) || h(i, t, "*", "*") || h(i, t, r.group, "*") || h(i, t, "*", r.resource));
return !!i && (m(i, t, r.group, r.resource) || m(i, t, "*", "*") || m(i, t, r.group, "*") || m(i, t, "*", r.resource));
},
canIAddToProject: function(e) {
return !!c || !!_.get(s.get(e || a), [ "canAddToProject" ]);
......@@ -1590,7 +1373,7 @@ t._websocketEventsMap = {};
function g(e) {
return e.length >= S && Date.now() - e[0].time < 3e4;
}
function h(e) {
function m(e) {
if (e.length < 5) return !1;
for (var t = e.length - 5; t < e.length; t++) if ("close" !== e[t].type) return !1;
return !0;
......@@ -1607,12 +1390,12 @@ angular.forEach(e, function(e, o) {
p(e, t, n, r ? r[o] : null);
});
};
var m = [], v = _.debounce(function() {
if (m.length) {
var h = [], v = _.debounce(function() {
if (h.length) {
var e = {
type: "error",
message: "An error occurred connecting to the server.",
details: m.join("\n"),
details: h.join("\n"),
links: [ {
label: "Refresh",
onClick: function() {
......@@ -1620,12 +1403,12 @@ window.location.reload();
}
} ]
};
r.$emit("NotificationsService.addNotification", e), m = [];
r.$emit("NotificationsService.addNotification", e), h = [];
}
}, 300, {
maxWait: 1e3
}), b = function(e, t) {
t && (e += " (status " + t + ")"), m.push(e), v();
t && (e += " (status " + t + ")"), h.push(e), v();
}, y = function(e, t) {
var n;
return n = e ? "Unknown resource: " + e.toString() : "Internal error: API resource not specified.", _.get(t, "errorNotification", !0) && b(n), o.reject({
......@@ -1793,7 +1576,7 @@ return l.promise;
}, f.prototype.createStream = function(e, t, r, o, i) {
var c = this;
e = a.toResourceGroupVersion(e);
var d, p = i ? "binary.k8s.io" : "base64.binary.k8s.io", f = {}, g = {}, h = {}, m = {}, v = function() {
var d, p = i ? "binary.k8s.io" : "base64.binary.k8s.io", f = {}, g = {}, m = {}, h = {}, v = function() {
return c._getNamespace(e, r, {}).then(function(a) {
var d = c._urlForResource(e, t, r, !0, _.extend(a, o));
if (!d) return y(e, o);
......@@ -1815,12 +1598,12 @@ i ? n(e.data) : n(t, e.data, v);
} else s.log("log stream response is not a string", e.data);
},
onclose: function(e) {
_.each(h, function(t) {
_.each(m, function(t) {
t(e);
});
},
onerror: function(e) {
_.each(m, function(t) {
_.each(h, function(t) {
t(e);
});
},
......@@ -1846,17 +1629,17 @@ return g[t] = e, t;
onClose: function(e) {
if (_.isFunction(e)) {
var t = _.uniqueId("stream_");
return h[t] = e, t;
return m[t] = e, t;
}
},
onError: function(e) {
if (_.isFunction(e)) {
var t = _.uniqueId("stream_");
return m[t] = e, t;
return h[t] = e, t;
}
},
remove: function(e) {
f[e] && delete f[e], g[e] && delete g[e], h[e] && delete h[e], m[e] && delete m[e];
f[e] && delete f[e], g[e] && delete g[e], m[e] && delete m[e], h[e] && delete h[e];
},
start: function() {
return d = v();
......@@ -1964,7 +1747,7 @@ time: Date.now()
}); n.length > S; ) n.shift();
}, f.prototype._isTooManyWebsocketRetries = function(e) {
var t = this._websocketEventsMap[e];
return !!t && (g(t) ? (s.log("Too many websocket open or close events for resource/context in a short period", e, t), !0) : !!h(t) && (s.log("Too many consecutive websocket close events for resource/context", e, t), !0));
return !!t && (g(t) ? (s.log("Too many websocket open or close events for resource/context in a short period", e, t), !0) : !!m(t) && (s.log("Too many consecutive websocket close events for resource/context", e, t), !0));
};
var w = function(e) {
var t = _.keysIn(_.pick(e, [ "fieldSelector", "labelSelector" ])).sort();
......@@ -2380,7 +2163,7 @@ var u, d = !1, p = r.getPreferredVersion("projects"), f = r.getPreferredVersion(
s.debug("ProjectsService: clearing project cache"), u = null, d = !1;
};
o.onUserChanged(g), o.onLogout(g);
var h = function(e) {
var m = function(e) {
var t = [ l("description"), l("displayName") ];
return _.each(t, function(t) {
e.metadata.annotations[t] || delete e.metadata.annotations[t];
......@@ -2428,7 +2211,7 @@ u = e, t(e);
});
},
update: function(e, t) {
return a.update(p, e, h(t), {
return a.update(p, e, m(t), {
projectName: e
}, {
errorNotification: !1
......@@ -2615,15 +2398,15 @@ if (!f.verified) return s.reject({
error: "invalid_request",
error_description: "Client state could not be verified"
});
var h = [ "grant_type=authorization_code", "code=" + encodeURIComponent(d.code), "redirect_uri=" + encodeURIComponent(r), "client_id=" + encodeURIComponent(e) ].join("&");
return o && (h += "&scope=" + encodeURIComponent(o)), t({
var m = [ "grant_type=authorization_code", "code=" + encodeURIComponent(d.code), "redirect_uri=" + encodeURIComponent(r), "client_id=" + encodeURIComponent(e) ].join("&");
return o && (m += "&scope=" + encodeURIComponent(o)), t({
method: "POST",
url: n,
headers: {
Authorization: "Basic " + window.btoa(e + ":"),
"Content-Type": "application/x-www-form-urlencoded"
},
data: h
data: m
}).then(function(e) {
return c(e.data, f);
}, function(e) {
......@@ -2842,4 +2625,381 @@ this.dismissDelay = e;
}, this.setAutoDismissTypes = function(e) {
this.autoDismissTypes = e;
};
});
\ No newline at end of file
}), angular.module("openshiftCommonUI").component("bindApplicationForm", {
controllerAs: "ctrl",
bindings: {
allowNoBinding: "<?",
createBinding: "=",
applicationName: "=",
formName: "=",
serviceClasses: "<",
serviceInstances: "<",
serviceToBind: "="
},
templateUrl: "src/components/binding/bindApplicationForm.html",
controller: [ "BindingService", function(e) {
function t(t) {
return e.isServiceBindable(t, n.serviceClasses);
}
var n = this;
n.$onChanges = function(e) {
(e.serviceInstances || e.serviceClasses) && (n.bindableServiceInstances = _.filter(n.serviceInstances, t));
};
} ]
}), angular.module("openshiftCommonUI").component("bindResults", {
controllerAs: "ctrl",
bindings: {
error: "<",
binding: "<",
serviceToBind: "<",
bindType: "@",
applicationToBind: "<",
showPodPresets: "<",
secretHref: "<"
},
templateUrl: "src/components/binding/bindResults.html"
}), angular.module("openshiftCommonUI").component("bindServiceForm", {
controllerAs: "ctrl",
bindings: {
serviceClass: "<",
showPodPresets: "<",
applications: "<",
formName: "=",
allowNoBinding: "<?",
projectName: "<",
bindType: "=",
appToBind: "="
},
templateUrl: "src/components/binding/bindServiceForm.html",
controller: [ "$filter", function(e) {
var t = this, n = e("humanizeKind");
t.groupByKind = function(e) {
return n(e.kind);
};
} ]
}), angular.module("openshiftCommonUI").directive("createProject", [ "$window", function(e) {
return {
restrict: "E",
scope: {
redirectAction: "&",
onCancel: "&?",
isDialog: "@"
},
templateUrl: "src/components/create-project/createProject.html",
controller: [ "$scope", "$location", "ProjectsService", "NotificationsService", "displayNameFilter", "Logger", function(t, n, r, o, i, a) {
t.submitButtonLabel || (t.submitButtonLabel = "Create"), t.isDialog = "true" === t.isDialog;
t.createProject = function() {
if (t.disableInputs = !0, t.createProjectForm.$valid) {
var e = t.displayName || t.name;
r.create(t.name, t.displayName, t.description).then(function(e) {
var r = t.redirectAction();
r ? r(encodeURIComponent(e.metadata.name)) : n.path("project/" + encodeURIComponent(e.metadata.name) + "/create"), o.addNotification({
type: "success",
message: "Project '" + i(e) + "' was successfully created."
});
}, function(n) {
t.disableInputs = !1;
var r = n.data || {};
if ("AlreadyExists" === r.reason) t.nameTaken = !0; else {
var i = r.message || "An error occurred creating project '" + e + "'.";
o.addNotification({
type: "error",
message: i
}), a.error("Project '" + e + "' could not be created.", n);
}
});
}
}, t.cancelCreateProject = function() {
if (t.onCancel) {
var n = t.onCancel();
n && n();
} else e.history.back();
}, t.$on("$destroy", function() {
o.hideNotification("create-project-error");
});
} ]
};
} ]), angular.module("openshiftCommonUI").directive("deleteProject", [ "$uibModal", "$location", "$filter", "$q", "hashSizeFilter", "APIService", "NotificationsService", "ProjectsService", "Logger", function(e, t, n, r, o, i, a, s, c) {
return {
restrict: "E",
scope: {
project: "=",
disableDelete: "=?",
typeNameToConfirm: "=?",
label: "@?",
buttonOnly: "@",
stayOnCurrentPage: "=?",
success: "=?",
redirectUrl: "@?"
},
templateUrl: function(e, t) {
return angular.isDefined(t.buttonOnly) ? "src/components/delete-project/delete-project-button.html" : "src/components/delete-project/delete-project.html";
},
replace: !0,
link: function(r, o, i) {
var l = n("displayName"), u = function() {
if (!r.stayOnCurrentPage) if (r.redirectUrl) t.url(r.redirectUrl); else if ("/" !== t.path()) {
var e = URI("/");
t.url(e);
} else r.$emit("deleteProject");
};
r.openDeleteModal = function() {
r.disableDelete || e.open({
templateUrl: "src/components/delete-project/delete-project-modal.html",
controller: "DeleteProjectModalController",
scope: r
}).result.then(function() {
var e = "Project '" + l(r.project) + "'";
s.delete(r.project).then(function() {
a.addNotification({
type: "success",
message: e + " was marked for deletion."
}), r.success && r.success(), u();
}).catch(function(t) {
a.addNotification({
type: "error",
message: e + " could not be deleted.",
details: n("getErrorDetails")(t)
}), c.error(e + " could not be deleted.", t);
});
});
};
}
};
} ]), angular.module("openshiftCommonUI").controller("DeleteProjectModalController", [ "$scope", "$uibModalInstance", function(e, t) {
e.delete = function() {
t.close("delete");
}, e.cancel = function() {
t.dismiss("cancel");
};
} ]), angular.module("openshiftCommonUI").directive("editProject", [ "$window", function(e) {
return {
restrict: "E",
scope: {
project: "=",
submitButtonLabel: "@",
redirectAction: "&",
onCancel: "&",
isDialog: "@"
},
templateUrl: "src/components/edit-project/editProject.html",
controller: [ "$scope", "$filter", "$location", "Logger", "NotificationsService", "ProjectsService", "annotationNameFilter", "displayNameFilter", function(t, n, r, o, i, a, s, c) {
t.submitButtonLabel || (t.submitButtonLabel = "Save"), t.isDialog = "true" === t.isDialog;
var l = n("annotation"), u = n("annotationName"), d = function(e) {
return {
description: l(e, "description"),
displayName: l(e, "displayName")
};
}, p = function(e, t) {
var n = angular.copy(e);
return n.metadata.annotations[u("description")] = t.description, n.metadata.annotations[u("displayName")] = t.displayName, n;
}, f = function(e) {
var t = [ s("description"), s("displayName") ];
return _.each(t, function(t) {
e.metadata.annotations[t] || delete e.metadata.annotations[t];
}), e;
};
t.editableFields = d(t.project), t.update = function() {
t.disableInputs = !0, t.editProjectForm.$valid && a.update(t.project.metadata.name, f(p(t.project, t.editableFields))).then(function(e) {
var n = t.redirectAction();
n && n(encodeURIComponent(t.project.metadata.name)), i.addNotification({
type: "success",
message: "Project '" + c(e) + "' was successfully updated."
});
}, function(e) {
t.disableInputs = !1, t.editableFields = d(t.project), i.addNotification({
type: "error",
message: "An error occurred while updating project '" + c(t.project) + "'.",
details: n("getErrorDetails")(e)
}), o.error("Project '" + c(t.project) + "' could not be updated.", e);
});
}, t.cancelEditProject = function() {
var n = t.onCancel();
n ? n() : e.history.back();
};
} ]
};
} ]), angular.module("openshiftCommonUI").component("originModalPopup", {
transclude: !0,
bindings: {
modalTitle: "@",
shown: "<",
position: "@",
referenceElement: "<?",
onClose: "<"
},
templateUrl: "src/components/origin-modal-popup/origin-modal-popup.html",
controller: [ "$scope", "HTMLService", "$element", "$window", function(e, t, n, r) {
function o() {
var e = d.referenceElement || n[0].parentNode;
if (e && t.isWindowAboveBreakpoint(t.WINDOW_SIZE_SM)) {
var o, i, a = d.position && d.position.indexOf("top") > -1, s = d.position && d.position.indexOf("left") > -1, c = e.getBoundingClientRect(), l = r.innerHeight, u = n[0].children[0], p = _.get(u, "offsetHeight", 0), f = _.get(u, "offsetWidth", 0);
c.top < p ? a = !1 : c.bottom + p > l && (a = !0), o = a ? c.top - p + "px" : c.bottom + "px", i = s ? c.left + "px" : c.right - f + "px", d.showAbove = a, d.showLeft = s, d.positionStyle = {
left: i,
top: o
};
} else d.positionStyle = {};
}
function i() {
var e = d.referenceElement ? d.referenceElement.parentNode : n[0].parentNode;
$(e).append('<div class="origin-modal-popup-backdrop modal-backdrop fade in tile-click-prevent"></div>');
}
function a() {
$(".origin-modal-popup-backdrop").remove();
}
function s() {
e.$evalAsync(o);
}
function c() {
i(), u = _.debounce(s, 50, {
maxWait: 250
}), angular.element(r).on("resize", u);
}
function l() {
a(), u && (angular.element(r).off("resize", u), u = null);
}
var u, d = this;
d.$onChanges = function(e) {
e.shown && (d.shown ? c() : l()), (e.shown || e.referenceElement) && d.shown && o();
}, d.$onDestroy = function() {
d.shown && l();
};
} ]
}), angular.module("openshiftCommonUI").directive("oscUnique", function() {
return {
restrict: "A",
scope: {
oscUnique: "=",
oscUniqueDisabled: "="
},
require: "ngModel",
link: function(e, t, n, r) {
var o = [], i = !0;
e.$watchCollection("oscUnique", function(e) {
o = _.isArray(e) ? e : _.keys(e);
});
var a = function() {
r.$setValidity("oscUnique", e.oscUniqueDisabled || i);
};
e.$watch("oscUniqueDisabled", a), r.$parsers.unshift(function(e) {
return i = !_.includes(o, e), a(), e;
});
}
};
}), angular.module("openshiftCommonUI").directive("toggle", [ "IS_IOS", function(e) {
var t = function(e) {
$("body").css("cursor", e);
}, n = _.partial(t, "pointer"), r = _.partial(t, "auto");
return e && ($(document).on("shown.bs.popover", n), $(document).on("shown.bs.tooltip", n), $(document).on("hide.bs.popover", r), $(document).on("hide.bs.tooltip", r)), {
restrict: "A",
scope: {
dynamicContent: "@?"
},
link: function(e, t, n) {
var r = {
container: n.container || "body",
placement: n.placement || "auto"
};
if (n) switch (n.toggle) {
case "popover":
(n.dynamicContent || "" === n.dynamicContent) && e.$watch("dynamicContent", function() {
$(t).popover("destroy"), setTimeout(function() {
$(t).attr("data-content", e.dynamicContent).popover(r);
}, 200);
}), $(t).popover(r), e.$on("$destroy", function() {
$(t).popover("destroy");
});
break;
case "tooltip":
(n.dynamicContent || "" === n.dynamicContent) && e.$watch("dynamicContent", function() {
$(t).tooltip("destroy"), setTimeout(function() {
$(t).attr("title", e.dynamicContent).tooltip(r);
}, 200);
}), $(t).tooltip(r), e.$on("$destroy", function() {
$(t).tooltip("destroy");
});
break;
case "dropdown":
"dropdown" === n.hover && ($(t).dropdownHover({
delay: 200
}), $(t).dropdown());
}
}
};
} ]), angular.module("openshiftCommonUI").directive("takeFocus", [ "$timeout", function(e) {
return {
restrict: "A",
link: function(t, n) {
e(function() {
$(n).focus();
}, 300);
}
};
} ]), angular.module("openshiftCommonUI").directive("tileClick", function() {
return {
restrict: "AC",
link: function(e, t) {
$(t).click(function(e) {
var n = $(e.target);
n && (n.closest("a", t).length || n.closest("button", t).length) || n.closest(".tile-click-prevent", t).length || angular.element($("a.tile-target", t))[0].click();
});
}
};
}), angular.module("openshiftCommonUI").directive("toastNotifications", [ "NotificationsService", "$rootScope", "$timeout", function(e, t, n) {
return {
restrict: "E",
scope: {},
templateUrl: "src/components/toast-notifications/toast-notifications.html",
link: function(r) {
r.notifications = [];
var o = function(e) {
return e.hidden && !e.isHover;
}, i = function(e) {
e.isHover = !1, e.hidden = !0;
}, a = function() {
r.notifications = _.reject(r.notifications, o);
};
r.close = function(e) {
i(e), _.isFunction(e.onClose) && e.onClose();
}, r.onClick = function(e, t) {
_.isFunction(t.onClick) && t.onClick() && i(e);
}, r.setHover = function(e, t) {
o(e) || (e.isHover = t);
};
var s = t.$on("NotificationsService.onNotificationAdded", function(t, o) {
o.skipToast || r.$evalAsync(function() {
r.notifications.push(o), e.isAutoDismiss(o) && n(function() {
o.hidden = !0;
}, e.dismissDelay), a();
});
});
r.$on("$destroy", function() {
s && (s(), s = null);
});
}
};
} ]), angular.module("openshiftCommonUI").directive("truncateLongText", [ "truncateFilter", function(e) {
return {
restrict: "E",
scope: {
content: "=",
limit: "=",
newlineLimit: "=",
useWordBoundary: "=",
expandable: "=",
hideCollapse: "=",
keywords: "=highlightKeywords",
linkify: "=?"
},
templateUrl: "src/components/truncate-long-text/truncateLongText.html",
link: function(t) {
t.toggles = {
expanded: !1
}, t.$watch("content", function(n) {
n ? (t.truncatedContent = e(n, t.limit, t.useWordBoundary, t.newlineLimit), t.truncated = t.truncatedContent.length !== n.length) : (t.truncatedContent = null, t.truncated = !1);
});
}
};
} ]);
\ No newline at end of file
......@@ -25,11 +25,11 @@ angular.module('openshiftCommonServices', ['ab-base64'])
RedirectLoginServiceProvider.OAuthRedirectURI(URI(AUTH_CFG.oauth_redirect_base).segment("oauth").toString());
});
hawtioPluginLoader.addModule('openshiftCommonServices');
pluginLoader.addModule('openshiftCommonServices');
// API Discovery, this runs before the angular app is bootstrapped
// TODO we want this to be possible with a single request against the API instead of being dependent on the numbers of groups and versions
hawtioPluginLoader.registerPreBootstrapTask(function(next) {
pluginLoader.registerPreBootstrapTask(function(next) {
// Skips api discovery, needed to run spec tests
if ( _.get(window, "OPENSHIFT_CONFIG.api.k8s.resources") ) {
next();
......
......@@ -26,4 +26,4 @@ angular.module('openshiftCommonUI', [])
.constant('IS_IOS', /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);
hawtioPluginLoader.addModule('openshiftCommonUI');
pluginLoader.addModule('openshiftCommonUI');
/*
* This is a pared down version of hawtio-core in order to remove the outdated
* dependency as part the migration from bower to yarn.
*
* TODO Figure out a better strategy for API discovery so that this can be
* removed altogether.
*
*/
// log initialization
/* globals Logger window console document localStorage $ angular jQuery navigator Jolokia */
(function() {
'use strict';
Logger.setLevel(Logger.INFO);
window['LogBuffer'] = 100;
if ('localStorage' in window) {
if (!('logLevel' in window.localStorage)) {
window.localStorage['logLevel'] = JSON.stringify(Logger.INFO);
}
var logLevel = Logger.DEBUG;
try {
logLevel = JSON.parse(window.localStorage['logLevel']);
} catch (e) {
console.error("Failed to parse log level setting: ", e);
}
Logger.setLevel(logLevel);
if ('logBuffer' in window.localStorage) {
var logBuffer = window.localStorage['logBuffer'];
window['LogBuffer'] = parseInt(logBuffer, 10);
} else {
window.localStorage['logBuffer'] = window['LogBuffer'];
}
}
})();
/*
* Plugin loader and discovery mechanism
*/
var pluginLoader = (function(self) {
'use strict';
var log = Logger;
var bootstrapEl = document.documentElement;
self.log = log;
/**
* Holds all of the angular modules that need to be bootstrapped
* @type {Array}
*/
self.modules = [];
/**
* Tasks to be run before bootstrapping, tasks can be async.
* Supply a function that takes the next task to be
* executed as an argument and be sure to call the passed
* in function.
*
* @type {Array}
*/
self.tasks = [];
self.setBootstrapElement = function(el) {
log.debug("Setting bootstrap element to: ", el);
bootstrapEl = el;
}
self.getBootstrapElement = function() {
return bootstrapEl;
}
self.registerPreBootstrapTask = function(task, front) {
if (angular.isFunction(task)) {
log.debug("Adding legacy task");
task = {
task: task
};
}
if (!task.name) {
task.name = 'unnamed-task-' + (self.tasks.length + 1);
}
if (task.depends && !angular.isArray(task.depends) && task.depends !== '*') {
task.depends = [task.depends];
}
if (!front) {
self.tasks.push(task);
} else {
self.tasks.unshift(task);
}
};
self.addModule = function(module) {
log.debug("Adding module: " + module);
self.modules.push(module);
};
self.getModules = function() {
return self.modules;
};
self.loaderCallback = null;
self.setLoaderCallback = function(cb) {
self.loaderCallback = cb;
};
function intersection(search, needle) {
if (!angular.isArray(needle)) {
needle = [needle];
}
var answer = [];
needle.forEach(function(n) {
search.forEach(function(s) {
if (n === s) {
answer.push(s);
}
});
});
return answer;
}
self.loadPlugins = function(callback) {
var lcb = self.loaderCallback;
var plugins = {};
var bootstrap = function() {
var executedTasks = [];
var deferredTasks = [];
var bootstrapTask = {
name: 'Bootstrap',
depends: '*',
runs: 0,
task: function(next) {
function listTasks() {
deferredTasks.forEach(function(task) {
self.log.info(" name: " + task.name + " depends: ", task.depends);
});
}
if (deferredTasks.length > 0) {
self.log.info("tasks yet to run: ");
listTasks();
bootstrapTask.runs = bootstrapTask.runs + 1;
self.log.info("Task list restarted : ", bootstrapTask.runs, " times");
if (bootstrapTask.runs === 5) {
self.log.info("Orphaned tasks: ");
listTasks();
deferredTasks.length = 0;
} else {
deferredTasks.push(bootstrapTask);
}
}
self.log.debug("Executed tasks: ", executedTasks);
next();
}
}
self.registerPreBootstrapTask(bootstrapTask);
var executeTask = function() {
var tObj = null;
var tmp = [];
// if we've executed all of the tasks, let's drain any deferred tasks
// into the regular task queue
if (self.tasks.length === 0) {
tObj = deferredTasks.shift();
}
// first check and see what tasks have executed and see if we can pull a task
// from the deferred queue
while(!tObj && deferredTasks.length > 0) {
var task = deferredTasks.shift();
if (task.depends === '*') {
if (self.tasks.length > 0) {
tmp.push(task);
} else {
tObj = task;
}
} else {
var intersect = intersection(executedTasks, task.depends);
if (intersect.length === task.depends.length) {
tObj = task;
} else {
tmp.push(task);
}
}
}
if (tmp.length > 0) {
tmp.forEach(function(task) {
deferredTasks.push(task);
});
}
// no deferred tasks to execute, let's get a new task
if (!tObj) {
tObj = self.tasks.shift();
}
// check if task has dependencies
if (tObj && tObj.depends && self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' has dependencies: ", tObj.depends);
if (tObj.depends === '*') {
if (self.tasks.length > 0) {
self.log.debug("Task '" + tObj.name + "' wants to run after all other tasks, deferring");
deferredTasks.push(tObj);
executeTask();
return;
}
} else {
var intersect = intersection(executedTasks, tObj.depends);
if (intersect.length != tObj.depends.length) {
self.log.debug("Deferring task: '" + tObj.name + "'");
deferredTasks.push(tObj);
executeTask();
return;
}
}
}
if (tObj) {
self.log.debug("Executing task: '" + tObj.name + "'");
var called = false;
var next = function() {
if (next.notFired) {
next.notFired = false;
executedTasks.push(tObj.name);
setTimeout(executeTask, 1);
}
}
next.notFired = true;
tObj.task(next);
} else {
self.log.debug("All tasks executed");
setTimeout(callback, 1);
}
};
setTimeout(executeTask, 1);
};
var loadScripts = (function() {
// keep track of when scripts are loaded so we can execute the callback
var loaded = 0;
$.each(plugins, function(key, data) {
loaded = loaded + data.Scripts.length;
});
var totalScripts = loaded;
var scriptLoaded = function() {
$.ajaxSetup({async:true});
loaded = loaded - 1;
if (lcb) {
lcb.scriptLoaderCallback(lcb, totalScripts, loaded + 1);
}
if (loaded === 0) {
bootstrap();
}
};
if (loaded > 0) {
$.each(plugins, function(key, data) {
data.Scripts.forEach( function(script) {
var scriptName = data.Context + "/" + script;
log.debug("Fetching script: ", scriptName);
$.ajaxSetup({async:false});
$.getScript(scriptName)
.done(function(textStatus) {
log.debug("Loaded script: ", scriptName);
})
.fail(function(jqxhr, settings, exception) {
log.info("Failed loading script: \"", exception.message, "\" (<a href=\"", scriptName, ":", exception.lineNumber, "\">", scriptName, ":", exception.lineNumber, "</a>)");
})
.always(scriptLoaded);
});
});
} else {
// no scripts to load, so just do the callback
$.ajaxSetup({async:true});
bootstrap();
}
return this;
})();
};
self.debug = function() {
log.debug("modules");
log.debug(self.modules);
};
self.setLoaderCallback({
scriptLoaderCallback: function (self, total, remaining) {
log.debug("Total scripts: ", total, " Remaining: ", remaining);
}
});
return self;
})(pluginLoader || {}, window, undefined);
// Plugin responsible for bootstrapping the app
var BootstrapPlugin = (function () {
'use strict';
function BootstrapPluginClass(){}
/**
* The app's injector, set once bootstrap is completed
*/
Object.defineProperty(BootstrapPluginClass.prototype, "injector", {
get: function() {
return BootstrapPlugin._injector;
},
enumerable: true,
configurable: true
});
var BootstrapPlugin = new BootstrapPluginClass();
/**
* This plugin's name and angular module
*/
BootstrapPlugin.pluginName = "bootstrap-plugin";
/**
* This plugins logger instance
*/
var log = Logger.get(BootstrapPlugin.pluginName);
var _module = angular.module(BootstrapPlugin.pluginName, []);
_module.config(["$locationProvider", function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
_module.run(['documentBase', function (documentBase) {
log.debug("loaded");
}]);
BootstrapPlugin.documentBase = function() {
var base = $('head').find('base');
var answer = '/'
if (base && base.length > 0) {
answer = base.attr('href');
} else {
log.warn("Document is missing a 'base' tag, defaulting to '/'");
}
return answer;
}
// Holds the document base so plugins can easily
// figure out absolute URLs when needed
_module.factory('documentBase', function() {
return BootstrapPlugin.documentBase();
});
pluginLoader.addModule("ng");
pluginLoader.addModule("ngSanitize");
pluginLoader.addModule(BootstrapPlugin.pluginName);
// bootstrap the app
$(function () {
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if ( !jQuery.browser ) {
var matched = jQuery.uaMatch( navigator.userAgent );
var browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
}
pluginLoader.loadPlugins(function() {
if (BootstrapPlugin.injector) {
log.debug("Application already bootstrapped");
return;
}
var bootstrapEl = pluginLoader.getBootstrapElement();
log.debug("Using bootstrap element: ", bootstrapEl);
BootstrapPlugin._injector = angular.bootstrap(bootstrapEl, pluginLoader.getModules(), {
strictDi: false
});
log.debug("Bootstrapped application");
});
});
return BootstrapPlugin;
})();
// Create an alias for hawtioPluginLoader since it may still be used in other
// downstream repos.
window.hawtioPluginLoader = pluginLoader;
......@@ -38,8 +38,6 @@
"xit": false,
"jasmine": false,
"spyOn": false,
"hawtioPluginLoader": false,
"HawtioCore": false,
"Logger" : false,
"LabelSelector": false,
"moment": false,
......
......@@ -16,6 +16,8 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
// Load dependencies
"bower_components/jquery/dist/jquery.js",
"bower_components/lodash/lodash.js",
"bower_components/compare-versions/index.js",
......@@ -28,19 +30,24 @@ module.exports = function(config) {
"bower_components/uri.js/src/URITemplate.js",
"bower_components/uri.js/src/jquery.URI.js",
"bower_components/uri.js/src/URI.fragmentURI.js",
"bower_components/hawtio-core/dist/hawtio-core.js",
"bower_components/kubernetes-container-terminal/dist/container-terminal.js",
"bower_components/hawtio-extension-service/dist/hawtio-extension-service.js",
// load up the fixtures first
// load fixtures before source
'test/spec/fixtures/config.js',
'test/spec/fixtures/constants.js',
'test/spec/fixtures/api-discovery.js',
// TODO: is this causing modules to load multiple times? see `src/**/*.js` below
'src/**/*module.js',
// Load source files
'src/pluginLoader.js',
'src/*.module.js',
'dist/scripts/templates.js',
'src/**/*.js',
'src/constants/**/*.js',
'src/filters/**/*.js',
'src/services/**/*.js',
'src/ui-services/**/*.js',
'src/components/**/*.js',
'test/spec/spec-helper.js',
'test/spec/**/*.js'
'test/spec/filters/**/*.js',
'test/spec/services/**/*.js'
],
// list of files / patterns to exclude
......@@ -63,7 +70,7 @@ module.exports = function(config) {
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_WARN,
// enable / disable watching file and executing tests whenever any file changes
// CLI --auto-watch --no-auto-watch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment