2017-11-16 05:42:22 +00:00
|
|
|
registerController('SSLsplit_Controller', ['$api', '$scope', '$rootScope', '$interval', '$timeout', function($api, $scope, $rootScope, $interval, $timeout) {
|
|
|
|
$scope.title = "Loading...";
|
|
|
|
$scope.version = "Loading...";
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshInfo = (function() {
|
2017-11-16 05:42:22 +00:00
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: 'SSLsplit',
|
|
|
|
action: "refreshInfo"
|
|
|
|
}, function(response) {
|
|
|
|
$scope.title = response.title;
|
|
|
|
$scope.version = "v" + response.version;
|
|
|
|
})
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshInfo();
|
2017-11-16 05:42:22 +00:00
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
registerController('SSLsplit_ControlsController', ['$api', '$scope', '$rootScope', '$interval', '$timeout', function($api, $scope, $rootScope, $interval, $timeout) {
|
|
|
|
$scope.status = "Loading...";
|
|
|
|
$scope.statusLabel = "default";
|
|
|
|
$scope.verbose = false;
|
|
|
|
$scope.starting = false;
|
|
|
|
|
|
|
|
$scope.install = "Loading...";
|
|
|
|
$scope.installLabel = "default";
|
|
|
|
$scope.processing = false;
|
|
|
|
|
|
|
|
$scope.certificate = "Loading...";
|
|
|
|
$scope.certificateLabel = "default";
|
|
|
|
$scope.generating = false;
|
|
|
|
|
|
|
|
$scope.bootLabelON = "default";
|
|
|
|
$scope.bootLabelOFF = "default";
|
|
|
|
|
|
|
|
$scope.device = '';
|
|
|
|
$scope.sdAvailable = false;
|
|
|
|
|
|
|
|
$rootScope.status = {
|
2018-08-27 00:32:32 +00:00
|
|
|
installed: false,
|
|
|
|
generated: false,
|
|
|
|
refreshOutput: false,
|
|
|
|
refreshHistory: false
|
2017-11-16 05:42:22 +00:00
|
|
|
};
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshStatus = (function() {
|
2017-11-16 05:42:22 +00:00
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: "SSLsplit",
|
|
|
|
action: "refreshStatus"
|
|
|
|
}, function(response) {
|
|
|
|
$scope.status = response.status;
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.statusLabel = response.statusLabel;
|
|
|
|
$scope.verbose = response.verbose;
|
|
|
|
|
|
|
|
$rootScope.status.installed = response.installed;
|
|
|
|
$scope.device = response.device;
|
|
|
|
$scope.sdAvailable = response.sdAvailable;
|
2018-08-27 00:32:32 +00:00
|
|
|
if (response.processing) $scope.processing = true;
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.install = response.install;
|
|
|
|
$scope.installLabel = response.installLabel;
|
|
|
|
|
|
|
|
$rootScope.status.generated = response.generated;
|
|
|
|
$scope.certificate = response.certificate;
|
2018-08-27 00:32:32 +00:00
|
|
|
if (response.generating) $scope.generating = true;
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.certificateLabel = response.certificateLabel;
|
|
|
|
|
|
|
|
$scope.bootLabelON = response.bootLabelON;
|
|
|
|
$scope.bootLabelOFF = response.bootLabelOFF;
|
2018-08-27 00:32:32 +00:00
|
|
|
})
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.handleCertificate = (function() {
|
|
|
|
if ($scope.certificate != "Generated")
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.certificate = "Generating...";
|
|
|
|
else
|
|
|
|
$scope.certificate = "Removing...";
|
|
|
|
|
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'handleCertificate'
|
|
|
|
}, function(response) {
|
|
|
|
if (response.success === true) {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.certificateLabel = "warning";
|
|
|
|
$scope.generating = true;
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.handleCertificateInterval = $interval(function() {
|
|
|
|
$api.request({
|
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'handleCertificateStatus'
|
|
|
|
}, function(response) {
|
|
|
|
if (response.success === true) {
|
|
|
|
$scope.generating = false;
|
|
|
|
$interval.cancel($scope.handleCertificateInterval);
|
|
|
|
$scope.refreshStatus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 5000);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.toggleSSLsplit = (function() {
|
|
|
|
if ($scope.status != "Stop")
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.status = "Starting...";
|
|
|
|
else
|
|
|
|
$scope.status = "Stopping...";
|
|
|
|
|
|
|
|
$scope.statusLabel = "warning";
|
|
|
|
$scope.starting = true;
|
|
|
|
|
|
|
|
$rootScope.status.refreshOutput = false;
|
|
|
|
$rootScope.status.refreshHistory = false;
|
|
|
|
|
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'toggleSSLsplit',
|
2017-11-16 05:42:22 +00:00
|
|
|
verbose: $scope.verbose
|
2018-08-27 00:32:32 +00:00
|
|
|
}, function(response) {
|
|
|
|
$timeout(function() {
|
|
|
|
$rootScope.status.refreshOutput = true;
|
|
|
|
$rootScope.status.refreshHistory = true;
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.starting = false;
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshStatus();
|
2018-08-27 00:32:32 +00:00
|
|
|
}, 2000);
|
|
|
|
})
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.toggleSSLsplitOnBoot = (function() {
|
|
|
|
if ($scope.bootLabelON == "default") {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.bootLabelON = "success";
|
|
|
|
$scope.bootLabelOFF = "default";
|
2018-08-27 00:32:32 +00:00
|
|
|
} else {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.bootLabelON = "default";
|
|
|
|
$scope.bootLabelOFF = "danger";
|
|
|
|
}
|
|
|
|
|
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'toggleSSLsplitOnBoot',
|
|
|
|
}, function(response) {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshStatus();
|
2018-08-27 00:32:32 +00:00
|
|
|
})
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.handleDependencies = (function(param) {
|
|
|
|
if (!$rootScope.status.installed)
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.install = "Installing...";
|
|
|
|
else
|
|
|
|
$scope.install = "Removing...";
|
|
|
|
|
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'handleDependencies',
|
|
|
|
destination: param
|
|
|
|
}, function(response) {
|
|
|
|
if (response.success === true) {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.installLabel = "warning";
|
|
|
|
$scope.processing = true;
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.handleDependenciesInterval = $interval(function() {
|
|
|
|
$api.request({
|
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'handleDependenciesStatus'
|
|
|
|
}, function(response) {
|
|
|
|
if (response.success === true) {
|
|
|
|
$scope.processing = false;
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshStatus();
|
2018-08-27 00:32:32 +00:00
|
|
|
$interval.cancel($scope.handleDependenciesInterval);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 5000);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
|
|
|
$scope.refreshStatus();
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
registerController('SSLsplit_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.output = 'Loading...';
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.filter = '';
|
|
|
|
|
|
|
|
$scope.refreshLabelON = "default";
|
|
|
|
$scope.refreshLabelOFF = "danger";
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshOutput = (function() {
|
2017-11-16 05:42:22 +00:00
|
|
|
$api.request({
|
2018-08-27 00:32:32 +00:00
|
|
|
module: "SSLsplit",
|
|
|
|
action: "refreshOutput",
|
2017-11-16 05:42:22 +00:00
|
|
|
filter: $scope.filter
|
2018-08-27 00:32:32 +00:00
|
|
|
}, function(response) {
|
|
|
|
$scope.output = response;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.clearFilter = (function() {
|
|
|
|
$scope.filter = '';
|
|
|
|
$scope.refreshOutput();
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.toggleAutoRefresh = (function() {
|
|
|
|
if ($scope.autoRefreshInterval) {
|
2017-11-16 05:42:22 +00:00
|
|
|
$interval.cancel($scope.autoRefreshInterval);
|
|
|
|
$scope.autoRefreshInterval = null;
|
|
|
|
$scope.refreshLabelON = "default";
|
|
|
|
$scope.refreshLabelOFF = "danger";
|
2018-08-27 00:32:32 +00:00
|
|
|
} else {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshLabelON = "success";
|
|
|
|
$scope.refreshLabelOFF = "default";
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.autoRefreshInterval = $interval(function() {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshOutput();
|
2018-08-27 00:32:32 +00:00
|
|
|
}, 5000);
|
2017-11-16 05:42:22 +00:00
|
|
|
}
|
2018-08-27 00:32:32 +00:00
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshOutput();
|
2017-11-16 05:42:22 +00:00
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$rootScope.$watch('status.refreshOutput', function(param) {
|
|
|
|
if (param) {
|
|
|
|
$scope.refreshOutput();
|
|
|
|
}
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
registerController('SSLsplit_HistoryController', ['$api', '$scope', '$rootScope', function($api, $scope, $rootScope) {
|
|
|
|
$scope.history = [];
|
|
|
|
$scope.historyOutput = 'Loading...';
|
|
|
|
$scope.historyDate = 'Loading...';
|
|
|
|
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.refreshHistory = (function() {
|
|
|
|
$api.request({
|
|
|
|
module: "SSLsplit",
|
|
|
|
action: "refreshHistory"
|
|
|
|
}, function(response) {
|
|
|
|
$scope.history = response;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.viewHistory = (function(param) {
|
|
|
|
$api.request({
|
|
|
|
module: "SSLsplit",
|
|
|
|
action: "viewHistory",
|
|
|
|
file: param
|
|
|
|
}, function(response) {
|
|
|
|
$scope.historyOutput = response.output;
|
|
|
|
$scope.historyDate = response.date;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.deleteHistory = (function(param) {
|
|
|
|
$api.request({
|
|
|
|
module: "SSLsplit",
|
|
|
|
action: "deleteHistory",
|
|
|
|
file: param
|
|
|
|
}, function(response) {
|
|
|
|
$scope.refreshHistory();
|
|
|
|
})
|
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
|
|
|
$scope.downloadHistory = (function(param) {
|
2018-08-27 00:32:32 +00:00
|
|
|
$api.request({
|
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'downloadHistory',
|
|
|
|
file: param
|
|
|
|
}, function(response) {
|
|
|
|
if (response.error === undefined) {
|
|
|
|
window.location = '/api/?download=' + response.download;
|
|
|
|
}
|
2017-11-16 05:42:22 +00:00
|
|
|
});
|
2018-08-27 00:32:32 +00:00
|
|
|
});
|
2017-11-16 05:42:22 +00:00
|
|
|
|
|
|
|
$scope.refreshHistory();
|
|
|
|
|
|
|
|
$rootScope.$watch('status.refreshHistory', function(param) {
|
2018-08-27 00:32:32 +00:00
|
|
|
if (param) {
|
2017-11-16 05:42:22 +00:00
|
|
|
$scope.refreshHistory();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
registerController('SSLsplit_ConfigurationController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
|
|
|
|
$scope.configurationData = '';
|
|
|
|
$scope.saveConfigurationLabel = "primary";
|
|
|
|
$scope.saveConfiguration = "Save";
|
|
|
|
$scope.saving = false;
|
|
|
|
|
|
|
|
$scope.saveConfigurationData = (function() {
|
|
|
|
$scope.saveConfigurationLabel = "warning";
|
|
|
|
$scope.saveConfiguration = "Saving...";
|
|
|
|
$scope.saving = true;
|
|
|
|
|
|
|
|
$api.request({
|
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'saveConfigurationData',
|
|
|
|
configurationData: $scope.configurationData
|
|
|
|
}, function(response) {
|
2018-08-27 00:32:32 +00:00
|
|
|
$scope.saveConfigurationLabel = "success";
|
|
|
|
$scope.saveConfiguration = "Saved";
|
|
|
|
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.saveConfigurationLabel = "primary";
|
|
|
|
$scope.saveConfiguration = "Save";
|
|
|
|
$scope.saving = false;
|
|
|
|
}, 2000);
|
2017-11-16 05:42:22 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.getConfigurationData = (function() {
|
|
|
|
$api.request({
|
|
|
|
module: 'SSLsplit',
|
|
|
|
action: 'getConfigurationData'
|
|
|
|
}, function(response) {
|
|
|
|
$scope.configurationData = response.configurationData;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.getConfigurationData();
|
|
|
|
}]);
|