mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 20:06:22 -05:00
Converting Theme.js to typescript so we can use shorthands like Card.Icon.
This commit is contained in:
parent
c715c4d8ac
commit
a92104728d
34 changed files with 936 additions and 710 deletions
131
app/package-lock.json
generated
131
app/package-lock.json
generated
|
|
@ -31,7 +31,12 @@
|
|||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.9.1"
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@types/lodash": "^4.17.21",
|
||||
"@types/node": "^20.17.10",
|
||||
"@types/react": "^18.3.17",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@adobe/css-tools": {
|
||||
|
|
@ -3965,15 +3970,26 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
|
||||
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
|
||||
},
|
||||
"node_modules/@types/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mime": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
|
||||
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.11.18",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
||||
"version": "20.19.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
|
||||
"integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/offscreencanvas": {
|
||||
"version": "2019.7.0",
|
||||
|
|
@ -3991,9 +4007,10 @@
|
|||
"integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg=="
|
||||
},
|
||||
"node_modules/@types/prop-types": {
|
||||
"version": "15.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
|
||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||
"version": "15.7.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
||||
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/q": {
|
||||
"version": "1.5.5",
|
||||
|
|
@ -4011,21 +4028,22 @@
|
|||
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw=="
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "18.0.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz",
|
||||
"integrity": "sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==",
|
||||
"version": "18.3.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.27.tgz",
|
||||
"integrity": "sha512-cisd7gxkzjBKU2GgdYrTdtQx1SORymWyaAFhaxQPK9bYO9ot3Y5OikQRvY0VYQtvwjeQnizCINJAenh/V7MK2w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
"csstype": "^3.0.2"
|
||||
"csstype": "^3.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react-dom": {
|
||||
"version": "18.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz",
|
||||
"integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==",
|
||||
"dependencies": {
|
||||
"@types/react": "*"
|
||||
"version": "18.3.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz",
|
||||
"integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react-reconciler": {
|
||||
|
|
@ -4049,11 +4067,6 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz",
|
||||
"integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA=="
|
||||
},
|
||||
"node_modules/@types/scheduler": {
|
||||
"version": "0.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
"version": "7.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz",
|
||||
|
|
@ -6544,9 +6557,10 @@
|
|||
"integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg=="
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
|
||||
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cypress": {
|
||||
"version": "13.15.2",
|
||||
|
|
@ -17725,7 +17739,7 @@
|
|||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"peer": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
@ -17748,6 +17762,12 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
|
|
@ -21628,15 +21648,24 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
|
||||
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
|
||||
},
|
||||
"@types/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mime": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
|
||||
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "18.11.18",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
||||
"version": "20.19.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
|
||||
"integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
|
||||
"requires": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"@types/offscreencanvas": {
|
||||
"version": "2019.7.0",
|
||||
|
|
@ -21654,9 +21683,9 @@
|
|||
"integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg=="
|
||||
},
|
||||
"@types/prop-types": {
|
||||
"version": "15.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
|
||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||
"version": "15.7.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
||||
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw=="
|
||||
},
|
||||
"@types/q": {
|
||||
"version": "1.5.5",
|
||||
|
|
@ -21674,22 +21703,19 @@
|
|||
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw=="
|
||||
},
|
||||
"@types/react": {
|
||||
"version": "18.0.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz",
|
||||
"integrity": "sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==",
|
||||
"version": "18.3.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.27.tgz",
|
||||
"integrity": "sha512-cisd7gxkzjBKU2GgdYrTdtQx1SORymWyaAFhaxQPK9bYO9ot3Y5OikQRvY0VYQtvwjeQnizCINJAenh/V7MK2w==",
|
||||
"requires": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
"csstype": "^3.0.2"
|
||||
"csstype": "^3.2.2"
|
||||
}
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"version": "18.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz",
|
||||
"integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==",
|
||||
"requires": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
"version": "18.3.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz",
|
||||
"integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
|
||||
"requires": {}
|
||||
},
|
||||
"@types/react-reconciler": {
|
||||
"version": "0.26.7",
|
||||
|
|
@ -21712,11 +21738,6 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz",
|
||||
"integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA=="
|
||||
},
|
||||
"@types/scheduler": {
|
||||
"version": "0.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
|
||||
},
|
||||
"@types/semver": {
|
||||
"version": "7.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz",
|
||||
|
|
@ -23503,9 +23524,9 @@
|
|||
}
|
||||
},
|
||||
"csstype": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
|
||||
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="
|
||||
},
|
||||
"cypress": {
|
||||
"version": "13.15.2",
|
||||
|
|
@ -31441,8 +31462,7 @@
|
|||
"typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"peer": true
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g=="
|
||||
},
|
||||
"unbox-primitive": {
|
||||
"version": "1.0.2",
|
||||
|
|
@ -31455,6 +31475,11 @@
|
|||
"which-boxed-primitive": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
|
||||
},
|
||||
"unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.9.1"
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@types/lodash": "^4.17.21",
|
||||
"@types/node": "^20.17.10",
|
||||
"@types/react": "^18.3.17",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,8 @@ import {
|
|||
Form,
|
||||
Header,
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
Segment,
|
||||
Statistic,
|
||||
StatisticGroup
|
||||
Statistic
|
||||
} from "./components/Theme";
|
||||
import {Link, useNavigate} from "react-router";
|
||||
import {BandwidthProgressCombined, CPUUsageProgress} from "./components/admin/Status";
|
||||
|
|
@ -219,10 +216,10 @@ export function Getters() {
|
|||
centered={false}
|
||||
onClose={() => handleSetGetter(null, null)}
|
||||
>
|
||||
<ModalHeader>Download from the Internet</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Download from the Internet</Modal.Header>
|
||||
<Modal.Content>
|
||||
<DownloadMenu disabled={gettersDisabled}/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>;
|
||||
} else if (selectedGetter === 'upload') {
|
||||
getterModal = <Modal closeIcon
|
||||
|
|
@ -230,10 +227,10 @@ export function Getters() {
|
|||
centered={false}
|
||||
onClose={() => handleSetGetter(null, null)}
|
||||
>
|
||||
<ModalHeader>Upload from your device</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Upload from your device</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Upload disabled={gettersDisabled}/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>;
|
||||
}
|
||||
|
||||
|
|
@ -279,11 +276,11 @@ function DashboardStatus() {
|
|||
<Header as='h2'>Status</Header>
|
||||
<CPUUsageProgress value={percent} label='CPU Usage'/>
|
||||
|
||||
<StatisticGroup size='mini'>
|
||||
<Statistic.Group size='mini'>
|
||||
<LoadStatistic label='1 Min. Load' value={load['minute_1']} cores={cores}/>
|
||||
<LoadStatistic label='5 Min. Load' value={load['minute_5']} cores={cores}/>
|
||||
<LoadStatistic label='15 Min. Load' value={load['minute_15']} cores={cores}/>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
|
||||
<Header as='h3'>Bandwidth</Header>
|
||||
{bandwidths}
|
||||
|
|
@ -292,9 +289,9 @@ function DashboardStatus() {
|
|||
<Divider style={{marginTop: '3em'}}/>
|
||||
|
||||
<Link to='/admin'>
|
||||
<StatisticGroup size='mini'>
|
||||
<Statistic.Group size='mini'>
|
||||
<Statistic label='Downloading' value={pending_downloads}/>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Link>
|
||||
|
||||
</Segment>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, {useEffect} from "react";
|
||||
import {ApiDownError, deleteTag, getTags, saveTag} from "./api";
|
||||
import {Dimmer, Divider, Form, Grid, GridColumn, GridRow, Label, TableCell, TableRow,} from "semantic-ui-react";
|
||||
import {Dimmer, Divider, Grid, GridColumn, GridRow, Label, TableCell, TableRow,} from "semantic-ui-react";
|
||||
import {
|
||||
APIButton,
|
||||
contrastingColor,
|
||||
|
|
@ -11,13 +11,10 @@ import {
|
|||
} from "./components/Common";
|
||||
import {
|
||||
Button,
|
||||
FormInput,
|
||||
Form,
|
||||
Header,
|
||||
Loader,
|
||||
Modal,
|
||||
ModalActions,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
Segment
|
||||
} from "./components/Theme";
|
||||
import _ from "lodash";
|
||||
|
|
@ -294,7 +291,7 @@ function EditTagsModal() {
|
|||
onOpen={() => setOpen(true)}
|
||||
onClose={localOnClose}
|
||||
>
|
||||
<ModalHeader>Edit Tags</ModalHeader>
|
||||
<Modal.Header>Edit Tags</Modal.Header>
|
||||
<div className={`content scrolling ${inverted}`} id='editModalContent'>
|
||||
<Label.Group tag>
|
||||
<Label size='large' style={{backgroundColor: tagColor, color: textColor}}>
|
||||
|
|
@ -303,7 +300,7 @@ function EditTagsModal() {
|
|||
</Label.Group>
|
||||
|
||||
<Form autoComplete='off'>
|
||||
<FormInput required
|
||||
<Form.Input required
|
||||
label={<b>Tag Name</b>}
|
||||
placeholder='Unique name'
|
||||
value={tagName}
|
||||
|
|
@ -464,7 +461,7 @@ export function AddTagsButton({
|
|||
open={open}
|
||||
onOpen={(e) => handleOpen(e)}
|
||||
onClose={() => setOpen(false)}>
|
||||
<ModalContent>
|
||||
<Modal.Content>
|
||||
{loading && <Dimmer active><Loader/></Dimmer>}
|
||||
<Header as='h4'>Applied Tags</Header>
|
||||
|
||||
|
|
@ -473,8 +470,8 @@ export function AddTagsButton({
|
|||
<Divider/>
|
||||
|
||||
{unusedTags && unusedTags.length > 0 ? unusedTagsGroup : 'You have no tags'}
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Grid textAlign='left'>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={8}>
|
||||
|
|
@ -487,7 +484,7 @@ export function AddTagsButton({
|
|||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {
|
|||
useTitle
|
||||
} from "./Common";
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, Table, TextArea} from "./Theme";
|
||||
import {Button, Header, Loader, Segment, Statistic, Table, TextArea} from "./Theme";
|
||||
import {useStatistics, useVINDecoder} from "../hooks/customHooks";
|
||||
import {CalculatorsPage} from "./Calculators";
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ function StatisticsPage() {
|
|||
<Header as='h1'>Statistics</Header>
|
||||
<Header as='h2'>Files</Header>
|
||||
<Segment>
|
||||
<StatisticGroup>
|
||||
<Statistic.Group>
|
||||
<Statistic>
|
||||
<StatisticValue>{toLocaleString(total_count)}</StatisticValue>
|
||||
<StatisticLabel>All Files</StatisticLabel>
|
||||
|
|
@ -261,10 +261,10 @@ function StatisticsPage() {
|
|||
<StatisticValue>{humanFileSize(total_size)}</StatisticValue>
|
||||
<StatisticLabel>Total Size</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
<Segment>
|
||||
<StatisticGroup size='small'>
|
||||
<Statistic.Group size='small'>
|
||||
<Link to={'/videos/statistics'}>
|
||||
<Statistic color={mimetypeColor('video/')}>
|
||||
<StatisticValue>{toLocaleString(video_count)}</StatisticValue>
|
||||
|
|
@ -287,10 +287,10 @@ function StatisticsPage() {
|
|||
<StatisticValue>{toLocaleString(image_count)}</StatisticValue>
|
||||
<StatisticLabel>Images</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
<Segment>
|
||||
<StatisticGroup size='tiny'>
|
||||
<Statistic.Group size='tiny'>
|
||||
<Statistic>
|
||||
<StatisticValue>{toLocaleString(zip_count)}</StatisticValue>
|
||||
<StatisticLabel>ZIP</StatisticLabel>
|
||||
|
|
@ -299,12 +299,12 @@ function StatisticsPage() {
|
|||
<StatisticValue>{toLocaleString(audio_count)}</StatisticValue>
|
||||
<StatisticLabel>Audio</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
|
||||
<Header as='h2'>Tags</Header>
|
||||
<Segment>
|
||||
<StatisticGroup>
|
||||
<Statistic.Group>
|
||||
<Statistic>
|
||||
<StatisticValue>{humanNumber(tags_count)}</StatisticValue>
|
||||
<StatisticLabel>Tags</StatisticLabel>
|
||||
|
|
@ -317,17 +317,17 @@ function StatisticsPage() {
|
|||
<StatisticValue>{humanNumber(tagged_zims)}</StatisticValue>
|
||||
<StatisticLabel>Tagged Zims</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
|
||||
<Header as='h2'>Database</Header>
|
||||
<Segment>
|
||||
<StatisticGroup>
|
||||
<Statistic.Group>
|
||||
<Statistic>
|
||||
<StatisticValue>{humanFileSize(db_size)}</StatisticValue>
|
||||
<StatisticLabel>Size</StatisticLabel>
|
||||
</Statistic>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
</>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ import {FileCards, FileRowTagIcon, FilesView} from "./Files";
|
|||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import _ from "lodash";
|
||||
import {Media, ThemeContext} from "../contexts/contexts";
|
||||
import {Button, Card, CardIcon, darkTheme, Header, Loader, Popup, Segment, Tab, TabPane} from "./Theme";
|
||||
import {Button, Card, darkTheme, Header, Loader, Popup, Segment, Tab} from "./Theme";
|
||||
import {taggedImageLabel, TagsSelector} from "../Tags";
|
||||
import {toast} from "react-semantic-toasts-2";
|
||||
import {API_ARCHIVE_UPLOAD_URI, Downloaders} from "./Vars";
|
||||
|
|
@ -210,7 +210,7 @@ function ArchivePage() {
|
|||
: 'unknown';
|
||||
|
||||
const aboutPane = {
|
||||
menuItem: 'About', render: () => <TabPane>
|
||||
menuItem: 'About', render: () => <Tab.Pane>
|
||||
<Header as={'h3'}>Domain</Header>
|
||||
{domainHeader}
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ function ArchivePage() {
|
|||
|
||||
<Header as={'h3'}>Modified Date</Header>
|
||||
<p>{modifiedDatetimeString}</p>
|
||||
</TabPane>
|
||||
</Tab.Pane>
|
||||
};
|
||||
|
||||
const localPreviewPath = (path, mimetype) => {
|
||||
|
|
@ -234,7 +234,7 @@ function ArchivePage() {
|
|||
}
|
||||
|
||||
const filesPane = {
|
||||
menuItem: 'Files', render: () => <TabPane>
|
||||
menuItem: 'Files', render: () => <Tab.Pane>
|
||||
<Header as={'h3'}>Singlefile File</Header>
|
||||
{localPreviewPath(data.singlefile_path, 'text/html')}
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ function ArchivePage() {
|
|||
|
||||
<Header as={'h3'}>Directory</Header>
|
||||
{archiveFileLink(archiveFile.directory, true)}
|
||||
</TabPane>
|
||||
</Tab.Pane>
|
||||
};
|
||||
|
||||
const tabPanes = [aboutPane, filesPane];
|
||||
|
|
@ -316,7 +316,7 @@ export function ArchiveCard({file}) {
|
|||
const imageSrc = data.screenshot_path ? `/media/${encodeMediaPath(data.screenshot_path)}` : null;
|
||||
const singlefileUrl = data.singlefile_path ? `/media/${encodeMediaPath(data.singlefile_path)}` : null;
|
||||
|
||||
let screenshot = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
let screenshot = <Card.Icon><FileIcon file={file}/></Card.Icon>;
|
||||
const imageLabel = file.tags && file.tags.length ? taggedImageLabel : null;
|
||||
if (imageSrc) {
|
||||
screenshot = <Image src={imageSrc} wrapped style={{position: 'relative', width: '100%'}} label={imageLabel}/>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import {Button, Divider, Header, Loader, Modal, ModalActions, ModalContent, ModalHeader, Progress} from "./Theme";
|
||||
import {Button, Divider, Header, Loader, Modal, Progress} from "./Theme";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {applyBulkTags, getBulkTagPreview, getBulkTagProgress} from "../api";
|
||||
import {TagsContext} from "../Tags";
|
||||
|
|
@ -129,8 +129,8 @@ export function BulkTagModal({open, onClose, paths, onComplete}) {
|
|||
|
||||
return (
|
||||
<Modal closeIcon open={open} onClose={handleClose} size="small">
|
||||
<ModalHeader>Bulk Tag Files</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Bulk Tag Files</Modal.Header>
|
||||
<Modal.Content>
|
||||
{state === 'loading' && (
|
||||
<div style={{textAlign: 'center', padding: '2em'}}>
|
||||
<Loader active inline="centered">Loading preview...</Loader>
|
||||
|
|
@ -213,8 +213,8 @@ export function BulkTagModal({open, onClose, paths, onComplete}) {
|
|||
)}
|
||||
</div>
|
||||
)}
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
{state === 'preview' && (
|
||||
<>
|
||||
<Button onClick={handleClose}>Cancel</Button>
|
||||
|
|
@ -237,7 +237,7 @@ export function BulkTagModal({open, onClose, paths, onComplete}) {
|
|||
Done
|
||||
</Button>
|
||||
)}
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,9 @@ jest.mock('../api', () => ({
|
|||
getBulkTagProgress: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock Theme components
|
||||
jest.mock('./Theme', () => ({
|
||||
...jest.requireActual('./Theme'),
|
||||
Modal: ({open, onClose, children, closeIcon}) => {
|
||||
// Mock Theme components with compound patterns
|
||||
jest.mock('./Theme', () => {
|
||||
const MockModal = ({open, onClose, children, closeIcon}) => {
|
||||
if (!open) return null;
|
||||
return (
|
||||
<div data-testid="modal">
|
||||
|
|
@ -21,25 +20,31 @@ jest.mock('./Theme', () => ({
|
|||
{children}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
ModalHeader: ({children}) => <div data-testid="modal-header">{children}</div>,
|
||||
ModalContent: ({children}) => <div data-testid="modal-content">{children}</div>,
|
||||
ModalActions: ({children}) => <div data-testid="modal-actions">{children}</div>,
|
||||
Button: ({children, onClick, disabled, color, ...props}) => (
|
||||
<button onClick={onClick} disabled={disabled} data-testid={`button-${children}`} {...props}>{children}</button>
|
||||
),
|
||||
Header: ({children, as}) => <div data-testid="header">{children}</div>,
|
||||
Divider: () => <hr data-testid="divider"/>,
|
||||
Loader: ({children}) => <div data-testid="loader">{children}</div>,
|
||||
Message: ({children, warning, negative, positive}) => (
|
||||
<div data-testid={`message-${warning ? 'warning' : negative ? 'negative' : positive ? 'positive' : 'info'}`}>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
Progress: ({percent, children}) => (
|
||||
<div data-testid="progress" data-percent={percent}>{children}</div>
|
||||
),
|
||||
}));
|
||||
};
|
||||
MockModal.Header = ({children}) => <div data-testid="modal-header">{children}</div>;
|
||||
MockModal.Content = ({children}) => <div data-testid="modal-content">{children}</div>;
|
||||
MockModal.Actions = ({children}) => <div data-testid="modal-actions">{children}</div>;
|
||||
MockModal.Description = ({children}) => <div data-testid="modal-description">{children}</div>;
|
||||
|
||||
return {
|
||||
...jest.requireActual('./Theme'),
|
||||
Modal: MockModal,
|
||||
Button: ({children, onClick, disabled, color, ...props}) => (
|
||||
<button onClick={onClick} disabled={disabled} data-testid={`button-${children}`} {...props}>{children}</button>
|
||||
),
|
||||
Header: ({children, as}) => <div data-testid="header">{children}</div>,
|
||||
Divider: () => <hr data-testid="divider"/>,
|
||||
Loader: ({children}) => <div data-testid="loader">{children}</div>,
|
||||
Message: ({children, warning, negative, positive}) => (
|
||||
<div data-testid={`message-${warning ? 'warning' : negative ? 'negative' : positive ? 'positive' : 'info'}`}>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
Progress: ({percent, children}) => (
|
||||
<div data-testid="progress" data-percent={percent}>{children}</div>
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
// Import mocked API functions
|
||||
import {getBulkTagPreview, applyBulkTags, getBulkTagProgress} from '../api';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {Link, useNavigate, useParams} from "react-router";
|
|||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {useChannel, useChannels, useOneQuery} from "../hooks/customHooks";
|
||||
import _ from "lodash";
|
||||
import {Button, Form, Header, Loader, Modal, ModalContent, Segment, Statistic} from "./Theme";
|
||||
import {Button, Form, Header, Loader, Modal, Segment, Statistic} from "./Theme";
|
||||
import {toast} from "react-semantic-toasts-2";
|
||||
import {RecurringDownloadsTable} from "./admin/Downloads";
|
||||
import {InputForm, ToggleForm} from "../hooks/useForm";
|
||||
|
|
@ -296,7 +296,7 @@ export function ChannelEditPage() {
|
|||
</Grid.Row>
|
||||
</Grid>
|
||||
<Modal open={downloadModalOpen} closeIcon onClose={() => setDownloadModalOpen(false)}>
|
||||
<ModalContent>
|
||||
<Modal.Content>
|
||||
<Header as='h2'>New Channel Download</Header>
|
||||
<ChannelDownloadForm
|
||||
channel_id={channelId}
|
||||
|
|
@ -304,7 +304,7 @@ export function ChannelEditPage() {
|
|||
onCancel={() => setDownloadModalOpen(false)}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
|
||||
<RecurringDownloadsTable downloads={channel?.downloads} fetchDownloads={fetchChannel} onDelete={onDelete}/>
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@ import {Media, SettingsContext, StatusContext, ThemeContext} from "../contexts/c
|
|||
import {
|
||||
Accordion,
|
||||
Breadcrumb,
|
||||
BreadcrumbDivider,
|
||||
Button,
|
||||
CardIcon,
|
||||
Card as ThemedCard,
|
||||
darkTheme,
|
||||
Form,
|
||||
Header,
|
||||
|
|
@ -38,10 +37,6 @@ import {
|
|||
Loader,
|
||||
Menu,
|
||||
Modal,
|
||||
ModalActions,
|
||||
ModalContent,
|
||||
ModalDescription,
|
||||
ModalHeader,
|
||||
Popup,
|
||||
Segment,
|
||||
Statistic
|
||||
|
|
@ -735,18 +730,18 @@ export function CardPoster({to, file}) {
|
|||
if (!to || (to.startsWith('/media/') || to.startsWith('/download/'))) {
|
||||
// "to" is a downloadable file outside the app, preview the file.
|
||||
return <PreviewLink file={file}>
|
||||
<CardIcon>
|
||||
<ThemedCard.Icon>
|
||||
{imageLabel}
|
||||
<FileIcon file={file}/>
|
||||
</CardIcon>
|
||||
</ThemedCard.Icon>
|
||||
</PreviewLink>
|
||||
} else if (!posterPath && to) {
|
||||
// Link to the full page in this App.
|
||||
return <Link to={to}>
|
||||
<CardIcon onClick={() => navigate(to)}>
|
||||
<ThemedCard.Icon onClick={() => navigate(to)}>
|
||||
{imageLabel}
|
||||
<FileIcon file={file}/>
|
||||
</CardIcon>
|
||||
</ThemedCard.Icon>
|
||||
</Link>
|
||||
}
|
||||
}
|
||||
|
|
@ -1066,14 +1061,14 @@ export function UnsupportedModal(header, message, icon) {
|
|||
<Icon name={icon || 'exclamation triangle'}/>
|
||||
{header || 'Unsupported'}
|
||||
</Header>
|
||||
<ModalContent>
|
||||
<ModalDescription>
|
||||
<Modal.Content>
|
||||
<Modal.Description>
|
||||
{message}
|
||||
</ModalDescription>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Description>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button basic inverted onClick={onClose}>Ok</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>;
|
||||
|
||||
return {modal, doClose: onClose, doOpen: onOpen};
|
||||
|
|
@ -1389,10 +1384,10 @@ export function SortButton({sorts = []}) {
|
|||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
>
|
||||
<ModalHeader>Sort By</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Sort By</Modal.Header>
|
||||
<Modal.Content>
|
||||
{sortFields}
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
<ButtonGroup icon>
|
||||
<Button icon={desc ? 'sort down' : 'sort up'} onClick={() => toggleDesc()}/>
|
||||
|
|
@ -1825,7 +1820,7 @@ export function Breadcrumbs({crumbs, size = undefined}) {
|
|||
{crumbs.map((crumb, index) => (
|
||||
<React.Fragment key={index}>
|
||||
{getSection(crumb)}
|
||||
{index < crumbs.length - 1 && <BreadcrumbDivider icon='right chevron'/>}
|
||||
{index < crumbs.length - 1 && <Breadcrumb.Divider icon='right chevron'/>}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</Breadcrumb>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import {Button, Form, FormField, Modal, ModalActions, ModalContent, ModalHeader, Segment} from "./Theme";
|
||||
import {Button, Form, Modal, Segment} from "./Theme";
|
||||
import {Checkbox, Dropdown} from "semantic-ui-react";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import {monthNames} from "./Common";
|
||||
|
|
@ -120,7 +120,7 @@ function DateRangeForm({dateRange, setDateRange}) {
|
|||
<Grid>
|
||||
<Grid.Row columns={2}>
|
||||
<Grid.Column>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>From Year</label>
|
||||
<Dropdown search scrolling fluid
|
||||
options={yearRange}
|
||||
|
|
@ -128,10 +128,10 @@ function DateRangeForm({dateRange, setDateRange}) {
|
|||
onChange={handleFromYear}
|
||||
error={!!error}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>To Year</label>
|
||||
<Dropdown search scrolling fluid
|
||||
options={yearRange.reverse()}
|
||||
|
|
@ -139,7 +139,7 @@ function DateRangeForm({dateRange, setDateRange}) {
|
|||
onChange={handleToYear}
|
||||
error={!!error}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
|
|
@ -231,19 +231,19 @@ export function DateSelectorButton({
|
|||
onClose={handleClose}
|
||||
size='tiny'
|
||||
>
|
||||
<ModalHeader>Filter by Published Date</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Filter by Published Date</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Segment>
|
||||
<DateRangeForm dateRange={dateRange} setDateRange={localOnSetDateRange}/>
|
||||
</Segment>
|
||||
<Segment>
|
||||
<MonthsForm monthsSelected={monthsSelected} setMonthsSelected={setMonthsSelected}/>
|
||||
</Segment>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={handleClear} secondary>Clear</Button>
|
||||
<Button onClick={handleClose}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, {useState} from "react";
|
||||
import {PageContainer, useTitle} from "./Common";
|
||||
import {Button, Header, Modal, ModalContent, ModalHeader, Segment, Table} from "./Theme";
|
||||
import {Button, Header, Modal, Segment, Table} from "./Theme";
|
||||
import {Icon, TableBody, TableCell, TableRow} from "semantic-ui-react";
|
||||
import QRCode from "react-qr-code";
|
||||
|
||||
|
|
@ -26,12 +26,12 @@ function CoinQRButton({qrCodeValue, header, buttonColor}) {
|
|||
onClose={() => setOpen(false)}
|
||||
onOpen={() => setOpen(true)}
|
||||
>
|
||||
<ModalHeader>{header}</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>{header}</Modal.Header>
|
||||
<Modal.Content>
|
||||
<div style={{backgroundColor: '#FFFFFF', display: 'inline-block', padding: '1em'}}>
|
||||
<QRCode value={qrCodeValue} size={300}/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "./Common";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {Button, Form, FormInput, Header} from "./Theme";
|
||||
import {Button, Form, Header} from "./Theme";
|
||||
import {Form as SForm, FormDropdown} from "semantic-ui-react";
|
||||
import {Link} from "react-router";
|
||||
import {TagsSelector} from "../Tags";
|
||||
|
|
@ -170,12 +170,12 @@ export function TitleInclusionInput({form, path = 'settings.title_include'}) {
|
|||
headerContent='Title Match Words'
|
||||
popupContent='List of words, separated by commas, that titles must contain to be downloaded.'
|
||||
/>
|
||||
<FormInput
|
||||
<Form.Input
|
||||
placeholder='Shelter,Solar Power'
|
||||
error={inputProps.error}
|
||||
>
|
||||
<input {...inputProps}/>
|
||||
</FormInput>
|
||||
</Form.Input>
|
||||
</>
|
||||
}
|
||||
|
||||
|
|
@ -192,12 +192,12 @@ export function TitleExclusionInput({form, path = 'settings.title_exclude'}) {
|
|||
headerContent='Title Exclusion Words'
|
||||
popupContent='List of words, separated by commas, that may not appear in titles to be downloaded.'
|
||||
/>
|
||||
<FormInput
|
||||
<Form.Input
|
||||
placeholder='Giveaway,Prize'
|
||||
error={inputProps.error}
|
||||
>
|
||||
<input {...inputProps}/>
|
||||
</FormInput>
|
||||
</Form.Input>
|
||||
</>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {Button, Header, Icon, Modal, ModalActions, ModalContent, ModalHeader, Placeholder, Table} from "./Theme";
|
||||
import {Button, Header, Icon, Modal, Placeholder, Table} from "./Theme";
|
||||
import {
|
||||
Checkbox,
|
||||
Form,
|
||||
|
|
@ -380,8 +380,8 @@ export function RenameModal({open, onClose, path, onSubmit, onPending}) {
|
|||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<ModalHeader>Rename: {name}</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Rename: {name}</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Header as='h4'>New Name</Header>
|
||||
<pre>{parent ? parent + '/' : null}{value}</pre>
|
||||
|
|
@ -392,8 +392,8 @@ export function RenameModal({open, onClose, path, onSubmit, onPending}) {
|
|||
onChange={handleInputChange}
|
||||
/>
|
||||
</Form>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button
|
||||
color='violet'
|
||||
disabled={disabled}
|
||||
|
|
@ -407,7 +407,7 @@ export function RenameModal({open, onClose, path, onSubmit, onPending}) {
|
|||
>
|
||||
Reset
|
||||
</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
}
|
||||
|
||||
|
|
@ -446,8 +446,8 @@ export function MoveModal({open, paths, onClose, onSubmit}) {
|
|||
onClose={onClose}
|
||||
open={open}
|
||||
>
|
||||
<ModalHeader>Move Files/Directories</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Move Files/Directories</Modal.Header>
|
||||
<Modal.Content>
|
||||
<p>Search for a directory to move your files into:</p>
|
||||
<DirectorySearch onSelect={handleDirectory} disabled={pending}/>
|
||||
|
||||
|
|
@ -462,8 +462,8 @@ export function MoveModal({open, paths, onClose, onSubmit}) {
|
|||
{destinationRows}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button
|
||||
color='violet'
|
||||
onClick={handleMove}
|
||||
|
|
@ -474,7 +474,7 @@ export function MoveModal({open, paths, onClose, onSubmit}) {
|
|||
floated='left'
|
||||
disabled={pending}
|
||||
>Reset</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
}
|
||||
|
||||
|
|
@ -508,15 +508,15 @@ export function IgnoreDirectoryModal({open, onClose, onSubmit, directory, ignore
|
|||
>{ignored ? 'Un-ignore' : 'Ignore'}</Button>;
|
||||
|
||||
return <Modal closeIcon open={open} onClose={onClose}>
|
||||
<ModalHeader>{header}</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>{header}</Modal.Header>
|
||||
<Modal.Content>
|
||||
{content}
|
||||
<pre>{mediaDirectory}/{directory}</pre>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
{submitButton}
|
||||
<Button secondary floated='left' onClick={onClose}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
}
|
||||
|
||||
|
|
@ -548,8 +548,8 @@ export function MakeDirectoryModal({open, onClose, parent, onSubmit}) {
|
|||
}
|
||||
|
||||
return <Modal closeIcon open={open} onClose={onClose}>
|
||||
<ModalHeader>Make Directory</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Make Directory</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<pre>{mediaDirectory}/{parent}{value}</pre>
|
||||
<Input fluid
|
||||
|
|
@ -558,9 +558,9 @@ export function MakeDirectoryModal({open, onClose, parent, onSubmit}) {
|
|||
onChange={handleInputChange}
|
||||
/>
|
||||
</Form>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button color='violet' onClick={handleSubmit}>Create</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {Media} from "../contexts/contexts";
|
|||
import {encodeMediaPath} from "./Common";
|
||||
import {getFile, tagFileGroup, untagFileGroup} from "../api";
|
||||
import {StlViewer} from "react-stl-viewer";
|
||||
import {Button, Modal, ModalActions, ModalContent, ModalHeader} from "./Theme";
|
||||
import {Button, Modal} from "./Theme";
|
||||
import {toast} from "react-semantic-toasts-2";
|
||||
import {useOneQuery} from "../hooks/customHooks";
|
||||
import {ShareButton} from "./Share";
|
||||
|
|
@ -35,7 +35,7 @@ function getEpubViewerURL(previewFile) {
|
|||
|
||||
function getIframePreviewModal(previewFile, url) {
|
||||
url = url || getMediaPathURL(previewFile);
|
||||
return <ModalContent>
|
||||
return <Modal.Content>
|
||||
<div className='full-height'>
|
||||
<iframe title='textModal' src={url}
|
||||
style={{
|
||||
|
|
@ -44,7 +44,7 @@ function getIframePreviewModal(previewFile, url) {
|
|||
backgroundColor: '#ffffff',
|
||||
}}/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
}
|
||||
|
||||
function getImagePreviewModal(previewFile) {
|
||||
|
|
@ -53,14 +53,14 @@ function getImagePreviewModal(previewFile) {
|
|||
// Get the file name from the absolute path.
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
<Modal.Header>
|
||||
{name}
|
||||
</ModalHeader>
|
||||
<ModalContent>
|
||||
</Modal.Header>
|
||||
<Modal.Content>
|
||||
<a href={url}>
|
||||
<Image src={url}/>
|
||||
</a>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -69,10 +69,10 @@ function getVideoPreviewModal(previewFile) {
|
|||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
<Modal.Header>
|
||||
{name}
|
||||
</ModalHeader>
|
||||
<ModalContent>
|
||||
</Modal.Header>
|
||||
<Modal.Content>
|
||||
<SHeader as='h5'>{path['path']}</SHeader>
|
||||
<video controls
|
||||
autoPlay={true}
|
||||
|
|
@ -82,7 +82,7 @@ function getVideoPreviewModal(previewFile) {
|
|||
>
|
||||
<source src={url}/>
|
||||
</video>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -93,10 +93,10 @@ function getAudioPreviewModal(previewFile) {
|
|||
// Some audio files may not have the correct mimetype. Trust the suffix identifies an audio file.
|
||||
const type = previewFile['mimetype'] !== 'application/octet-stream' ? previewFile['mimetype'] : 'audio/mpeg';
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
<Modal.Header>
|
||||
{name}
|
||||
</ModalHeader>
|
||||
<ModalContent>
|
||||
</Modal.Header>
|
||||
<Modal.Content>
|
||||
<audio controls
|
||||
autoPlay={true}
|
||||
id="player"
|
||||
|
|
@ -105,7 +105,7 @@ function getAudioPreviewModal(previewFile) {
|
|||
>
|
||||
<source src={url} type={type}/>
|
||||
</audio>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -114,14 +114,14 @@ function getSTLPreviewModal(previewFile) {
|
|||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
return <React.Fragment>
|
||||
<ModalHeader>{name}</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>{name}</Modal.Header>
|
||||
<Modal.Content>
|
||||
<StlViewer orbitControls shadows
|
||||
url={url}
|
||||
style={{height: '80vw', width: '80vw'}}
|
||||
modelProps={{color: '#7353a8'}}
|
||||
/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ function getGenericPreviewModal(previewFile) {
|
|||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
|
||||
return <React.Fragment>
|
||||
<ModalHeader>{name}</ModalHeader>
|
||||
<Modal.Header>{name}</Modal.Header>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -164,11 +164,11 @@ export function FilePreviewProvider({children}) {
|
|||
open={errorModalOpen}
|
||||
onClose={handleErrorModalClose}
|
||||
>
|
||||
<ModalHeader>Unknown File</ModalHeader>
|
||||
<ModalContent>Cannot display preview, no such file exists: {previewQuery}</ModalContent>
|
||||
<ModalActions>
|
||||
<Modal.Header>Unknown File</Modal.Header>
|
||||
<Modal.Content>Cannot display preview, no such file exists: {previewQuery}</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={handleErrorModalClose}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
@ -254,9 +254,9 @@ export function FilePreviewProvider({children}) {
|
|||
: null;
|
||||
const directoryURL = path ? `/files?folders=${encodeURIComponent(pathDirectory(path))}` : null;
|
||||
const directoryButton = path ? <Button as='a' href={directoryURL} icon='folder'/> : null;
|
||||
const pathContent = path ? <ModalContent>
|
||||
const pathContent = path ? <Modal.Content>
|
||||
<pre>{path}</pre>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
: null;
|
||||
console.log('Previewing', path);
|
||||
console.log('Preview Download URL', downloadURL);
|
||||
|
|
@ -268,7 +268,7 @@ export function FilePreviewProvider({children}) {
|
|||
onClose={e => handleClose(e)}
|
||||
>
|
||||
{pathContent}
|
||||
<ModalActions>
|
||||
<Modal.Actions>
|
||||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
|
|
@ -293,7 +293,7 @@ export function FilePreviewProvider({children}) {
|
|||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
{content}
|
||||
</Modal>);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,12 +49,8 @@ import {Media, ThemeContext} from "../contexts/contexts";
|
|||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardIcon,
|
||||
Icon,
|
||||
Modal,
|
||||
ModalActions,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
Placeholder,
|
||||
Popup,
|
||||
Progress,
|
||||
|
|
@ -212,7 +208,7 @@ function ImageRowCells({file}) {
|
|||
}
|
||||
|
||||
export function EbookRowCells({file}) {
|
||||
let cover = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
let cover = <Card.Icon><FileIcon file={file}/></Card.Icon>;
|
||||
const posterPath = findPosterPath(file);
|
||||
if (posterPath) {
|
||||
const coverSrc = `/media/${encodeMediaPath(posterPath)}`;
|
||||
|
|
@ -429,16 +425,16 @@ export function SearchFilter({filters = [], modalHeader, size = 'medium'}) {
|
|||
if (filters && filters.length > 0) {
|
||||
return <>
|
||||
<Modal open={open} onOpen={() => handleOpen()} onClose={() => setOpen(false)} closeIcon>
|
||||
{modalHeader || <ModalHeader>Filter</ModalHeader>}
|
||||
<ModalContent>
|
||||
{modalHeader || <Modal.Header>Filter</Modal.Header>}
|
||||
<Modal.Content>
|
||||
<Form>
|
||||
{filterFields}
|
||||
</Form>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={handleClear} secondary>Clear</Button>
|
||||
<Button onClick={() => setOpen(false)}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
<Button
|
||||
icon='filter'
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import {arraysEqual, enumerate, PageContainer, replaceNullValues, TabLinks, useT
|
|||
import _ from 'lodash';
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {useInventory} from "../hooks/customHooks";
|
||||
import {Button, FormGroup, FormInput, Header, Segment, Table} from "./Theme";
|
||||
import {Button, Form as ThemedForm, Header, Segment, Table} from "./Theme";
|
||||
|
||||
function InventorySummary() {
|
||||
const {t} = useContext(ThemeContext);
|
||||
|
|
@ -252,7 +252,7 @@ class InventoryList extends React.Component {
|
|||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="name"
|
||||
value={editItem.name}
|
||||
|
|
@ -260,7 +260,7 @@ class InventoryList extends React.Component {
|
|||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="item_size"
|
||||
value={editItem.item_size}
|
||||
|
|
@ -268,7 +268,7 @@ class InventoryList extends React.Component {
|
|||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="unit"
|
||||
value={editItem.unit}
|
||||
|
|
@ -276,7 +276,7 @@ class InventoryList extends React.Component {
|
|||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="count"
|
||||
value={editItem.count}
|
||||
|
|
@ -289,7 +289,7 @@ class InventoryList extends React.Component {
|
|||
category={editItem.category}
|
||||
/>
|
||||
<TableCell>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="expiration_date"
|
||||
value={editItem.expiration_date}
|
||||
|
|
@ -460,7 +460,7 @@ class InventoryPortal extends React.Component {
|
|||
<Header>{this.props.header}</Header>
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<label {...s}>Name</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
name='name'
|
||||
value={this.state.name}
|
||||
onChange={this.handleInputChange}
|
||||
|
|
@ -675,7 +675,7 @@ class SuggestionInput extends React.Component {
|
|||
{({s}) => (
|
||||
<>
|
||||
<label {...s}>{this.props.label}</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid={this.props.fluid !== undefined ? this.props.fluid : false}
|
||||
list={this.props.list}
|
||||
name={this.props.name}
|
||||
|
|
@ -770,7 +770,7 @@ class CategoryInputs extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={8} mobile={16}>
|
||||
<label {...s}>Category</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
name="category"
|
||||
placeholder="Category"
|
||||
onChange={this.handleInputChange}
|
||||
|
|
@ -799,7 +799,7 @@ class TableCategoryInputs extends CategoryInputs {
|
|||
/>
|
||||
</TableCell>
|
||||
<TableCell style={{paddingTop: '1.5em', paddingBottom: '1.5em'}}>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
fluid
|
||||
name="category"
|
||||
placeholder="Category"
|
||||
|
|
@ -969,7 +969,7 @@ class InventoryAddList extends React.Component {
|
|||
<>
|
||||
<InventorySelector setInventory={this.setInventory}/>
|
||||
<Form onSubmit={this.handleSubmit} style={{marginLeft: '0.5em', marginTop: '1em'}}>
|
||||
<FormGroup widths='equal'>
|
||||
<ThemedForm.Group widths='equal'>
|
||||
<Grid>
|
||||
<Grid.Column computer={2} mobile={16}>
|
||||
<BrandInput
|
||||
|
|
@ -980,7 +980,7 @@ class InventoryAddList extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={3} mobile={16}>
|
||||
<label {...s}>Product Name</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
required
|
||||
name="name"
|
||||
placeholder="Product Name"
|
||||
|
|
@ -990,7 +990,7 @@ class InventoryAddList extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={1} mobile={4}>
|
||||
<label {...s}>Size</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
required
|
||||
name="item_size"
|
||||
placeholder="Size"
|
||||
|
|
@ -1000,7 +1000,7 @@ class InventoryAddList extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={1} mobile={4}>
|
||||
<label {...s}>Unit</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
required
|
||||
name="unit"
|
||||
placeholder="Unit"
|
||||
|
|
@ -1010,7 +1010,7 @@ class InventoryAddList extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={1} mobile={4}>
|
||||
<label {...s}>Count</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
required
|
||||
name="count"
|
||||
placeholder="Count"
|
||||
|
|
@ -1026,7 +1026,7 @@ class InventoryAddList extends React.Component {
|
|||
</Grid.Column>
|
||||
<Grid.Column computer={2} mobile={16}>
|
||||
<label {...s}>Expiration Date</label>
|
||||
<FormInput
|
||||
<ThemedForm.Input
|
||||
name="expiration_date"
|
||||
placeholder="Expiration Date"
|
||||
onChange={this.handleInputChange}
|
||||
|
|
@ -1037,7 +1037,7 @@ class InventoryAddList extends React.Component {
|
|||
<Button primary icon='plus' type='submit' style={{marginTop: '1.4em'}}/>
|
||||
</Grid.Column>
|
||||
</Grid>
|
||||
</FormGroup>
|
||||
</ThemedForm.Group>
|
||||
</Form>
|
||||
<Header as='h4'>Items in: {this.state.inventory ? this.state.inventory.name : ''}</Header>
|
||||
<InventoryList
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {filterToMimetypes, fuzzyMatch, normalizeEstimate, SearchResultsInput, Ta
|
|||
import _ from "lodash";
|
||||
import {TagsContext} from "../Tags";
|
||||
import {AccordionContent, AccordionTitle, Grid, GridColumn, GridRow, Header as SHeader, Label} from "semantic-ui-react";
|
||||
import {Accordion, Header, Icon, Loader, Modal, ModalContent, Segment} from "./Theme";
|
||||
import {Accordion, Header, Icon, Loader, Modal, Segment} from "./Theme";
|
||||
import {QueryContext, ThemeContext} from "../contexts/contexts";
|
||||
|
||||
const SUGGESTED_APPS = [
|
||||
|
|
@ -456,9 +456,9 @@ export function SearchIconButton() {
|
|||
<Icon name='search'/>
|
||||
</a>
|
||||
<Modal open={open} onClose={() => setOpen(false)} centered={false}>
|
||||
<ModalContent>
|
||||
<Modal.Content>
|
||||
{modalContents}
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import {Button, Header, Icon, Modal, ModalActions, ModalContent, ModalHeader} from "./Theme";
|
||||
import {Button, Header, Icon, Modal} from "./Theme";
|
||||
import {IconGroup} from "semantic-ui-react";
|
||||
import QRCode from "react-qr-code";
|
||||
import {sendNotification} from "../api";
|
||||
|
|
@ -43,17 +43,17 @@ export const ShareButton = () => {
|
|||
open={open}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<ModalHeader>Share this page</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Share this page</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Header as='h4'>Another user can scan this QR code to view this page</Header>
|
||||
<div style={{padding: '1em', backgroundColor: '#ffffff', display: "inline-block"}}>
|
||||
<QRCode value={window.location.href}/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<ShareEveryoneButton url={window.location.href} onClick={handleClose}/>
|
||||
<Button onClick={handleClose}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
<a href='#' onClick={handleOpen}>
|
||||
<IconGroup size='large'>
|
||||
|
|
|
|||
|
|
@ -1,360 +0,0 @@
|
|||
import React, {useContext, useEffect, useState} from 'react';
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {
|
||||
Accordion as SAccordion,
|
||||
Breadcrumb as SBreadcrumb,
|
||||
Button as SButton,
|
||||
Card as SCard,
|
||||
Divider as SDivider,
|
||||
Form as SForm,
|
||||
FormField as SFormField,
|
||||
FormGroup as SFormGroup,
|
||||
FormInput as SFormInput,
|
||||
Header as SHeader,
|
||||
Icon as SIcon,
|
||||
Loader as SLoader,
|
||||
Menu as SMenu,
|
||||
Modal as SModal,
|
||||
ModalActions as SModalActions,
|
||||
ModalContent as SModalContent,
|
||||
ModalDescription as SModalDescription,
|
||||
ModalHeader as SModalHeader,
|
||||
Placeholder as SPlaceholder,
|
||||
Popup as SPopup,
|
||||
Progress as SProgress,
|
||||
Segment as SSegment,
|
||||
Statistic as SStatistic,
|
||||
StatisticGroup as SStatisticGroup,
|
||||
Tab as STab,
|
||||
Table as STable,
|
||||
TabPane as STabPane,
|
||||
TextArea as STextArea
|
||||
} from "semantic-ui-react";
|
||||
import {ColorToSemanticHexColor} from "./Common";
|
||||
import _ from "lodash";
|
||||
|
||||
export const darkTheme = 'dark';
|
||||
export const lightTheme = 'light';
|
||||
export const defaultTheme = lightTheme;
|
||||
export const systemTheme = 'system';
|
||||
export const themeSessionKey = 'color-scheme';
|
||||
|
||||
export function ThemeProvider({children, ...props}) {
|
||||
if (!_.isEmpty(props)) {
|
||||
console.log(props);
|
||||
console.error('ThemeWrapper does not support props!');
|
||||
}
|
||||
|
||||
// Properties to manipulate elements with theme.
|
||||
// Invert when Semantic supports it. Example: <Menu {...i}>
|
||||
const [i, setI] = useState({});
|
||||
// Invert style when Semantic does not support it. Example: <p {...s}>This paragraph changes style</p>
|
||||
const [s, setS] = useState({});
|
||||
// Invert text when Semantic does not support it.
|
||||
const [t, setT] = useState({});
|
||||
const [inverted, setInverted] = useState('');
|
||||
|
||||
// theme can be one of [darkTheme, lightTheme]
|
||||
const [theme, setTheme] = useState(defaultTheme);
|
||||
// savedTheme can be one of [null, darkTheme, lightTheme, systemTheme]
|
||||
const [savedTheme, setSavedTheme] = useState(localStorage.getItem('color-scheme'));
|
||||
|
||||
const setDarkTheme = (save = false) => {
|
||||
console.debug('setDarkTheme');
|
||||
setI({inverted: true});
|
||||
setS({style: {backgroundColor: '#1B1C1D', color: '#dddddd'}});
|
||||
setT({style: {color: '#eeeeee'}});
|
||||
setInverted('inverted');
|
||||
setTheme(darkTheme);
|
||||
document.body.style.background = '#171616';
|
||||
if (save) {
|
||||
saveTheme(darkTheme);
|
||||
}
|
||||
}
|
||||
|
||||
const setLightTheme = (save = false) => {
|
||||
console.debug('setLightTheme');
|
||||
setI({inverted: undefined});
|
||||
setS({});
|
||||
setT({});
|
||||
setInverted('');
|
||||
setTheme(lightTheme);
|
||||
document.body.style.background = '#FFFFFF';
|
||||
if (save) {
|
||||
saveTheme(lightTheme);
|
||||
}
|
||||
}
|
||||
|
||||
const saveTheme = (value) => {
|
||||
setSavedTheme(value);
|
||||
localStorage.setItem(themeSessionKey, value);
|
||||
}
|
||||
|
||||
const cycleSavedTheme = (e) => {
|
||||
// Cycle: System -> Dark -> Light
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if (savedTheme === systemTheme || savedTheme == null) {
|
||||
saveTheme(darkTheme);
|
||||
} else if (savedTheme === darkTheme) {
|
||||
saveTheme(lightTheme);
|
||||
} else if (savedTheme === lightTheme) {
|
||||
saveTheme(systemTheme);
|
||||
} else {
|
||||
console.error(`Unknown theme! savedTheme=${savedTheme}`);
|
||||
}
|
||||
applyTheme();
|
||||
}
|
||||
|
||||
const matchTheme = () => {
|
||||
// Returns darkTheme if saved theme is dark, lightTheme if saved theme is dark,
|
||||
// darkTheme if system prefers dark, otherwise lightTheme.
|
||||
const colorScheme = localStorage.getItem(themeSessionKey);
|
||||
setSavedTheme(colorScheme);
|
||||
if (colorScheme === darkTheme) {
|
||||
return darkTheme;
|
||||
} else if (colorScheme === lightTheme) {
|
||||
return lightTheme
|
||||
}
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? darkTheme : lightTheme;
|
||||
}
|
||||
|
||||
const applyTheme = () => {
|
||||
const match = matchTheme();
|
||||
if (match === darkTheme) {
|
||||
setDarkTheme();
|
||||
} else {
|
||||
setLightTheme();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
applyTheme();
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyTheme);
|
||||
}, []);
|
||||
|
||||
const themeValue = {
|
||||
i, // Used for Semantic elements which support "inverted".
|
||||
s, // Used to invert the style some elements.
|
||||
t, // Used to invert text.
|
||||
inverted, // Used to add "invert" to className.
|
||||
theme,
|
||||
savedTheme,
|
||||
setDarkTheme,
|
||||
setLightTheme,
|
||||
cycleSavedTheme,
|
||||
};
|
||||
|
||||
return <ThemeContext.Provider value={themeValue}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
}
|
||||
|
||||
// Simple wrappers for Semantic UI elements to use the current theme.
|
||||
|
||||
const invertedNull = (props) => {
|
||||
if (props['inverted'] === true) {
|
||||
props['inverted'] = null;
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
const defaultGrey = (props, inverted) => {
|
||||
// Some elements look softer when grey, use grey only if another color is not provided.
|
||||
if (inverted) {
|
||||
return {color: 'grey', ...props};
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
export function Accordion(props) {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
props = defaultGrey({...i, ...props}, inverted);
|
||||
return <SAccordion {...props}/>
|
||||
}
|
||||
|
||||
export const Button = React.forwardRef((props, ref) => {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
props = defaultGrey({...i, ...props}, inverted);
|
||||
return <SButton ref={ref} {...props}/>
|
||||
});
|
||||
|
||||
export function Divider({...props}) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SDivider {...props}/>
|
||||
}
|
||||
|
||||
export function Header(props) {
|
||||
const {t} = useContext(ThemeContext);
|
||||
props = {...t, ...props};
|
||||
return <SHeader {...props}/>
|
||||
}
|
||||
|
||||
export function Form(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SForm {...props}/>
|
||||
}
|
||||
|
||||
export function FormField(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = invertedNull({...i, ...props});
|
||||
return <SFormField {...props}/>
|
||||
}
|
||||
|
||||
export function FormGroup(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = invertedNull({...i, ...props});
|
||||
return <SFormGroup {...props}/>
|
||||
}
|
||||
|
||||
export function FormInput(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SFormInput {...props}/>
|
||||
}
|
||||
|
||||
export function Icon(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SIcon {...props}/>
|
||||
}
|
||||
|
||||
export function Loader(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SLoader {...props}/>
|
||||
}
|
||||
|
||||
export function Menu(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SMenu {...props}/>
|
||||
}
|
||||
|
||||
export function Modal({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModal {...props} className={`${inverted}`}/>
|
||||
}
|
||||
|
||||
export function ModalActions({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalActions {...props} className={`${inverted}`}/>
|
||||
}
|
||||
|
||||
export function ModalContent({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalContent {...props} className={`${inverted}`}/>
|
||||
}
|
||||
|
||||
export function ModalDescription({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalDescription {...props} className={`${inverted}`}/>
|
||||
}
|
||||
|
||||
export function ModalHeader({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalHeader {...props} className={`${inverted}`}>
|
||||
{props.children}
|
||||
</SModalHeader>
|
||||
}
|
||||
|
||||
export function Placeholder(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SPlaceholder {...props}/>
|
||||
}
|
||||
|
||||
export function Popup(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SPopup {...i} style={{border: '1px solid grey'}} {...props}/>
|
||||
}
|
||||
|
||||
export function Progress(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SProgress {...props}/>
|
||||
}
|
||||
|
||||
export function Segment(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <SSegment {...props}/>
|
||||
}
|
||||
|
||||
export function Statistic(props) {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
props = defaultGrey({...i, ...props}, inverted);
|
||||
return <SStatistic {...props}/>
|
||||
}
|
||||
|
||||
export function StatisticGroup(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
props['style'] = {...props['style'], marginLeft: 0, marginRight: 0};
|
||||
return <SStatisticGroup {...props}/>
|
||||
}
|
||||
|
||||
export function Tab(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = invertedNull({...i, ...props});
|
||||
return <STab {...props}/>
|
||||
}
|
||||
|
||||
export function TabPane(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <STabPane {...props}/>
|
||||
}
|
||||
|
||||
export function Table(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = {...i, ...props};
|
||||
return <STable {...props}/>
|
||||
}
|
||||
|
||||
export function TextArea(props) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
props = invertedNull({...i, ...props});
|
||||
return <STextArea {...props}/>
|
||||
}
|
||||
|
||||
export function CardIcon({onClick, ...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
const cardIcon = <center className={`card-icon ${inverted}`} {...props}/>;
|
||||
if (onClick) {
|
||||
return <div onClick={onClick} className='clickable'>
|
||||
{cardIcon}
|
||||
</div>
|
||||
} else {
|
||||
return cardIcon;
|
||||
}
|
||||
}
|
||||
|
||||
export function Card({color, ...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
|
||||
props['style'] = props['style'] || {};
|
||||
let emphasisColor = ColorToSemanticHexColor(color);
|
||||
if (emphasisColor) {
|
||||
// Increase drop shadow to emphasize color.
|
||||
const borderColor = inverted ? '#888' : '#ddd';
|
||||
props['style']['boxShadow'] = `0 0 0 2px ${borderColor}, 0 5px 0 0 ${emphasisColor}, 0 0px 3px 0 #d4d4d5`;
|
||||
}
|
||||
return <SCard {...props}/>
|
||||
}
|
||||
|
||||
export function Breadcrumb({...props}) {
|
||||
const {t} = useContext(ThemeContext);
|
||||
return <SBreadcrumb {...props} {...t}/>
|
||||
}
|
||||
|
||||
export function BreadcrumbDivider({...props}) {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
|
||||
// TODO this only handles icons for now.
|
||||
let className = `divider icon ${inverted} ${props.icon || ''}`;
|
||||
return <i aria-hidden="true" className={className}></i>
|
||||
}
|
||||
500
app/src/components/Theme.tsx
Normal file
500
app/src/components/Theme.tsx
Normal file
|
|
@ -0,0 +1,500 @@
|
|||
import React, {useContext, useEffect, useState, forwardRef, HTMLAttributes, CSSProperties} from 'react';
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {
|
||||
Accordion as SAccordion,
|
||||
Breadcrumb as SBreadcrumb,
|
||||
Button as SButton,
|
||||
Card as SCard,
|
||||
Divider as SDivider,
|
||||
Form as SForm,
|
||||
FormField as SFormField,
|
||||
FormGroup as SFormGroup,
|
||||
FormInput as SFormInput,
|
||||
Header as SHeader,
|
||||
Icon as SIcon,
|
||||
Loader as SLoader,
|
||||
Menu as SMenu,
|
||||
Modal as SModal,
|
||||
ModalActions as SModalActions,
|
||||
ModalContent as SModalContent,
|
||||
ModalDescription as SModalDescription,
|
||||
ModalHeader as SModalHeader,
|
||||
Placeholder as SPlaceholder,
|
||||
Popup as SPopup,
|
||||
Progress as SProgress,
|
||||
Segment as SSegment,
|
||||
Statistic as SStatistic,
|
||||
StatisticGroup as SStatisticGroup,
|
||||
Tab as STab,
|
||||
Table as STable,
|
||||
TabPane as STabPane,
|
||||
TextArea as STextArea,
|
||||
AccordionProps,
|
||||
BreadcrumbProps,
|
||||
ButtonProps,
|
||||
CardProps as SCardProps,
|
||||
DividerProps,
|
||||
FormProps,
|
||||
FormFieldProps,
|
||||
FormGroupProps,
|
||||
FormInputProps,
|
||||
HeaderProps,
|
||||
IconProps,
|
||||
LoaderProps,
|
||||
MenuProps,
|
||||
ModalProps,
|
||||
ModalActionsProps,
|
||||
ModalContentProps,
|
||||
ModalDescriptionProps,
|
||||
ModalHeaderProps,
|
||||
PlaceholderProps,
|
||||
PopupProps,
|
||||
ProgressProps,
|
||||
SegmentProps,
|
||||
StatisticProps,
|
||||
StatisticGroupProps,
|
||||
TabProps,
|
||||
TableProps,
|
||||
TabPaneProps,
|
||||
TextAreaProps,
|
||||
} from "semantic-ui-react";
|
||||
import {ColorToSemanticHexColor} from "./Common";
|
||||
import _ from "lodash";
|
||||
import {ThemeContextValue, ThemeName, SavedThemeName} from "../types/theme";
|
||||
|
||||
export const darkTheme = 'dark';
|
||||
export const lightTheme = 'light';
|
||||
export const defaultTheme = lightTheme;
|
||||
export const systemTheme = 'system';
|
||||
export const themeSessionKey = 'color-scheme';
|
||||
|
||||
interface ThemeProviderProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function ThemeProvider({children, ...props}: ThemeProviderProps) {
|
||||
if (!_.isEmpty(props)) {
|
||||
console.log(props);
|
||||
console.error('ThemeWrapper does not support props!');
|
||||
}
|
||||
|
||||
// Properties to manipulate elements with theme.
|
||||
// Invert when Semantic supports it. Example: <Menu {...i}>
|
||||
const [i, setI] = useState<{inverted?: boolean}>({});
|
||||
// Invert style when Semantic does not support it. Example: <p {...s}>This paragraph changes style</p>
|
||||
const [s, setS] = useState<{style?: CSSProperties}>({});
|
||||
// Invert text when Semantic does not support it.
|
||||
const [t, setT] = useState<{style?: CSSProperties}>({});
|
||||
const [inverted, setInverted] = useState<string>('');
|
||||
|
||||
// theme can be one of [darkTheme, lightTheme]
|
||||
const [theme, setTheme] = useState<ThemeName>(lightTheme);
|
||||
// savedTheme can be one of [null, darkTheme, lightTheme, systemTheme]
|
||||
const [savedTheme, setSavedTheme] = useState<SavedThemeName>(
|
||||
localStorage.getItem('color-scheme') as SavedThemeName
|
||||
);
|
||||
|
||||
const setDarkTheme = (save = false) => {
|
||||
console.debug('setDarkTheme');
|
||||
setI({inverted: true});
|
||||
setS({style: {backgroundColor: '#1B1C1D', color: '#dddddd'}});
|
||||
setT({style: {color: '#eeeeee'}});
|
||||
setInverted('inverted');
|
||||
setTheme(darkTheme);
|
||||
document.body.style.background = '#171616';
|
||||
if (save) {
|
||||
saveTheme(darkTheme);
|
||||
}
|
||||
}
|
||||
|
||||
const setLightTheme = (save = false) => {
|
||||
console.debug('setLightTheme');
|
||||
setI({inverted: undefined});
|
||||
setS({});
|
||||
setT({});
|
||||
setInverted('');
|
||||
setTheme(lightTheme);
|
||||
document.body.style.background = '#FFFFFF';
|
||||
if (save) {
|
||||
saveTheme(lightTheme);
|
||||
}
|
||||
}
|
||||
|
||||
const saveTheme = (value: ThemeName) => {
|
||||
setSavedTheme(value);
|
||||
localStorage.setItem(themeSessionKey, value);
|
||||
}
|
||||
|
||||
const cycleSavedTheme = (e?: React.MouseEvent) => {
|
||||
// Cycle: System -> Dark -> Light
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if (savedTheme === systemTheme || savedTheme == null) {
|
||||
saveTheme(darkTheme);
|
||||
} else if (savedTheme === darkTheme) {
|
||||
saveTheme(lightTheme);
|
||||
} else if (savedTheme === lightTheme) {
|
||||
saveTheme(systemTheme as ThemeName);
|
||||
} else {
|
||||
console.error(`Unknown theme! savedTheme=${savedTheme}`);
|
||||
}
|
||||
applyTheme();
|
||||
}
|
||||
|
||||
const matchTheme = (): ThemeName => {
|
||||
// Returns darkTheme if saved theme is dark, lightTheme if saved theme is dark,
|
||||
// darkTheme if system prefers dark, otherwise lightTheme.
|
||||
const colorScheme = localStorage.getItem(themeSessionKey);
|
||||
setSavedTheme(colorScheme as SavedThemeName);
|
||||
if (colorScheme === darkTheme) {
|
||||
return darkTheme;
|
||||
} else if (colorScheme === lightTheme) {
|
||||
return lightTheme
|
||||
}
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? darkTheme : lightTheme;
|
||||
}
|
||||
|
||||
const applyTheme = () => {
|
||||
const match = matchTheme();
|
||||
if (match === darkTheme) {
|
||||
setDarkTheme();
|
||||
} else {
|
||||
setLightTheme();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
applyTheme();
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyTheme);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const themeValue: ThemeContextValue = {
|
||||
i, // Used for Semantic elements which support "inverted".
|
||||
s, // Used to invert the style some elements.
|
||||
t, // Used to invert text.
|
||||
inverted, // Used to add "invert" to className.
|
||||
theme,
|
||||
savedTheme,
|
||||
setDarkTheme,
|
||||
setLightTheme,
|
||||
cycleSavedTheme,
|
||||
};
|
||||
|
||||
return <ThemeContext.Provider value={themeValue}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
}
|
||||
|
||||
// Simple wrappers for Semantic UI elements to use the current theme.
|
||||
|
||||
const invertedNull = <T extends {inverted?: boolean | null}>(props: T): T => {
|
||||
if (props['inverted'] === true) {
|
||||
return {...props, inverted: null};
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
const defaultGrey = <T extends object>(props: T, inverted: boolean): T => {
|
||||
// Some elements look softer when grey, use grey only if another color is not provided.
|
||||
if (inverted) {
|
||||
return {color: 'grey', ...props} as T;
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
export function Accordion(props: AccordionProps) {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
||||
return <SAccordion {...mergedProps}/>
|
||||
}
|
||||
|
||||
export const Button = forwardRef<any, ButtonProps>((props, ref) => {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
||||
return <SButton ref={ref} {...mergedProps}/>
|
||||
});
|
||||
Button.displayName = 'Button';
|
||||
|
||||
export function Divider(props: DividerProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SDivider {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Header(props: HeaderProps) {
|
||||
const {t} = useContext(ThemeContext);
|
||||
return <SHeader {...t} {...props}/>
|
||||
}
|
||||
|
||||
export function Icon(props: IconProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SIcon {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Loader(props: LoaderProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SLoader {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Menu(props: MenuProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SMenu {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Placeholder(props: PlaceholderProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SPlaceholder {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Popup(props: PopupProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SPopup {...i} style={{border: '1px solid grey'}} {...props}/>
|
||||
}
|
||||
|
||||
export function Progress(props: ProgressProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SProgress {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Segment(props: SegmentProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SSegment {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function Table(props: TableProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <STable {...i} {...props}/>
|
||||
}
|
||||
|
||||
export function TextArea(props: TextAreaProps) {
|
||||
const {i} = useContext(ThemeContext);
|
||||
const mergedProps = invertedNull({...i, ...props});
|
||||
return <STextArea {...mergedProps}/>
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// COMPOUND COMPONENTS
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Modal Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type ModalActionsComponent = React.FC<ModalActionsProps>;
|
||||
type ModalContentComponent = React.FC<ModalContentProps>;
|
||||
type ModalDescriptionComponent = React.FC<ModalDescriptionProps>;
|
||||
type ModalHeaderComponent = React.FC<ModalHeaderProps>;
|
||||
|
||||
interface ModalComponent extends React.FC<ModalProps> {
|
||||
Actions: ModalActionsComponent;
|
||||
Content: ModalContentComponent;
|
||||
Description: ModalDescriptionComponent;
|
||||
Header: ModalHeaderComponent;
|
||||
}
|
||||
|
||||
const ModalActions: ModalActionsComponent = (props) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalActions {...props} className={`${inverted}`}/>
|
||||
};
|
||||
|
||||
const ModalContent: ModalContentComponent = (props) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalContent {...props} className={`${inverted}`}/>
|
||||
};
|
||||
|
||||
const ModalDescription: ModalDescriptionComponent = (props) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalDescription {...props} className={`${inverted}`}/>
|
||||
};
|
||||
|
||||
const ModalHeader: ModalHeaderComponent = (props) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModalHeader {...props} className={`${inverted}`}>
|
||||
{props.children}
|
||||
</SModalHeader>
|
||||
};
|
||||
|
||||
const ModalBase: React.FC<ModalProps> = (props) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
return <SModal {...props} className={`${inverted}`}/>
|
||||
};
|
||||
|
||||
export const Modal: ModalComponent = Object.assign(ModalBase, {
|
||||
Actions: ModalActions,
|
||||
Content: ModalContent,
|
||||
Description: ModalDescription,
|
||||
Header: ModalHeader,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Form Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type FormFieldComponent = React.FC<FormFieldProps>;
|
||||
type FormGroupComponent = React.FC<FormGroupProps>;
|
||||
type FormInputComponent = React.FC<FormInputProps>;
|
||||
|
||||
interface FormComponent extends React.FC<FormProps> {
|
||||
Field: FormFieldComponent;
|
||||
Group: FormGroupComponent;
|
||||
Input: FormInputComponent;
|
||||
}
|
||||
|
||||
const FormField: FormFieldComponent = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
const mergedProps = invertedNull({...i, ...props});
|
||||
return <SFormField {...mergedProps}/>
|
||||
};
|
||||
|
||||
const FormGroup: FormGroupComponent = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
const mergedProps = invertedNull({...i, ...props});
|
||||
return <SFormGroup {...mergedProps}/>
|
||||
};
|
||||
|
||||
const FormInput: FormInputComponent = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SFormInput {...i} {...props}/>
|
||||
};
|
||||
|
||||
const FormBase: React.FC<FormProps> = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <SForm {...i} {...props}/>
|
||||
};
|
||||
|
||||
export const Form: FormComponent = Object.assign(FormBase, {
|
||||
Field: FormField,
|
||||
Group: FormGroup,
|
||||
Input: FormInput,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Card Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
interface CardIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
onClick?: () => void;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
type CardIconComponent = React.FC<CardIconProps>;
|
||||
|
||||
interface CardProps extends Omit<SCardProps, 'color'> {
|
||||
color?: string;
|
||||
}
|
||||
|
||||
interface CardComponent extends React.FC<CardProps> {
|
||||
Icon: CardIconComponent;
|
||||
}
|
||||
|
||||
const CardIcon: CardIconComponent = ({onClick, children, ...props}) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
const cardIcon = <center className={`card-icon ${inverted}`} {...props}>{children}</center>;
|
||||
if (onClick) {
|
||||
return <div onClick={onClick} className='clickable'>
|
||||
{cardIcon}
|
||||
</div>
|
||||
} else {
|
||||
return cardIcon;
|
||||
}
|
||||
};
|
||||
|
||||
const CardBase: React.FC<CardProps> = ({color, ...props}) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
|
||||
const style: CSSProperties = props.style || {};
|
||||
const emphasisColor = ColorToSemanticHexColor(color);
|
||||
if (emphasisColor) {
|
||||
// Increase drop shadow to emphasize color.
|
||||
const borderColor = inverted ? '#888' : '#ddd';
|
||||
style.boxShadow = `0 0 0 2px ${borderColor}, 0 5px 0 0 ${emphasisColor}, 0 0px 3px 0 #d4d4d5`;
|
||||
}
|
||||
return <SCard {...props} style={style}/>
|
||||
};
|
||||
|
||||
export const Card: CardComponent = Object.assign(CardBase, {
|
||||
Icon: CardIcon,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Tab Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type TabPaneComponent = React.FC<TabPaneProps>;
|
||||
|
||||
interface TabComponent extends React.FC<TabProps> {
|
||||
Pane: TabPaneComponent;
|
||||
}
|
||||
|
||||
const TabPane: TabPaneComponent = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
return <STabPane {...i} {...props}/>
|
||||
};
|
||||
|
||||
const TabBase: React.FC<TabProps> = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
const mergedProps = invertedNull({...i, ...props});
|
||||
return <STab {...mergedProps}/>
|
||||
};
|
||||
|
||||
export const Tab: TabComponent = Object.assign(TabBase, {
|
||||
Pane: TabPane,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Statistic Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type StatisticGroupComponent = React.FC<StatisticGroupProps>;
|
||||
|
||||
interface StatisticComponent extends React.FC<StatisticProps> {
|
||||
Group: StatisticGroupComponent;
|
||||
}
|
||||
|
||||
const StatisticGroup: StatisticGroupComponent = (props) => {
|
||||
const {i} = useContext(ThemeContext);
|
||||
const style: CSSProperties = {...props.style, marginLeft: 0, marginRight: 0};
|
||||
return <SStatisticGroup {...i} {...props} style={style}/>
|
||||
};
|
||||
|
||||
const StatisticBase: React.FC<StatisticProps> = (props) => {
|
||||
const {i, inverted} = useContext(ThemeContext);
|
||||
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
||||
return <SStatistic {...mergedProps}/>
|
||||
};
|
||||
|
||||
export const Statistic: StatisticComponent = Object.assign(StatisticBase, {
|
||||
Group: StatisticGroup,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Breadcrumb Compound Component
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
interface BreadcrumbDividerProps {
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
type BreadcrumbDividerComponent = React.FC<BreadcrumbDividerProps>;
|
||||
|
||||
interface BreadcrumbComponent extends React.FC<BreadcrumbProps> {
|
||||
Divider: BreadcrumbDividerComponent;
|
||||
}
|
||||
|
||||
const BreadcrumbDivider: BreadcrumbDividerComponent = ({icon, ...props}) => {
|
||||
const {inverted} = useContext(ThemeContext);
|
||||
|
||||
// TODO this only handles icons for now.
|
||||
const className = `divider icon ${inverted} ${icon || ''}`;
|
||||
return <i aria-hidden="true" className={className}></i>
|
||||
};
|
||||
|
||||
const BreadcrumbBase: React.FC<BreadcrumbProps> = (props) => {
|
||||
const {t} = useContext(ThemeContext);
|
||||
return <SBreadcrumb {...props} {...t}/>
|
||||
};
|
||||
|
||||
export const Breadcrumb: BreadcrumbComponent = Object.assign(BreadcrumbBase, {
|
||||
Divider: BreadcrumbDivider,
|
||||
});
|
||||
|
|
@ -20,7 +20,7 @@ import Container from "semantic-ui-react/dist/commonjs/elements/Container";
|
|||
import {VideoPlaceholder} from "./Placeholder";
|
||||
import {useChannel, useVideoExtras} from "../hooks/customHooks";
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import {Button, darkTheme, Header, Icon, Segment, Tab, TabPane} from "./Theme";
|
||||
import {Button, darkTheme, Header, Icon, Segment, Tab} from "./Theme";
|
||||
import {VideoCard} from "./Videos";
|
||||
import {TagsSelector} from "../Tags";
|
||||
import {Comment, CommentGroup, Label} from "semantic-ui-react";
|
||||
|
|
@ -228,22 +228,22 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
}
|
||||
|
||||
const descriptionPane = {
|
||||
menuItem: 'Description', render: () => <TabPane>
|
||||
menuItem: 'Description', render: () => <Tab.Pane>
|
||||
<pre className="wrap-text">
|
||||
{description}
|
||||
</pre>
|
||||
</TabPane>
|
||||
</Tab.Pane>
|
||||
};
|
||||
|
||||
const captionsPane = {
|
||||
menuItem: 'Captions', render: () => <TabPane>
|
||||
menuItem: 'Captions', render: () => <Tab.Pane>
|
||||
<pre>{captions || 'No captions available.'}</pre>
|
||||
</TabPane>
|
||||
</Tab.Pane>
|
||||
};
|
||||
|
||||
const {poster_file, info_json_file} = video;
|
||||
const filesPane = {
|
||||
menuItem: 'Files', render: () => <TabPane>
|
||||
menuItem: 'Files', render: () => <Tab.Pane>
|
||||
<h3>Video File</h3>
|
||||
{videoFileLink(video['video_path'])}
|
||||
|
||||
|
|
@ -270,14 +270,14 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
|
||||
<h4>Directory</h4>
|
||||
{videoFileLink(videoFile['directory'], true)}
|
||||
</TabPane>
|
||||
</Tab.Pane>
|
||||
}
|
||||
|
||||
const commentsPane = {
|
||||
menuItem: 'Comments', render: () => <TabPane>
|
||||
menuItem: 'Comments', render: () => <Tab.Pane>
|
||||
<Header as='h3'>Top Comments</Header>
|
||||
<Comments comments={comments} video={videoFile}/>
|
||||
</TabPane>,
|
||||
</Tab.Pane>,
|
||||
};
|
||||
|
||||
const tabPanes = [commentsPane, descriptionPane, filesPane, captionsPane];
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import {useChannel, useSearchOrder, useSearchVideos, useVideo, useVideoStatistic
|
|||
import {FileRowTagIcon, FilesView} from "./Files";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import {Button, Card, Header, Loader, Placeholder, Popup, Segment, Statistic, StatisticGroup} from "./Theme";
|
||||
import {Button, Card, Header, Loader, Placeholder, Popup, Segment, Statistic} from "./Theme";
|
||||
import {
|
||||
deleteVideos,
|
||||
fetchBrowserProfiles,
|
||||
|
|
@ -490,7 +490,7 @@ function VideosStatistics() {
|
|||
const buildSegment = (title, names, stats) => {
|
||||
return <Segment>
|
||||
<Header textAlign='center' as='h1'>{title}</Header>
|
||||
<StatisticGroup>
|
||||
<Statistic.Group>
|
||||
{names.map(
|
||||
({key, label}) =>
|
||||
<Statistic key={key} style={{margin: '2em'}}>
|
||||
|
|
@ -498,7 +498,7 @@ function VideosStatistics() {
|
|||
<StatisticLabel>{label}</StatisticLabel>
|
||||
</Statistic>
|
||||
)}
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import {
|
|||
Icon,
|
||||
Loader,
|
||||
Modal,
|
||||
ModalActions,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
Placeholder,
|
||||
Segment
|
||||
} from "./Theme";
|
||||
|
|
@ -134,18 +131,18 @@ export const OutdatedZimsMessage = ({onClick}) => {
|
|||
onClose={onClose}
|
||||
onOpen={onOpen}
|
||||
>
|
||||
<ModalHeader>Delete</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Delete</Modal.Header>
|
||||
<Modal.Content>
|
||||
{modalContent}
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<APIButton
|
||||
color='red'
|
||||
floated='left'
|
||||
onClick={handleDelete}
|
||||
>Delete</APIButton>
|
||||
<Button onClick={onClose}>Close</Button>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
|
||||
<Link to='/files?folders=zims'><SButton>Delete Manually</SButton></Link>
|
||||
|
|
@ -203,7 +200,7 @@ const ZimSearchEntry = ({zimId, onTag, onUntag, entry}) => {
|
|||
<Modal closeIcon
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}>
|
||||
<ModalContent>
|
||||
<Modal.Content>
|
||||
<div className='full-height'>
|
||||
<ZimViewer src={url} style={{
|
||||
height: '100%', width: '100%', border: 'none', position: 'absolute', top: 0,
|
||||
|
|
@ -211,8 +208,8 @@ const ZimSearchEntry = ({zimId, onTag, onUntag, entry}) => {
|
|||
backgroundColor: '#ffffff',
|
||||
}}/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Grid>
|
||||
<Grid.Column mobile={10} tablet={14}>
|
||||
<TagsSelector selectedTagNames={tag_names} onAdd={localAddTag} onRemove={localUntag}/>
|
||||
|
|
@ -221,7 +218,7 @@ const ZimSearchEntry = ({zimId, onTag, onUntag, entry}) => {
|
|||
<Button color='blue' as='a' href={url} target='_blank'>Open</Button>
|
||||
</Grid.Column>
|
||||
</Grid>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
</div>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
TableHeaderCell,
|
||||
TableRow
|
||||
} from "semantic-ui-react";
|
||||
import {Button, Header, Modal, ModalActions, ModalContent, ModalHeader, Placeholder, Segment, Table} from "../Theme";
|
||||
import {Button, Header, Modal, Placeholder, Segment, Table} from "../Theme";
|
||||
import {useDownloads} from "../../hooks/customHooks";
|
||||
import {
|
||||
EditArchiveDownloadForm,
|
||||
|
|
@ -143,13 +143,13 @@ function RecurringDownloadRow({download, fetchDownloads, onDelete}) {
|
|||
open={errorModalOpen}
|
||||
trigger={<Button icon='exclamation circle' color='orange'/>}
|
||||
>
|
||||
<ModalHeader>Download Error</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Download Error</Modal.Header>
|
||||
<Modal.Content>
|
||||
<pre style={{overflowX: 'scroll'}}>{error}</pre>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<SButton onClick={handleEditClose}>Close</SButton>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>;
|
||||
|
||||
const editButton = <Button icon='edit' onClick={handleEditOpen}/>;
|
||||
|
|
@ -221,10 +221,10 @@ function RecurringDownloadRow({download, fetchDownloads, onDelete}) {
|
|||
open={editModalOpen}
|
||||
onClose={handleEditClose}
|
||||
>
|
||||
<ModalHeader>Edit Download</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Edit Download</Modal.Header>
|
||||
<Modal.Content>
|
||||
{editForm}
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>;
|
||||
|
||||
return <TableRow>
|
||||
|
|
@ -357,10 +357,10 @@ class OnceDownloadRow extends React.Component {
|
|||
closeIcon
|
||||
trigger={<Button icon='exclamation circle' color='red'/>}
|
||||
>
|
||||
<ModalHeader>Download Error</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Download Error</Modal.Header>
|
||||
<Modal.Content>
|
||||
<pre style={{overflowX: 'scroll'}}>{error}</pre>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
|
@ -375,8 +375,8 @@ class OnceDownloadRow extends React.Component {
|
|||
open={this.state.editModalOpen}
|
||||
onClose={this.handleEditClose}
|
||||
>
|
||||
<ModalHeader>Edit Video Download</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Edit Video Download</Modal.Header>
|
||||
<Modal.Content>
|
||||
<EditVideosDownloadForm
|
||||
download={{
|
||||
urls: url,
|
||||
|
|
@ -387,7 +387,7 @@ class OnceDownloadRow extends React.Component {
|
|||
onSuccess={this.handleEditSuccess}
|
||||
onDelete={this.handleDelete}
|
||||
/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
);
|
||||
} else if (downloader === Downloaders.Archive) {
|
||||
|
|
@ -397,8 +397,8 @@ class OnceDownloadRow extends React.Component {
|
|||
open={this.state.editModalOpen}
|
||||
onClose={this.handleEditClose}
|
||||
>
|
||||
<ModalHeader>Edit Archive Download</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>Edit Archive Download</Modal.Header>
|
||||
<Modal.Content>
|
||||
<EditArchiveDownloadForm
|
||||
download={{
|
||||
urls: url,
|
||||
|
|
@ -409,7 +409,7 @@ class OnceDownloadRow extends React.Component {
|
|||
onSuccess={this.handleEditSuccess}
|
||||
onDelete={this.handleDelete}
|
||||
/>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,9 @@ import {
|
|||
Button,
|
||||
Divider,
|
||||
Form,
|
||||
FormField,
|
||||
FormGroup,
|
||||
FormInput,
|
||||
Header,
|
||||
Loader,
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
Segment
|
||||
} from "../Theme";
|
||||
import {ButtonGroup, Container, Dimmer, Dropdown, GridColumn, GridRow, Icon, Input} from "semantic-ui-react";
|
||||
|
|
@ -409,8 +404,8 @@ export function SettingsPage() {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<FormGroup inline>
|
||||
<FormInput
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Download Timeout</b>
|
||||
<InfoPopup content='Downloads will be stopped after this many seconds have elapsed.
|
||||
|
|
@ -420,28 +415,28 @@ export function SettingsPage() {
|
|||
disabled={disabled || state.download_timeout === null}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_timeout', i.value)}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Form.Group>
|
||||
|
||||
<FormGroup inline>
|
||||
<FormInput
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label='Hotspot SSID'
|
||||
value={state.hotspot_ssid}
|
||||
disabled={disabled || state.hotspot_ssid === null}
|
||||
onChange={(e, i) => setState({...state, hotspot_ssid: i.value})}
|
||||
/>
|
||||
<FormInput
|
||||
<Form.Input
|
||||
label='Hotspot Password'
|
||||
disabled={disabled || state.hotspot_password === null}
|
||||
value={state.hotspot_password}
|
||||
onChange={(e, i) => setState({...state, hotspot_password: i.value})}
|
||||
/>
|
||||
<FormInput
|
||||
<Form.Input
|
||||
label='Hotspot Device'
|
||||
disabled={disabled || state.hotspot_password === null}
|
||||
value={state.hotspot_device}
|
||||
onChange={(e, i) => handleInputChange(e, 'hotspot_device', i.value)}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Form.Group>
|
||||
|
||||
<Modal closeIcon
|
||||
onClose={() => setQrOpen(false)}
|
||||
|
|
@ -449,14 +444,14 @@ export function SettingsPage() {
|
|||
open={qrOpen}
|
||||
trigger={qrButton}
|
||||
>
|
||||
<ModalHeader>
|
||||
<Modal.Header>
|
||||
Scan this code to join the hotspot
|
||||
</ModalHeader>
|
||||
<ModalContent>
|
||||
</Modal.Header>
|
||||
<Modal.Content>
|
||||
<div style={{display: 'inline-block', backgroundColor: '#ffffff', padding: '1em'}}>
|
||||
<QRCode value={qrCodeValue} size={300}/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
|
||||
<br/>
|
||||
|
|
@ -503,7 +498,7 @@ export function SettingsPage() {
|
|||
<Grid stackable>
|
||||
<GridRow columns={2}>
|
||||
<GridColumn>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>Archive Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
|
|
@ -511,10 +506,10 @@ export function SettingsPage() {
|
|||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'archive_destination', d.value)}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
<GridColumn>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>Videos Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
|
|
@ -522,12 +517,12 @@ export function SettingsPage() {
|
|||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'videos_destination', d.value)}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
<GridRow columns={2}>
|
||||
<GridColumn>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>Map Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
|
|
@ -535,10 +530,10 @@ export function SettingsPage() {
|
|||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'map_destination', d.value)}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
<GridColumn>
|
||||
<FormField>
|
||||
<Form.Field>
|
||||
<label>Zims Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
|
|
@ -546,7 +541,7 @@ export function SettingsPage() {
|
|||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'zims_destination', d.value)}
|
||||
/>
|
||||
</FormField>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
<GridRow columns={1}>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {Accordion, Header, Progress, Segment, Statistic, StatisticGroup, Table} from "../Theme";
|
||||
import {Accordion, Header, Progress, Segment, Statistic, Table} from "../Theme";
|
||||
import React, {useContext} from "react";
|
||||
import {humanBandwidth, humanFileSize, InfoHeader, LoadStatistic, useTitle} from "../Common";
|
||||
import {ProgressPlaceholder} from "../Placeholder";
|
||||
|
|
@ -248,7 +248,7 @@ export function StatusPage() {
|
|||
<Segment>
|
||||
{cpuProgress}
|
||||
{memoryUsageProgress}
|
||||
<StatisticGroup>
|
||||
<Statistic.Group>
|
||||
<CPUTemperatureStatistic
|
||||
id='cpu_temperature_statistic'
|
||||
temperature={temperature}
|
||||
|
|
@ -258,14 +258,14 @@ export function StatusPage() {
|
|||
<LoadStatistic label='1 Minute Load' value={minute_1} cores={cores}/>
|
||||
<LoadStatistic label='5 Minute Load' value={minute_5} cores={cores}/>
|
||||
<LoadStatistic label='15 Minute Load' value={minute_15} cores={cores}/>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Segment>
|
||||
{cpuProgress}
|
||||
{memoryUsageProgress}
|
||||
<StatisticGroup size='mini'>
|
||||
<Statistic.Group size='mini'>
|
||||
<CPUTemperatureStatistic
|
||||
id='cpu_temperature_statistic'
|
||||
temperature={temperature}
|
||||
|
|
@ -276,7 +276,7 @@ export function StatusPage() {
|
|||
<LoadStatistic label='1 Min. Load' value={minute_1} cores={cores}/>
|
||||
<LoadStatistic label='5 Min.' value={minute_5} cores={cores}/>
|
||||
<LoadStatistic label='15 Min.' value={minute_15} cores={cores}/>
|
||||
</StatisticGroup>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
</Media>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React, {useCallback, useEffect, useState} from 'react';
|
||||
import {Grid, Input} from 'semantic-ui-react';
|
||||
import Message from 'semantic-ui-react/dist/commonjs/collections/Message';
|
||||
import {Button, Modal, ModalActions, ModalContent, ModalHeader} from '../Theme';
|
||||
import {Button, Modal} from '../Theme';
|
||||
import {TagsSelector} from '../../Tags';
|
||||
import {APIButton, Toggle} from '../Common';
|
||||
|
||||
|
|
@ -105,8 +105,8 @@ export function CollectionTagModal({
|
|||
onClose={handleClose}
|
||||
closeIcon
|
||||
>
|
||||
<ModalHeader>{modalTitle}</ModalHeader>
|
||||
<ModalContent>
|
||||
<Modal.Header>{modalTitle}</Modal.Header>
|
||||
<Modal.Content>
|
||||
<Grid columns={1}>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
|
|
@ -152,15 +152,15 @@ export function CollectionTagModal({
|
|||
</Grid.Row>
|
||||
)}
|
||||
</Grid>
|
||||
</ModalContent>
|
||||
<ModalActions>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button onClick={handleClose}>Cancel</Button>
|
||||
<APIButton
|
||||
color='violet'
|
||||
onClick={handleSave}
|
||||
obeyWROLMode={true}
|
||||
>{saveButtonText}</APIButton>
|
||||
</ModalActions>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ import {act, render, screen, waitFor} from '../../test-utils';
|
|||
import userEvent from '@testing-library/user-event';
|
||||
import {CollectionTagModal} from './CollectionTagModal';
|
||||
|
||||
// Mock Theme components
|
||||
jest.mock('../Theme', () => ({
|
||||
...jest.requireActual('../Theme'),
|
||||
Modal: ({open, onClose, children, closeIcon}) => {
|
||||
// Mock Theme components with compound patterns
|
||||
jest.mock('../Theme', () => {
|
||||
const MockModal = ({open, onClose, children, closeIcon}) => {
|
||||
if (!open) return null;
|
||||
return (
|
||||
<div data-testid="modal">
|
||||
|
|
@ -14,14 +13,20 @@ jest.mock('../Theme', () => ({
|
|||
{children}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
ModalHeader: ({children}) => <div data-testid="modal-header">{children}</div>,
|
||||
ModalContent: ({children}) => <div data-testid="modal-content">{children}</div>,
|
||||
ModalActions: ({children}) => <div data-testid="modal-actions">{children}</div>,
|
||||
Button: ({children, onClick, ...props}) => (
|
||||
<button onClick={onClick} data-testid={`button-${children}`} {...props}>{children}</button>
|
||||
),
|
||||
}));
|
||||
};
|
||||
MockModal.Header = ({children}) => <div data-testid="modal-header">{children}</div>;
|
||||
MockModal.Content = ({children}) => <div data-testid="modal-content">{children}</div>;
|
||||
MockModal.Actions = ({children}) => <div data-testid="modal-actions">{children}</div>;
|
||||
MockModal.Description = ({children}) => <div data-testid="modal-description">{children}</div>;
|
||||
|
||||
return {
|
||||
...jest.requireActual('../Theme'),
|
||||
Modal: MockModal,
|
||||
Button: ({children, onClick, ...props}) => (
|
||||
<button onClick={onClick} data-testid={`button-${children}`} {...props}>{children}</button>
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
// Mock Common components
|
||||
jest.mock('../Common', () => ({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
import React from "react";
|
||||
import {createMedia} from "@artsy/fresnel";
|
||||
|
||||
export const ThemeContext = React.createContext({theme: null, i: {}});
|
||||
/** @type {React.Context<import('../types/theme').ThemeContextValue>} */
|
||||
export const ThemeContext = React.createContext({
|
||||
theme: 'light',
|
||||
i: {},
|
||||
s: {},
|
||||
t: {},
|
||||
inverted: '',
|
||||
savedTheme: null,
|
||||
setDarkTheme: () => {},
|
||||
setLightTheme: () => {},
|
||||
cycleSavedTheme: () => {},
|
||||
});
|
||||
|
||||
export const StatusContext = React.createContext({
|
||||
status: {},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import _ from "lodash";
|
||||
import {InfoPopup, RequiredAsterisk, Toggle, validURL, validURLs} from "../components/Common";
|
||||
import {FormInput, Icon, TextArea} from "../components/Theme";
|
||||
import {Form, Icon, TextArea} from "../components/Theme";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
|
||||
|
||||
|
|
@ -339,13 +339,13 @@ export function InputForm({
|
|||
/>
|
||||
}
|
||||
</label>
|
||||
<FormInput
|
||||
<Form.Input
|
||||
id={`${name}_input`}
|
||||
placeholder={placeholder}
|
||||
error={inputProps.error}
|
||||
>
|
||||
<input {...extraInputProps} {...inputProps}/>
|
||||
</FormInput>
|
||||
</Form.Input>
|
||||
{messageElm}
|
||||
</>
|
||||
}
|
||||
|
|
@ -435,7 +435,7 @@ export function UrlsTextarea({name = 'urls', required, form}) {
|
|||
};
|
||||
|
||||
return (
|
||||
<FormInput required error={inputProps.error} label="URLs">
|
||||
<Form.Input required error={inputProps.error} label="URLs">
|
||||
<TextArea
|
||||
id="urls_textarea"
|
||||
placeholder="Enter one URL per line"
|
||||
|
|
@ -444,7 +444,7 @@ export function UrlsTextarea({name = 'urls', required, form}) {
|
|||
onKeyDown={handleKeyDown}
|
||||
{...inputProps}
|
||||
/>
|
||||
</FormInput>
|
||||
</Form.Input>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ export function ToggleForm({form, name, label, path, icon = null, iconSize = 'bi
|
|||
const [inputProps, inputAttrs] = form.getCustomProps({name, path})
|
||||
|
||||
const iconElm = icon ? <Icon size={iconSize} name={icon}/> : null;
|
||||
return <FormInput
|
||||
return <Form.Input
|
||||
label={label}>
|
||||
{iconElm}
|
||||
<Toggle
|
||||
|
|
@ -461,5 +461,5 @@ export function ToggleForm({form, name, label, path, icon = null, iconSize = 'bi
|
|||
checked={inputProps.value}
|
||||
onChange={inputProps.onChange}
|
||||
/>
|
||||
</FormInput>
|
||||
</Form.Input>
|
||||
}
|
||||
|
|
|
|||
36
app/src/types/theme.ts
Normal file
36
app/src/types/theme.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { CSSProperties } from 'react';
|
||||
|
||||
// Theme values
|
||||
export type ThemeName = 'dark' | 'light';
|
||||
export type SavedThemeName = ThemeName | 'system' | null;
|
||||
|
||||
// Style objects used by theme
|
||||
export interface InvertedProps {
|
||||
inverted?: boolean;
|
||||
}
|
||||
|
||||
export interface StyleProps {
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
// ThemeContext value type
|
||||
export interface ThemeContextValue {
|
||||
/** Props for Semantic elements that support "inverted" */
|
||||
i: InvertedProps;
|
||||
/** Props to invert styles on elements */
|
||||
s: StyleProps;
|
||||
/** Props to invert text color */
|
||||
t: StyleProps;
|
||||
/** Class name string: 'inverted' or '' */
|
||||
inverted: string;
|
||||
/** Current applied theme */
|
||||
theme: ThemeName;
|
||||
/** User's saved theme preference */
|
||||
savedTheme: SavedThemeName;
|
||||
/** Set dark theme */
|
||||
setDarkTheme: (save?: boolean) => void;
|
||||
/** Set light theme */
|
||||
setLightTheme: (save?: boolean) => void;
|
||||
/** Cycle through theme options */
|
||||
cycleSavedTheme: (e?: React.MouseEvent) => void;
|
||||
}
|
||||
22
app/tsconfig.json
Normal file
22
app/tsconfig.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"lib": ["dom", "dom.iterable", "ES2020"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": "src"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ USER root
|
|||
RUN npm install -g serve
|
||||
COPY app/public /app/public
|
||||
COPY app/src /app/src
|
||||
COPY app/package.json app/package-lock.json /app/
|
||||
COPY app/package.json app/package-lock.json app/tsconfig.json /app/
|
||||
# "node" user will run the app after build.
|
||||
RUN chown -R node:node /app
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue