Skip to content

Commit

Permalink
minimum版の参加表実装
Browse files Browse the repository at this point in the history
  • Loading branch information
oshiro3 committed May 10, 2024
1 parent 02cf92a commit bf2a9be
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 6 deletions.
16 changes: 16 additions & 0 deletions app/assets/stylesheets/example.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.a8-container {
display: grid;
color: red;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
height: 297mm; /* A4の高さ */
width: 210mm; /* A4の幅 */
}

.a8 {
border: 1px solid black; /* 各A8の境界線 */
display: flex;
justify-content: center;
align-items: center;
}

7 changes: 7 additions & 0 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ProfilesController < ApplicationController
before_action :set_current_profile, only: [:edit, :update, :destroy, :checkin, :entry_sheet]
skip_before_action :logged_in_using_omniauth?, only: [:new]
before_action :is_admin?, :find_profile, only: [:destroy_id, :set_role]
before_action :set_current_user, :set_speaker, only: [:entry_sheet]

def new
@profile = Profile.new
Expand Down Expand Up @@ -131,6 +132,12 @@ def set_current_profile
@profile = Profile.find_by(email: @current_user[:info][:email], conference_id: set_conference.id)
end

def set_speaker
if @current_user
@speaker = Speaker.find_by(email: @current_user[:info][:email], conference_id: set_conference.id)
end
end

def profile_params
params.require(:profile).permit(
:sub,
Expand Down
25 changes: 25 additions & 0 deletions app/javascript/packs/qr_reader1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
document.addEventListener("DOMContentLoaded", function() {
const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const snapBtn = document.getElementById('snap');

navigator.mediaDevices.getUserMedia({ video: true })
.then(function(stream) {
video.srcObject = stream;
video.play();
})
.catch(function(err) {
console.log("カメラの起動に失敗しました: " + err);
});

snapBtn.addEventListener('click', function() {
const context = canvas.getContext('2d');
context.drawImage(video, 0, 0, canvas.width, canvas.height);

// キャプチャした画像をデータURLとして取得
const imageData = canvas.toDataURL('image/jpeg');
console.log(imageData);

// ここで取得したデータURLをサーバーに送信するなどの処理を行う
});
});
19 changes: 18 additions & 1 deletion app/javascript/stylesheets/_entry_sheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
justify-content: flex-start;
flex-direction: column;
align-items: center;
.logo-image{
.logo-image {
margin-top: 3rem;
}
.attendance {
font-size: xxx-large;
}
.profile {
display: inherit;
margin-top: 2rem;
Expand All @@ -28,12 +31,26 @@
display: inherit;
margin-left: 2rem;
flex-direction: column;
font-size: x-large;
}
img.avatar-image{
width: 80px;
margin: 20px;
}
}
}

#printButton {
text-align: center;
margin: 0 auto;
margin-top: 3rem;
}

@media print {
.a8-container {
page-break-after: always; // コンテンツの後に改ページ
}
#printButton {
display: none;
}
}
3 changes: 2 additions & 1 deletion app/javascript/stylesheets/cnds2024.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@import "./_tracks.scss";
@import "./_admin.scss";
@import "./_booth.scss";
@import "./_entry_sheet.scss";
@import "./_links.scss";
@import "./_talks.scss";
@import "./_team.scss";
Expand All @@ -20,4 +21,4 @@
@import "./_contents.scss";
@import "./cnds2024/_cnds2024.scss";
// Import custom utilities
@import "./cnds2024/_utilities.scss";
@import "./cnds2024/_utilities.scss";
1 change: 1 addition & 0 deletions app/views/profiles/entry_sheet.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div class="a8">Content 3</div>
<div class="a8">Content 4</div>
</div>
<button class="btn btn-secondary btn-xl" id="printButton" onclick="window.print();">印刷する</button>
</body>
</html>

23 changes: 19 additions & 4 deletions app/views/profiles/partial_entry_sheet/_up_left_cell.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
<div class="a8">
<div class="logo-image">
<%= image_tag "cndt2023/header_logo.png", class: "img-fluid header_logo" %>
<%= image_tag "#{@conference.abbr}/header_logo.png", class: "img-fluid header_logo" %>
</div>
<div class="attendance">
<% if @speaker.present? %>
<%= h("登壇者") %>
<% else %>
<%= h("一般参加") %>
<% end %>
</div>
<div class="profile">
<div class="qrcode">
<img src=<%= "data:image/png;base64,#{@profile.qrcode_image}" %> />
<%= h("受付用QRコード") %>
</div>
<div class="detail">
<%= h("<Attendee>") %>
<%= image_tag @profile.public_profile.avatar_url(:small) %>
Name: <%= @profile.public_profile.nickname %>
<% if @speaker.present? %>
<%= image_tag @speaker.avatar_url(:small), class: "avatar-image" %>
Name: <%= @speaker.name %>
<% elsif @profile.public_profile.present? %>
<%= image_tag @profile.public_profile.avatar_url(:small), class: "avatar-image" %>
Name: <%= @profile.public_profile.nickname %>
<% end %>
<% if @profile.public_profile.present? %>
</br>
X(Twitter) ID: <%= @profile.public_profile.twitter_id %>
<% end %>
</div>
</div>
</div>

0 comments on commit bf2a9be

Please sign in to comment.