Commit 7f82c313 authored by Cool Fire's avatar Cool Fire

Webinterface request processing + interface styling

parent f5da59a1
......@@ -43,9 +43,12 @@ class ApiController < ApplicationController
@jobr.email = params[:email]
@jobr.save
# Send notifivation to admin there is a pending job
# Send notification to admin there is a pending job
JobwaitingMailer.jobwaiting(@jobr).deliver
# Send notification to user that the job is received and pending approval
JobwaitingMailer.jobpending(@jobr).deliver
@result = "Job is pending approval"
end
end
......
......@@ -35,7 +35,7 @@ class JobsController < ApplicationController
end
@servers = Server.all
@commands = Command.all
@commands = Command.order('name ASC').all
end
def create
......
......@@ -29,6 +29,12 @@ class ServersController < ApplicationController
rescue => e
@jobcount = 0
end
begin
@jobrequestcount = @server.jobrequests.size
rescue => e
@jobrequstcount = 0
end
end
......
......@@ -3,7 +3,13 @@ class JobwaitingMailer < ActionMailer::Base
def jobwaiting(jobrequest)
@jobrequest = jobrequest
mail :to => @jobrequest.email, :subject => "New pending job for #{@jobrequest.user}"
mail :to => 'coolfire@insomnia247.nl', :subject => "New pending job for #{@jobrequest.user}"
end
def jobpending(jobrequest)
@jobrequest = jobrequest
job = Command.find(jobrequest.command_id)
mail :to => @jobrequest.email, :subject => "#{@job.name} pending"
end
def jobdisapproved(jobrequest, reason)
......
......@@ -3,7 +3,7 @@
</div>
<div class='form'>
<table>
<%= form_for :disapprove_reason, url: jobrequest_disapprove_path do |f| %>
<%= form_for :disapprove_reason, url: jobrequest_disapprove_post_path do |f| %>
<tr>
<td>
<%= f.label :reason, 'Reason for disapproval' %>
......
......@@ -3,7 +3,7 @@
</div>
<div class='list'>
<table>
<tr class='listtiles'>
<tr class='listtitle'>
<td>Job ID</td>
<td>User</td>
<td>E-mail</td>
......
......@@ -44,8 +44,8 @@
<td><%= showtime(@job.timestampcompleted) %></td>
</tr>
<tr>
<td><%= link_to 'Approve', jobrequest_approve_path, :method => :post %></td>
<td><%= link_to 'Disapprove', jobrequest_disapprove_path, :method => :post %></td>
<td><%= link_to 'Approve', jobrequest_approve_path %></td>
<td><%= link_to 'Disapprove', jobrequest_disapprove_path %></td>
</tr>
</table>
</div>
\ No newline at end of file
......@@ -3,7 +3,7 @@
</div>
<div class='list'>
<table>
<tr class='listtiles'>
<tr class='listtitle'>
<td>Job ID</td>
<td>Started</td>
<td>Finished</td>
......
<!DOCTYPE html>
<html>
<head>
<meta content='text/html, charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<p>
Request has been disapproved:
</p>
<p>
<%= @reason %>
</p>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta content='text/html, charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<p>
Your request has been received and is pending approval by our staff.
</p>
</body>
</html>
\ No newline at end of file
......@@ -2,8 +2,7 @@
<html>
<head>
<title>Frontend</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= stylesheet_link_tag 'main', media: 'all' %>
<%= csrf_meta_tags %>
</head>
<body>
......@@ -23,7 +22,28 @@
</div>
<% end %>
<%= yield %>
<% content_for :global_menu do %>
<div class
<% end %>
<div id='menu'>
<div id='global_menu'>
<ul>
<li><%= link_to 'Jobs', jobs_path %></li>
<li><%= link_to 'Job requests', jobrequests_path %></li>
<li><%= link_to 'Commands', commands_path %></li>
<li><%= link_to 'Servers', servers_path %></li>
</ul>
<ul>
<li><%= link_to 'Lydia', Server.find(1) %></li>
<li><%= link_to 'New job', new_job_path %></li>
</ul>
</div>
</div>
<div id='content'>
<%= yield %>
</div>
</body>
</html>
<div class='pagetitle'>
Server: <%= @server.shortname %>
</div>
<div class='serverdesc'>
<table>
<tr>
<td>Name</td>
<td><%= @server.shortname %></td>
</tr>
<tr>
<td>FQDN</td>
<td><%= @server.longname %></td>
</tr>
<tr>
<td>Local IP</td>
<td><%= @server.localip %></td>
</tr>
<tr>
<td>WAN IP</td>
<td><%= @server.wanip %></td>
</tr>
<tr>
<td>Description</td>
<td><%= @server.description %></td>
</tr>
</table>
</div>
<div class='newserverjob'>
<%= link_to 'New job', new_job_path(:server_id => @server.id) %>
</div>
<div class='servertaskspending'>
<% if @jobrequestcount > 0 %>
<div class='list'>
<table>
<% printheader = true %>
<% @server.jobrequests.reverse.each do |job| %>
<% if job.state == 2 %>
<% if printheader %>
<tr class='listtitle'>
<td>Job ID</td>
<td>User</td>
<td>E-mail</td>
<td>Requested</td>
<td>Processed</td>
<td>Server</td>
<td>Command</td>
<td>Arguments</td>
<td>Status</td>
</tr>
<% printheader = false %>
<% end %>
<tr class='jobstatus<%= job.state %>'>
<td><%= job.id %></td>
<td><%= job.user %></td>
<td><%= job.email %></td>
<td><%= showtime(job.timestampstarted) %></td>
<td><%= showtime(job.timestampcompleted) %></td>
<td><%= link_to job.server.shortname, server_path(job.server) %></td>
<td><%= link_to job.command.name, jobrequest_path(job) %></td>
<td><%= job.args %></td>
<td><%= job.result %></td>
</tr>
<% end %>
<% end %>
</table>
</div>
<% else %>
No job requests on this server.
<% end %>
</div>
<div class='servertasks'>
<% if @jobcount > 0 %>
<div class='list'>
<table>
<tr class='listtitles'>
<tr class='listtitle'>
<td>Job ID</td>
<td>Started</td>
<td>Finished</td>
......@@ -31,28 +99,4 @@
<% else %>
No jobs on this server.
<% end %>
</div>
<div class='serverdesc'>
<table>
<tr>
<td>Name</td>
<td><%= @server.shortname %></td>
</tr>
<tr>
<td>FQDN</td>
<td><%= @server.longname %></td>
</tr>
<tr>
<td>Local IP</td>
<td><%= @server.localip %></td>
</tr>
<tr>
<td>WAN IP</td>
<td><%= @server.wanip %></td>
</tr>
<tr>
<td>Description</td>
<td><%= @server.description %></td>
</tr>
</table>
</div>
\ No newline at end of file
......@@ -12,8 +12,9 @@ Rails.application.routes.draw do
get '/logout' => 'login#logout'
post '/jobrequests/:id/approve', to: 'jobrequests#approve', as: 'jobrequest_approve'
post '/jobrequests/:id/disapprove', to: 'jobrequests#disapprove', as: 'jobrequest_disapprove'
get '/jobrequests/:id/approve', to: 'jobrequests#approve', as: 'jobrequest_approve'
get '/jobrequests/:id/disapprove', to: 'jobrequests#disapprove', as: 'jobrequest_disapprove'
post '/jobrequests/:id/disapprove', to: 'jobrequests#disapprove', as: 'jobrequest_disapprove_post'
resources :commands, :servers, :jobs, :jobrequests
......
*{
-moz-box-sizing : border-box;
-webkit-box-sizing: border-box;
-o-box-sizing : border-box;
box-sizing : border-box;
margin : 0px;
padding : 0px;
}
header, section, footer, aside, nav, article, hgroup{
display: block;
}
body{
font-family: Verdana,Arial,sans-serif;
font-size : 14px;
}
#content{
float: right;
width: 90%;
}
.pagetitle{
font-size : 150%;
font-weight: bold;
}
.list table{
border-collapse: collapse;
width : 100%;
}
.list tr.jobstatus0{
background: #CCFF99;
}
.list tr.jobstatus1{
background: #FFADAD;
}
.list tr.jobstatus2{
background: #FFFFCC;
}
.list tr:hover{
opacity: 0.7;
}
.list td{
padding-left: 5px;
}
.listtitle{
font-weight: bold;
}
#menu{
position :fixed;
float : left;
width : 10%;
height : 100%;
background: #0066FF;
}
#menu ul{
padding-top: 20px;
}
#menu a{
display : block;
padding-bottom : 10px;
padding-top : 10px;
padding-left : 10px;
text-decoration: none;
color : #FFF;
}
#menu a:hover{
background: #0099FF;
}
.error{
width : 100%;
float : left;
text-align: center;
background: #FF5050;
}
.waring{
width : 100%;
float : left;
text-align: center;
background: #FF8533;
}
.notice{
width : 100%;
float : left;
text-align: center;
background: #CCFF99;
}
.serverdesc td{
padding-right: 15px;
}
.serverdesc table{
padding-top : 15px;
padding-bottom: 15px;
}
.servertasks table{
margin-top: 20px;
}
.servertaskspending table{
margin-top: 20px;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment