Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$scope.doConnect = (container, view) => {
// TODO at least obfusicate this
$scope.connect.userName = Core.username || localStorage['fabric.userName'];
$scope.connect.password = Core.password || localStorage['fabric.password'];
$scope.connect.container = container;
$scope.connect.view = view || "/logs";
var alwaysPrompt = localStorage['fabricAlwaysPrompt'];
if ((alwaysPrompt && alwaysPrompt !== "false") || !$scope.connect.userName || !$scope.connect.password) {
$scope.connect.dialog.open();
} else {
$scope.connect.onOK();
}
};
export function CreateContainerController($scope, $element, $compile, $location, workspace, jolokia, localStorage, userDetails) {
var log:Logging.Logger = Logger.get("Fabric");
if (!('fabric.userName' in localStorage)) {
localStorage['fabric.userName'] = userDetails.username;
localStorage['fabric.password'] = userDetails.password;
}
$scope.versionsOp = 'versions()';
$scope.entity = {
// default options
number: 1,
saveJmxCredentials: true
};
// the form properties stored in local storage
// which we then default when creating a new container
var localStorageProperties = {
child: {
jmxUser: 'fabric.userName',
onOK: () => {
var userName = $scope.connect.userName;
var password = $scope.connect.password;
var container = $scope.connect.container;
log.info("Logging into container " + container + " with user " + userName);
if ($scope.connect.saveCredentials) {
$scope.connect.saveCredentials = false;
if (userName) {
localStorage['fabric.userName'] = userName;
}
if (password) {
localStorage['fabric.password'] = password;
}
}
console.log("Connecting as user " + userName);
var options = new Core.ConnectToServerOptions();
options.view = $scope.connect.view;
Fabric.connect(localStorage, container, userName, password, true, options);
$scope.connect.container = {};
setTimeout(() => {
$scope.connect.dialog.close();
Core.$apply($scope);
}, 100);
}
};
_module.controller("Fabric.PatchingController", ["$scope", "jolokia", "localStorage", "$location", ($scope, jolokia, localStorage, $location) => {
$scope.files = [];
$scope.targetVersion = $location.search()['versionId'];
$scope.newVersionName = '';
$scope.proxyUser = localStorage['fabric.userName'];
$scope.proxyPassword = localStorage['fabric.password'];
$scope.saveJmxCredentials = false;
$scope.cancel = () => {
$location.url('wiki/branch/default-version/view/fabric/profiles');
}
$scope.valid = () => {
return $scope.files && $scope.files.length > 0 && $scope.targetVersion !== null && $scope.proxyUser && $scope.proxyPassword;
}
$scope.go = () => {
var message = $scope.files.length + ' patches';
if ($scope.files.length === 1) {
message = "patch: " + $scope.files[0].fileName;
}
$scope.go = () => {
var message = $scope.files.length + ' patches';
if ($scope.files.length === 1) {
message = "patch: " + $scope.files[0].fileName;
}
Core.notification('info', "Applying " + message);
if ($scope.saveJmxCredentials) {
localStorage['fabric.userName'] = $scope.proxyUser;
localStorage['fabric.password'] = $scope.proxyPassword;
}
var files = $scope.files.map((file) => { return file.absolutePath; });
applyPatches(jolokia, files, $scope.targetVersion, $scope.newVersionName, $scope.proxyUser, $scope.proxyPassword,
() => {
Core.notification('success', "Successfully applied " + message);
$location.url("/fabric/view");
Core.$apply($scope);
}, (response) => {
log.error("Failed to apply ", message, " due to ", response.error);
log.info("Stack trace: ", response.stacktrace);
Core.$apply($scope);
});
}
}]);