Skip to content

Commit

Permalink
Merge pull request #5 from chonla/main
Browse files Browse the repository at this point in the history
Persist form data
  • Loading branch information
chonla authored Oct 21, 2024
2 parents 97120cc + 9acf530 commit a4fa096
Show file tree
Hide file tree
Showing 23 changed files with 991 additions and 418 deletions.
4 changes: 4 additions & 0 deletions cdmm/app/assets/images/save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cdmm/app/assets/images/tristate-checked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cdmm/app/assets/images/tristate-inapplicable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
659 changes: 659 additions & 0 deletions cdmm/app/controllers/cdmm_controller.rb

Large diffs are not rendered by default.

360 changes: 1 addition & 359 deletions cdmm/app/controllers/home_controller.rb

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions cdmm/app/helpers/cdmm_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module CdmmHelper
def get_data_at(table, row_index, col_index)
if table[:rows].count < row_index + 1
[]
elsif table[:rows][row_index].count < col_index + 1
[]
else
table[:rows][row_index][col_index]
end
end

def label_to_key(label)
label.gsub(/::/, '__')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
.gsub(/[^a-z]/, '_')
.gsub(/__+/, '_')
.gsub(/^_+/,'')
.gsub(/_+$/, '')
end
end
17 changes: 0 additions & 17 deletions cdmm/app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
module HomeHelper
def get_data_at(table, row_index, col_index)
if table[:rows].count < row_index + 1
[]
elsif table[:rows][row_index].count < col_index + 1
[]
else
table[:rows][row_index][col_index]
end
end

def label_to_key(label)
label.gsub(/::/, '__')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
.gsub(/[^a-z]/, '_')
end
end
21 changes: 21 additions & 0 deletions cdmm/app/javascript/controllers/page_capture_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Controller } from "@hotwired/stimulus"
import html2canvas from "html2canvas";

// Connects to data-controller="page-capture"
export default class extends Controller {
static targets = [ 'table' ];

connect() {
}

capture() {
window.scrollTo(0, 0);
html2canvas(this.tableTarget).then(function (canvas) {
const screenshot = canvas.toDataURL("image/png");
const downloadLink = document.createElement('a');
downloadLink.download = 'canvas_image.png';
downloadLink.href = screenshot;
downloadLink.click();
});
}
}
2 changes: 2 additions & 0 deletions cdmm/app/models/evaluation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Evaluation < ApplicationRecord
end
9 changes: 9 additions & 0 deletions cdmm/app/views/cdmm/_capability_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="flex flex-row" data-controller="event-sensor" data-event-sensor-identifier-value="<%= key %>">
<div class="mr-2">
<%= render "shared/tristate_checkbox", state: value, identifier: key, event_sensor: "#{key}:triggered" %>
</div>
<div>
<label data-action="click->event-sensor#invoke" for="<%= key %>" class="leading-4 font-semibold text-slate-600 inline-flex text-xs md:text-sm select-none cursor-pointer hover:underline"><%= label %></label>
<p class="text-xs text-slate-400 inline-flex select-none"><%= description %></p>
</div>
</div>
26 changes: 26 additions & 0 deletions cdmm/app/views/cdmm/_form_table.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<table class="border-separate table-fixed border-spacing-0">
<thead class="sticky top-0 z-10">
<tr>
<th class="border-gray-300 bg-slate-100 border p-2 text-xs md:text-sm sticky left-0 z-20"></th>
<% table[:col_headers].each_with_index do |col_header, col_index| %>
<th class="border-gray-300 bg-slate-100 border border-l-0 p-2 text-center text-xs md:text-sm font-bold z-10 relative"><%= col_header %></th>
<% end %>
</tr>
</thead>
<tbody>
<% table[:row_headers].each_with_index do |row_header, row_index| %>
<tr>
<td class="sticky left-0 border-gray-300 bg-slate-100 border border-t-0 p-2 text-center text-xs md:text-sm font-bold z-10"><%= row_header %></td>
<% table[:col_headers].each_with_index do |col_header, col_index| %>
<td class="relative border-gray-300 border border-l-0 border-t-0 p-2 text-xs md:text-sm align-top">
<div class="flex flex-col gap-y-4 items-start">
<% get_data_at(table, row_index, col_index).each_with_index do |data, data_index| %>
<%= render :partial => "capability_item", :locals => { key: data[:key], label: data[:label], description: data[:description], value: data[:value] } %>
<% end %>
</div>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
14 changes: 14 additions & 0 deletions cdmm/app/views/cdmm/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="w-full">
<%= form_with url: evaluation_save_path, method: :post, data: { turbo: false } do |form| %>
<div class="flex flex-row justify-between items-center">
<h1 class="noto-serif-thai-bold text-xl md:text-2xl lg:text-3xl leading-loose">Continuous Delivery Maturity Model</h1>
<button class="p-2 border rounded w-8 h-8 bg-slate-700" data-action="click->page-capture#capture">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-full h-full text-slate-100">
<path d="M1 12l0 9l22 0l0 -9" fill="none" stroke-width="2" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
<path d="M12 2l0 14M5 10l7 6l7 -6" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
<%= render "form_table", table: @table %>
<% end %>
</div>
15 changes: 15 additions & 0 deletions cdmm/app/views/cdmm/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="w-full">
<%= form_with url: evaluation_save_path, method: :post, data: { turbo: false } do |form| %>
<input type="hidden" name="form_key" value="<%= params[:form_key] %>">
<div class="flex flex-row justify-between items-center">
<h1 class="noto-serif-thai-bold text-xl md:text-2xl lg:text-3xl leading-loose">Continuous Delivery Maturity Model</h1>
<button class="p-2 border rounded w-8 h-8 bg-slate-700" data-action="click->page-capture#capture">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-full h-full text-slate-100">
<path d="M1 12l0 9l22 0l0 -9" fill="none" stroke-width="2" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
<path d="M12 2l0 14M5 10l7 6l7 -6" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
<%= render "form_table", table: @table %>
<% end %>
</div>
9 changes: 0 additions & 9 deletions cdmm/app/views/home/_capability_item.html.erb

