Skip to content

Commit

Permalink
CCS-100748 Add clean cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Sep 2, 2024
1 parent 7b8019b commit e13623e
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 7 deletions.
23 changes: 23 additions & 0 deletions frontend/app/modules/clean-cache/CleanCachePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { FC } from 'react'
import { useStore } from '../../hooks/useStore'
import { observer } from 'mobx-react'
import FeatureHeader from '../../components/FeatureHeader'
import Button from '../../components/Button'
import FeaturePage from '../../components/FeaturePage'

const CleanCachePage: FC = () => {
const { cleanCacheStore: store } = useStore()

const handleSubmit = () => {
store.cleanCache()
}

return (
<FeaturePage>
<FeatureHeader name="Очистка кеша статики" />
<Button onClick={handleSubmit} id="submit" title="Очистить" />
</FeaturePage>
)
}

export default observer(CleanCachePage)
28 changes: 28 additions & 0 deletions frontend/app/modules/clean-cache/clean-cache.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as SDK from '@expressms/smartapp-sdk'
import { RootStore } from '../../store/rootStore'
import { STATUS } from '@expressms/smartapp-sdk/build/main/types'
import { makeAutoObservable } from 'mobx'

export class CleanCacheStore {
rootStore: RootStore
response: object | null

constructor(rootStore: RootStore) {
makeAutoObservable(this)

this.rootStore = rootStore
this.response = null
}

async cleanCache(): Promise<void> {
try {
const response = await SDK.cleanCache()

if (response.payload.status === STATUS.ERROR) {
this.rootStore.toastStore.showToast(`Ошибка очистки кеша ${response.payload.errorCode}`)
}
} catch (e) {
this.rootStore.toastStore.showToast(`Ошибка очистки кеша ${e?.message}`)
}
}
}
4 changes: 4 additions & 0 deletions frontend/app/modules/features-list/ClientFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ const ClientFeatures: FC = () => {
<span className="material-icons">text_snippet</span>
Скрытие данных в логах
</StyledLink>
<StyledLink to="clean-cache">
<span className="material-icons">folder_off</span>
Очистка кеша статики
</StyledLink>
</>
)
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/modules/features-list/FeaturesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import BotCommandPage from '../bot-command/BotCommandPage'
import MaxFileSizePage from '../max-file-size/MaxFileSizePage'
import SendBotCommandPage from '../send-bot-command/SendBotCommandPage'
import HideLogsPage from '../hide-logs/HideLogsPage'
import CleanCachePage from '../clean-cache/CleanCachePage'

const Wrapper = styled.div`
margin-bottom: 30px;
Expand Down Expand Up @@ -104,6 +105,7 @@ const FeaturesListPage = () => {
<Route path="/max-file-size" element={<MaxFileSizePage />} />
<Route path="/send-bot-command" element={<SendBotCommandPage />} />
<Route path="/hide-log-data" element={<HideLogsPage />} />
<Route path="/clean-cache" element={<CleanCachePage />} />
</Routes>
</Wrapper>
{store.showMainLoader && <MainLoader />}
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/store/rootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { BotCommandStore } from '../modules/bot-command/bot-command.store'
import { MaxFileSizeStore } from '../modules/max-file-size/max-file-size.store'
import { SendBotCommandStore } from '../modules/send-bot-command/send-bot-command.store'
import { HideLogsStore } from '../modules/hide-logs/hide-logs.store'
import { CleanCacheStore } from '../modules/clean-cache/clean-cache.store'

export class RootStore {
appStore: AppStore
Expand Down Expand Up @@ -66,6 +67,7 @@ export class RootStore {
maxFileSizeStore: MaxFileSizeStore
sendBotCommandStore: SendBotCommandStore
hideLogsStore: HideLogsStore
cleanCacheStore: CleanCacheStore

constructor() {
this.appStore = new AppStore(this)
Expand Down Expand Up @@ -101,5 +103,6 @@ export class RootStore {
this.maxFileSizeStore = new MaxFileSizeStore(this)
this.sendBotCommandStore = new SendBotCommandStore(this)
this.hideLogsStore = new HideLogsStore(this)
this.cleanCacheStore = new CleanCacheStore(this)
}
}
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-feature-smartapp",
"version": "2.3.11",
"version": "2.4.0",
"description": "SmartApp with all features",
"main": "index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"license": "ISC",
"dependencies": {
"@amcharts/amcharts5": "5.9.12",
"@expressms/smartapp-sdk": "1.10.0-alpha.1",
"@expressms/smartapp-sdk": "1.10.0-alpha.2",
"html5-qrcode": "2.3.8",
"jsoneditor": "10.1.0",
"material-icons": "1.13.12",
Expand Down
2 changes: 1 addition & 1 deletion frontend/smartapp-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"manifestVersion": "1.0.0",
"smartAppVersion": "",
"bundlePath": "",
"changeLog": "Фикс AT CCS-100500"
"changeLog": "CCS-100748 Очистка кеша"
}
8 changes: 4 additions & 4 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,10 @@
lodash-es "^4.17.21"
uuid "^8.3.2"

"@expressms/[email protected].1":
version "1.10.0-alpha.1"
resolved "https://registry.yarnpkg.com/@expressms/smartapp-sdk/-/smartapp-sdk-1.10.0-alpha.1.tgz#b4eba2a5b68529a0c64b106839543a40a6282007"
integrity sha512-ykvx75XDGJKxodEezO+3iJTJy8EE0fzehKRx7DY8geg3J8Mr9OdZCTk52X0phgMw08F4jCogsU1UVQzYdYvUrQ==
"@expressms/[email protected].2":
version "1.10.0-alpha.2"
resolved "https://registry.yarnpkg.com/@expressms/smartapp-sdk/-/smartapp-sdk-1.10.0-alpha.2.tgz#2ca8ba6b66bfedbfb1d2af354dca6a9bc907438e"
integrity sha512-dZyzPSTpOEOJxm+0Vagh5L1V7pTI6Oua9SmL4gD0yERp9sYOOuq0tziJSGhqksIzO1TrRqUg6eZ8d/cgxNQYcw==
dependencies:
"@expressms/smartapp-bridge" "1.4.0-alpha.1"

Expand Down

0 comments on commit e13623e

Please sign in to comment.