Skip to content

Commit

Permalink
complete the onboarding function
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 25, 2024
1 parent c9392be commit a4b6cbf
Show file tree
Hide file tree
Showing 10 changed files with 606 additions and 149 deletions.
156 changes: 153 additions & 3 deletions baseTemplate/static/baseTemplate/custom-js/system-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/* Utilities */



function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
Expand Down Expand Up @@ -576,8 +575,6 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
};




url = "/base/upgrade";
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);

Expand Down Expand Up @@ -717,3 +714,156 @@ app.controller('designtheme', function ($scope, $http, $timeout) {
});


app.controller('OnboardingCP', function ($scope, $http, $timeout, $window) {

$scope.cyberpanelLoading = true;
$scope.ExecutionStatus = true;
$scope.ReportStatus = true;
$scope.OnboardineDone = true;


function statusFunc() {
$scope.cyberpanelLoading = false;
$scope.ExecutionStatus = false;
var url = "/emailPremium/statusFunc";

var data = {
statusFile: statusFile
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);


function ListInitialData(response) {
if (response.data.status === 1) {
if (response.data.abort === 1) {
$scope.functionProgress = {"width": "100%"};
$scope.functionStatus = response.data.currentStatus;
$scope.cyberpanelLoading = true;
$scope.OnboardineDone = false;
$timeout.cancel();
} else {
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
$scope.functionStatus = response.data.currentStatus;
$timeout(statusFunc, 3000);
}

} else {
$scope.cyberpanelLoading = true;
$scope.functionStatus = response.data.error_message;
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
$timeout.cancel();
}

}

function cantLoadInitialData(response) {
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
$scope.functionStatus = 'Could not connect to server, please refresh this page.';
$timeout.cancel();
}
}

$scope.RunOnboarding = function () {
$scope.cyberpanelLoading = false;
$scope.OnboardineDone = true;

var url = "/base/runonboarding";

var data = {
hostname: $scope.hostname,
rDNSCheck: $scope.rDNSCheck
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};


$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);

function ListInitialData(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
statusFile = response.data.tempStatusPath;
statusFunc();


} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}

}

function cantLoadInitialData(response) {
$scope.cyberpanelLoading = true;

new PNotify({
title: 'Error',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
};

$scope.RestartCyberPanel = function () {
$scope.cyberpanelLoading = false;

var url = "/base/RestartCyberPanel";

var data = {

};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};


$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Success',
text: 'Refresh your browser after 3 seconds to fetch new SSL.',
type: 'success'
});

function ListInitialData(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {

} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}

}

function cantLoadInitialData(response) {
$scope.cyberpanelLoading = true;

new PNotify({
title: 'Error',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
};

});
46 changes: 26 additions & 20 deletions baseTemplate/templates/baseTemplate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -849,22 +849,22 @@
</div><!-- .sidebar-submenu -->
</li>

