diff --git a/.node-version b/.node-version deleted file mode 100644 index 728f7de..0000000 --- a/.node-version +++ /dev/null @@ -1 +0,0 @@ -22.9.0 diff --git a/Dockerfile b/Dockerfile index 56cc69a..6c34fdd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,30 +28,17 @@ ENV RAILS_ENV="production" \ # Throw-away build stage to reduce size of final image FROM base AS build -# Install packages needed to build gems and node modules +# Install packages needed to build gems RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git libpq-dev node-gyp pkg-config python-is-python3 && \ + apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config && \ rm -rf /var/lib/apt/lists /var/cache/apt/archives -# Install JavaScript dependencies -ARG NODE_VERSION=22.9.0 -ARG YARN_VERSION=1.22.22 -ENV PATH=/usr/local/node/bin:$PATH -RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \ - /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \ - npm install -g yarn@$YARN_VERSION && \ - rm -rf /tmp/node-build-master - # Install application gems COPY Gemfile Gemfile.lock ./ RUN bundle install && \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ bundle exec bootsnap precompile --gemfile -# Install node modules -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile - # Copy application code COPY . . @@ -62,7 +49,6 @@ RUN bundle exec bootsnap precompile app/ lib/ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile -RUN rm -rf node_modules # Final stage for app image diff --git a/Gemfile b/Gemfile index bfe38f3..c49ce97 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem "turbo-rails" # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] gem "stimulus-rails" # Bundle and process CSS [https://github.com/rails/cssbundling-rails] -gem "cssbundling-rails" +gem "dartsass-rails" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" diff --git a/Gemfile.lock b/Gemfile.lock index d557e55..02ef087 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,8 +87,9 @@ GEM concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) - cssbundling-rails (1.4.1) + dartsass-rails (0.5.1) railties (>= 6.0.0) + sass-embedded (~> 1.63) date (3.4.1) debug (1.10.0) irb (~> 1.10) @@ -111,6 +112,24 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) + google-protobuf (4.29.3) + bigdecimal + rake (>= 13) + google-protobuf (4.29.3-aarch64-linux) + bigdecimal + rake (>= 13) + google-protobuf (4.29.3-arm64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.29.3-x86-linux) + bigdecimal + rake (>= 13) + google-protobuf (4.29.3-x86_64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.29.3-x86_64-linux) + bigdecimal + rake (>= 13) i18n (1.14.6) concurrent-ruby (~> 1.0) importmap-rails (2.1.0) @@ -290,6 +309,19 @@ GEM rubocop-performance rubocop-rails ruby-progressbar (1.13.0) + sass-embedded (1.83.4) + google-protobuf (~> 4.29) + rake (>= 13) + sass-embedded (1.83.4-aarch64-linux-gnu) + google-protobuf (~> 4.29) + sass-embedded (1.83.4-arm-linux-gnueabihf) + google-protobuf (~> 4.29) + sass-embedded (1.83.4-arm64-darwin) + google-protobuf (~> 4.29) + sass-embedded (1.83.4-x86_64-darwin) + google-protobuf (~> 4.29) + sass-embedded (1.83.4-x86_64-linux-gnu) + google-protobuf (~> 4.29) securerandom (0.4.1) shoulda-matchers (6.4.0) activesupport (>= 5.2.0) @@ -363,7 +395,7 @@ DEPENDENCIES bcrypt (~> 3.1.7) bootsnap brakeman - cssbundling-rails + dartsass-rails debug factory_bot_rails importmap-rails diff --git a/Procfile.dev b/Procfile.dev index 18f64d2..6e70024 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,2 +1,2 @@ web: env RUBY_DEBUG_OPEN=true bin/rails server -css: yarn watch:css +css: bin/rails dartsass:watch diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss deleted file mode 100644 index b61b612..0000000 --- a/app/assets/stylesheets/application.bootstrap.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import 'bootstrap/scss/bootstrap'; -@import 'bootstrap-icons/font/bootstrap-icons'; diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..fe93333 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,10 @@ +/* + * This is a manifest file that'll be compiled into application.css. + * + * With Propshaft, assets are served efficiently without preprocessing steps. You can still include + * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard + * cascading order, meaning styles declared later in the document or manifest will override earlier ones, + * depending on specificity. + * + * Consider organizing styles into separate files for maintainability. + */ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 0000000..8d7af90 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1 @@ +// Sassy diff --git a/app/assets/stylesheets/sessions.css b/app/assets/stylesheets/sessions.css deleted file mode 100644 index 6468762..0000000 --- a/app/assets/stylesheets/sessions.css +++ /dev/null @@ -1,59 +0,0 @@ -body { - background-color: var(--bs-body-bg); -} - -#auth { - height: 100vh; - overflow-x: hidden; -} - -#auth #auth-right { - height: 100%; - - background: url(../png/4853433.png), linear-gradient(90deg, #2d499d, #3f5491); -} - -#auth #auth-left { - padding: 5rem; -} - -#auth #auth-left .auth-title { - font-size: 4rem; - margin-bottom: 1rem; -} - -#auth #auth-left .auth-subtitle { - font-size: 1.7rem; - line-height: 2.5rem; - color: #a8aebb; -} - -#auth #auth-left .auth-logo { - margin-bottom: 7rem; -} - -#auth #auth-left .auth-logo img { - height: 2rem; -} - -@media screen and (max-width: 1399.9px) { - #auth #auth-left { - padding: 3rem; - } -} - -@media screen and (max-width: 767px) { - #auth #auth-left { - padding: 5rem; - } -} - -@media screen and (max-width: 576px) { - #auth #auth-left { - padding: 5rem 3rem; - } -} - -html[data-bs-theme=dark] #auth-right { - background: url(../png/4853433.png), linear-gradient(90deg, #2d499d, #3f5491); -} diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb index 20688ed..7219645 100644 --- a/app/controllers/regions_controller.rb +++ b/app/controllers/regions_controller.rb @@ -27,7 +27,7 @@ def create respond_to do |format| if @region.save - format.html { redirect_to @region, notice: "Region was successfully created." } + format.html { redirect_to @region, notice: "#{@region.name} Region was successfully added to the system." } format.json { render :show, status: :created, location: @region } else format.html { render :new, status: :unprocessable_entity } @@ -54,7 +54,7 @@ def destroy @region.destroy! respond_to do |format| - format.html { redirect_to regions_path, status: :see_other, notice: "Region was successfully destroyed." } + format.html { redirect_to regions_path, status: :see_other, notice: "#{@region.name} Region was removed from the system." } format.json { head :no_content } end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee97fe6..3f9ff93 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,6 +3,15 @@ def sidebar render partial: "layouts/sidebar" end + def flash_messages + render "layouts/flash" + end + + def turbo_stream_flash_messages + turbo_stream.prepend "flash", partial: "layouts/flash_messages" + end + + def linked_logo render partial: "layouts/linked_logo" end @@ -28,6 +37,13 @@ def show_page_tool_link(item, label = "Show") end def delete_tool_link(item, label = "Delete") - link_to ''.html_safe, item, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger btn-sm" + link_to ''.html_safe, + item, + class: "btn btn-danger btn-sm", + data: { + turbo_method: :delete, + turbo_confirm: "Are you sure you want to delete this?" + }, + aria: { label: label } end end diff --git a/app/javascript/application.js b/app/javascript/application.js index d16fcbe..0d7b494 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,4 +1,3 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers" -import * as bootstrap from "bootstrap" diff --git a/app/javascript/controllers/flash_controller.js b/app/javascript/controllers/flash_controller.js new file mode 100644 index 0000000..8c06ef6 --- /dev/null +++ b/app/javascript/controllers/flash_controller.js @@ -0,0 +1,42 @@ +import { Controller } from "@hotwired/stimulus" +import Swal from 'sweetalert2' + +export default class extends Controller { + static values = { + message: String, + type: String + } + + connect() { + if (this.messageValue) { + const Toast = Swal.mixin({ + toast: true, + position: 'top', + width: '600px', + padding: '1.5rem', + showClass: { + popup: '' + }, + hideClass: { + popup: '' + }, + showConfirmButton: true, + buttonsStyling: true, + showCloseButton: false, + customClass: { + confirmButton: 'swal2-confirm swal2-styled', + actions: 'swal2-actions-right', + popup: 'swal2-popup-custom', + title: 'swal2-title-custom', + icon: 'swal2-icon-custom' + } + }) + + Toast.fire({ + icon: this.typeValue || 'success', + title: this.messageValue, + width: '600px' + }) + } + } +} diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 0000000..8dcfdac --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,6 @@ +<% flash.each do |type, message| %> +