Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-server
Commits
476eccac
You need to sign in or sign up before continuing.
Commit
476eccac
authored
Jun 15, 2022
by
Soldatoff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a function to get the number of typos. And displaying their number for all sites.
parent
929100e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
7 deletions
+44
-7
Typos.php
cp/application/controllers/users/Typos.php
+11
-0
Typo.php
cp/application/models/Typo.php
+8
-0
SiteList.jsx
cp/javascript/src/components/SiteList.jsx
+23
-6
index.jsx
cp/javascript/src/components/TypoList/index.jsx
+2
-1
No files found.
cp/application/controllers/users/Typos.php
View file @
476eccac
...
@@ -195,6 +195,17 @@ class Typos extends CI_Controller {
...
@@ -195,6 +195,17 @@ class Typos extends CI_Controller {
->
set_status_header
(
200
)
->
set_status_header
(
200
)
->
set_output
(
json_encode
(
$this
->
typo
->
getSiteTypos
(
$siteId
)));
->
set_output
(
json_encode
(
$this
->
typo
->
getSiteTypos
(
$siteId
)));
}
}
function
getCountTypos
(
$siteId
=
null
)
{
if
(
is_null
(
$siteId
))
{
return
$this
->
output
->
set_status_header
(
400
)
->
set_output
(
"Missing siteId parameter!"
);
}
return
$this
->
output
->
set_content_type
(
"application/json"
)
->
set_status_header
(
200
)
->
set_output
(
json_encode
(
$this
->
typo
->
getCountTypos
(
$siteId
)));
}
/**
/**
* Получить список сообщений об опечатках для пользователя
* Получить список сообщений об опечатках для пользователя
...
...
cp/application/models/Typo.php
View file @
476eccac
...
@@ -202,6 +202,14 @@ class Typo extends CI_Model {
...
@@ -202,6 +202,14 @@ class Typo extends CI_Model {
return
$this
->
db
->
get
()
->
result
();
return
$this
->
db
->
get
()
->
result
();
}
}
function
getCountTypos
(
$siteId
)
{
$this
->
db
->
select
(
"count(*)"
);
$this
->
db
->
from
(
"messages"
);
$this
->
db
->
where
(
"site_id"
,
$siteId
);
$this
->
db
->
where
(
"status"
,
0
);
return
$this
->
db
->
get
()
->
result
();
}
/* Получаем список сообщений об опечатках */
/* Получаем список сообщений об опечатках */
function
getMessagesList
(
$data
)
{
function
getMessagesList
(
$data
)
{
...
...
cp/javascript/src/components/SiteList.jsx
View file @
476eccac
...
@@ -11,6 +11,7 @@ export default class SiteList extends React.Component {
...
@@ -11,6 +11,7 @@ export default class SiteList extends React.Component {
super
(
props
);
super
(
props
);
this
.
sites
=
this
.
props
.
sites
;
this
.
sites
=
this
.
props
.
sites
;
this
.
updateCountTypos
();
console
.
log
(
"Render SiteList"
);
console
.
log
(
"Render SiteList"
);
this
.
state
=
{
this
.
state
=
{
...
@@ -56,6 +57,12 @@ export default class SiteList extends React.Component {
...
@@ -56,6 +57,12 @@ export default class SiteList extends React.Component {
);
);
}
}
updateCountTypos
(){
for
(
let
i
=
0
;
i
<
this
.
sites
.
length
;
i
+=
1
)
{
this
.
getCountTypos
(
this
.
sites
[
i
],
i
)
}
}
loadSiteTypos
(
siteId
,
done
)
{
loadSiteTypos
(
siteId
,
done
)
{
$
.
ajax
({
$
.
ajax
({
url
:
`
${
window
.
baseUrl
}
/users/typos/getSiteTypos/
${
this
.
sites
[
siteId
].
id
}
`
,
url
:
`
${
window
.
baseUrl
}
/users/typos/getSiteTypos/
${
this
.
sites
[
siteId
].
id
}
`
,
...
@@ -83,21 +90,31 @@ export default class SiteList extends React.Component {
...
@@ -83,21 +90,31 @@ export default class SiteList extends React.Component {
});
});
}
}
getCountTypos
(
site
,
num
)
{
$
.
ajax
({
url
:
`
${
window
.
baseUrl
}
/users/typos/getCountTypos/
${
this
.
sites
[
num
].
id
}
`
,
}).
done
((
count
)
=>
{
const
count_typos
=
count
;
this
.
sites
[
num
].
count
=
count_typos
[
0
][
"count(*)"
];
}).
fail
((
error
)
=>
{
console
.
log
(
error
);
});
}
render
()
{
render
()
{
const
tabItems
=
this
.
sites
.
map
((
site
,
index
)
=>
const
tabItems
=
this
.
sites
.
map
((
site
,
index
)
=>
<
NavItem
key=
{
index
}
>
<
NavItem
key=
{
index
}
>
<
NavLink
className=
{
this
.
state
.
activeTab
===
index
?
"active"
:
""
}
<
NavLink
className=
{
this
.
state
.
activeTab
===
index
?
"active"
:
""
}
onClick=
{
()
=>
{
this
.
updateTab
(
index
)
}
}
>
onClick=
{
()
=>
{
this
.
updateTab
(
index
)
,
this
.
updateCountTypos
()
}
}
>
{
site
.
name
}
{
site
.
name
}
<
Badge
id=
{
site
.
id
+
"-typos-count"
}
className=
{
"typos-count"
}
>
<
Badge
id=
{
site
.
id
+
"-typos-count"
}
className=
{
"typos-count"
}
{
site
.
count
}
hidden=
{
this
.
state
.
activeTab
!==
index
}
>
{
this
.
state
.
typos
.
length
}
</
Badge
>
</
Badge
>
</
NavLink
>
</
NavLink
>
{
this
.
state
.
activeTab
===
index
&&
{
this
.
state
.
activeTab
===
index
&&
<
FaRefresh
className=
"refresh-site"
title=
"Обновить"
<
FaRefresh
className=
"refresh-site"
title=
"Обновить"
onClick=
{
()
=>
{
this
.
updateTab
()
}
}
/>
}
onClick=
{
()
=>
{
this
.
updateTab
(
index
),
this
.
updateCountTypos
(
)
}
}
/>
}
</
NavItem
>
</
NavItem
>
);
);
...
...
cp/javascript/src/components/TypoList/index.jsx
View file @
476eccac
...
@@ -156,6 +156,6 @@ export default class TypoList extends Component {
...
@@ -156,6 +156,6 @@ export default class TypoList extends Component {
* @private
* @private
*/
*/
updateSiteTyposCount
()
{
updateSiteTyposCount
()
{
$
(
`#
${
this
.
state
.
siteId
}
-typos-count`
)
.
text
(
this
.
props
.
typos
.
length
)
;
$
(
`#
${
this
.
state
.
siteId
}
-typos-count`
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment