Commit 43085cf0 authored by Hugo's avatar Hugo
Browse files

More bug fixes

parent 70a83eaf
......@@ -290,7 +290,7 @@ get '/api/statistics/subcounter/:period_type/:branch_id' do
counter.send(report_method).each do |stats|
date_string = stats.date.strftime('%d-%m-%Y')
results[date_string] ||= { date_label: stats.label, date: stats.date }
if counter.is_a?(Camera) && stats.is_missing_record
if counter.source.is_a?(Camera) && stats.is_missing_record
results[date_string][counter.name] = "<span class='missing_record'>--</span>"
else
results[date_string][counter.name] = "#{stats.visitors_in}/#{stats.visitors_out} (#{stats.ratio})"
......@@ -543,7 +543,8 @@ end
delete '/adm/api/counters/:id' do
counter = Counter.find(params[:id].to_i) rescue halt(400, 'Ugyldig teller-ID')
counter.destroy!
counter.destroy
resolve_status(counter, 'OK. Teller slettet')
end
post '/adm/api/branches/:branch_id/entrance' do
......@@ -596,7 +597,7 @@ post '/adm/api/entrances/:entrance_id/counters' do
if counter_attributes['counter_id'].blank? # Using 'counter_id' here, as 'id' is used by source
entrance.add_counter!(counter_attributes, source_attributes)
success_msg = 'OK. Periode opprettet.'
success_msg = 'OK. Teller opprettet.'
else
entrance.update_counter!(counter_attributes['counter_id'], counter_attributes, source_attributes)
success_msg = 'OK. Endringer lagret.'
......
......@@ -78,6 +78,7 @@ ActiveRecord::Schema.define(version: 0) do
t.string "oh_code", limit: 1
t.boolean "is_primary_source", default: true
t.datetime "datetime", default: "2000-01-01 00:00:00", null: false
t.index ["datetime", "counter_id"], name: "idx_datetime_counter_id"
end
create_table "downtimes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
......@@ -151,6 +152,7 @@ ActiveRecord::Schema.define(version: 0) do
t.string "oh_code", limit: 1
t.integer "count_correction_id"
t.index ["counter_id", "datetime"], name: "uk_counter_id_datetime", unique: true
t.index ["datetime", "counter_id"], name: "idx_datetime_counter_id"
end
create_table "statistics_views", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
......
......@@ -72,7 +72,7 @@ class PeopleCounterStereo < CounterInterface
end
unless status
msg = response&.inspect || 'No message received'
msg = response_body || 'No message received'
errors.add(:connection, "failed for #{counter.name} with: #{msg}")
end
......
......@@ -81,12 +81,12 @@ $(function() {
fra ${branchName} `
showConfirm(message).done(() => {
//showInProgressModal("hmm")
showInProgressModal('')
$.ajax({
url: `/adm/api/counters/${counter.val()}`,
type: 'DELETE',
success: data => {console.log(data); location.reload()},
error: (data, error) => console.log( "Alvorlig serverfeil: " + error)
success: data => {showAlert(data).done(() => location.reload())},
error: (data, error) => showAlert("Alvorlig serverfeil: " + error)
})
})
})
......@@ -103,7 +103,7 @@ $(function() {
const entranceID = counterData['entrance_id']
$.post(`/adm/api/entrances/${entranceID}/counters`, JSON.stringify(formData))
.done(data => {
showAlert(data)
showAlert(data).done(() => location.reload())
})
.fail((xhr, status, error) => showAlert(xhr.responseText) )
})
......
......@@ -57,7 +57,7 @@
</p>
<p>
<label>Passord:</label>
<input type="password" id="password" <%="value='#{source&.pw}'"%>>
<input type="password" id="password" name="pw" <%="value='#{source&.pw}'"%>>
<button type="button" id="show_password_button">Vis</button>
</p>
</form>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment