Skip to content

Commit

Permalink
Add ability to specify the port CircIT is listening on
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe committed May 29, 2024
1 parent 48b4d08 commit d543098
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 57 deletions.
12 changes: 9 additions & 3 deletions Koha/Plugin/Com/ByWaterSolutions/RFID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ sub configure {

## Grab the values we already have for our settings, if any exist
$template->param(
SomeSetting => $self->retrieve_data('SomeSetting'),
TechLogicCircItPort => $self->retrieve_data('TechLogicCircItPort'),
);

$self->output_html($template->output());
}
else {
$self->store_data({
SomeSetting => $cgi->param('SomeSetting'),
TechLogicCircItPort => $cgi->param('TechLogicCircItPort'),
});
$self->go_home();
}
Expand All @@ -79,7 +79,13 @@ sub static_routes {
sub intranet_js {
my ( $self ) = @_;

return '<script type="text/javascript" src="/api/v1/contrib/rfid/static/static_files/rfid.js"></script>';
my $TechLogicCircItPort = $self->retrieve_data('TechLogicCircItPort') || '9201';
return qq{
<script>
const TechLogicCircItPort = "$TechLogicCircItPort";
</script>
<script type="text/javascript" src="/api/v1/contrib/rfid/static/static_files/rfid.js"></script>
};
}

1;
63 changes: 11 additions & 52 deletions Koha/Plugin/Com/ByWaterSolutions/RFID/configure.tt
Original file line number Diff line number Diff line change
@@ -1,78 +1,37 @@
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha: Kitchen Sink Plugin: Configuration</title>
<title>Koha: RFID Plugin: Configuration</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body>
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]

<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/plugins/plugins-home.pl">Plugins</a> &rsaquo; Kitchen Sink &rsaquo; Configuration</div>
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/plugins/plugins-home.pl">Plugins</a> &rsaquo; RFID &rsaquo; Configuration</div>

<div id="doc3">
<!-- We can access our own plugins resource files using the PLUGIN_PATH variable. -->
<img src="[% PLUGIN_PATH %]/logo.png" />
<h3>Koha: Kitchen Sink Plugin: Configuration</h3>
<h3>RFID plugin configuration</h3>

<!-- Notice our form here has no 'action', this is good, it means that our forms will always get passed back to 'plugins/run.pl'. You could hard code it instead if you prefer -->
<form method="get">
<!-- Always pass these two parameters so the plugin system knows what to execute! -->
<input type="hidden" name="class" value="[% CLASS %]"/>
<input type="hidden" name="method" value="[% METHOD %]"/>

<label for="foo">Parameter 'foo': </label>
<select name="foo">
[% IF foo == 'A' %]
<option value="A" selected="selected">Option A</option>
[% ELSE %]
<option value="A">Option A</option>
[% END %]
<fieldset>
<legend>Tech Logic</legend>

[% IF foo == 'B' %]
<option value="B" selected="selected">Option B</option>
[% ELSE %]
<option value="B">Option B</option>
[% END %]
</select>

<p>

<label for="bar">Parameter 'bar': </label>
<input type="text" name="bar" value="[% bar %]" />

<p>

<label for="enable_opac_payments">Enable OPAC Account Payments: </label>
<select name="enable_opac_payments">
[% IF enable_opac_payments == 'No' %]
<option value="No" selected="selected">No</option>
[% ELSE %]
<option value="No">No</option>
[% END %]

[% IF enable_opac_payments == 'Yes' %]
<option value="Yes" selected="selected">Yes</option>
[% ELSE %]
<option value="Yes">Yes</option>
[% END %]
</select>

<p>
<div class="form-group">
<label for="TechLogicCircItPort">Port</label>
<input type="number" class="form-control" name="TechLogicCircItPort" value="[% TechLogicCircItPort | html %]"placeholder="9201">
<span class="hint">The port that CircIT is listening on. Defaults to 9201 if blank.</span>
</div>
</fieldset>

<input type="hidden" name="save" value="1" />

<input type="submit" value="Save configuration" />
</form>

<hr/>

<p>
<h5>Upgrade status</h5>
[% IF last_upgraded %]
Plugin was last upgraded on this system on [% last_upgraded | $KohaDates with_hours => 1 %]
[% ELSE %]
Plugin has never been upgraded.
[% END %]
</p>

[% INCLUDE 'intranet-bottom.inc' %]
2 changes: 1 addition & 1 deletion Koha/Plugin/Com/ByWaterSolutions/RFID/static_files/rfid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const circit_address = "http://localhost:9201";
const circit_address = `http://localhost:${TechLogicCircItPort}` || "9201";
const rfid_get_items_url = `${circit_address}/getitems`;

// Sometimes we need to halt processing on non-batch pages and continue after the issue has been resolved
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"prettier": "3.2.5"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"tidy": "prettier . --write"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit d543098

Please sign in to comment.