This file was deleted.

29 changes: 0 additions & 29 deletions cdmm/app/views/home/index.html.erb

This file was deleted.

4 changes: 2 additions & 2 deletions cdmm/app/views/shared/_tristate_checkbox.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<div data-tristate-checkbox-target="checked">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-full h-full text-blue-500">
<rect x="1" y="1" width="22" height="22" rx="4" ry="4" fill="none" stroke-width="2" stroke="currentColor" />
<path d="M5 14l4 5l10 -14" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
<path d="M6 14l4 4l8 -12" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</div>
<div data-tristate-checkbox-target="inapplicable">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-full h-full text-red-500">
<rect x="1" y="1" width="22" height="22" rx="4" ry="4" fill="none" stroke-width="2" stroke="currentColor" />
<path d="M5 5l14 14M19 5l-14 14" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
<path d="M6 6l12 12M18 6l-12 12" fill="none" stroke-width="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</div>
</div>
3 changes: 3 additions & 0 deletions cdmm/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

root "home#index"
get "cdmm" => "cdmm#index", as: :evaluation_index
post "cdmm" => "cdmm#save", as: :evaluation_save
get "cdmm/:form_key" => "cdmm#show", as: :evaluation_show

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
Expand Down
80 changes: 80 additions & 0 deletions cdmm/db/migrate/20241019170318_create_evaluations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class CreateEvaluations < ActiveRecord::Migration[7.2]
def change
create_table :evaluations do |t|
t.timestamps
t.string "form_key", null: false
t.string "teams_organized_based_on_platform_technology", null: false, default: "unchecked"
t.string "defined_and_documented_process", null: false, default: "unchecked"
t.string "one_backlog_per_team", null: false, default: "unchecked"
t.string "adopt_agile_methodologies", null: false, default: "unchecked"
t.string "remove_team_boundaries", null: false, default: "unchecked"
t.string "extended_team_collaboration", null: false, default: "unchecked"
t.string "remove_boundary_dev_ops", null: false, default: "unchecked"
t.string "common_process_for_all_changes", null: false, default: "unchecked"
t.string "cross_team_continuous_improvement", null: false, default: "unchecked"
t.string "teams_responsible_all_the_way_to_production", null: false, default: "unchecked"
t.string "cross_functional_teams", null: false, default: "unchecked"
t.string "centralized_version_control", null: false, default: "unchecked"
t.string "automated_build_scripts", null: false, default: "unchecked"
t.string "no_management_of_artifacts", null: false, default: "unchecked"
t.string "manual_deployment", null: false, default: "unchecked"
t.string "environments_are_manually_provisioned", null: false, default: "unchecked"
t.string "polling_ci_builds", null: false, default: "unchecked"
t.string "any_build_can_be_re_created_from_source_control", null: false, default: "unchecked"
t.string "management_of_build_artifacts", null: false, default: "unchecked"
t.string "automated_deployment_scripts", null: false, default: "unchecked"
t.string "automated_provisioning_of_environments", null: false, default: "unchecked"
t.string "commit_hook_ci_builds", null: false, default: "unchecked"
t.string "build_fails_if_quality_is_not_met_code_analysis_performance_etc", null: false, default: "unchecked"
t.string "push_button_deployment_and_release_of_any_releasable_artifact_to_any_environment", null: false, default: "unchecked"
t.string "standard_deployment_process_for_all_environments", null: false, default: "unchecked"
t.string "team_priorities_keeping_codebase_deployable_over_doing_new_work", null: false, default: "unchecked"
t.string "builds_are_not_left_broken", null: false, default: "unchecked"
t.string "orchestrated_deployments", null: false, default: "unchecked"
t.string "blue_green_deployments", null: false, default: "unchecked"
t.string "zero_touch_continuous_deployments", null: false, default: "unchecked"
t.string "infrequent_and_unreliable_releases", null: false, default: "unchecked"
t.string "manual_process", null: false, default: "unchecked"
t.string "painful_infrequent_but_reliable_releases", null: false, default: "unchecked"
t.string "infrequent_but_fully_automated_and_reliable_releases_in_any_environment", null: false, default: "unchecked"
t.string "frequent_fully_automated_releases", null: false, default: "unchecked"
t.string "deployment_disconnected_from_release", null: false, default: "unchecked"
t.string "canary_releases", null: false, default: "unchecked"
t.string "no_rollbacks_always_roll_forward", null: false, default: "unchecked"
t.string "data_migrations_are_performed_manually_no_scripts", null: false, default: "unchecked"
t.string "data_migrations_using_versioned_scripts_performed_manually", null: false, default: "unchecked"
t.string "automated_and_versioned_changes_to_datastores", null: false, default: "unchecked"
t.string "changes_to_datastores_automatically_performed_as_part_of_the_deployment_process", null: false, default: "unchecked"
t.string "automatic_datastore_changes_and_rollbacks_tested_with_every_deployment", null: false, default: "unchecked"
t.string "automated_unit_tests", null: false, default: "unchecked"
t.string "separate_test_environment", null: false, default: "unchecked"
t.string "automatic_integration_tests", null: false, default: "unchecked"
t.string "static_code_analysis", null: false, default: "unchecked"
t.string "test_coverage_analysis", null: false, default: "unchecked"
t.string "automatic_functional_tests", null: false, default: "unchecked"
t.string "manual_performance_security_tests", null: false, default: "unchecked"
t.string "fully_automatic_acceptance", null: false, default: "unchecked"
t.string "automatic_performance_security_tests", null: false, default: "unchecked"
t.string "manual_exploratory_testing_based_on_risk_based_testing_analysis", null: false, default: "unchecked"
t.string "verify_expected_business_value", null: false, default: "unchecked"
t.string "defects_found_and_fixed_immediately_roll_forward", null: false, default: "unchecked"
t.string "baseline_process_metrics", null: false, default: "unchecked"
t.string "manual_reporting", null: false, default: "unchecked"
t.string "visible_to_report_runner", null: false, default: "unchecked"
t.string "measure_the_process", null: false, default: "unchecked"
t.string "automatic_reporting", null: false, default: "unchecked"
t.string "visible_to_team", null: false, default: "unchecked"
t.string "automatic_generation_of_release_notes", null: false, default: "unchecked"
t.string "pipeline_traceability", null: false, default: "unchecked"
t.string "reporting_history", null: false, default: "unchecked"
t.string "visible_to_cross_silo", null: false, default: "unchecked"
t.string "report_trend_analysis", null: false, default: "unchecked"
t.string "real_time_graphs_on_deployment_pipeline_metrics", null: false, default: "unchecked"
t.string "dynamic_self_service_of_information", null: false, default: "unchecked"
t.string "customizable_dashboards", null: false, default: "unchecked"
t.string "cross_reference_across_organizational_boundaries", null: false, default: "unchecked"

t.index ["form_key"], name: "index_evaluation_form_key"
end
end
end
Loading

0 comments on commit a4fa096

Please sign in to comment.