|
@@ -4,6 +4,11 @@ use Data::Dumper;
|
|
|
use POSIX ();
|
|
|
|
|
|
our $VERSION = '0.1';
|
|
|
+die "config.yml not loaded" unless defined config->{appname};
|
|
|
+
|
|
|
+get '/' => sub {
|
|
|
+ return "Welcome on " . config->{appname};
|
|
|
+};
|
|
|
|
|
|
get '/shake' => sub {
|
|
|
my %param = params;
|
|
@@ -50,7 +55,7 @@ get '/status' => sub {
|
|
|
my $opt_projet = $param{projetId};
|
|
|
|
|
|
my $cocktail_store = config->{cocktail}{store};
|
|
|
- if(not -d $cocktail_store) {
|
|
|
+ if(not defined $cocktail_store) {
|
|
|
$error->{message} .= qq{"cocktail:store" n'est pas configuré dans config.yml};
|
|
|
}
|
|
|
|
|
@@ -62,22 +67,25 @@ get '/status' => sub {
|
|
|
return template 'error', $error;
|
|
|
}
|
|
|
|
|
|
- my $compilation_status;
|
|
|
+ my ($compilation_status, $compilation_text);
|
|
|
if(-e "$cocktail_store/$opt_dossier/$opt_projet.lock") {
|
|
|
- $compilation_status = "En cours de compilation...";
|
|
|
+ $compilation_text = "En cours de compilation...";
|
|
|
+ $compilation_status = 'IN PROGRESS';
|
|
|
}
|
|
|
elsif(-e "$cocktail_store/$opt_dossier/$opt_projet.pdf") {
|
|
|
my @stat = stat "$cocktail_store/$opt_dossier/$opt_projet.pdf";
|
|
|
my $ctime = $stat[10];
|
|
|
my $date_time = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime($ctime) );
|
|
|
- $compilation_status = $date_time;
|
|
|
+ $compilation_text = $date_time;
|
|
|
+ $compilation_status = 'COMPLETED';
|
|
|
}
|
|
|
else {
|
|
|
- $compilation_status = "Aucune compilation.";
|
|
|
+ $compilation_text = "Aucune compilation.";
|
|
|
+ $compilation_status = 'NONE';
|
|
|
}
|
|
|
|
|
|
header 'Content-Type' => 'application/json';
|
|
|
- return to_json { text => $compilation_status };
|
|
|
+ return to_json { text => $compilation_text, status => $compilation_status };
|
|
|
};
|
|
|
|
|
|
|