2 use strict; use warnings;
4 # --------------------------------------------------------------------
5 # Loads the offline script files for a given org, sorts and runs the
6 # scripts, and returns the exception list
7 # --------------------------------------------------------------------
11 require 'offline-lib.pl';
16 my $evt = $U->check_perms(&offline_requestor->id, &offline_org, 'OFFLINE_VIEW');
18 handle_event($evt) if $evt;
20 my $html = &offline_cgi->param('html');
21 my $wslist = &gather_workstations;
24 &report_html($wslist);
27 &report_json($wslist);
31 # XXX Make me search by session key ...
34 # --------------------------------------------------------------------
35 # Collects a list of workstations that have pending files
36 # --------------------------------------------------------------------
37 sub gather_workstations {
38 my $dir = &offline_pending_dir;
39 my @files = <$dir/*.log>;
40 $_ =~ s/\.log//og for @files; # remove .log
41 $_ =~ s#/.*/(\w+)#$1#og for @files; # remove leading file path
47 # --------------------------------------------------------------------
48 # Reports the workstations and their results as JSON
49 # --------------------------------------------------------------------
53 my $meta = &offline_read_meta;
54 my $results = &offline_read_results;
55 for my $ws (@$wslist) {
56 my ($m) = grep { $_ and $_->{'log'} and $_->{'log'} =~ m#/.*/$ws.log# } @$meta;
57 my @res = grep { $_->{command}->{_workstation} eq $ws } @$results;
59 push( @data, { meta => $m, workstation => $ws, results => \@res } );
61 &offline_handle_json(\@data);