Skip to content

Commit

Permalink
Make web working without assets (#93)
Browse files Browse the repository at this point in the history
* Make web working without assets

* Proper indentation

* Update changelog
  • Loading branch information
ka8725 committed Aug 7, 2024
1 parent 5ec4c0d commit 520a1fb
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 163 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.7.8] - 2024-08-07
- Make UI working without assets pipeline

## [0.7.7] - 2024-07-22
- Unlock compatibility with Rails versions earlier than 6.0

Expand Down
39 changes: 0 additions & 39 deletions app/assets/javascripts/application.js

This file was deleted.

114 changes: 0 additions & 114 deletions app/assets/stylesheets/styles.css

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/actual_db_schema/migrations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Migrations</title>
<%= stylesheet_link_tag 'styles', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= render partial: 'actual_db_schema/shared/js' %>
<%= render partial: 'actual_db_schema/shared/style' %>
</head>
<body>
<div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/actual_db_schema/migrations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Migration Details</title>
<%= stylesheet_link_tag 'styles', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= render partial: 'actual_db_schema/shared/js' %>
<%= render partial: 'actual_db_schema/shared/style' %>
</head>
<body>
<div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/actual_db_schema/phantom_migrations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Phantom Migrations</title>
<%= stylesheet_link_tag 'styles', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= render partial: 'actual_db_schema/shared/js' %>
<%= render partial: 'actual_db_schema/shared/style' %>
</head>
<body>
<div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/actual_db_schema/phantom_migrations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Phantom Migration Details</title>
<%= stylesheet_link_tag 'styles', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= render partial: 'actual_db_schema/shared/js' %>
<%= render partial: 'actual_db_schema/shared/style' %>
</head>
<body>
<div>
Expand Down
43 changes: 43 additions & 0 deletions app/views/actual_db_schema/shared/_js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script>
document.addEventListener('DOMContentLoaded', function() {
const migrationActions = document.querySelectorAll('.migration-action');

migrationActions.forEach(button => {
button.addEventListener('click', function(event) {
const originalText = button.value;
button.value = 'Loading...';
disableButtons();

fetch(event.target.form.action, {
method: 'POST'
})
.then(response => {
if (response.ok) {
window.location.reload();
} else {
throw new Error('Network response was not ok.');
}
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
enableButtons();
button.value = originalText;
});

event.preventDefault();
});
});

function disableButtons() {
migrationActions.forEach(button => {
button.disabled = true;
});
}

function enableButtons() {
migrationActions.forEach(button => {
button.disabled = false;
});
}
});
</script>
116 changes: 116 additions & 0 deletions app/views/actual_db_schema/shared/_style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<style>
body {
margin: 8px;
background-color: #fff;
color: #333;
}

body, p, td {
font-family: helvetica, verdana, arial, sans-serif;
font-size: 13px;
line-height: 18px;
}

h2 {
padding-left: 10px;
}

table {
margin: 0;
border-collapse: collapse;

thead tr {
border-bottom: 2px solid #ddd;
}

tbody {
.migration-row.phantom {
background-color: #fff3f3;
}

.migration-row.normal {
background-color: #ffffff;
}

.migration-row:nth-child(odd).phantom {
background-color: #ffe6e6;
}

.migration-row:nth-child(odd).normal {
background-color: #f9f9f9;
}
}

td {
padding: 14px 30px;
}
}

.top-buttons {
margin: 8px;
display: flex;
align-items: center;

.top-button {
background-color: #ddd;
}
}

.button, .top-button {
font-weight: bold;
color: #000;
border: none;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 0 2px;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.3s;
background: none;
}

.button:hover, .top-button:hover {
color: #fff;
background-color: #000;
}

.button:disabled, .button:hover:disabled {
background-color: transparent;
color: #666;
cursor: not-allowed;
}

.button-container {
display: flex;
}

pre {
background-color: #f7f7f7;
padding: 10px;
border: 1px solid #ddd;
}

.truncate-text {
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
}

.flash {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
}

.flash.notice {
background-color: #d4edda;
color: #155724;
}

.flash.alert {
background-color: #f8d7da;
color: #721c24;
}
</style>
2 changes: 0 additions & 2 deletions lib/actual_db_schema/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class Engine < ::Rails::Engine
app.routes.append do
mount ActualDbSchema::Engine => "/rails"
end

app.config.assets.precompile += %w[styles.css application.js]
end
end
end
Expand Down

0 comments on commit 520a1fb

Please sign in to comment.