-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: add /app/project/:id with propagation
- Loading branch information
1 parent
57fc805
commit b6d6079
Showing
19 changed files
with
249 additions
and
15 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
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,11 @@ | ||
function setupProjectPropagation(id) { | ||
var table = $('#project_propagation'); | ||
var dataTable = table.DataTable({ | ||
ajax: { | ||
url: '/rest/project/propagation/' + id, | ||
}, | ||
deferRender: true, | ||
columns: [{data: 'dt'}, {data: 'prefix'}, {data: 'version'}, {data: 'mirrors'}], | ||
order: [[0, 'desc']], | ||
}); | ||
} |
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,41 @@ | ||
# Copyright (C) 2024 SUSE LLC | ||
# | ||
# This program 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 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program 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 this program; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
package MirrorCache::WebAPI::Controller::App::Project; | ||
use Mojo::Base 'MirrorCache::WebAPI::Controller::App::Table'; | ||
|
||
sub index { | ||
my $c = shift; | ||
|
||
$c->SUPER::admintable('project'); | ||
} | ||
|
||
sub show { | ||
my $self = shift; | ||
my $id = $self->param('id'); | ||
|
||
my $f = $self->schema->resultset('Project')->find($id) | ||
or return $self->reply->not_found; | ||
|
||
my $info = { | ||
id => $f->id, | ||
path => $f->path, | ||
name => $f->name, | ||
}; | ||
|
||
return $self->render('app/project/show', project => $info); | ||
} | ||
|
||
1; |
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
48 changes: 48 additions & 0 deletions
48
lib/MirrorCache/WebAPI/Controller/Rest/ProjectPropagation.pm
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,48 @@ | ||
# Copyright (C) 2024 SUSE LLC | ||
# | ||
# This program 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 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program 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 this program; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
package MirrorCache::WebAPI::Controller::Rest::ProjectPropagation; | ||
use Mojo::Base 'Mojolicious::Controller'; | ||
use Data::Dumper; | ||
|
||
sub list { | ||
my ($self) = @_; | ||
|
||
my $project_id = $self->param("project_id"); | ||
|
||
return $self->render(code => 400, text => "Mandatory argument is missing") unless $project_id; | ||
|
||
my $sql = <<'END_SQL'; | ||
with propagation as ( | ||
select prefix, rollout_server.dt, epc, version, count(*) as mirror_count | ||
from | ||
rollout_server | ||
join rollout on id = rollout_id | ||
where rollout.project_id = ? | ||
group by prefix, version, epc, rollout_server.dt | ||
) | ||
select p2.prefix, p2.dt, p2.version, sum(p1.mirror_count) as mirrors | ||
from propagation p1 | ||
join propagation p2 on p1.epc = p2.epc and p1.dt <= p2.dt and p1.prefix = p2.prefix | ||
group by p2.prefix, p2.dt, p2.version | ||
order by p2.dt desc | ||
END_SQL | ||
|
||
my $res = $self->schema->storage->dbh->selectall_arrayref($sql, {Columns => {}}, $project_id); | ||
|
||
return $self->render(json => { data => $res }); | ||
} | ||
|
||
1; |
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
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,33 @@ | ||
% layout 'bootstrap'; | ||
% title 'Projects'; | ||
|
||
% content_for 'ready_function' => begin | ||
setupAdminTable(<%= is_admin_js %>); | ||
% end | ||
|
||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<h2><%= title %></h2> | ||
|
||
%= include 'layouts/info' | ||
|
||
<table id="folders" class="admintable table table-striped"> | ||
<thead> | ||
<tr> | ||
<th class="col_value">Id</th> | ||
<th class="col_value">Name</th> | ||
<th class="col_value">Path</th> | ||
<th class="col_action">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
</tbody> | ||
</table> | ||
% if (is_admin && !eval('$mirror_provider_url')) { | ||
<div class="text-center"> | ||
<input value="New project" onclick="addAdminTableRow();" type="button" class="btn btn-default"/> | ||
</div> | ||
% } | ||
<input type="hidden" id="admintable_api_url" value="/rest/project"/> | ||
</div> | ||
</div> |
Oops, something went wrong.