{# <li id="sidebar-menu-item-containerization">#}
{# <a href="#" title="{% trans 'Containerization' %}">#}
{# <i class="glyph-icon icon-linecons-fire"></i>#}
{# <span>{% trans "Containerization" %}</span>#}
{# <span class="bs-label badge-yellow">{% trans "NEW" %}</span>#}
{# </a>#}
{# <div class="sidebar-submenu">#}
{##}
{# <ul>#}
{# <li><a href="{% url 'cHome' %}"#}
{# title="{% trans 'Create Website Limits' %}"><span>{% trans "Create Limits" %}</span></a>#}
{# </li>#}
{# </ul>#}
{##}
{# </div><!-- .sidebar-submenu -->#}
{# </li>#}
{# <li id="sidebar-menu-item-containerization">#}
{# <a href="#" title="{% trans 'Containerization' %}">#}
{# <i class="glyph-icon icon-linecons-fire"></i>#}
{# <span>{% trans "Containerization" %}</span>#}
{# <span class="bs-label badge-yellow">{% trans "NEW" %}</span>#}
{# </a>#}
{# <div class="sidebar-submenu">#}
{##}
{# <ul>#}
{# <li><a href="{% url 'cHome' %}"#}
{# title="{% trans 'Create Website Limits' %}"><span>{% trans "Create Limits" %}</span></a>#}
{# </li>#}
{# </ul>#}
{##}
{# </div><!-- .sidebar-submenu -->#}
{# </li>#}

<li id="sidebar-menu-item-docker">
<a href="#" title="{% trans 'Docker' %}">
Expand Down Expand Up @@ -1120,7 +1120,13 @@
<div id="page-content-wrapper">
<div id="page-content">


{% if onboarding == 0 %}
<div ng-hide="success" class="alert alert-info">
<p>{{ onboardingError | safe }}</p>
</div>
{% elif onboarding == 3 %}
<p>Looks like something is wrong with your initial setup, please double check on <a href="/base/onboarding">Setup Wizard.</a> </p>
{% endif %}
{% block content %}
{% endblock %}

Expand Down Expand Up @@ -1156,9 +1162,9 @@
<script src="{% static 'containerization/containerization.js' %}?ver={{ version }}"></script>
<script src="{% static 'CLManager/CLManager.js' %}?ver={{ version }}"></script>
<script src="{% static 'IncBackups/IncBackups.js' %}?ver={{ version }}"></script>
<script src="{% static 'WebTerminal/term.js' %}?ver={{ version }}"></script>
<script src="{% static 'WebTerminal/ws.js' %}?ver={{ version }}"></script>
<script src="{% static 'WebTerminal/main.js' %}?ver={{ version }}"></script>
{# <script src="{% static 'WebTerminal/term.js' %}?ver={{ version }}"></script>#}
{# <script src="{% static 'WebTerminal/ws.js' %}?ver={{ version }}"></script>#}
{# <script src="{% static 'WebTerminal/main.js' %}?ver={{ version }}"></script>#}

{% endwith %}

Expand Down
115 changes: 115 additions & 0 deletions baseTemplate/templates/baseTemplate/onboarding.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Configure Hostname and other default Settings - CyberPanel" %}{% endblock %}
{% block content %}

{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->


<div class="container">
<div id="page-title">
<h2>{% trans "Initial Configurations" %}- <a target="_blank" href="https://go.cyberpanel.net/setup-wizard"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Learn More" %}</span></a></h2>
<p>{% trans "Configure Hostname and other default Settings for CyberPanel" %}</p>
</div>

<div ng-controller="OnboardingCP" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Initial Configurations" %} <img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">

<form action="/" class="form-horizontal bordered-row panel-body">
<div ng-hide="success" class="alert alert-info">
<ul>
<li><strong>Choose this wisely, if you are not going to use email service on this server, skip rDNS checks.</strong> Ensure that the hostname you provide below is set as rDNS (reverse DNS, also called PTR record) against your
IP address. (Only required if you want to use email services on the same server)
</li>
<li>Make sure that the provided hostname also has an A record pointing to your server's
IP address.
</li>
<li>If the above conditions fail, your server may not function as expected, especially
for email services.
</li>
</ul>

</div>

<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Hostname" %}</label>
<div class="col-sm-6">
<input name="dom" type="text" class="form-control"
ng-model="hostname" required>
</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="rDNSCheck" type="checkbox" value="">
Skip rDNS/PTR Check (If you don't want to use email service on this server)
</label>
</div>
</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="RunOnboarding()"
class="btn btn-primary btn-lg btn-block">{% trans "Start Configurations" %}</button>

</div>
</div>


<div ng-hide="OnboardineDone" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="RestartCyberPanel()"
class="btn btn-primary btn-lg btn-block">{% trans "Restart CyberPanel" %}</button>

</div>
</div>




</form>


</div>

<div ng-hide="ExecutionStatus" class="row">
<div class="col-md-12">
<div class="form-group">
<p>Note: once configurations are completed, click Restart CyberPanel above, after clicking Restart CyberPanel refresh page to fetch new SSL from the browser.</p>
<h4 style="margin-top: 2%; margin-bottom: 2%"> {$ functionStatus $} <img
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
</h4>
<div class="progress">
<div ng-style="functionProgress"
class="progress-bar progress-bar-striped bg-info"
role="progressbar"
aria-valuenow="50" aria-valuemin="0"
aria-valuemax="100"></div>
</div>
</div>
</div>
</div> <!-- end row -->
</div>
</div>


</div>


{% endblock %}
3 changes: 3 additions & 0 deletions baseTemplate/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
url(r'^getthemedata', views.getthemedata, name='getthemedata'),

url(r'^upgrade',views.upgrade, name='upgrade'),
url(r'^onboarding$', views.onboarding, name='onboarding'),
url(r'^RestartCyberPanel$', views.RestartCyberPanel, name='RestartCyberPanel'),
url(r'^runonboarding', views.runonboarding, name='runonboarding'),

url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
Expand Down
Loading

0 comments on commit a4b6cbf

Please sign in to comment.