Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/angular-rails-templates-1…
Browse files Browse the repository at this point in the history
….3.1
  • Loading branch information
epugh committed Mar 6, 2025
2 parents f53af9c + 875de42 commit af7c8e4
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gem 'sassc-rails', '~> 2.1'
gem 'solid_cable', '~> 3.0'
gem 'solid_queue'
gem 'thor'
gem 'turbo-rails', '~> 2.0', '>= 2.0.5'
gem 'turbo-rails', '~> 2.0'
gem 'vega'

group :development, :test do
Expand Down Expand Up @@ -90,4 +90,4 @@ group :test do
gem 'selenium-webdriver'
end

gem 'mini_racer', '~> 0.16.0'
gem 'mini_racer', '~> 0.18.0'
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ GEM
childprocess (~> 5.0)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
libv8-node (18.19.0.0-aarch64-linux)
libv8-node (18.19.0.0-x86_64-darwin)
libv8-node (18.19.0.0-x86_64-linux)
libv8-node (23.6.1.0-aarch64-linux)
libv8-node (23.6.1.0-x86_64-darwin)
libv8-node (23.6.1.0-x86_64-linux)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -271,8 +271,8 @@ GEM
memory_profiler (1.1.0)
mini_histogram (0.3.1)
mini_mime (1.1.5)
mini_racer (0.16.0)
libv8-node (~> 18.19.0.0)
mini_racer (0.18.0)
libv8-node (~> 23.6.1.0)
minitest (5.25.4)
minitest-reporters (1.7.1)
ansi
Expand Down Expand Up @@ -322,7 +322,7 @@ GEM
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
omniauth (2.1.2)
omniauth (2.1.3)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
Expand Down Expand Up @@ -438,7 +438,7 @@ GEM
rexml (3.4.1)
rover-df (0.4.1)
numo-narray (>= 0.9.1.9)
rubocop (1.73.1)
rubocop (1.73.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand All @@ -453,7 +453,7 @@ GEM
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-rails (2.30.2)
rubocop-rails (2.30.3)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
Expand Down Expand Up @@ -515,9 +515,9 @@ GEM
thor (1.3.2)
tilt (2.6.0)
timeout (0.4.3)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo-rails (2.0.13)
actionpack (>= 7.1.0)
railties (>= 7.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
Expand Down Expand Up @@ -587,7 +587,7 @@ DEPENDENCIES
listen (~> 3.3)
local_time
memory_profiler
mini_racer (~> 0.16.0)
mini_racer (~> 0.18.0)
minitest-reporters (>= 0.5.0)
mission_control-jobs (~> 0.5.0)
mocha (~> 2.7)
Expand Down Expand Up @@ -616,7 +616,7 @@ DEPENDENCIES
solid_cable (~> 3.0)
solid_queue
thor
turbo-rails (~> 2.0, >= 2.0.5)
turbo-rails (~> 2.0)
vega
web-console
webmock
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="modal-header">
<button type="button" class="close btn-core-close" ng-click="ctrl.cancel()" aria-label="Close"></button>
<h3 class="modal-title">Archive This Search Endpoint for Later?</h3>
</div>
<div class="modal-body">
<p>You're about to put this search endpoint into deep freeze. You'll be able to unarchive it later through the "Archived Search Endpoint" filter in the Search Endpoint Listings.</p>
</div>
<div class="modal-footer">
<button class="btn btn-danger" ng-click="ctrl.ok()">Archive</button>
<button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="modal-header">
<button type="button" class="close btn-core-close" ng-click="ctrl.cancel()" aria-label="Close"></button>
<h3 class="modal-title">Delete This Search Endpoint</h3>
</div>
<div class="modal-body">
<p>You're about to delete this Search Endpoint forever! If you think you might want it later, use the Archive function instead.</p>
</div>
<div class="modal-footer">
<button class="btn btn-danger" ng-click="ctrl.ok()">Delete</button>
<button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<a class="action-icon" ng-click="ctrl.openDeleteModal()">
<i
class="glyphicon glyphicon-trash"
aria-hidden="true"
title="Delete"
alt="Delete"
></i>
</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';

/*jshint latedef:false*/

angular.module('QuepidApp')
.controller('DeleteSearchEndpointCtrl', [
'$scope',
'$uibModal',
'flash',
'searchEndpointSvc',
function (
$scope,
$uibModal,
flash,
searchEndpointSvc
) {
var ctrl = this;

ctrl.thisSearchEndpoint = $scope.thisSearchEndpoint;
ctrl.deleteSearchEndpoint = deleteSearchEndpoint;
ctrl.openDeleteModal = openDeleteModal;

function deleteSearchEndpoint() {
searchEndpointSvc.deleteSearchEndpoint(ctrl.thisSearchEndpoint).then(
function () {
flash.success = 'Search Endpoint deleted successfully.';
}, function (data) {
var message = 'Oooops! Could not delete the Search Endpoint. ';
message += data.message;
flash.error = message;
}
);
}

function openDeleteModal() {
var modalInstance = $uibModal.open({
templateUrl: 'delete_search_endpoint/_modal.html',
controller: 'DeleteSearchEndpointModalInstanceCtrl',
controllerAs: 'ctrl',
size: 'sm',
resolve: {}
});

modalInstance.result.then(function (deleteClicked) {
if( deleteClicked ){
ctrl.deleteSearchEndpoint();
}
});
}
}
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

angular.module('QuepidApp')
.directive('deleteSearchEndpoint', [
function () {
return {
restrict: 'E',
controller: 'DeleteSearchEndpointCtrl',
controllerAs: 'ctrl',
templateUrl: 'delete_search_endpoint/delete_search_endpoint.html',
scope: {
thisSearchEndpoint: '=',
},
};
}
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

angular.module('QuepidApp')
.controller('DeleteSearchEndpointModalInstanceCtrl', [
'$rootScope',
'$uibModalInstance',
function ($rootScope, $uibModalInstance) {
var ctrl = this;

ctrl.ok = function () {
$uibModalInstance.close(true);
};

ctrl.cancel = function () {
$uibModalInstance.close(false);
};

}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
alt="Edit"
></i>
</a>
<delete-search-endpoint this-search-endpoint="ctrl.searchEndpoint"></delete-search-endpoint>
<archive-search-endpoint this-search-endpoint="ctrl.searchEndpoint"></archive-search-endpoint>
</span>
</div>
Expand Down
16 changes: 16 additions & 0 deletions app/assets/javascripts/services/searchEndpointSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,21 @@ angular.module('QuepidApp')
});
};

this.deleteSearchEndpoint = function(searchEndpointToDelete) {
var self = this;

return $http.delete('api/search_endpoints/' + searchEndpointToDelete.id)
.then(function() {
//that.refetchCaseLists();
var indexOfSearchEndpoint = self.searchEndpoints.indexOf( self.searchEndpoints.filter( function (item) {
return item.id === searchEndpointToDelete.id;
})[0] );
self.searchEndpoints.splice(indexOfSearchEndpoint, 1);

broadcastSvc.send('updatedSearchEndpointsList', self.searchEndpoints);

});
};

}
]);
2 changes: 1 addition & 1 deletion app/controllers/api/v1/search_endpoints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Api
module V1
class SearchEndpointsController < Api::ApiController
before_action :set_search_endpoint, only: [ :show, :update ]
before_action :set_search_endpoint, only: [ :show, :update, :destroy ]

def_param_group :search_endpoint_params do
param :search_endpoint, Hash, required: true do
Expand Down
13 changes: 11 additions & 2 deletions app/controllers/search_endpoints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

class SearchEndpointsController < ApplicationController
include Pagy::Backend
before_action :set_search_endpoint, only: [ :show, :edit, :update, :destroy, :clone ]
before_action :set_search_endpoint, only: [ :show, :edit, :update, :destroy, :clone, :archive ]

respond_to :html

def index
bool = ActiveRecord::Type::Boolean.new
@archived = bool.deserialize(params[:archived] || false )

query = @current_user.search_endpoints_involved_with.order(updated_at: :desc)
query = query.where(archived: @archived)

query = query.where(owner_id: current_user.id) if params[:owned].present?
query = query.where(teams: { id: params[:team_id] }) if params[:team_id].present?
Expand Down Expand Up @@ -35,6 +39,11 @@ def clone
respond_with(@search_endpoint)
end

def archive
@search_endpoint.mark_archived!
redirect_to search_endpoints_path, notice: 'Search Endpoint was archived.'
end

def edit
end

Expand Down Expand Up @@ -69,7 +78,7 @@ def update

def destroy
@search_endpoint.destroy
respond_with(@search_endpoint)
redirect_to search_endpoints_path, notice: 'Search Endpoint was deleted.'
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/case_prophet.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<turbo-frame id="case_frame_<%= @case.id %>">
<h5 class="card-title">
<%= number_with_precision(@case.last_score.score, precision: 2) unless @case.scores.empty? %>
<%= @case.scorer.name %>
<%= @case.scorer&.name %>
</h5>
<p class="card-text">
<% if @case.scores.empty? %>
Expand Down
10 changes: 6 additions & 4 deletions app/views/search_endpoints/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1>Edit Search Endpoint <%= @search_endpoint.fullname %></h1>
<h1>Edit Search Endpoint</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2">
<%= button_to "Delete this Search Endpoint", @search_endpoint, method: :delete, class: 'btn btn-sm btn-outline-danger', onclick: "return confirm('Are you sure you want to delete this Search Endpoint?');" %>
<%= link_to "Back to Search Endpoints", search_endpoints_path, class: "btn btn-sm btn-outline-secondary" %>
<%= button_to "Delete", @search_endpoint, method: :delete, class: 'btn btn-sm btn-outline-danger', onclick: "return confirm('Are you sure you want to delete this Search Endpoint?');" %>
<%= button_to "Archive", archive_search_endpoint_path(@search_endpoint), method: :post, class: 'btn btn-sm btn-outline-warning', onclick: "return confirm('Are you sure you want to archive this Search Endpoint?');" %>
</div>


<%= link_to "Back", search_endpoints_path, class: "btn btn-sm btn-outline-secondary" %>

</div>
</div>

Expand Down
16 changes: 13 additions & 3 deletions app/views/search_endpoints/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Search Endpoints represents a search engine (or API!) that is receiving queries
<div class="card h-100">
<div class="card-header">
<%= form_tag(search_endpoints_path, { method: :get }) do %>
<div class="mb-0 d-flex fs-6 ">
<div class="mb-0 d-flex fs-6 justify-content-center">

<div class="input-group">
<%= text_field_tag :q, params[:q],
Expand All @@ -32,7 +32,8 @@ Search Endpoints represents a search engine (or API!) that is receiving queries
<i class="bi bi-search-heart"></i>
<% end %>
</div>
<div class="d-flex flex-row justify-content-between">

<div class="d-flex justify-content-between">
<label class="ms-2">Mine</label>
<%= check_box_tag :owned,
true,
Expand All @@ -41,7 +42,16 @@ Search Endpoints represents a search engine (or API!) that is receiving queries
onchange: 'this.form.submit()'
%>
</div>
<div class="d-flex">
<div class="d-flex flex-row justify-content-between">
<label class="ms-2">Archived?</label>
<%= check_box_tag :archived,
true,
params[:archived].present?,
class: 'ms-2 form-check-input form-check-input-sm',
onchange: 'this.form.submit()'
%>
</div>
<div class="d-flex justify-content-between">
<%= select_tag :team_id,
options_for_select(
[['Team', '']] + @current_user.teams.map { |j| [j.name, j.id] },
Expand Down
4 changes: 2 additions & 2 deletions app/views/search_endpoints/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2">
<%= link_to 'Edit', edit_search_endpoint_path(@search_endpoint), class: "btn btn-sm btn-outline-primary " %>
<%= link_to 'Clone', clone_search_endpoint_path(@search_endpoint), method: :post, data: { turbo: false }, class: "btn btn-sm btn-outline-secondary" %>
<%= link_to "Back to Search Endpoints", search_endpoints_path, class: "btn btn-sm btn-outline-secondary" %>
<%= link_to 'Clone', clone_search_endpoint_path(@search_endpoint), method: :post, data: { turbo: false }, class: "btn btn-sm btn-outline-secondary" %>
</div>
<%= link_to "Back", search_endpoints_path, class: "btn btn-sm btn-outline-secondary" %>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
resources :search_endpoints do
member do
get 'clone'
post 'archive'
end
end

Expand Down

0 comments on commit af7c8e4

Please sign in to comment.