mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Inherit all stimulus controllers from base_controller
This commit is contained in:
parent
7dfec304e4
commit
aaa3c77162
16 changed files with 71 additions and 30 deletions
|
|
@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
- Fixed a bug where background jobs to import Immich and Photoprism geolocation data data could not be created by non-admin users.
|
||||
|
||||
### Changed
|
||||
|
||||
- Restrict access to Sidekiq in non self-hosted mode.
|
||||
- Restrict access to background jobs in non self-hosted mode.
|
||||
- Restrict access to users management in non self-hosted mode.
|
||||
|
||||
# 0.24.1 - 2025-02-13
|
||||
|
||||
## Custom map tiles
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
include Pundit::Authorization
|
||||
|
||||
before_action :unread_notifications
|
||||
before_action :unread_notifications, :set_self_hosted_status
|
||||
|
||||
protected
|
||||
|
||||
|
|
@ -24,4 +24,10 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
redirect_to root_path, notice: 'You are not authorized to perform this action.', status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_self_hosted_status
|
||||
@self_hosted = DawarichSettings.self_hosted?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
23
app/javascript/controllers/base_controller.js
Normal file
23
app/javascript/controllers/base_controller.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {
|
||||
selfHosted: Boolean
|
||||
}
|
||||
|
||||
// Every controller that extends BaseController and uses initialize()
|
||||
// should call super.initialize()
|
||||
// Example:
|
||||
// export default class extends BaseController {
|
||||
// initialize() {
|
||||
// super.initialize()
|
||||
// }
|
||||
// }
|
||||
initialize() {
|
||||
// Get the self-hosted value from the HTML root element
|
||||
if (!this.hasSelfHostedValue) {
|
||||
const selfHosted = document.documentElement.dataset.selfHosted === 'true'
|
||||
this.selfHostedValue = selfHosted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
|
||||
// Connects to data-controller="checkbox-select-all"
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["parent", "child"]
|
||||
|
||||
connect() {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
// - trips/new
|
||||
// - trips/edit
|
||||
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["startedAt", "endedAt", "apiKey"]
|
||||
static values = { tripsId: String }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
import BaseController from "./base_controller";
|
||||
import consumer from "../channels/consumer";
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["index"];
|
||||
|
||||
connect() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
import L from "leaflet"
|
||||
import { showFlashMessage } from "../maps/helpers"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["urlInput", "mapContainer", "saveButton"]
|
||||
|
||||
DEFAULT_TILE_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
|
||||
import { fetchAndDrawAreas, handleAreaCreated } from "../maps/areas";
|
||||
|
||||
import { showFlashMessage, fetchAndDisplayPhotos, debounce } from "../maps/helpers";
|
||||
import { showFlashMessage, fetchAndDisplayPhotos } from "../maps/helpers";
|
||||
|
||||
import {
|
||||
osmMapLayer,
|
||||
|
|
@ -31,8 +31,9 @@ import { countryCodesMap } from "../maps/country_codes";
|
|||
import "leaflet-draw";
|
||||
import { initializeFogCanvas, drawFogCanvas, createFogOverlay } from "../maps/fog_of_war";
|
||||
import { TileMonitor } from "../maps/tile_monitor";
|
||||
import BaseController from "./base_controller";
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["container"];
|
||||
|
||||
settingsButtonAdded = false;
|
||||
|
|
@ -41,6 +42,7 @@ export default class extends Controller {
|
|||
trackedMonthsCache = null;
|
||||
|
||||
connect() {
|
||||
super.connect();
|
||||
console.log("Map controller connected");
|
||||
|
||||
this.apiKey = this.element.dataset.api_key;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
import consumer from "../channels/consumer"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["badge", "list"]
|
||||
static values = { userId: Number }
|
||||
|
||||
initialize() {
|
||||
super.initialize()
|
||||
this.subscription = null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static values = {
|
||||
timeout: Number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// This controller is being used on:
|
||||
// - trips/index
|
||||
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
import L from "leaflet"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static values = {
|
||||
tripId: Number,
|
||||
path: String,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// - trips/edit
|
||||
// - trips/new
|
||||
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import BaseController from "./base_controller"
|
||||
import L from "leaflet"
|
||||
import {
|
||||
osmMapLayer,
|
||||
|
|
@ -22,7 +22,7 @@ import {
|
|||
showFlashMessage
|
||||
} from '../maps/helpers';
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["container", "startedAt", "endedAt"]
|
||||
static values = { }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
import L, { latLng } from "leaflet";
|
||||
import { osmMapLayer } from "../maps/layers";
|
||||
import BaseController from "./base_controller"
|
||||
import L from "leaflet"
|
||||
import { osmMapLayer } from "../maps/layers"
|
||||
|
||||
// This controller is used to display a map of all coordinates for a visit
|
||||
// on the "Map" modal of a visit on the Visits page
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["container"];
|
||||
export default class extends BaseController {
|
||||
static targets = ["container"]
|
||||
|
||||
connect() {
|
||||
this.coordinates = JSON.parse(this.element.dataset.coordinates);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
import BaseController from "./base_controller"
|
||||
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["name", "input"]
|
||||
|
||||
connect() {
|
||||
this.visitId = this.element.dataset.id;
|
||||
this.apiKey = this.element.dataset.api_key;
|
||||
this.visitId = this.element.dataset.id;
|
||||
|
||||
this.element.addEventListener("visit-name:updated", this.updateAll.bind(this));
|
||||
}
|
||||
|
||||
// Action to handle selection change
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
import BaseController from "./base_controller"
|
||||
|
||||
// This controller is used to handle the updating of visit names on the Visits page
|
||||
export default class extends Controller {
|
||||
export default class extends BaseController {
|
||||
static targets = ["name", "input"];
|
||||
|
||||
connect() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html data-theme="<%= app_theme %>">
|
||||
<html data-theme="<%= app_theme %>" data-self-hosted="<%= @self_hosted %>">
|
||||
<head>
|
||||
<title><%= full_title(yield(:title)) %></title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
|
|
|||
Loading…
Reference in a new issue