modify expire page

This commit is contained in:
Zin Moe
2020-06-18 18:02:02 +06:30
parent b46cefc8bc
commit 02ba0f21e6
5 changed files with 46 additions and 22 deletions

View File

@@ -10,8 +10,7 @@ class RenewLicenseController < ApplicationController
def renew def renew
status, message = current_license.verify_license status, message = current_license.verify_license
render json: {message: message, status: status}
redirect_to expire_url(message: message, status: status)
end end
end end

View File

@@ -170,6 +170,10 @@ class License
else else
delete_license_file delete_license_file
stauts = 0
message = "*** Your license has been expired. ***"
return status, message
end end
rescue SocketError => e rescue SocketError => e

View File

@@ -5,8 +5,12 @@
<% if @license_status == 0 <% if @license_status == 0
text = 'Your license has been expired.' text = 'Your license has been expired.'
elsif @license_status == 2 elsif @license_status == 2
if date_count == 0
text = "Your license will expire in tomorrow."
else
text = "Your license will expire in #{day}." text = "Your license will expire in #{day}."
end end
end
%> %>
<style> <style>
.centered { .centered {
@@ -27,17 +31,9 @@
<div class="card-block"> <div class="card-block">
<h3 class="pt-2 d-inline">Review Your License</h3> <h3 class="pt-2 d-inline">Review Your License</h3>
<%= link_to origami_dashboard_url do %> <%= link_to origami_dashboard_url do %>
<img src="/image/logo.png" style="margin-left: 25pc; width: 150px"> <img src="/image/logo.png" style="margin-left: 25pc; width: 140px">
<% end %>
<% if params[:message].present?
if params[:status].to_i == 1
color = 'text-success'
else
color = 'text-danger'
end
%>
<p class="<%= color %> m-t--30" style="font-weight: bold; font-size: 18px;"><%= params[:message] %></p><br>
<% end %> <% end %>
<p class="m-t--30" id="warning_text" style="font-weight: bold; font-size: 18px;"></p><br>
<% if text %> <% if text %>
<h6 class="mb-2 "><%= text %></h6><br> <h6 class="mb-2 "><%= text %></h6><br>
<% end %> <% end %>
@@ -64,8 +60,10 @@
</div> </div>
<br> <br>
<div class="col-md-12" style="padding-bottom: 20px;"> <div class="col-md-12" style="padding-bottom: 20px;">
<%= link_to 'Review License', renew_url, class: 'btn btn-primary btn-lg float-right m-l-10 m-r-5' %> <button type="button" class="btn btn-primary btn-lg float-right m-l-10 m-r-5" id="review_license">
<%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right' %> Review License
</button>
<%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right', id: 'go_to_home' %>
</div> </div>
</div> </div>
<div class="col-sm-2"></div> <div class="col-sm-2"></div>
@@ -74,9 +72,28 @@
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('.alert-danger, .navbar').hide() $('.alert-danger, .navbar, #warning_text').hide()
$('html, section').css('background-color', '#61B8C9') $('html, section').css('background-color', '#61B8C9')
// $('html').css('overflow-x', 'hidden')
$('section.content').css('margin', '70px 0 0 0') $('section.content').css('margin', '70px 0 0 0')
$('#review_license').on ('click', function() {
$.ajax({
url: '/renew',
type: 'POST',
success: function(res) {
if (res.message.length != 0) {
if (res.status == 1) {
color = 'text-success'
} else if (res.status == 2) {
color = 'text-danger'
} else {
color = 'text-danger'
$('#go_to_home').hide()
}
$('#warning_text').addClass(color).text(res.message).show()
}
}
})
})
}) })
</script> </script>

View File

@@ -6,8 +6,12 @@
<% if license_status == 0 <% if license_status == 0
text = 'Your license has expired.' text = 'Your license has expired.'
elsif license_status == 2 elsif license_status == 2
if date_count == 0
text = "Your license will expire in tomorrow."
else
text = "Your license will expire in #{day}." text = "Your license will expire in #{day}."
end end
end
%> %>
<% if license_status == 0 || license_status == 2 %> <% if license_status == 0 || license_status == 2 %>
<div id="license-alert" class="alert alert-danger fade show text-center" role="alert"> <div id="license-alert" class="alert alert-danger fade show text-center" role="alert">

View File

@@ -30,7 +30,7 @@ scope "(:locale)", locale: /en|mm/ do
get 'dashboard' => 'home#dashboard' get 'dashboard' => 'home#dashboard'
get 'expire' => 'renew_license#expire' get 'expire' => 'renew_license#expire'
get 'renew' => 'renew_license#renew' post 'renew' => 'renew_license#renew'
namespace :induties do namespace :induties do
# resources :assign_in_duties # resources :assign_in_duties