Skip to content

Commit

Permalink
added finished auctions page, added cookies, added timezone localization
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Dec 18, 2023
1 parent 8aeb5bd commit b072af8
Show file tree
Hide file tree
Showing 34 changed files with 2,783 additions and 626 deletions.
1,221 changes: 1,221 additions & 0 deletions app/assets/builds/application.css

Large diffs are not rendered by default.

1,240 changes: 975 additions & 265 deletions app/assets/builds/application.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions app/assets/builds/application.js.map

This file was deleted.

23 changes: 0 additions & 23 deletions app/assets/builds/google_analytics.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/assets/builds/google_analytics.js.map

This file was deleted.

1 change: 1 addition & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
@import "elements/elements";
@import "components/components";
@import "utilities/utilities";
@import "vanilla-cookieconsent/dist/cookieconsent";
11 changes: 10 additions & 1 deletion app/components/pages/auction/filter/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
<%= component 'common/form/search_field', form: f, attribute: :domain_name, value: params[:domain_name], placeholder: t('search_by_domain_name') %>
</div>

<%= component 'pages/auction/notification_subscribe', current_user: @current_user %>

<div class="c-table__filters__more">
<% if current_page?(auctions_path) %>
<%= component 'common/links/link_button', link_title: t(:finished_auctions), href: histories_path, color: 'ghost' %>
<% else %>
<%= component 'common/links/link_button', link_title: t(:auctions_name), href: auctions_path, color: 'ghost' %>
<% end %>

<%= component 'pages/auction/notification_subscribe', current_user: @current_user %>
</div>

<div class="c-auctions__legend">
<div><span class="o-io-icon o-icon--sm"></span><%= t('auctions.english_auction') %></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="c-table__filters__more">

<% if @current_user&.daily_summary %>
<%= component 'common/links/link_button', link_title: t('auctions.unsubscribe_for_notifications'), href: user_toggle_sub_path, color: 'ghost' %>
<% elsif @current_user %>
<%= component 'common/links/link_button', link_title: t('auctions.subscribe_for_notifications'), href: user_toggle_sub_path(@current_user), color: 'ghost' %>
<% end %>
</div>

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= component 'common/table', header_collection: header_collection, options: { class: 'table--black' } do %>
<%= tag.tbody do %>
<tr>
<tr data-controller="auction-timezone" data-auction-timezone-end-time-value="<%= @offer.auction.ends_at.iso8601 %>">
<td><strong><%= @offer.auction.domain_name %></strong></td>
<td>2<%= I18n.l(@offer.auction.ends_at) %></td>
<td><span data-auction-timezone-target="display"><%= @offer.auction.ends_at %></span></td>
<td><%= t('offers.price_in_currency', price: @offer.price) %></td>
<td><%= t('offers.price_in_currency', price: @offer.total) %></td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<h2 class="c-block__title u-h3"><%= t('offers.overview') %></h2>
<%= component 'common/table', header_collection: overview_table_headers, options: { class: 'table--black' } do %>
<%= tag.tbody do %>
<tr>
<tr data-controller="auction-timezone" data-auction-timezone-end-time-value="<%= @offer.auction.ends_at.iso8601 %>">
<td><strong><%= @offer.auction.domain_name %></strong></td>
<td>2<%= I18n.l(@offer.auction.ends_at) %></td>
<td><span data-auction-timezone-target="display"><%= @offer.auction.ends_at %></span></td>
<td><%= t('offers.price_in_currency', price: @offer.price) %></td>
<td><%= t('offers.price_in_currency', price: @offer.total) %></td>
</tr>
Expand Down
12 changes: 0 additions & 12 deletions app/controllers/cookies_controller.rb

This file was deleted.

8 changes: 0 additions & 8 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ def end_of_procdure
Rails.configuration.customization[:end_of_procedure]
end

def show_cookie_dialog?
session[:cookie_dialog] != 'accepted'
end

def show_google_analytics?
session[:google_analytics] == 'accepted'
end

private

def ban_error_message(domains, valid_until)
Expand Down
1 change: 1 addition & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
import "./turbo_streams"
import "@hotwired/turbo-rails"
import "./controllers"

21 changes: 21 additions & 0 deletions app/javascript/controllers/auction_timezone_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = { endTime: String }
static targets = ["display"]

connect() {
this.updateTime()
}

