Commit 3c848a3277eab5630ef8b80f36e7448847401364
1 parent
6efc2d3c
Exists in
master
reports
Showing
5 changed files
with
82 additions
and
15 deletions
Show diff stats
wscacicneo/__init__.py
... | ... | @@ -61,7 +61,7 @@ def main(global_config, **settings): |
61 | 61 | # |
62 | 62 | # relatorios |
63 | 63 | cfg.add_route('conf_report', 'relatorios/configuracao') |
64 | - cfg.add_route('report_hd', 'relatorio/{orgao}/{item}') | |
64 | + cfg.add_route('report_itens', 'relatorio/{nm_orgao}/{attr}/{child}') | |
65 | 65 | # |
66 | 66 | cfg.add_route('list', 'list') |
67 | 67 | cfg.add_route('gestao', 'gestao') |
... | ... | @@ -75,7 +75,6 @@ def main(global_config, **settings): |
75 | 75 | cfg.add_route('login', 'login') |
76 | 76 | cfg.add_route('loginautentication', 'loginautentication') |
77 | 77 | cfg.add_route('logout', 'logout') |
78 | - cfg.add_route('reports', 'reports') | |
79 | 78 | cfg.add_route('computador', 'computador') |
80 | 79 | cfg.add_route('busca', 'busca') |
81 | 80 | cfg.add_route('gestor', 'gestor') |
... | ... | @@ -87,7 +86,6 @@ def main(global_config, **settings): |
87 | 86 | cfg.add_route('processador','processador') |
88 | 87 | cfg.add_route('configcoleta','configcoleta') |
89 | 88 | cfg.add_route('configfav','configfav') |
90 | - cfg.add_route('reportsgestor','reportsgestor') | |
91 | 89 | cfg.add_route('questionarcoleta','questionarcoleta') |
92 | 90 | cfg.add_route('confighome','confighome') |
93 | 91 | cfg.add_route('db','db') | ... | ... |
wscacicneo/templates/conf_report.pt
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <div class="col-lg-2"> |
10 | 10 | <select id="orgao" class="form-control"> |
11 | 11 | <option></option> |
12 | - <option tal:repeat="doc orgao_doc">${doc.sigla}</option> | |
12 | + <option tal:repeat="doc orgao_doc">${doc.nome}</option> | |
13 | 13 | </select> |
14 | 14 | </div> |
15 | 15 | </div> |
... | ... | @@ -37,7 +37,28 @@ |
37 | 37 | <metal:content fill-slot="javascript"> |
38 | 38 | <script type="text/javascript"> |
39 | 39 | $('#enviar').click(function(){ |
40 | - window.location = "${request.route_url('root')}home" | |
40 | + orgao = $('#orgao').val() | |
41 | + attr = $('#coleta').val() | |
42 | + if(attr == 'hd'){ | |
43 | + item = "tipo_hd" | |
44 | + } | |
45 | + else if(attr == 'bios'){ | |
46 | + item = "fabricante_bios" | |
47 | + } | |
48 | + else if(attr == 'Sistemas Operacionais'){ | |
49 | + attr = 'sistemaoperacional' | |
50 | + item = 'nome_so' | |
51 | + } | |
52 | + else if(attr == 'memoria'){ | |
53 | + item = 'interface_memoria' | |
54 | + } | |
55 | + else if(attr == 'processador'){ | |
56 | + item = 'nome_processador' | |
57 | + } | |
58 | + else{ | |
59 | + alert('Selecione o Item da coleta') | |
60 | + } | |
61 | + window.location = "${request.route_url('root')}relatorio/"+orgao+"/"+attr+"/"+item+"" | |
41 | 62 | }); |
42 | 63 | </script> |
43 | 64 | </metal:content> | ... | ... |
wscacicneo/templates/report.pt
1 | 1 | <metal:main use-macro="load: master.pt"> |
2 | 2 | <metal:content fill-slot="conteudo"> |
3 | - </metal:content> | |
3 | + <div class="matter"> | |
4 | + <div class="container"> | |
5 | + <div class="row"> | |
6 | + <div class="col-md-12"> | |
7 | + <div class="widget"> | |
8 | + <div class="widget-head"> | |
9 | + <div class="pull-left">Data Tables</div> | |
10 | + <div class="widget-icons pull-right"> | |
11 | + <a href="#" class="wminimize"><i class="fa fa-chevron-up"></i></a> | |
12 | + <a href="#" class="wclose"><i class="fa fa-times"></i></a> | |
13 | + </div> | |
14 | + <div class="clearfix"></div> | |
15 | + </div> | |
16 | + <div class="widget-content"> | |
17 | + <div class="padd"> | |
18 | + <div class="page-tables"> | |
19 | + <div class="table-responsive"> | |
20 | + <table cellpadding="0" cellspacing="0" border="0" id="data-table" width="100%"> | |
21 | + <thead> | |
22 | + <tr> | |
23 | + <th>Item</th> | |
24 | + <th>Quantidade</th> | |
25 | + <th>Opçoes</th> | |
26 | + </tr> | |
27 | + </thead> | |
28 | + <tbody> | |
29 | + <tr tal:repeat="k data.keys()"> | |
30 | + <td>${k}</td> | |
31 | + <td tal:content="data[k]"></td> | |
32 | + <td> | |
33 | + <a href="" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></a> | |
34 | + </td> | |
35 | + </tr> | |
36 | + </tbody> | |
37 | + </table> | |
38 | + <div class="clearfix"></div> | |
39 | + </div> | |
40 | + </div> | |
41 | + </div> | |
42 | + </div> | |
43 | + <div class="widget-foot"> | |
44 | + </div> | |
45 | + </div> | |
46 | + </div> | |
47 | + </div> | |
48 | + </div> | |
49 | + </div> | |
50 | + </metal:content> | |
4 | 51 | <metal:content fill-slot="javascript"> |
5 | 52 | <script type="text/javascript"> |
6 | 53 | </script> | ... | ... |
wscacicneo/test/test_reports.py
... | ... | @@ -46,7 +46,7 @@ class TestRelatorio(unittest.TestCase): |
46 | 46 | hd = get_doc.get_attribute('hd') |
47 | 47 | self.assertGreater(len(hd.results), 0) |
48 | 48 | |
49 | - hd_count = get_doc.count_attribute('hd', 'tipo_hd') | |
49 | + hd_count = get_doc.count_attribute('memoria', 'interface_memoria') | |
50 | 50 | fd = open('/tmp/teste.json', 'w+') |
51 | 51 | fd.write(json.dumps(hd_count)) |
52 | 52 | fd.close() | ... | ... |
wscacicneo/views.py
... | ... | @@ -17,6 +17,7 @@ from wscacicneo.model.user import UserBase |
17 | 17 | from wscacicneo.model.notify import Notify |
18 | 18 | from wscacicneo.model.notify import NotifyBase |
19 | 19 | from wscacicneo.model import coleta_manual |
20 | +from wscacicneo.model.reports import Reports | |
20 | 21 | |
21 | 22 | from liblightbase.lbbase.struct import Base |
22 | 23 | from liblightbase.lbutils import conv |
... | ... | @@ -51,7 +52,7 @@ def home(request): |
51 | 52 | return {'project': 'WSCacicNeo'} |
52 | 53 | |
53 | 54 | @view_config(route_name='list_notify', renderer='templates/list_notify.pt') |
54 | -def reports(request): | |
55 | +def list_notify(request): | |
55 | 56 | notify_obj = Notify( |
56 | 57 | orgao = 'deasdsd', |
57 | 58 | id_coleta = 'saudhasd', |
... | ... | @@ -198,10 +199,6 @@ def error(request): |
198 | 199 | def configfav(request): |
199 | 200 | return {'project': 'WSCacicNeo'} |
200 | 201 | |
201 | -@view_config(route_name='reportsgestor', renderer='templates/reportsgestor.pt') | |
202 | -def reportsgestor(request): | |
203 | - return {'project': 'WSCacicNeo'} | |
204 | - | |
205 | 202 | @view_config(route_name='questionarcoleta', renderer='templates/questionarcoleta.pt') |
206 | 203 | def questionarcoleta(request): |
207 | 204 | return {'project': 'WSCacicNeo'} |
... | ... | @@ -238,9 +235,13 @@ def conf_report(request): |
238 | 235 | search = orgao_obj.search_list_orgaos() |
239 | 236 | return {'orgao_doc': search.results} |
240 | 237 | |
241 | -@view_config(route_name='report_hd', renderer='templates/report.pt') | |
242 | -def report_hd(request): | |
243 | - return { } | |
238 | +@view_config(route_name='report_itens', renderer='templates/report.pt') | |
239 | +def report_itens(request): | |
240 | + nm_orgao = request.matchdict['nm_orgao'] | |
241 | + attr = request.matchdict['attr'] | |
242 | + child = request.matchdict['child'] | |
243 | + data = Reports(nm_orgao).count_attribute(attr, child) | |
244 | + return {'data': data } | |
244 | 245 | |
245 | 246 | @view_config(route_name='post_orgao') |
246 | 247 | def post_orgao(request): | ... | ... |