mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
Merge pull request #1474 from umami-software/brian/big-int-rollback
roll back bigint. add loading
This commit is contained in:
commit
2f21bb351e
@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import styles from './Loading.module.css';
|
||||
|
||||
function Loading({ className }) {
|
||||
function Loading({ className, overlay = false }) {
|
||||
return (
|
||||
<div className={classNames(styles.loading, className)}>
|
||||
<div className={classNames(styles.loading, { [styles.overlay]: overlay }, className)}>
|
||||
<div />
|
||||
<div />
|
||||
<div />
|
||||
@ -15,6 +15,7 @@ function Loading({ className }) {
|
||||
|
||||
Loading.propTypes = {
|
||||
className: PropTypes.string,
|
||||
overlay: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default Loading;
|
||||
|
@ -21,6 +21,14 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.loading.overlay {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 10;
|
||||
background: var(--gray400);
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.loading div {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
@ -30,6 +38,10 @@
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
|
||||
.loading.overlay div {
|
||||
background: var(--gray900);
|
||||
}
|
||||
|
||||
.loading div + div {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import FormLayout, {
|
||||
FormMessage,
|
||||
FormRow,
|
||||
} from 'components/layout/FormLayout';
|
||||
import Loading from 'components/common/Loading';
|
||||
import useApi from 'hooks/useApi';
|
||||
|
||||
const CONFIRMATION_WORD = 'DELETE';
|
||||
@ -29,8 +30,11 @@ const validate = ({ confirmation }) => {
|
||||
export default function DeleteForm({ values, onSave, onClose }) {
|
||||
const { del } = useApi();
|
||||
const [message, setMessage] = useState();
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
|
||||
const handleSubmit = async ({ type, id }) => {
|
||||
setDeleting(true);
|
||||
|
||||
const { ok, data } = await del(`/${type}/${id}`);
|
||||
|
||||
if (ok) {
|
||||
@ -39,11 +43,14 @@ export default function DeleteForm({ values, onSave, onClose }) {
|
||||
setMessage(
|
||||
data || <FormattedMessage id="message.failure" defaultMessage="Something went wrong." />,
|
||||
);
|
||||
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FormLayout>
|
||||
{deleting && <Loading overlay />}
|
||||
<Formik
|
||||
initialValues={{ confirmation: '', ...values }}
|
||||
validate={validate}
|
||||
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `account` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `user_id` on the `account` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- The primary key for the `event` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `event_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `website_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `session_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- The primary key for the `event_data` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `event_data_id` on the `event_data` table. The data in that column could be lost. The data in that column will be cast from `Int` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `event_id` on the `event_data` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- The primary key for the `pageview` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `view_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `website_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `session_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- The primary key for the `session` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `session_id` on the `session` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `website_id` on the `session` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- The primary key for the `website` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to alter the column `website_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
- You are about to alter the column `user_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `event` DROP FOREIGN KEY `event_ibfk_1`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `event` DROP FOREIGN KEY `event_ibfk_2`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `event_data` DROP FOREIGN KEY `event_data_event_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `pageview` DROP FOREIGN KEY `pageview_ibfk_1`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `pageview` DROP FOREIGN KEY `pageview_ibfk_2`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `session` DROP FOREIGN KEY `session_ibfk_1`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `website` DROP FOREIGN KEY `website_ibfk_1`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `account` DROP PRIMARY KEY,
|
||||
MODIFY `user_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ADD PRIMARY KEY (`user_id`);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `event` DROP PRIMARY KEY,
|
||||
MODIFY `event_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
|
||||
MODIFY `session_id` BIGINT UNSIGNED NOT NULL,
|
||||
ADD PRIMARY KEY (`event_id`);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `event_data` DROP PRIMARY KEY,
|
||||
MODIFY `event_data_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `event_id` BIGINT UNSIGNED NOT NULL,
|
||||
ADD PRIMARY KEY (`event_data_id`);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `pageview` DROP PRIMARY KEY,
|
||||
MODIFY `view_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
|
||||
MODIFY `session_id` BIGINT UNSIGNED NOT NULL,
|
||||
ADD PRIMARY KEY (`view_id`);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `session` DROP PRIMARY KEY,
|
||||
MODIFY `session_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
|
||||
ADD PRIMARY KEY (`session_id`);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `website` DROP PRIMARY KEY,
|
||||
MODIFY `website_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `user_id` BIGINT UNSIGNED NOT NULL,
|
||||
ADD PRIMARY KEY (`website_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `event` ADD CONSTRAINT `event_ibfk_2` FOREIGN KEY (`session_id`) REFERENCES `session`(`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `event` ADD CONSTRAINT `event_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `event_data` ADD CONSTRAINT `event_data_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `event`(`event_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `pageview` ADD CONSTRAINT `pageview_ibfk_2` FOREIGN KEY (`session_id`) REFERENCES `session`(`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `pageview` ADD CONSTRAINT `pageview_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `session` ADD CONSTRAINT `session_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `website` ADD CONSTRAINT `website_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`(`user_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `account` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `event` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `event_data` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `pageview` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `session` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `website` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "event" DROP CONSTRAINT "event_session_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "event" DROP CONSTRAINT "event_website_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "event_data" DROP CONSTRAINT "event_data_event_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_session_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_website_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "session" DROP CONSTRAINT "session_website_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "website" DROP CONSTRAINT "website_user_id_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "account" DROP CONSTRAINT "account_pkey",
|
||||
ALTER COLUMN "user_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "account_pkey" PRIMARY KEY ("user_id");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "event" DROP CONSTRAINT "event_pkey",
|
||||
ALTER COLUMN "event_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "event_pkey" PRIMARY KEY ("event_id");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "event_data" DROP CONSTRAINT "event_data_pkey",
|
||||
ALTER COLUMN "event_data_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "event_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "event_data_pkey" PRIMARY KEY ("event_data_id");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_pkey",
|
||||
ALTER COLUMN "view_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "pageview_pkey" PRIMARY KEY ("view_id");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "session" DROP CONSTRAINT "session_pkey",
|
||||
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "session_pkey" PRIMARY KEY ("session_id");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "website" DROP CONSTRAINT "website_pkey",
|
||||
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
|
||||
ALTER COLUMN "user_id" SET DATA TYPE BIGINT,
|
||||
ADD CONSTRAINT "website_pkey" PRIMARY KEY ("website_id");
|
||||
|
||||
-- Dev: Alter Sequence
|
||||
ALTER SEQUENCE account_user_id_seq AS BIGINT;
|
||||
ALTER SEQUENCE event_data_event_data_id_seq AS BIGINT;
|
||||
ALTER SEQUENCE event_event_id_seq AS BIGINT;
|
||||
ALTER SEQUENCE pageview_view_id_seq AS BIGINT;
|
||||
ALTER SEQUENCE session_session_id_seq AS BIGINT;
|
||||
ALTER SEQUENCE website_website_id_seq AS BIGINT;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "event" ADD CONSTRAINT "event_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "session"("session_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "event" ADD CONSTRAINT "event_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "event_data" ADD CONSTRAINT "event_data_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "event"("event_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "pageview" ADD CONSTRAINT "pageview_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "session"("session_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "pageview" ADD CONSTRAINT "pageview_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "session" ADD CONSTRAINT "session_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "website" ADD CONSTRAINT "website_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "account"("user_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -8,7 +8,7 @@ datasource db {
|
||||
}
|
||||
|
||||
model account {
|
||||
user_id BigInt @id @default(autoincrement())
|
||||
user_id Int @id @default(autoincrement())
|
||||
username String @unique @db.VarChar(255)
|
||||
password String @db.VarChar(60)
|
||||
is_admin Boolean @default(false)
|
||||
@ -18,9 +18,9 @@ model account {
|
||||
}
|
||||
|
||||
model event {
|
||||
event_id BigInt @id @default(autoincrement())
|
||||
website_id BigInt
|
||||
session_id BigInt
|
||||
event_id Int @id @default(autoincrement())
|
||||
website_id Int
|
||||
session_id Int
|
||||
created_at DateTime? @default(now()) @db.Timestamptz(6)
|
||||
url String @db.VarChar(500)
|
||||
event_name String @db.VarChar(50)
|
||||
@ -34,16 +34,16 @@ model event {
|
||||
}
|
||||
|
||||
model event_data {
|
||||
event_data_id BigInt @id @default(autoincrement())
|
||||
event_id BigInt @unique
|
||||
event_data_id Int @id @default(autoincrement())
|
||||
event_id Int @unique
|
||||
event_data Json
|
||||
event event @relation(fields: [event_id], references: [event_id])
|
||||
}
|
||||
|
||||
model pageview {
|
||||
view_id BigInt @id @default(autoincrement())
|
||||
website_id BigInt
|
||||
session_id BigInt
|
||||
view_id Int @id @default(autoincrement())
|
||||
website_id Int
|
||||
session_id Int
|
||||
created_at DateTime? @default(now()) @db.Timestamptz(6)
|
||||
url String @db.VarChar(500)
|
||||
referrer String? @db.VarChar(500)
|
||||
@ -58,9 +58,9 @@ model pageview {
|
||||
}
|
||||
|
||||
model session {
|
||||
session_id BigInt @id @default(autoincrement())
|
||||
session_id Int @id @default(autoincrement())
|
||||
session_uuid String @unique @db.Uuid
|
||||
website_id BigInt
|
||||
website_id Int
|
||||
created_at DateTime? @default(now()) @db.Timestamptz(6)
|
||||
hostname String? @db.VarChar(100)
|
||||
browser String? @db.VarChar(20)
|
||||
@ -70,25 +70,25 @@ model session {
|
||||
language String? @db.VarChar(35)
|
||||
country String? @db.Char(2)
|
||||
website website @relation(fields: [website_id], references: [website_id])
|
||||
pageview pageview[]
|
||||
event event[]
|
||||
pageview pageview[]
|
||||
|
||||
@@index([created_at])
|
||||
@@index([website_id])
|
||||
}
|
||||
|
||||
model website {
|
||||
website_id BigInt @id @default(autoincrement())
|
||||
website_id Int @id @default(autoincrement())
|
||||
website_uuid String @unique @db.Uuid
|
||||
user_id BigInt
|
||||
user_id Int
|
||||
name String @db.VarChar(100)
|
||||
domain String? @db.VarChar(500)
|
||||
share_id String? @unique @db.VarChar(64)
|
||||
created_at DateTime? @default(now()) @db.Timestamptz(6)
|
||||
account account @relation(fields: [user_id], references: [user_id])
|
||||
event event[]
|
||||
pageview pageview[]
|
||||
session session[]
|
||||
event event[]
|
||||
|
||||
@@index([user_id])
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ async function addRedis(ids) {
|
||||
const redis = process.env.REDIS_URL && (global[REDIS] || getClient());
|
||||
|
||||
(async () => {
|
||||
if (!(await redis.get(INITIALIZED))) {
|
||||
if (redis && !(await redis.get(INITIALIZED))) {
|
||||
await stageData();
|
||||
}
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user