updateTime() {
if (!this.hasDisplayTarget) {
return;
}

const endTime = new Date(this.endTimeValue)
const userLocalTime = endTime.toLocaleString(undefined, {timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone})

this.displayTarget.textContent = userLocalTime
}
}
214 changes: 214 additions & 0 deletions app/javascript/controllers/cookie_consent_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
import { Controller } from "@hotwired/stimulus"
import "vanilla-cookieconsent";

export default class extends Controller {
connect() {
var cc = initCookieConsent();

// run plugin with your configuration
cc.run({
current_lang: 'en',
autoclear_cookies: false, // default: false
page_scripts: true, // default: false

// mode: 'opt-in' // default: 'opt-in'; value: 'opt-in' or 'opt-out'
// delay: 0, // default: 0
auto_language: 'document', // default: null; could also be 'browser' or 'document'
// autorun: true, // default: true
// force_consent: false, // default: false
// hide_from_bots: true, // default: true
// remove_cookie_tables: false // default: false
cookie_name: 'cc_cookie', // default: 'cc_cookie'
// cookie_expiration: 182, // default: 182 (days)
// cookie_necessary_only_expiration: 182 // default: disabled
// cookie_domain: location.hostname, // default: current domain
// cookie_path: '/', // default: root
// cookie_same_site: 'Lax', // default: 'Lax'
// use_rfc_cookie: false, // default: false
revision: 0, // default: 0

onFirstAction: function(user_preferences, cookie){
// callback triggered only once on the first accept/reject action
},

onAccept: function (cookie) {
// callback triggered on the first accept/reject action, and after each page load
},

onChange: function (cookie, changed_categories) {
// callback triggered when user changes preferences after consent has already been given
},

gui_options: {
consent_modal: {
layout: 'cloud',
position: 'bottom center',
transition: 'slide',
swap_buttons: false,
},
settings_modal: {
layout: 'box',
position: 'right',
transition: 'slide',
},
},

languages: {
en: {
consent_modal: {
title: 'We use cookies!',
description:
'To ensure the best user experience for our services, our websites use cookies. We use cookies to personalize content and ads, and to provide social media features. We ask for your permission to use cookies that are not necessarily essential for the basic functions of our website. Please read our detailed descriptions and rules of cookies <a class="cc__link" href="https://www.internet.ee/eif/cookies-on-internet-ee-webpage" target="_blank">here</a>.',
primary_btn: {
text: 'ACCEPT ALL',
role: 'accept_all', // 'accept_selected' or 'accept_all'
},
secondary_btn: {
text: 'SETTINGS',
role: 'settings', // 'settings' or 'accept_necessary'
},
},
settings_modal: {
title: 'Cookie Settings',
save_settings_btn: 'SAVE SETTINGS',
accept_all_btn: 'ACCEPT ALL',
reject_all_btn: 'REJECT ALL',
close_btn_label: 'Close',
// cookie_table_headers: [
// { col1: 'Name' },
// { col2: 'Domain' },
// { col3: 'Expiration' },
// { col4: 'Description' },
// ],
blocks: [
{
title: 'Cookie usage',
description:
'We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below. The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site.',
},
{
title: 'Strictly necessary cookies',
description:
'Help us make the website more user-friendly by activating essential functions. The website cannot function properly without these cookies. As these cookies are needed for the secure provision of services, the visitor cannot refuse them.',
toggle: {
value: 'necessary',
enabled: true,
readonly: true, // cookie categories with readonly=true are all treated as "necessary cookies"
},
// cookie_table: [
// // list of all expected cookies
// {
// col1: '_registrar_center2_session',
// col2: 'registrar.internet.ee',
// col3: 'At the end of the session',
// col4: 'Session cookie used by web application for maintaining session state for a user.',
// is_regex: true,
// },
// {
// col1: 'request_ip',
// col2: 'registrar.internet.ee',
// col3: '1 day',
// col4: "Used to store the IP address of the user's request for various purposes, like rate limiting or logging in.",
// },
// {
// col1: 'locale',
// col2: 'registrar.internet.ee',
// col3: '2 years',
// col4: "Used to store the user's preferred language setting.",
// },
// ],
},
{
title: 'Statistics and Analytics Cookies',
description:
'Help us understand how a specific visitor uses the website. This way we see how many people visit the site during a certain period, how they navigate through web pages, and what they click on. These cookies provide us with information based on which we improve the customer experience.',
toggle: {
value: 'analytics',
enabled: true,
readonly: false, // cookie categories with readonly=true are all treated as "necessary cookies"
},
}
],
},
},
et: {
consent_modal: {
title: 'Kasutame küpsiseid!',
description:
'Meie teenuste parima kasutajakogemuse tagamiseks kasutavad meie veebisaidid küpsiseid. Kasutame küpsiseid sisu ja reklaamide isikupärastamiseks, sotsiaalse meedia funktsioonide pakkumiseks. Küsime sinult luba, et kasutada küpsiseid, mis ei ole tingimata vajalikud meie veebilehe põhifunktsioonide toimimiseks. Palun loe meie küpsiste üksikasjalikke kirjeldusi ja reegleid <a class="cc__link" href="https://www.internet.ee/eis/kupsised-internet-ee-lehel" target="_blank">siit</a>.',
primary_btn: {
text: 'LUBA KÕIK',
role: 'accept_all', // 'accept_selected' or 'accept_all'
},
secondary_btn: {
text: 'SEADISTUSED',
role: 'settings', // 'settings' or 'accept_necessary'
},
},
settings_modal: {
title: 'Küpsiste seaded',
save_settings_btn: 'SALVESTA',
accept_all_btn: 'LUBA KÕIK',
reject_all_btn: 'KEELA KÕIK',
close_btn_label: 'Sulge',
// cookie_table_headers: [
// { col1: 'Nimi' },
// { col2: 'Domeen' },
// { col3: 'Kehtivus' },
// { col4: 'Kirjeldus' },
// ],
blocks: [
{
title: 'Küpsiste kasutamine',
description:
'Kasutame küpsiseid, et aidata Teil tõhusalt navigeerida ja teatud funktsioone täita. Üksikasjalikku teavet kõigi küpsiste kohta leiate allpool iga nõusolekukategooria alt. Küpsistest, mis on liigitatud kui "Vajalikud" ei saa loobuda, sest need on olulised saidi põhifunktsioonide toimimiseks.',
},
{
title: 'Vajalikud küpsised',
description:
'Veebileht ei saa ilma nende küpsisteta korralikult toimida. Seetõttu ei ole külastajal võimalik neist keelduda.',
toggle: {
value: 'necessary',
enabled: true,
readonly: true, // cookie categories with readonly=true are all treated as "necessary cookies"
},
// cookie_table: [
// // list of all expected cookies
// {
// col1: '_registrar_center2_session',
// col2: 'registrar.internet.ee',
// col3: 'Sessiooni lõpus',
// col4: 'Sessiooni küpsis, mida veebirakendus kasutab kasutaja seansi oleku säilitamiseks.',
// is_regex: true,
// },
// {
// col1: 'request_ip',
// col2: 'registrar.internet.ee',
// col3: '1 päev',
// col4: "Kasutatakse kasutaja päringu IP-aadressi salvestamiseks mitmesugustel eesmärkidel, nagu rate limiting või sisselogimine.",
// },
// {
// col1: 'locale',
// col2: 'registrar.internet.ee',
// col3: '2 aastat',
// col4: "Kasutatakse kasutaja eelistatud keeleseade salvestamiseks.",
// },
// ],
},
{
title: 'Statistics and Analytics Cookies',
description:
'Aitavad meil mõista, kuidas konkreetne külastaja veebilehte kasutab. Nii näeme, kui palju inimesi kindlal ajavahemikul lehte külastab, kuidas veebilehtedel liigutakse ja millele klikitakse. Need küpsised annavad meile infot, mille põhjal parendada kliendikogemust.',
toggle: {
value: 'analytics',
enabled: true,
readonly: false, // cookie categories with readonly=true are all treated as "necessary cookies"
},
}
],
},
},
},
});
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
document.addEventListener('turbo:load', (event) => {
// app/javascript/controllers/english_offers_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
const googleId = document
.getElementById('google-tracking-id')
.getAttribute('data-value');
Expand All @@ -17,4 +21,7 @@ document.addEventListener('turbo:load', (event) => {
'cookie_domain': 'auction.ee',
});
};
});

console.log('Google Analytics controller connected...');
}
}
Loading

0 comments on commit b072af8

Please sign in to comment.