Commit ac0bbe33 authored by nanahira's avatar nanahira

add logout button

parent 409cebf9
Pipeline #17241 passed with stages
in 2 minutes and 48 seconds
...@@ -64,13 +64,12 @@ import Checkbox from '../components/controls/checkbox' ...@@ -64,13 +64,12 @@ import Checkbox from '../components/controls/checkbox'
import { getStorage } from '../data/storage/storage' import { getStorage } from '../data/storage/storage'
import { getUserSetting } from '../data/user/settings' import { getUserSetting } from '../data/user/settings'
import { useReload } from '../hooks/useReload' import { useReload } from '../hooks/useReload'
import { import { BackendURLTagSearch } from '../globals/constants'
BackendURLTagSearch,
} from '../globals/constants'
import Tooltip from '../components/tooltip' import Tooltip from '../components/tooltip'
import { WorkerInterface } from '../tokenizer/interface' import { WorkerInterface } from '../tokenizer/interface'
import { EncoderType } from '../tokenizer/encoder' import { EncoderType } from '../tokenizer/encoder'
import { isTouchScreenDevice } from '../util/compat' import { isTouchScreenDevice } from '../util/compat'
import { mycard } from '../util/mycard'
export const ToastArea = styled.div` export const ToastArea = styled.div`
position: fixed; position: fixed;
...@@ -98,7 +97,7 @@ export const ToastArea = styled.div` ...@@ -98,7 +97,7 @@ export const ToastArea = styled.div`
--toastify-color-progress-light: ${(props) => props.theme.colors.textHeadings}; --toastify-color-progress-light: ${(props) => props.theme.colors.textHeadings};
--toastify-text-color-light: ${(props) => props.theme.colors.textMain}; --toastify-text-color-light: ${(props) => props.theme.colors.textMain};
--toastify-font-family: ${(props) => props.theme.fonts.default}; --toastify-font-family: ${(props) => props.theme.fonts.default};
`; `
const MOBILE_WIDTH = 900 const MOBILE_WIDTH = 900
...@@ -144,7 +143,7 @@ const parsePrompt = (prompt: string[]): string => { ...@@ -144,7 +143,7 @@ const parsePrompt = (prompt: string[]): string => {
} }
const maxSamplesForSize = (width: number, height: number, max?: number): number => { const maxSamplesForSize = (width: number, height: number, max?: number): number => {
let limit = 100; const limit = 100
if (max) return Math.min(limit, max) if (max) return Math.min(limit, max)
return limit return limit
} }
...@@ -297,7 +296,7 @@ const ImageModels = [ ...@@ -297,7 +296,7 @@ const ImageModels = [
name: 'NAI Diffusion Anime (Full)', name: 'NAI Diffusion Anime (Full)',
description: 'The expanded training set allows for a wider variety of generations.', description: 'The expanded training set allows for a wider variety of generations.',
}, },
/* /*
{ {
id: ImageGenerationModels.naiDiffusionFurry, id: ImageGenerationModels.naiDiffusionFurry,
name: 'NAI Diffusion Furry (Beta)', name: 'NAI Diffusion Furry (Beta)',
...@@ -514,8 +513,7 @@ function ImageGenContent(): JSX.Element { ...@@ -514,8 +513,7 @@ function ImageGenContent(): JSX.Element {
const [purchaseModalOpen, setPurchaseModalOpen] = useState(false) const [purchaseModalOpen, setPurchaseModalOpen] = useState(false)
useEffect(() => { useEffect(() => {}, [
}, [
params, params,
selectedModel, selectedModel,
session, session,
...@@ -628,9 +626,7 @@ function ImageGenContent(): JSX.Element { ...@@ -628,9 +626,7 @@ function ImageGenContent(): JSX.Element {
fetch( fetch(
BackendURLTagSearch + BackendURLTagSearch +
//`?model=${encodeURIComponent(selectedModel.toString())}&prompt=${encodeURIComponent( //`?model=${encodeURIComponent(selectedModel.toString())}&prompt=${encodeURIComponent(
`?prompt=${encodeURIComponent( `?prompt=${encodeURIComponent(prompt.trim())}`,
prompt.trim()
)}`,
{ {
mode: 'cors', mode: 'cors',
cache: 'default', cache: 'default',
...@@ -1002,7 +998,7 @@ function ImageGenContent(): JSX.Element { ...@@ -1002,7 +998,7 @@ function ImageGenContent(): JSX.Element {
}, },
(error: any) => { (error: any) => {
setGenerating(false) setGenerating(false)
toast(error.message); toast(error.message)
}, },
() => { () => {
setGenerating(false) setGenerating(false)
...@@ -1344,9 +1340,7 @@ function ImageGenContent(): JSX.Element { ...@@ -1344,9 +1340,7 @@ function ImageGenContent(): JSX.Element {
</InputLabel> </InputLabel>
<EnhanceButton <EnhanceButton
disabled={ disabled={
generating || generating || prompt.some((p) => !p) || !validateParameters(params, selectedModel)
prompt.some((p) => !p) ||
!validateParameters(params, selectedModel)
} }
onClick={() => { onClick={() => {
setEnhanceBoxVisible(false) setEnhanceBoxVisible(false)
...@@ -1706,10 +1700,7 @@ function ImageGenContent(): JSX.Element { ...@@ -1706,10 +1700,7 @@ function ImageGenContent(): JSX.Element {
<PenIcon style={{ width: 16, height: 16 }} /> <PenIcon style={{ width: 16, height: 16 }} />
</OverlayButton> </OverlayButton>
</Tooltip> </Tooltip>
<Tooltip <Tooltip tooltip={`Generate Variations`} delay={0}>
tooltip={`Generate Variations`}
delay={0}
>
<OverlayButton <OverlayButton
disabled={generating} disabled={generating}
style={{ style={{
...@@ -1896,6 +1887,7 @@ function ImageGenContent(): JSX.Element { ...@@ -1896,6 +1887,7 @@ function ImageGenContent(): JSX.Element {
style={{ style={{
fontSize: '0.875rem', fontSize: '0.875rem',
width: 'max-content', width: 'max-content',
marginRight: '20px',
}} }}
> >
<ImportIcon <ImportIcon
...@@ -1907,6 +1899,19 @@ function ImageGenContent(): JSX.Element { ...@@ -1907,6 +1899,19 @@ function ImageGenContent(): JSX.Element {
/>{' '} />{' '}
Upload Image Upload Image
</ImportImageButton> </ImportImageButton>
<ImportImageButton
onClick={() => {
mycard.logout()
}}
style={{
fontSize: '0.875rem',
width: 'max-content',
visibility: mycard.isActive ? 'visible' : 'hidden',
// marginRight: '20px',
}}
>
Logout
</ImportImageButton>
</HideMobileInline> </HideMobileInline>
</> </>
)} )}
...@@ -2693,13 +2698,7 @@ function ImageGenContent(): JSX.Element { ...@@ -2693,13 +2698,7 @@ function ImageGenContent(): JSX.Element {
} }
}} }}
> >
{!downloadingImages ? ( {!downloadingImages ? 'Download ZIP' : <span>Downloading...</span>}
'Download ZIP'
) : (
<span>
Downloading...
</span>
)}
</SubtleButton> </SubtleButton>
</HistoryBar> </HistoryBar>
</Sidebar> </Sidebar>
...@@ -3810,7 +3809,7 @@ const GenerateButton = styled.button` ...@@ -3810,7 +3809,7 @@ const GenerateButton = styled.button`
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
font-weight: 700; font-weight: 700;
flex: .1 0 auto; flex: 0.1 0 auto;
border: 1px solid ${(props) => props.theme.colors.textHeadings}; border: 1px solid ${(props) => props.theme.colors.textHeadings};
&:disabled { &:disabled {
color: ${(props) => props.theme.colors.textHeadings}; color: ${(props) => props.theme.colors.textHeadings};
......
...@@ -38,11 +38,14 @@ export class MyCard { ...@@ -38,11 +38,14 @@ export class MyCard {
user: MyCardSSOUser user: MyCardSSOUser
isActive: boolean isActive: boolean
constructor() { constructor() {
if (!process.env.NEXT_PUBLIC_MYCARD || typeof window === 'undefined') { if (!process.env.NEXT_PUBLIC_MYCARD) {
this.isActive = false this.isActive = false
return return
} }
this.isActive = true this.isActive = true
if (typeof window === 'undefined') {
return
}
const ssoString = new URLSearchParams(window.location.search).get('sso') const ssoString = new URLSearchParams(window.location.search).get('sso')
const loginString = ssoString || window.localStorage.getItem('mycardLogin') const loginString = ssoString || window.localStorage.getItem('mycardLogin')
if (!loginString) { if (!loginString) {
...@@ -57,6 +60,9 @@ export class MyCard { ...@@ -57,6 +60,9 @@ export class MyCard {
} }
login() { login() {
if (typeof window === 'undefined') {
return
}
const currentUrl = window.location.href const currentUrl = window.location.href
window.location.replace(loginUrl(currentUrl)) window.location.replace(loginUrl(currentUrl))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment