diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 7837e8358..1f01db5c2 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -90,6 +90,64 @@ columns: - name filter: {} +- table: + schema: public + name: Map + insert_permissions: + - role: player + permission: + check: {} + columns: + - author_address + - data + - name + - id + backend_only: false + - role: public + permission: + check: {} + columns: + - author_address + - data + - name + - id + backend_only: false + select_permissions: + - role: player + permission: + columns: + - author_address + - data + - name + - id + filter: {} + - role: public + permission: + columns: + - author_address + - data + - name + - id + filter: {} + update_permissions: + - role: player + permission: + columns: + - author_address + - data + - name + - id + filter: {} + check: null + - role: public + permission: + columns: + - author_address + - data + - name + - id + filter: {} + check: null - table: schema: public name: Player diff --git a/hasura/migrations/1606958646709_create_table_public_Map/down.sql b/hasura/migrations/1606958646709_create_table_public_Map/down.sql new file mode 100644 index 000000000..3b1e60205 --- /dev/null +++ b/hasura/migrations/1606958646709_create_table_public_Map/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."Map"; diff --git a/hasura/migrations/1606958646709_create_table_public_Map/up.sql b/hasura/migrations/1606958646709_create_table_public_Map/up.sql new file mode 100644 index 000000000..8f6844bc8 --- /dev/null +++ b/hasura/migrations/1606958646709_create_table_public_Map/up.sql @@ -0,0 +1,2 @@ +CREATE EXTENSION IF NOT EXISTS pgcrypto; +CREATE TABLE "public"."Map"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "author_address" text NOT NULL, "name" Text NOT NULL, "data" Text NOT NULL, PRIMARY KEY ("id") , UNIQUE ("id")); diff --git a/packages/codegen/schema.graphql b/packages/codegen/schema.graphql index fc1180832..7110d19a2 100644 --- a/packages/codegen/schema.graphql +++ b/packages/codegen/schema.graphql @@ -1037,6 +1037,206 @@ input json_comparison_exp { _nin: [json!] } +""" +columns and relationships of "Map" +""" +type Map { + author_address: String! + data: String! + id: uuid! + name: String! +} + +""" +aggregated selection of "Map" +""" +type Map_aggregate { + aggregate: Map_aggregate_fields + nodes: [Map!]! +} + +""" +aggregate fields of "Map" +""" +type Map_aggregate_fields { + count(columns: [Map_select_column!], distinct: Boolean): Int + max: Map_max_fields + min: Map_min_fields +} + +""" +order by aggregate values of table "Map" +""" +input Map_aggregate_order_by { + count: order_by + max: Map_max_order_by + min: Map_min_order_by +} + +""" +input type for inserting array relation for remote table "Map" +""" +input Map_arr_rel_insert_input { + data: [Map_insert_input!]! + on_conflict: Map_on_conflict +} + +""" +Boolean expression to filter rows from the table "Map". All fields are combined with a logical 'AND'. +""" +input Map_bool_exp { + _and: [Map_bool_exp] + _not: Map_bool_exp + _or: [Map_bool_exp] + author_address: String_comparison_exp + data: String_comparison_exp + id: uuid_comparison_exp + name: String_comparison_exp +} + +""" +unique or primary key constraints on table "Map" +""" +enum Map_constraint { + """unique or primary key constraint""" + Map_pkey +} + +""" +input type for inserting data into table "Map" +""" +input Map_insert_input { + author_address: String + data: String + id: uuid + name: String +} + +"""aggregate max on columns""" +type Map_max_fields { + author_address: String + data: String + id: uuid + name: String +} + +""" +order by max() on columns of table "Map" +""" +input Map_max_order_by { + author_address: order_by + data: order_by + id: order_by + name: order_by +} + +"""aggregate min on columns""" +type Map_min_fields { + author_address: String + data: String + id: uuid + name: String +} + +""" +order by min() on columns of table "Map" +""" +input Map_min_order_by { + author_address: order_by + data: order_by + id: order_by + name: order_by +} + +""" +response of any mutation on the table "Map" +""" +type Map_mutation_response { + """number of affected rows by the mutation""" + affected_rows: Int! + + """data of the affected rows by the mutation""" + returning: [Map!]! +} + +""" +input type for inserting object relation for remote table "Map" +""" +input Map_obj_rel_insert_input { + data: Map_insert_input! + on_conflict: Map_on_conflict +} + +""" +on conflict condition type for table "Map" +""" +input Map_on_conflict { + constraint: Map_constraint! + update_columns: [Map_update_column!]! + where: Map_bool_exp +} + +""" +ordering options when selecting data from "Map" +""" +input Map_order_by { + author_address: order_by + data: order_by + id: order_by + name: order_by +} + +""" +primary key columns input for table: "Map" +""" +input Map_pk_columns_input { + id: uuid! +} + +""" +select columns of table "Map" +""" +enum Map_select_column { + """column name""" + author_address + + """column name""" + data + + """column name""" + id + + """column name""" + name +} + +""" +input type for updating data in table "Map" +""" +input Map_set_input { + author_address: String + data: String + id: uuid + name: String +} + +""" +update columns of table "Map" +""" +enum Map_update_column { + """column name""" + author_address + + """column name""" + data + + """column name""" + id + + """column name""" + name +} + """ columns and relationships of "me" """ @@ -1272,6 +1472,19 @@ type mutation_root { """ delete_Guild_by_pk(id: uuid!): Guild + """ + delete data from the table: "Map" + """ + delete_Map( + """filter the rows which have to be deleted""" + where: Map_bool_exp! + ): Map_mutation_response + + """ + delete single row from the table: "Map" + """ + delete_Map_by_pk(id: uuid!): Map + """ delete data from the table: "Player" """ @@ -1468,6 +1681,28 @@ type mutation_root { on_conflict: Guild_on_conflict ): Guild + """ + insert data into the table: "Map" + """ + insert_Map( + """the rows to be inserted""" + objects: [Map_insert_input!]! + + """on conflict condition""" + on_conflict: Map_on_conflict + ): Map_mutation_response + + """ + insert a single row into the table: "Map" + """ + insert_Map_one( + """the row to be inserted""" + object: Map_insert_input! + + """on conflict condition""" + on_conflict: Map_on_conflict + ): Map + """ insert data into the table: "Player" """ @@ -1712,6 +1947,26 @@ type mutation_root { pk_columns: Guild_pk_columns_input! ): Guild + """ + update data of the table: "Map" + """ + update_Map( + """sets the columns of the filtered rows to the given values""" + _set: Map_set_input + + """filter the rows which have to be updated""" + where: Map_bool_exp! + ): Map_mutation_response + + """ + update single row of the table: "Map" + """ + update_Map_by_pk( + """sets the columns of the filtered rows to the given values""" + _set: Map_set_input + pk_columns: Map_pk_columns_input! + ): Map + """ update data of the table: "Player" """ @@ -3386,6 +3641,49 @@ type query_root { """fetch data from the table: "Guild" using primary key columns""" Guild_by_pk(id: uuid!): Guild + """ + fetch data from the table: "Map" + """ + Map( + """distinct select on columns""" + distinct_on: [Map_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [Map_order_by!] + + """filter the rows returned""" + where: Map_bool_exp + ): [Map!]! + + """ + fetch aggregated fields from the table: "Map" + """ + Map_aggregate( + """distinct select on columns""" + distinct_on: [Map_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [Map_order_by!] + + """filter the rows returned""" + where: Map_bool_exp + ): Map_aggregate! + + """fetch data from the table: "Map" using primary key columns""" + Map_by_pk(id: uuid!): Map + """ fetch data from the table: "Player" """ @@ -4316,6 +4614,49 @@ type subscription_root { """fetch data from the table: "Guild" using primary key columns""" Guild_by_pk(id: uuid!): Guild + """ + fetch data from the table: "Map" + """ + Map( + """distinct select on columns""" + distinct_on: [Map_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [Map_order_by!] + + """filter the rows returned""" + where: Map_bool_exp + ): [Map!]! + + """ + fetch aggregated fields from the table: "Map" + """ + Map_aggregate( + """distinct select on columns""" + distinct_on: [Map_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [Map_order_by!] + + """filter the rows returned""" + where: Map_bool_exp + ): Map_aggregate! + + """fetch data from the table: "Map" using primary key columns""" + Map_by_pk(id: uuid!): Map + """ fetch data from the table: "Player" """ diff --git a/packages/metamaps/.babelrc b/packages/metamaps/.babelrc deleted file mode 100644 index 3af6d738e..000000000 --- a/packages/metamaps/.babelrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "presets": [ - "next/babel" - ], - "plugins": [ - [ - "styled-components", - { - "ssr": true, - "displayName": true, - "preprocess": false - } - ] - ] - } \ No newline at end of file diff --git a/packages/metamaps/.eslintrc.json b/packages/metamaps/.eslintrc.json deleted file mode 100644 index 16d45e390..000000000 --- a/packages/metamaps/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "rules": { - "react/react-in-jsx-scope": "off" - }, - "overrides": [ - { - "files": ["./pages/**/*.{ts,tsx}"], - "rules": { - // NextJS requires default exports for pages - "import/no-default-export": "off", - "import/prefer-default-export": "error" - } - } - ] -} diff --git a/packages/metamaps/README.md b/packages/metamaps/README.md index 12ae35f32..685c29db0 100644 --- a/packages/metamaps/README.md +++ b/packages/metamaps/README.md @@ -15,8 +15,4 @@ Runs TypeScript to check if there are any type errors ### `yarn build` -Builds the app and exports the static site for production to the `out` folder. - -### `yarn start` - -Runs the NextJS server for production use (We generate a static site right now, not running a server) +Builds the app and exports the static site for production to the `build` folder. \ No newline at end of file diff --git a/packages/metamaps/codegen.yml b/packages/metamaps/codegen.yml new file mode 100644 index 000000000..4f0847fa7 --- /dev/null +++ b/packages/metamaps/codegen.yml @@ -0,0 +1,17 @@ +overwrite: true +require: + - ts-node/register +generates: + ./graphql/autogen/types.tsx: + schema: '../codegen/schema.graphql' + documents: + - ./graphql/**/(!(*.d)).ts + plugins: + - typescript + - typescript-operations + - typescript-urql + - add: + content: '/* eslint-disable */' + config: + gqlImport: fake-tag + skipTypename: true diff --git a/packages/metamaps/components/Circle.tsx b/packages/metamaps/components/Circle.tsx deleted file mode 100644 index b652ae2e8..000000000 --- a/packages/metamaps/components/Circle.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { FC } from 'react'; -import { useDrag } from 'react-dnd'; -import { connect } from 'react-redux'; - -import { CircleContainer } from '../styles/Mapping'; - -export interface CircleProps { - dispatch: any; - id: number; - type: string; - left: number; - top: number; - width: number; - height: number; - - selectedItem: number; - resizingItem: boolean; - - mouseX: number; - mouseY: number; - - url: string; - popup: string; -} - -export const CircleComponent: FC = ({ - dispatch, - selectedItem, - resizingItem, - mouseX, - mouseY, - id, - type, - left, - top, - width, - height, - - url, - popup, -}) => { - const [, drag] = useDrag({ - item: { id, type, left, top } - }) - - if (selectedItem === id && resizingItem) { - let rleft; let rtop; let rwidth; let rheight; - - if (mouseX > left) { - rleft = left; - rwidth = mouseX - left + 5; - } else { - rleft = mouseX - 5; - rwidth = left - mouseX + 5; - } - - if (mouseY > top) { - rtop = top; - rheight = mouseY - top + 5; - } else { - rtop = mouseY - 5; - rheight = top - mouseY + 5; - } - - dispatch({ type: 'UPDATE_VECTOR', rleft, rtop, rwidth, rheight }); - - return ( - dispatch({ type: 'RESIZE_ITEM_UPDATE' })} - > -
- - ) - } if (url) { - return( - - -
- - - ) - } - return ( - dispatch({ type: 'OPEN_POPUP', popup })} - > -
- - ) - -} - -export const Circle = connect( - (state: any) => ({ - selectedItem: state.selectedItem, - resizingItem: state.resizingItem, - - mouseX: state.mouseX, - mouseY: state.mouseY, - }) -)(CircleComponent); \ No newline at end of file diff --git a/packages/metamaps/components/Container.tsx b/packages/metamaps/components/Container.tsx deleted file mode 100644 index 0b7af358e..000000000 --- a/packages/metamaps/components/Container.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { FC } from 'react'; -import { useDrop, XYCoord } from 'react-dnd'; -import { connect } from 'react-redux'; - -import { MappingContainer } from '../styles/Mapping'; -import { Circle } from './Circle'; -import { Image } from './Image'; -import { Line } from './Line'; -import { Square } from './Square'; - -export interface ContainerProps { - dispatch: any; - items: Array; -} - -export const ContainerComponent: FC = ({ dispatch, items }) => { - const [, drop] = useDrop({ - accept: ['SQUARE', 'CIRCLE', 'LINE', 'IMAGE'], - drop(item: any, monitor) { - const delta = monitor.getDifferenceFromInitialOffset() as XYCoord; - const left = Math.round(item.left + delta.x); - const top = Math.round(item.top + delta.y); - - dispatch({ type: 'UPDATE_POSITION', object: item.type, index: item.id, left, top }) - } - }); - - return( - - { - items.map((item, id) => { - switch (item.type) { - case 'SQUARE': - return( - - ) - case 'CIRCLE': - return( - - ) - case 'LINE': - return( - - ) - case 'IMAGE': - return( - - ) - default: - return( -
- ) - } - }) - } - - ) -} - -export const Container = connect( - (state: any) => ({ - items: state.items, - }) -)(ContainerComponent); \ No newline at end of file diff --git a/packages/metamaps/components/Image.tsx b/packages/metamaps/components/Image.tsx deleted file mode 100644 index 7eced03a6..000000000 --- a/packages/metamaps/components/Image.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { FC } from 'react'; -import { useDrag } from 'react-dnd'; -import { connect } from 'react-redux'; - -import { ImageContainer } from '../styles/Mapping'; - -export interface ImageProps { - dispatch: any; - id: number; - type: string; - left: number; - top: number; - width: number; - height: number; - - selectedItem: number; - resizingItem: boolean; - - mouseX: number; - mouseY: number; - - url: string; - popup: string; -} - -export const ImageComponent: FC = ({ - dispatch, - - id, - type, - left, - top, - width, - height, - - selectedItem, - resizingItem, - mouseX, - mouseY, - - url, - popup, -}) => { - const [, drag] = useDrag({ - item: { id, type, left, top } - }) - - if (selectedItem === id && resizingItem) { - let rleft; let rtop; let rwidth; let rheight; - - if (mouseX > left) { - rleft = left; - rwidth = mouseX - left + 5; - } else { - rleft = mouseX - 5; - rwidth = left - mouseX + 5; - } - - if (mouseY > top) { - rtop = top; - rheight = mouseY - top + 5; - } else { - rtop = mouseY - 5; - rheight = top - mouseY + 5; - } - - dispatch({ type: 'UPDATE_VECTOR', rleft, rtop, rwidth, rheight }); - - return( - dispatch({ type: 'RESIZE_ITEM_UPDATE' })} - > - {id.toString()}/ - - ) - } if (url) { - return ( - - - {id.toString()}/ - - - ) - } - return ( - - {id.toString()}/ - - ) - -} - -export const Image = connect( - (state: any) => ({ - selectedItem: state.selectedItem, - resizingItem: state.resizingItem, - - mouseX: state.mouseX, - mouseY: state.mouseY, - }) -)(ImageComponent); \ No newline at end of file diff --git a/packages/metamaps/components/Line.tsx b/packages/metamaps/components/Line.tsx deleted file mode 100644 index 28a84d8e9..000000000 --- a/packages/metamaps/components/Line.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { FC } from 'react'; -import { useDrag } from 'react-dnd'; -import { connect } from 'react-redux'; - -import { LineContainer } from '../styles/Mapping'; -import { LineColor } from '../styles/Styles'; - -export interface LineProps { - dispatch: any; - id: number; - type: string; - - left: number; - top: number; - width: number; - height: number; - - x1: number; - y1: number; - x2: number; - y2: number; - - createLine: boolean; - menuX: number; - menuY: number; - mouseX: number; - mouseY: number; -} - -export const LineComponent: FC = ({ dispatch, menuX, menuY, mouseX, mouseY, createLine, id, type, left, top, width, height, x1, y1, x2, y2 }) => { - const [, drag] = useDrag({ item: { id, type, left, top } }) - - if (createLine) { - let rleft: number; let rtop: number; let rwidth: number; let rheight: number; - - if (mouseX > menuX) { - rleft = menuX; - rwidth = mouseX - menuX + 5; - } else { - rleft = mouseX - 5; - rwidth = menuX - mouseX + 5; - } - - if (mouseY > menuY) { - rtop = menuY; - rheight = mouseY - menuY + 5; - } else { - rtop = mouseY - 5; - rheight = menuY - mouseY + 5; - } - - const X1 = x1; - const X2 = rwidth; - let Y1 = y1; - let Y2 = rheight; - - if (mouseX > menuX && mouseY < menuY) { - Y1 = rheight; - Y2 = 0; - } - - if (mouseX < menuX && mouseY > menuY) { - Y1 = rheight; - Y2 = 0; - } - - return( - dispatch({ - type: 'DRAW_LINE', - index: id, - rleft, - rtop, - rwidth, - rheight, - x1: X1, - x2: X2, - y1: Y1, - y2: Y2, - })} - > - - - ) - } - - return ( - - - - ) - -} - -export const Line = connect( - (state: any) => ({ - createLine: state.createLine, - menuX: state.menuX, - menuY: state.menuY, - mouseX: state.mouseX, - mouseY: state.mouseY, - }) -)(LineComponent); \ No newline at end of file diff --git a/packages/metamaps/components/Loading.tsx b/packages/metamaps/components/Loading.tsx deleted file mode 100644 index f1f82ef09..000000000 --- a/packages/metamaps/components/Loading.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { CircularProgress } from "@chakra-ui/core"; -import { FC } from 'react'; -import { connect } from 'react-redux'; - -import { LoadingContainer } from '../styles/Loading'; - -export interface LoadingInterface { - loading: boolean; -} - -export const LoadingComponent: FC = ({ loading }) => { - return( - - - - ); -} - -export const Loading = connect( - (state: any) => ({ - loading: state.loading, - }) -)(LoadingComponent); \ No newline at end of file diff --git a/packages/metamaps/components/Menu.tsx b/packages/metamaps/components/Menu.tsx deleted file mode 100644 index 00fe53025..000000000 --- a/packages/metamaps/components/Menu.tsx +++ /dev/null @@ -1,205 +0,0 @@ -import { Button, ButtonGroup } from '@chakra-ui/core'; -import { FC } from 'react'; -import { connect } from 'react-redux'; - -import { MenuContainer } from '../styles/Menu'; -import { ButtonColor,WhiteColor } from '../styles/Styles'; - -export interface MenuProps { - dispatch: any; - menu: boolean; - menuType: string; - selectedItem: number; - menuX: number; - menuY: number; - urlText: string; - popupText: string; -}; - -export const MenuComponent: FC = ({ dispatch, menu, menuType, selectedItem, menuX, menuY, urlText, popupText }) => { - if (menuType === 'normal') { - return( - - - - - - - - { - const el: any = document.querySelector('input#file-input'); - const file = el.files[0]; - const reader = new FileReader(); - reader.onload = (e2: any) => { - const img: any = document.querySelector(`img#image-${selectedItem}`); - img.setAttribute('src', e2.target.result); - } - reader.readAsDataURL(file); - }} - /> - - - ) - } if (menuType === 'SQUARE' || menuType === 'CIRCLE' || menuType === 'IMAGE') { - return( - - - - - - - - - ) - } if (menuType === 'LINE') { - return( - - - - - - ) - } if (menuType === 'url') { - return( - - dispatch({ type: 'UPDATE_URL_TEXT', value: e.target.value })} - /> - - - - - ) - } if (menuType === 'popup') { - return( - -