-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rustem Mussabekov
committed
Apr 17, 2024
1 parent
76f14be
commit f0b0d78
Showing
31 changed files
with
747 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "app", | ||
"version": "5.6.21", | ||
"version": "5.6.22", | ||
"description": "", | ||
"author": "", | ||
"license": "ISC", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as c from '../constants/predictions' | ||
|
||
export const load = ()=>({ | ||
type: c.PREDICTIONS_LOAD_REQ | ||
}) | ||
|
||
export const patch = (details)=>({ | ||
type: c.PREDICTION_PATCH, | ||
...details | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const | ||
PREDICTIONS_LOAD_REQ = 'PREDICTIONS_LOAD_REQ', | ||
PREDICTIONS_LOAD_SUCCESS = 'PREDICTIONS_LOAD_SUCCESS', | ||
PREDICTIONS_LOAD_ERROR = 'PREDICTIONS_LOAD_ERROR', | ||
PREDICTION_PATCH = 'PREDICTION_PATCH' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Immutable from 'seamless-immutable' | ||
import { REHYDRATE } from 'redux-persist/src/constants' | ||
import * as c from '../constants/predictions' | ||
|
||
const supportedKinds = ['move', 'tag', 'untag', 'mergetags'] | ||
|
||
export default function(state = initialState, action){switch (action.type) { | ||
case REHYDRATE:{ | ||
const { predictions={} } = action.payload||{} | ||
|
||
if (predictions.status == 'loaded') | ||
return predictions | ||
|
||
return state | ||
} | ||
|
||
case 'RESET': | ||
return initialState | ||
|
||
case c.PREDICTIONS_LOAD_REQ:{ | ||
return state | ||
.set('status', 'loading') | ||
} | ||
|
||
case c.PREDICTIONS_LOAD_SUCCESS:{ | ||
const items = (action.items||[]).filter(item=> | ||
supportedKinds.includes(item.kind) | ||
) | ||
|
||
return state | ||
.set('status', 'loaded') | ||
.set('items', items) | ||
} | ||
|
||
case c.PREDICTIONS_LOAD_ERROR:{ | ||
return state | ||
.set('status', 'error') | ||
.set('items', initialState.items) | ||
} | ||
|
||
case c.PREDICTION_PATCH: { | ||
const { _id, ...props } = action | ||
|
||
return state | ||
.set('items', state.items.map(item=>{ | ||
if (item._id != _id) | ||
return item | ||
|
||
let patched = item | ||
for(const key in props) | ||
if (typeof item[key] != 'undefined') | ||
patched = patched.set(key, props[key]) | ||
return patched | ||
})) | ||
} | ||
|
||
default: | ||
return state | ||
}} | ||
|
||
const initialState = Immutable({ | ||
status: 'idle', //idle|loading|loaded|error | ||
items: [] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { put, takeLatest, call } from 'redux-saga/effects' | ||
import * as c from '../constants/predictions' | ||
import Api from '../modules/api' | ||
|
||
export default function* () { | ||
yield takeLatest(c.PREDICTIONS_LOAD_REQ, load) | ||
} | ||
|
||
function* load() { | ||
try { | ||
const { items } = yield call(Api.get, 'predictions?version=1') | ||
|
||
yield put({ | ||
type: c.PREDICTIONS_LOAD_SUCCESS, | ||
items | ||
}) | ||
} catch (error) { | ||
yield put({ | ||
type: c.PREDICTIONS_LOAD_ERROR, | ||
error | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createSelector } from 'reselect' | ||
import _ from 'lodash-es' | ||
|
||
export const makeGroupped = ()=> createSelector( | ||
[state=>state.predictions.items], | ||
(items)=>{ | ||
return Object.entries(_.groupBy(items, 'kind')) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import s from './index.module.css' | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
|
||
import Screen from '~co/screen/basic' | ||
import Header, { Title, FirstAction } from '~co/common/header' | ||
import Button from '~co/common/button' | ||
import { Link } from 'react-router-dom' | ||
import Icon from '~co/common/icon' | ||
import Intro from './intro' | ||
import Predictions from './predictions' | ||
|
||
export default function PageOrganize() { | ||
const enabled = useSelector(state=>state.config.ai_organize) | ||
|
||
return ( | ||
<Screen className={s.main} appSize='large'> | ||
<Header className={s.header} data-solid> | ||
<FirstAction className='svSidebarShowButton'> | ||
<Button as={Link} to='/'> | ||
<Icon name='back' /> | ||
</Button> | ||
</FirstAction> | ||
|
||
<Title>Organize with ✦ AI</Title> | ||
</Header> | ||
|
||
<div className={s.split} data-enabled={enabled}> | ||
<Intro /> | ||
|
||
{enabled ? ( | ||
<div className={s.content}> | ||
<Predictions /> | ||
</div> | ||
) : null} | ||
</div> | ||
</Screen> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.main, .header { | ||
background-color: var(--sidebar-background-color) !important; | ||
} | ||
|
||
.main { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.split { | ||
flex: 1; | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
} | ||
.split[data-enabled="false"] { | ||
align-items: center; | ||
} | ||
|
||
.content { | ||
padding: var(--padding-large) | ||
} | ||
|
||
@media (min-width: 1000px) { | ||
.split[data-enabled="true"] { | ||
grid-template-columns: 400px 1fr; | ||
} | ||
} |
Oops, something went wrong.