From 5b2a63f65edd13f182787ebb997ceaa493f61665 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 16 May 2016 16:13:33 +0200 Subject: Add config read-api and use it to detect public access Currently no way to modify the settings except by manual SQL, but it's coming. This allows us to have event-specific configuration in the database. This commit adds js that uses this to detect if the frontend is a public vhost or not. There are currently only three columns provided in addition to ID. publicvhost: The domain name of the publicly accessible version of Gondul. shortname: code name for the vent. e.g dx16, tg17, etc. data: jsonb to contain most other settings as we see fit. Most settings will be stored in 'data' if it's only or mainly used by the frontend. This will allow frontend developers to supply arbitrary configuration options without the need for API or database changes in the future. Fixes #51 References #54 Still need the GUI for it. --- build/schema.sql | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'build/schema.sql') diff --git a/build/schema.sql b/build/schema.sql index 4742575..4012eb3 100644 --- a/build/schema.sql +++ b/build/schema.sql @@ -4,7 +4,7 @@ SET statement_timeout = 0; SET lock_timeout = 0; -SET client_encoding = 'UTF8'; +SET client_encoding = 'SQL_ASCII'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; @@ -43,6 +43,41 @@ SET default_tablespace = ''; SET default_with_oids = false; +-- +-- Name: config; Type: TABLE; Schema: public; Owner: nms; Tablespace: +-- + +CREATE TABLE config ( + id integer NOT NULL, + publicvhost character varying, + shortname character varying, + data jsonb +); + + +ALTER TABLE config OWNER TO nms; + +-- +-- Name: config_id_seq; Type: SEQUENCE; Schema: public; Owner: nms +-- + +CREATE SEQUENCE config_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE config_id_seq OWNER TO nms; + +-- +-- Name: config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nms +-- + +ALTER SEQUENCE config_id_seq OWNED BY config.id; + + -- -- Name: dhcp; Type: TABLE; Schema: public; Owner: nms; Tablespace: -- @@ -305,6 +340,13 @@ CREATE TABLE test_table ( ALTER TABLE test_table OWNER TO nms; +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: nms +-- + +ALTER TABLE ONLY config ALTER COLUMN id SET DEFAULT nextval('config_id_seq'::regclass); + + -- -- Name: linknet; Type: DEFAULT; Schema: public; Owner: nms -- @@ -557,6 +599,15 @@ GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; +-- +-- Name: config; Type: ACL; Schema: public; Owner: nms +-- + +REVOKE ALL ON TABLE config FROM PUBLIC; +REVOKE ALL ON TABLE config FROM nms; +GRANT ALL ON TABLE config TO nms; + + -- -- Name: dhcp; Type: ACL; Schema: public; Owner: nms -- -- cgit v1.2.3