Commit 3c865f3d authored by MAUPETIT Charly's avatar MAUPETIT Charly
Browse files

Merge branch 'admin'

parents a361fd19 4cd27fa3
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs "Admin Details" do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end
......@@ -27,4 +27,4 @@ ActiveAdmin.register Job do
# end
end
end
\ No newline at end of file
......@@ -17,4 +17,4 @@ ActiveAdmin.register User do
#
# or
#
end
end
\ No newline at end of file
......@@ -31,4 +31,4 @@ ActiveAdmin.register Webapp do
# end
end
end
\ No newline at end of file
......@@ -3,4 +3,16 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def authenticate_admin!
unless current_user.nil?
if current_user.admin?
return true
else
redirect_to(root_path)
end
else
redirect_to(root_path)
end
end
end
......@@ -150,6 +150,9 @@ class NodesController < ApplicationController
end
def verify_is_admin
current_user.nil? ? redirect_to(root_path) : redirect_to(root_path) unless current_user.admin?
unless current_user.admin?
redirect_to(root_path)
end
return true
end
end
# -*- encoding : utf-8 -*-
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
......
<div class="container">
<h2>Resend confirmation instructions:</h2>
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email, class: "control-label col-md-3 lead" %>
<div class="col-md-4"><%= f.email_field :email, class: "form-control", autofocus: true %></div>
</div>
<div>
<%= f.label :email, class: "control-label col-md-3" %>
<div class="col-md-4"><%= f.email_field :email, class: "form-control", autofocus: true %></div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-3">
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
Resend confirmation instructions
Resend instructions
<% end %>
</div>
</div>
......
......@@ -5,7 +5,7 @@
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email, class: "control-label col-md-3 lead" %>
<%= f.label :email, class: "control-label col-md-3" %>
<div class="col-md-4"><%= f.email_field :email, class: "form-control", autofocus: true %></div>
</div>
<div>
......
<%= render 'users/menu' %>
<h1 class="brand">Edit your account</h1>
<br />
<div class="container">
<h3>Update my account</h3>
<br />
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal'}) do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal'}) do |f| %>
<%= devise_error_messages! %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="form-group">
<%= f.label :email, class: "lead control-label col-xs-3" %>
<div class="col-xs-4"><%= f.email_field :email, autofocus: true, class: "form-control" %></div>
<%= f.label :email, class: "control-label col-sm-3" %>
<div class="col-sm-5"><%= f.email_field :email, autofocus: true, class: "form-control" %></div>
</div>
<div class="form-group">
<%= f.label :password , class: "lead control-label col-xs-3" %>
<div class="col-xs-4"><%= f.password_field :password, class: "form-control" %></div>
<span class="help-block">(leave blank if you don't want to change it)</span>
<%= f.label :password , class: "control-label col-sm-3" %>
<div class="col-sm-5"><%= f.password_field :password, class: "form-control" %></div>
<span class="help-block">Leave blank if you don't want to change it</span>
</div>
<div class="form-group">
<%= f.label :password_confirmation , class: "lead control-label col-xs-3" %>
<div class="col-xs-4"><%= f.password_field :password_confirmation, class: "form-control" %></div>
<%= f.label :password_confirmation , class: "control-label col-sm-3" %>
<div class="col-sm-5"><%= f.password_field :password_confirmation, class: "form-control" %></div>
</div>
<div class="form-group">
<%= f.label t('public_ssh_key') , class: "lead control-label col-xs-3" %>
<div class="col-xs-6"><%= f.text_area :sshkey, rows: 9 , class: "form-control" %></div>
<label class="control-label col-sm-3">SSH key</label>
<div class="col-sm-5"><%= f.text_area :sshkey, rows: 9 , class: "form-control" %></div>
<span class="help-block">Must begin by 'ssh-rsa', mandatory for app providers</span>
</div>
<div class="form-group">
<%= f.label :current_password , class: "lead control-label col-xs-3" %>
<div class="col-xs-4"><%= f.password_field :current_password, class: "form-control" %></div>
<span class="help-block">(we need your current password to confirm your changes)</span>
<%= f.label :current_password , class: "control-label col-sm-3" %>
<div class="col-sm-5"><%= f.password_field :current_password, class: "form-control" %></div>
<span class="help-block">Mandatory to confirm your changes</span>
</div>
<div class="form-group">
<div class="col-xs-1"></div>
<div class="lead col-xs-4">
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
Update
<% end %>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<%= f.submit 'Update', class: 'btn btn-primary' %>
</div>
<% end %>
\ No newline at end of file
</div>
<% end %>
</div>
\ No newline at end of file
<div class="container">
<h2>Create your account:</h2>
<h2>Create your account</h2>
<div class="row">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-horizontal'}) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email, class: "control-label col-md-3 lead" %>
<%= f.label :email, class: "control-label col-md-3" %>
<div class="col-md-4"><%= f.email_field :email, class: "form-control", autofocus: true %></div>
</div>
<div class="form-group">
<%= f.label :password, class: "control-label col-md-3 lead" %>
<%= f.label :password, class: "control-label col-md-3" %>
<div class="col-md-4"><%= f.password_field :password, class: "form-control" %></div>
</div>
<div class="form-group">
<%= f.label :password_confirmation, class: "control-label col-md-3 lead" %>
<%= f.label :password_confirmation, class: "control-label col-md-3" %>
<div class="col-md-4"><%= f.password_field :password_confirmation, class: "form-control" %></div>
</div>
......
<div class="container">
<h2>Log in:</h2>
<h2>Log in</h2>
<div class="row">
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: 'form-horizontal'}) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email, class: "control-label col-md-3 lead" %>
<div class="col-md-4"><%= f.email_field :email, class: "form-control", autofocus: true %></div>
<%= f.label :email, class: "control-label col-md-3" %>
<div class="col-md-4">
<%= f.email_field :email, class: "form-control", autofocus: true %>
</div>
</div>
<div class="form-group">
<%= f.label :password, class: "control-label col-md-3 lead" %>
<div class="col-md-4"><%= f.password_field :password, class: "form-control" %></div>
<%= f.label :password, class: "control-label col-md-3" %>
<div class="col-md-4">
<%= f.password_field :password, class: "form-control" %>
</div>
</div>
<% if devise_mapping.rememberable? -%>
<div class="form-group">
<%= f.label :remember_me, class: "control-label col-md-3 lead" %>
<div class="col-md-1"><%= f.check_box :remember_me, class: "form-control" %></div>
<%= f.label :remember_me, class: "control-label col-md-3" %>
<div class="col-md-4">
<%= f.check_box :remember_me, html_options = {style: "margin-top: 12px;"} %>
</div>
</div>
<% end %>
......
......@@ -19,7 +19,7 @@
<%= link_to "Get started".html_safe, webapps_path, class: "btn btn-lg btn-success" %>
<br />
<br />
<p class="lead text-muted">
<p class="text-muted">
Currently in Beta
</p>
</div>
......
......@@ -23,6 +23,7 @@
<ul class="dropdown-menu" role="menu">
<li>
<%= link_to 'Nodes', nodes_path %>
<%= link_to 'Database', db_path %>
</li>
</ul>
</li>
......@@ -40,7 +41,7 @@
<a data-toggle="dropdown" role="button" aria-expanded="false"><i class="glyphicon glyphicon-menu-down"></i></a>
<ul class="dropdown-menu" role="menu" id="user-options">
<li>
<%= link_to 'Preferences', edit_user_registration_path %>
<%= link_to 'My account', edit_user_registration_path %>
</li>
<li>
<%= link_to 'My apps', show_apps_user_path %>
......@@ -49,7 +50,7 @@
<%= link_to 'My jobs', show_jobs_user_path %>
</li>
<li>
<%= link_to 'Quotas for apps', quotas_path %>
<%= link_to 'Quotas of my apps', quotas_path %>
</li>
<li>
<%= link_to 'Logout', destroy_user_session_path, method: "delete" %>
......@@ -65,6 +66,7 @@
<%= f.password_field :password, class: "form-control", placeholder: "Password" %>
<%= f.submit "Login", class: "btn btn-success btn-block" %>
<% end %>
<span style="padding-left: 27px;"><%= link_to 'Forgot your password?', '/users/password/new' %></span>
</ul>
</li>
<li>
......
<!-- vue listant tous les quotas de l'utilisateur-->
<%= render 'users/menu' %>
<h2> <%= t('your_quotas') %> : </h2>
<br /><br /><br />
<% @quotas.each do |q| %>
<div class="container">
<div class="row">
<div class="col-md-2">
<% cal = (100*q.quantity/q.webapp.default_quota) %> <!-- TODO changer la méthode de calcul -->
<strong class="lead"><%= link_to q.webapp.name.capitalize, q.webapp %></strong>
</div>
<div class="col-md-3">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="<%= cal %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= cal %>%" >
<%= q.quantity.to_s(:human_size) %> left
</div>
<div class="container">
<h2>My quotas</h2>
<br />
<% @quotas.each do |q| %>
<div class="container">
<div class="row">
<div class="col-md-2">
<% cal = (100*q.quantity/q.webapp.default_quota) %> <!-- TODO changer la méthode de calcul -->
<strong class="lead"><%= link_to q.webapp.name.capitalize, q.webapp %></strong>
</div>
<div class="col-md-3">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="<%= cal %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= cal %>%" >
<%= q.quantity.to_s(:human_size) %> left
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
......@@ -2,9 +2,10 @@
<ul class="nav nav-tabs">
<li role="presentation" class="tab" id ="myapps"><%= link_to "My apps", show_apps_user_path %></li>
<li role="presentation" class="tab" id ="jobs"><%= link_to "My jobs",show_jobs_user_path %></li>
<li role="presentation" class="tab" id ="quotas"><%= link_to "Quotas for apps", quotas_path %></li>
<li role="presentation" class="tab" id ="edit"><%= link_to "Personnal informations", edit_user_registration_path %></li>
<li role="presentation" class="tab" id ="quotas"><%= link_to "Quotas of my apps", quotas_path %></li>
<li role="presentation" class="tab" id ="edit"><%= link_to "My account", edit_user_registration_path %></li>
</ul>
</div>
<br />
<script>
......
<%= render 'users/menu' %>
<h3> Manage your apps </h3>
<div class="container">
<h3> Manage your apps </h3>
<% if @webapps_inprod.length != 0 %>
<h2 class="allgo-text">Installed apps : </h2>
<% @webapps_inprod.each do |w| %>
<%= link_to "Edit : #{w.name}".html_safe, edit_webapp_path(w) %><br />
<% end %>
<% end %>
<br />
<% if @webapps_inprod.length != 0 %>
<% @webapps_inprod.each do |w| %>
<%= link_to "Edit : #{w.name}".html_safe, edit_webapp_path(w) %><br />
<% end %>
<% end %>
<br />
<% if @webapp_waiting %>
<% w = @webapp_waiting %>
<div class="panel panel-info ">
<div class="panel-heading">
<h2 class="panel-title brand-ns">App waiting to be completed : <%= link_to w.name.capitalize, w %></h2>
</div>
<div class="panel-body">
<div class="row">
<%= image_tag w.logo.url(:thumb), class: "pull-right" %>
<div class="col-xs-8 col-md-10" style="border-right: 1px;">
<div id="app_status"> <!-- where the ajax data will be load -->
<p class="lead">
Note, you will need to provide an executable program name " <strong><%= w.entrypoint %></strong> "<br />
that A||go will call to run a job.<br /></p>
<% if w.ipadress.blank? && w.status == 0 %>
<p class="lead" id="is_waiting"> We're sorry, your machine is still in preparation, it'll be ready soon. <br /><br />
<u>During this time, </u></p>
<% elsif w.status == 0 %>
<%= render partial: 'app_connection', locals: {:@webapp => w} %> <!-- no partial, no parameters can be pass" -->
<% elsif w.status == 1 %> <!-- moderation, app is commited in docker, but ssh container still running -->
<%= render partial:'app_moderation', locals: {:w => w} %>
<% end %>
</div>
</div>
</div>
<br />
<div class="row col-xs-8" style="border-right: 1px;">
<p class="lead"><u> You can also provide more informations about your app : </u></p>
<%= render 'webapps/form_second' %>
<!-- TODO : Or you can follow our convention,
Create your app in /home/name_app/app/
Add Readme in /home/name_app/app/
Add input demo files in /home/name_app/demo/input
Add output demo files in input in /home/name_app/demo/output
<!-- add readme demo input file output file demo files dans public/app/demo/input -->
</div>
</div>
</div>
<script>
if ($('#is_waiting').length) {
setTimeout(function() {
//we load view users/_app_connection
$.get( "ajax/user_container_connection?webapp_id="+<%= @webapp_waiting ? @webapp_waiting.id : ''%>, function( data ) {
$("#app_status").hide().html(data).fadeIn();
});
}, 20000);
};
$('a[data-remote]').bind('ajax:complete', function(evt, xhr, status){
$('#app_status').hide().html(xhr.responseText).fadeIn();
});
</script>
<% if @webapp_waiting %>
<% w = @webapp_waiting %>
<div class="panel panel-info ">
<div class="panel-heading">
<h2 class="panel-title brand-ns">App waiting to be completed : <%= link_to w.name.capitalize, w %></h2>
</div>
<div class="panel-body">
<div class="row">
<%= image_tag w.logo.url(:thumb), class: "pull-right" %>
<div class="col-xs-8 col-md-10" style="border-right: 1px;">
<div id="app_status"> <!-- where the ajax data will be load -->
<p class="lead">
Note, you will need to provide an executable program name " <strong><%= w.entrypoint %></strong> "<br />
that A||go will call to run a job.<br /></p>
<% if w.ipadress.blank? && w.status == 0 %>
<p class="lead" id="is_waiting"> We're sorry, your machine is still in preparation, it'll be ready soon. <br /><br />
<u>During this time, </u></p>
<% elsif w.status == 0 %>
<%= render partial: 'app_connection', locals: {:@webapp => w} %> <!-- no partial, no parameters can be pass" -->
<% elsif w.status == 1 %> <!-- moderation, app is commited in docker, but ssh container still running -->
<%= render partial:'app_moderation', locals: {:w => w} %>
<% end %>
</div>
</div>
</div>
<br />
<div class="row col-xs-8" style="border-right: 1px;">
<p class="lead"><u> You can also provide more informations about your app : </u></p>
<%= render 'webapps/form_second' %>
<!-- TODO : Or you can follow our convention,
Create your app in /home/name_app/app/
Add Readme in /home/name_app/app/
Add input demo files in /home/name_app/demo/input
Add output demo files in input in /home/name_app/demo/output
<!-- add readme demo input file output file demo files dans public/app/demo/input -->
</div>
</div>
</div>
</div>
<% else %> <!-- no app in waiting -->
<p class="lead"> No app waiting, come here to add one : <%= link_to 'Add my app'.html_safe, new_webapp_path %> </p>
<% end %>
<%= render 'users/users_footer' %>
\ No newline at end of file
<script>
if ($('#is_waiting').length) {
setTimeout(function() {
//we load view users/_app_connection
$.get( "ajax/user_container_connection?webapp_id="+<%= @webapp_waiting ? @webapp_waiting.id : ''%>, function( data ) {
$("#app_status").hide().html(data).fadeIn();
});
}, 20000);
};
$('a[data-remote]').bind('ajax:complete', function(evt, xhr, status){
$('#app_status').hide().html(xhr.responseText).fadeIn();
});
</script>
<% else %> <!-- no app in waiting -->
<p class="lead"> No app waiting, come here to add one : <%= link_to 'Add my app'.html_safe, new_webapp_path %> </p>
<% end %>
<%= render 'users/users_footer' %>
\ No newline at end of file
<h1>Editing webapp : <%= link_to @webapp.name, @webapp %></h1>
<div class="container">
<h1>Editing webapp : <%= link_to @webapp.name, @webapp %></h1>
<ul class="nav nav-pills" id="edit_webapp_menu">
<li role="presentation" class="tab"><a href="edit_basic">Basic informations </a></li>
<li role="presentation" class="tab" ><a href="edit_advance">Advance informations </a></li>
<li role="presentation" class="tab" ><a href="edit_container">Launch the SSH access </a></li>
</ul>
<ul class="nav nav-pills" id="edit_webapp_menu">
<li role="presentation" class="tab"><a href="edit_basic">Basic informations </a></li>
<li role="presentation" class="tab" ><a href="edit_advance">Advance informations </a></li>
<li role="presentation" class="tab" ><a href="edit_container">Launch the SSH access </a></li>
</ul>
<div class="edit_webapp" id="edit_basic">
<%= render 'form' %>
</div><!-- I don't find the open div in 'form', so have to close it twice or the other div are include in this one-->
<div class="edit_webapp" id="edit_basic">
<%= render 'form' %>
</div><!-- I don't find the open div in 'form', so have to close it twice or the other div are include in this one-->
<div class="edit_webapp col-lg-5" id="edit_advance" style="display:none; margin-left:30%;">
<%= render 'form_second' %>
</div>
<div class="edit_webapp col-lg-5" id="edit_advance" style="display:none; margin-left:30%;">
<%= render 'form_second' %>
</div>
<div class="edit_webapp col-lg-5" id="edit_container" style="display:none; margin-left:30%;">
<% if @webapp.ipadress? %>
<%= render 'edit_container_informations' %>
<% else %>
<!-- link to launch ssh container with ajax -->
<p class="lead">Edit your app code :
<%= link_to 'Launch SSH access',
{ controller: :webapps, action: :container_edit_open, remote: true },
html_options = { class: 'btn btn-success'}
%>
</p>
<% end %>
<div class="edit_webapp col-lg-5" id="edit_container" style="display:none; margin-left:30%;">
<% if @webapp.ipadress? %>
<%= render 'edit_container_informations' %>
<% else %>
<!-- link to launch ssh container with ajax -->
<p class="lead">Edit your app code :
<%= link_to 'Launch SSH access',
{ controller: :webapps, action: :container_edit_open, remote: true },
html_options = { class: 'btn btn-success'}
%>
</p>
<% end %>
</div>
</div>
<script>
......
<div class="container">
<p id="notice"><%= notice %></p>
<p id="notice"><%= notice %></p>
<h2>Add your App</h2>
<p class="lead help-block">Note that we will provide you a way to acceed to your own machine to store your app through SSH protocol. <br />
At the same time, we will provide you a link to confirm when you'll have finish, and your app is ready to use, so we can store it. <br />
......
......@@ -5,7 +5,6 @@ ActiveAdmin.setup do |config|
# for each of the active admin pages.
#
config.site_title = "Allgo"
config.default_namespace = :db
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
......@@ -34,7 +33,7 @@ ActiveAdmin.setup do |config|
# config.default_namespace = false
#
# Default:
# config.default_namespace = :admin
config.default_namespace = :admin_db_path
#
# You can customize the settings for each namespace by using
# a namespace block. For example, to change the site title
......@@ -55,7 +54,7 @@ ActiveAdmin.setup do |config|
#
# This setting changes the method which Active Admin calls
# within the application controller.
config.authentication_method = :authenticate_admin_user!
config.authentication_method = :authenticate_admin!
# == User Authorization
#
......@@ -87,7 +86,7 @@ ActiveAdmin.setup do |config|
#
# This setting changes the method which Active Admin calls
# (within the application controller) to return the currently logged in user.
config.current_user_method = :current_admin_user
# config.current_user_method = :current_admin_user
# == Logging Out
#
......
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