Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Add ability to rebuild dbic schema's #13

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sandbox_manager/lib/SandboxManager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base 'Mojolicious';

# This method will run once at server start
sub startup {
my $self = shift;
my $self = shift;

# Load configuration from hash returned by "my_app.conf"
my $config = $self->plugin('Config');
Expand Down Expand Up @@ -36,6 +36,8 @@ sub startup {
$r->any('/delete/:name')->to('sandboxes#delete');
$r->any('/restart_all/:name')->to('sandboxes#restart_all');
$r->any('/reindex_full/:name')->to('sandboxes#reindex_full');
$r->any('/rebuild_dbic/:name')->to('sandboxes#rebuild_dbic');
$r->any('/build_css/:name')->to('sandboxes#build_css');
$r->any('/clear_database/:name')->to('sandboxes#clear_database');
}

Expand Down
32 changes: 32 additions & 0 deletions sandbox_manager/lib/SandboxManager/Controller/Sandboxes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,38 @@ sub apply_bug_submit {
);
}

sub rebuild_dbic {
my $self = shift;
my $name = $self->stash('name');

$self->redirect_to('/') unless -f "$config_dir/$name.yml";

my $output = qx{ docker exec koha-$name /bin/bash -c "/kohadevbox/bin/dbic" } . "\n";

$self->render(
title => "Full DBIC Schema Rebuild",
text => $output,
format => 'txt'
);
}

sub build_css {
my $self = shift;
my $name = $self->stash('name');

$self->redirect_to('/') unless -f "$config_dir/$name.yml";

my $output = qx{ docker exec koha-$name /bin/bash -c "(cd koha; yarn install)" } . "\n";
$output .= qx{ docker exec koha-$name /bin/bash -c "(cd koha; yarn build)" } . "\n";
$output .= qx{ docker exec koha-$name /bin/bash -c "(cd koha; yarn build --view=opac)" } . "\n";

$self->render(
title => "Rebuild of css from scss",
text => $output,
format => 'txt'
);
}

sub delete {
my $self = shift;
my $name = $self->stash('name');
Expand Down
2 changes: 2 additions & 0 deletions sandbox_manager/templates/sandboxes/list.html.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
<div class="dropdown-menu" aria-labelledby="btnGroupDropActions">
<a class="dropdown-item" target="_blank" href="/restart_all/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-sync"></i> Restart services</a>
<a class="dropdown-item" target="_blank" href="/reindex_full/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-file-alt"></i> Full Zebra Reindex</a>
<a class="dropdown-item" target="_blank" href="/build_css/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-file-alt"></i> Build CSS</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" target="_blank" href="/rebuild_dbic/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-database"></i> Refresh schema</a>
<a class="dropdown-item" target="_blank" href="/clear_database/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-database"></i> Clear database</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" target="_blank" href="/apply_bug/[% s.KOHA_INSTANCE | html %]"><i class="fas fa-file-signature"></i> Apply patches</a>
Expand Down