Skip to content
Snippets Groups Projects
Commit b4b0a077 authored by Escalante Martinez, Marisa's avatar Escalante Martinez, Marisa
Browse files

Adds ACSmI discovery and contracting

parent f43d509a
No related branches found
No related tags found
No related merge requests found
Showing
with 441 additions and 0 deletions
.contracts-content
.show
.row
.col-md-2
%label Resource ID
.col-md-6
= @contract.resource_id
.row
.col-md-2
%label Resource Name
.col-md-6
= @contract.resource_name
.delimiter
- if @contract.sessions.any?
%h4 Sessions
%table.table
%thead
%tr
%th ID
%th Created At
%th Updated At
%th State
%tbody
- @contract.sessions.each do |session|
%tr
%td= session.id
%td= session.created_at
%td= session.updated_at
%td= session.aasm_state
- else
%h4.no-records This contract does not have any sessions
= link_to 'Back', contracts_url, class: 'btn btn-default'
= link_to 'Delete', contract_url(@contract), method: :delete, class: 'btn btn-danger', data: { confirm: 'Are you sure?' }
\ No newline at end of file
.api_info
%h3
List of supported API calls
%table.table-hover.table-bordered
%tr
%th
Functionality
%th
Endpoint
%th
Method
%th
Request Parameters
%th
Response Parameters
%tr
%td
Initiate a new contracting session
%td
= "/decide/acsmi/contracting/api/v1/sessions"
%td
POST
%td
%ul
%li
resource_id: 'id_of_the_resource_from_acsmi_catalogue'
%td
%ul
%li
session_id: 'id_of_the_started_session'
%li
contracting_url: 'URL where the user is to be redirected to'
%tr
%td
Get the cloud connect credentials for the session
%td
= "/decide/acsmi/contracting/api/v1/sessions/{session_id}/credentials"
%td
GET
%td
%ul
%li
session_id: 'id_of_the_session_from_the_step_above'
%td
%ul
%li
session_id: 'id_of_the_requested_session'
%li
contracting_type: 'platform | own_credentials'
%li
platform_credentials['email']: 'email_to_access_the_platform'
%li
platform_credentials['password']: 'password_to_access_the_platform'
%li
resource_credentials['name']: 'name_of_the_parameter' (e.g. Access Key, Secret Key)
%li
resource_credentials['value']: 'value_of_the_parameter'
\ No newline at end of file
.license_info
= @license_text
\ No newline at end of file
.terms-info
%h2 Terms
Terms pending.
\ No newline at end of file
<footer class="footer">
<div class="footer-container-wrapper">
<div class="container footer-container">
<div>
<p class="footer-text">Prototype. © Copyright 2017, CloudBroker GmbH. </p>
</div>
<div>
<p class="footer-text">
<a href="https://www.decide-h2020.eu/" target="_blank">
This project has received funding from the European Union's Horizon 2020 research and innovation programme
under grant agreement No 731533
<img src="/flag_eu.jpg" class="footer-flag"/>
</a>
</p>
</div>
</div>
</div>
</footer>
\ No newline at end of file
<nav class="navbar navbar-default top-header">
<div class="container">
<div class="navbar-header">
<img src="https://decide-prototype.cloudbroker.com/images/decide_logo.png" class="header-logo">
</div>
<div class="navbar-header">
<a class="navbar-brand" href="/">
DECIDE - ACSmI Contracting
</a>
</div>
<ul class="nav navbar-nav navbar-right">
<% if current_user %>
<li class="disabled"><a>Logged in as: <%= current_user.full_name %></a></li>
<li><%= link_to 'Manage Contracts', contracts_url %></li>
<% end %>
<li><%= link_to 'License', '/license' %></li>
<li><%= link_to 'API', '/api_info' %></li>
<li>
<% if current_user %>
<%= link_to sign_out_url, method: :delete do %>
<span class="glyphicon glyphicon-log-out"></span> Logout
<% end %>
<% else %>
<%= link_to sign_in_url do %>
<span class="glyphicon glyphicon-log-in"></span> Login
<% end %>
<% end %>
</li>
</ul>
</div>
</nav>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>ACSmI Contracting4</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>
<%= render partial: 'layouts/header' %>
<% if alert %>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<%= alert %>
</div>
<% end %>
<div class="site-content">
<%= yield %>
</div>
<%= render partial: 'layouts/footer' %>
</body>
</html>
json.contract_exists @contract_exists
\ No newline at end of file
.contract-ready-container
.contract-ready-body
.contract-ready-ok
%span.glyphicon.glyphicon-ok-circle
%h3
Success!
.contract-ready-message
.alert.alert-success
Your contracting details are now set.
%br
You can now
%a.alert-link{href: '/'}
return back to ADAPT
and continue with your setup.
\ No newline at end of file
= form_tag own_creds_or_contract_session_path(@session) do
.form-container
%h3.form-header= "Contracting for #{@session.resource_name}"
%h4.form-prompt Please select an option you would like to proceed with:
.form-group
%label
= radio_button_tag 'have_credentials', true, true
= "I have credentials for #{@session.resource_name} resource"
.form-group
%label
= radio_button_tag 'have_credentials', false, false
= "I do not have #{@session.resource_name} resource credentials"
.form-group
= submit_tag 'Proceed', class: 'btn btn-primary'
\ No newline at end of file
json.contract_ready true
\ No newline at end of file
.form-container
%h3.form-header= "Account Details for #{@session.resource_name}"
%h4.form-prompt Please specify your API credentials
= form_tag use_own_creds_session_path(@session) do
- @credential_fields.each do |field|
.form-group
= text_field_tag "credential_fields[#{field['name']}]", nil, type: field_input_type(field['type']), class: 'form-control', placeholder: field['name']
.form-group
= link_to 'Back', sessions_url(session_id: @session.id), class: 'btn btn-default'
= submit_tag 'Proceed', class: 'btn btn-primary'
\ No newline at end of file
.contracter-container
.contracter-body
%h3.form-header= "Please wait while we are preparing a contract for you"
%p.contract-spinner
%i.fa.fa-spinner.fa-spin
%span{id: 'loading-text'}
Checking for existing contracts..
= hidden_field_tag :session_id, @session.id
:javascript
function checkExistingContract() {
$.ajax({
url: '/sessions/' + $('#session_id').val() + '/check_existing_contract',
dataType: 'json',
method: 'post',
success: function(json) {
if(json['contract_exists']) {
redirectToSuccess();
} else {
$("#loading-text").text('Setting up a new contract..');
$.ajax({
url: '/sessions/' + $('#session_id').val() + '/prepare_new_contract',
dataType: 'json',
method: 'post',
success: function(json) {
redirectToSuccess();
}
});
}
}
});
}
function redirectToSuccess() {
window.location = '/sessions/' + $('#session_id').val() + '/success';
}
checkExistingContract();
\ No newline at end of file
.form-container
%h3.form-header= "Login / Register"
%h4.form-prompt As a next step we need you to be signed into ACSml
= form_for @user_session, url: sign_in_url, class: 'form-inline' do |f|
= hidden_field_tag 'session_id', @session.id
.form-group
%label
= radio_button_tag 'have_account', true, @have_account, id: 'sign-in'
I already have ACSml account
.sign-in-subform{ style: "display: #{ @have_account ? '' : 'none' }" }
- if @user_session.errors.any?
.alert.alert-danger
%a{class: 'close', data: { dismiss: 'alert' } } &times;
%h4= "#{pluralize(@user_session.errors.count, 'error')} occured:"
%ul
- @user_session.errors.full_messages.each do |msg|
%li= msg
.form-group
= f.label :email
= f.email_field :email, class: 'form-control'
.form-group
= f.label :password
= f.password_field :password, class: 'form-control'
.form-group
%label
= radio_button_tag 'have_account', false, !@have_account, id: 'sign-up'
I want to register new ACSml account
.sign-up-subform{ style: "display: #{ @have_account ? 'none' : '' }" }
= fields_for @user do |ff|
- if @user.errors.any?
.alert.alert-danger
%a{class: 'close', data: { dismiss: 'alert' } } &times;
%h4= "#{pluralize(@user.errors.count, 'error')} occured:"
%ul
- @user.errors.full_messages.each do |msg|
%li= msg
.form-group
= ff.label :email
= ff.email_field :email, class: 'form-control'
.form-group
= ff.label :full_name
= ff.text_field :full_name, class: 'form-control'
.form-group
= ff.label :password
= ff.password_field :password, class: 'form-control'
.form-group
= ff.label :password_confirmation
= ff.password_field :password_confirmation, class: 'form-control'
.form-group
= ff.label :organization
= ff.text_field :organization, class: 'form-control'
.form-group
= ff.label :address
= ff.text_field :address, class: 'form-control'
.form-group
= ff.check_box :accept_terms
I accept
= link_to 'terms of usage', usage_terms_url, target: '_blank'
.form-group
= link_to 'Back', sessions_url(id: @session.id), class: 'btn btn-default'
= f.submit 'Proceed', class: 'btn btn-primary'
:javascript
$(document).on('change', '#sign-in, #sign-up', function(){
toggleSubforms();
});
.form-container
%h3.form-header Please sign in
= form_for @user_session, url: sign_in_url do |f|
= hidden_field_tag :sign_in, true
- if @user_session.errors.any?
.alert.alert-danger
%a{class: 'close', data: { dismiss: 'alert' } } &times;
%h4= "#{pluralize(@user_session.errors.count, 'error')} occured:"
%ul
- @user_session.errors.full_messages.each do |msg|
%li= msg
.form-group
%label Email
= f.email_field :email, class: 'form-control'
.form-group
%label Password
= f.password_field :password, class: 'form-control'
.form-group
= link_to 'Back', '/', class: 'btn btn-default'
= f.submit 'Sign In', class: 'btn btn-primary'
\ No newline at end of file
.container
.jumbotron
%h1 Welcome to ASCmI Contracting
%p
Please log in to manage your contracts.
%br
Please use the corresponding component of the DECIDE Framework to set up new contract.
.panel-group.tryout-acsmi
.panel.panel-default
%a{'data-toggle' => 'collapse', href: '#resourcesselector'}
.panel-heading
%h4.panel-title
Try ACSmI directly (for demo / testing purposes)
%div.panel-collapse.collapse{id: 'resourcesselector'}
.panel-body
%p
ACSmI Contracting component initially expects an API call to /decide/acsmi/contracting/api/v1/sessions with :resource_id as a request parameter.
You can emulate the API call in the form below:
= form_tag start_demo_sessions_url do
.form-group
= text_field_tag 'resource_id', 'c1fb1543-54aa-4247-91ee-3ea9a553f64e', class: 'form-control', placeholder: 'Please fill in the resource id'
.form-group
= submit_tag 'Start Contracting', class: 'btn btn-primary'
\ No newline at end of file
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment