Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
vanisha
/
log
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c8627f47
authored
2023-06-02 10:55:10 +0530
by
vanisha
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
date filter added
1 parent
36cae97a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
3 deletions
ajax.php
templates/cron_logs_view.mustache
view.php
ajax.php
0 → 100644
View file @
c8627f4
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Log block caps.
*
* @package block_log
* @copyright Vanisha <vanisha@teknoturf.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/config.php'
);
global
$CFG
;
require_login
();
if
(
isset
(
$_GET
[
'choice'
]))
{
$choice
=
$_GET
[
'choice'
];
if
(
$choice
===
'get_logs'
)
{
$date_filter
=
$_GET
[
'date'
];
$date_filter
=
date
(
'd-m-y'
,
strtotime
(
$date_filter
));
$configpaths
=
get_config
(
null
,
'block_log_path_info'
);
$table_content_array
=
array
();
$i
=
1
;
$split_paths
=
explode
(
","
,
$configpaths
);
foreach
(
$split_paths
as
$split_path
)
{
$files
=
scandir
(
$split_path
);
foreach
(
$files
as
$file
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;}
if
(
(
strpos
(
$file
,
$date_filter
)
!==
false
)
&&
(
strpos
(
$file
,
'.log'
))
)
{
$n
=
new
stdClass
();
$n
->
sno
=
$i
;
$n
->
name
=
$file
;
$n
->
log
=
file_get_contents
(
$split_path
.
'/'
.
$file
);
$table_content_array
[]
=
$n
;
$i
=
$i
+
1
;
}
}
}
$response_obj
=
new
stdClass
();
$response_obj
->
userdata
=
json_encode
(
$table_content_array
);
echo
json_encode
(
$response_obj
);
}
}
\ No newline at end of file
templates/cron_logs_view.mustache
View file @
c8627f4
...
...
@@ -14,6 +14,14 @@
<label
for=
"date_filter"
>
Date
</label>
<input
type=
"date"
id=
"date_filter"
class=
"form-control"
aria-label=
"Default"
aria-describedby=
"date_filter"
>
</div>
<div
id=
"date_filter_error_div"
></div>
</div>
<div
class=
"input-group mb-3"
>
<div>
<button
id=
"filter_logs"
class=
"btn btn-primary"
type=
"button"
title=
"Filter"
>
Filter
<span
class=
"icon-stack"
><i
style=
"line-height: 0.5em;"
class=
"icon-filter icon-stack-base"
aria-hidden=
"true"
></i>
<i
style=
"line-height: 0.2em;"
class=
"icon-add"
></i></span></button>
</div>
</div>
</div>
...
...
@@ -33,14 +41,50 @@
</div>
<script>
$
(
'#view_logs_entries_table'
).
DataTable
({
var
log_DataTable
=
""
;
log_DataTable
=
$
(
'#view_logs_entries_table'
).
DataTable
({
dom
:
'lBfrtip'
,
"pageLength"
:
30
,
"lengthChange"
:
false
,
lengthMenu
:
[[
10
,
25
,
50
,
100
],[
10
,
25
,
50
,
100
]],
"language"
:
{
"emptyTable"
:
"No records found."
},
"columns"
:
[
{
"data"
:
"sno"
},
{
"data"
:
"name"
},
{
"data"
:
"log"
}
]
});
$
(
'#view_slots_filter'
).
click
(
function
()
{
var
date
=
$
(
"#date_filter"
).
val
();
if
((
date
==
''
))
{
var
alert_message
=
'<p style="color: red;">* Please select date filter.</p>'
;
if
((
'#date_filter_error_div'
).
length
!=
0
)
{
$
(
'#date_filter_error_div'
).
empty
();
}
});
$
(
'#date_filter_error_div'
).
append
(
alert_message
);
}
else
{
if
((
'#date_filter_error_div'
).
length
!=
0
)
{
$
(
'#date_filter_error_div'
).
empty
();
}
$
.
ajax
({
method
:
"GET"
,
url
:
M
.
cfg
.
wwwroot
+
'/blocks/log/ajax.php'
,
data
:
{
"choice"
:
"get_logs"
,
"date"
:
date
}
}).
done
(
function
(
response
)
{
var
data
=
JSON
.
parse
(
response
);
var
userdata
=
JSON
.
parse
(
data
.
userdata
);
log_DataTable
.
clear
().
draw
();
log_DataTable
.
rows
.
add
(
userdata
).
draw
();
});
}
});
</script>
\ No newline at end of file
...
...
view.php
View file @
c8627f4
...
...
@@ -49,7 +49,7 @@ $templatecontext = array();
// breadcrumb template
$templatecontext
[
'breadcrumb_navbar'
]
=
$OUTPUT
->
navbar
();
$configpaths
=
get_config
(
'block_log'
,
'block_log_path_info'
);
$configpaths
=
get_config
(
null
,
'block_log_path_info'
);
$isadmin
=
has_capability
(
'block/log:manageall'
,
context_system
::
instance
());
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment