-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
67c08ef
commit ab734bb
Showing
14 changed files
with
108 additions
and
92 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,2 +1,2 @@ | ||
inherit_gem: | ||
rubocop-discourse: stree-compat.yml | ||
rubocop-discourse: stree-compat.yml |
8 changes: 8 additions & 0 deletions
8
admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-antivirus-stats.js
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,8 @@ | ||
import { ajax } from "discourse/lib/ajax"; | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
|
||
export default class DiscourseAntivirusStatsRoute extends DiscourseRoute { | ||
model() { | ||
return ajax("/admin/plugins/discourse-antivirus/stats"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ts/javascripts/discourse/templates/admin-plugins/show/discourse-antivirus-stats/index.hbs
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,44 @@ | ||
<section class="antivirus-stats admin-detail pull-left"> | ||
<div class="antivirus-stats__header"> | ||
<h3>{{i18n "antivirus.stats.title"}}</h3> | ||
</div> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>{{i18n "antivirus.version"}}</th> | ||
<th>{{i18n "antivirus.database_version"}}</th> | ||
<th>{{i18n "antivirus.database_updated_at"}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each this.model.versions as |version|}} | ||
<tr> | ||
<td>{{version.antivirus}}</td> | ||
<td>{{version.database}}</td> | ||
<td>{{version.updated_at}}</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>{{i18n "antivirus.stats.total_scans"}}</th> | ||
<th>{{i18n "antivirus.stats.recently_scanned"}}</th> | ||
<th>{{i18n "antivirus.stats.quarantined"}}</th> | ||
<th>{{i18n "antivirus.stats.found"}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>{{this.model.stats.scans}}</td> | ||
<td>{{this.model.stats.recently_scanned}}</td> | ||
<td>{{this.model.stats.quarantined}}</td> | ||
<td>{{this.model.stats.found}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</section> |
15 changes: 15 additions & 0 deletions
15
app/controllers/discourse_antivirus/admin/antivirus_controller.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module DiscourseAntivirus | ||
module Admin | ||
class AntivirusController < ::Admin::AdminController | ||
requires_plugin ::DiscourseAntivirus::PLUGIN_NAME | ||
|
||
def index | ||
antivirus = DiscourseAntivirus::ClamAv.instance | ||
|
||
render json: DiscourseAntivirus::BackgroundScan.new(antivirus).stats | ||
end | ||
end | ||
end | ||
end |
13 changes: 0 additions & 13 deletions
13
app/controllers/discourse_antivirus/antivirus_controller.rb
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
assets/javascripts/discourse/admin-discourse-antivirus-plugin-route-map.js
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,8 @@ | ||
export default { | ||
resource: "admin.adminPlugins.show", | ||
path: "/plugins", | ||
|
||
map() { | ||
this.route("discourse-antivirus-stats", { path: "stats" }); | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
assets/javascripts/discourse/initializers/admin-plugin-configuration-nav.js
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,26 @@ | ||
import { PLUGIN_NAV_MODE_TOP } from "discourse/lib/admin-plugin-config-nav"; | ||
import { withPluginApi } from "discourse/lib/plugin-api"; | ||
|
||
export default { | ||
name: "discourse-antivirus-admin-plugin-configuration-nav", | ||
|
||
initialize(container) { | ||
const currentUser = container.lookup("service:current-user"); | ||
if (!currentUser || !currentUser.admin) { | ||
return; | ||
} | ||
|
||
withPluginApi("1.1.0", (api) => { | ||
api.addAdminPluginConfigurationNav( | ||
"discourse-antivirus", | ||
PLUGIN_NAV_MODE_TOP, | ||
[ | ||
{ | ||
label: "antivirus.stats.title", | ||
route: "adminPlugins.show.discourse-antivirus-stats", | ||
}, | ||
] | ||
); | ||
}); | ||
}, | ||
}; |
17 changes: 0 additions & 17 deletions
17
assets/javascripts/discourse/routes/admin-plugins-antivirus.js
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
assets/javascripts/discourse/templates/admin/plugins-antivirus.hbs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
#DiscourseAntivirus::Engine.routes.draw do | ||
# root to: "antivirus#index" | ||
# get "/stats" => "antivirus#index" | ||
#end | ||
|
||
Discourse::Application.routes.draw do | ||
scope "/admin/plugins/antivirus", constraints: AdminConstraint.new do | ||
get "/stats" => "antivirus#index" | ||
scope "/admin/plugins/discourse-antivirus", constraints: AdminConstraint.new do | ||
get "/stats" => "discourse_antivirus/admin/antivirus#index" | ||
end | ||
end |
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