Skip to content

Commit

Permalink
change url to Alice and Bob
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Oct 22, 2023
1 parent 77c0707 commit 47a5f7a
Show file tree
Hide file tree
Showing 32 changed files with 162 additions and 157 deletions.
2 changes: 1 addition & 1 deletion app/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __toString()
foreach ($this->events as $event) {
for ($d = 0; $d <= $event[2] - 1; $d++) {
if (date('y-m-d', strtotime($this->active_year . '-' . $this->active_month . '-' . $i . ' -' . $d . ' day')) === date('y-m-d', strtotime($event[1]))) {
$html .= '<a href="/controls/' . $event[4] . '"><div class="event' . $event[3] . '">';
$html .= '<a href="/bob/show/' . $event[4] . '"><div class="event' . $event[3] . '">';
$html .= $event[0];
$html .= '</div></a>';
}
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/GenerateTestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
use App\Models\Control;
use App\Models\Measure;
use Carbon\Carbon;
use Faker;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

use Faker;

class GenerateTestData extends Command
{
/**
Expand Down Expand Up @@ -71,7 +70,6 @@ public function handle()
// loop on measures
$delta = $perPeriod - rand(-$perPeriod / 2, $perPeriod / 2);


$faker = Faker\Factory::create();

foreach ($measures as $measure) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/ActionplanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ActionplanController extends Controller
*/
public function index()
{
// TODO : improve me
$actions =
DB::select('
select
Expand Down
43 changes: 21 additions & 22 deletions app/Http/Controllers/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function index(Request $request)
}
}
sort($attributes);
$attributes=array_unique($attributes);
$attributes = array_unique($attributes);

// get domain base on his title
$domain_title = $request->get('domain_title');
Expand Down Expand Up @@ -114,8 +114,9 @@ public function index(Request $request)
}
} else {
$period = $request->session()->get('period');
if ($period==null)
if ($period === null) {
$request->session()->put('period', 99);
}
}

// Status filter
Expand All @@ -124,8 +125,9 @@ public function index(Request $request)
$request->session()->put('status', $status);
} else {
$status = $request->session()->get('status');
if ($status==null)
$status="2";
if ($status === null) {
$status = '2';
}
}

// Late filter
Expand Down Expand Up @@ -214,7 +216,7 @@ public function index(Request $request)
public function create()
{
// does not exists in that way
return redirect('/control');
return redirect('/bob/index');
}

/**
Expand Down Expand Up @@ -242,9 +244,7 @@ public function show(int $id)
$control = Control::find($id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

if ($control->next_id !== null) {
$next_control = DB::table('controls')
Expand Down Expand Up @@ -286,9 +286,7 @@ public function edit(int $id)
$control = Control::find($id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

$documents = DB::table('documents')->where('control_id', $id)->get();

Expand Down Expand Up @@ -323,7 +321,7 @@ public function edit(int $id)
}
}
sort($values);
$values=array_unique($values);
$values = array_unique($values);

return view('controls.edit')
->with('control', $control)
Expand All @@ -349,9 +347,7 @@ public function destroy(int $id)
$control = Control::find($id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

// Delete files
$documents = Document::select('id')->where('control_id', $id)->get();
Expand All @@ -369,7 +365,7 @@ public function destroy(int $id)
// Then delete the control
$control->delete();

return redirect('/controls');
return redirect('/bob/index');
}

public function history()
Expand Down Expand Up @@ -413,6 +409,7 @@ public function domains(Request $request)
}

// count control never made
// TODO : improve me
$controls_never_made = DB::select(
'select domain_id
from controls c1
Expand All @@ -424,6 +421,7 @@ public function domains(Request $request)
);

// Last controls made by measures
// TODO : improve me
$active_controls = DB::select('
select
c2.id,
Expand All @@ -442,7 +440,7 @@ public function domains(Request $request)
order by domains.title;');

// return
return view('/radar/domains')
return view('radar.domains')
->with('domains', $domains)
->with('scopes', $scopes)
->with('active_controls', $active_controls)
Expand Down Expand Up @@ -514,7 +512,7 @@ public function measures(Request $request)
->get();

// return
return view('radar.controls')
return view('/radar/controls')
->with('scopes', $scopes)
->with('controls', $controls)
// ->with('cur_date', $cur_date)
Expand All @@ -529,6 +527,7 @@ public function attributes(Request $request)
->get();

// Controls made
// TODO : improve me
$controls = DB::select('
select
c2.id,
Expand Down Expand Up @@ -628,7 +627,7 @@ public function unplan(Request $request)
$control->delete();
}

return redirect('/measures');
return redirect('/alice/index');
}

/**
Expand Down Expand Up @@ -674,7 +673,7 @@ public function doPlan(Request $request)
$control->owners()->sync($request->input('owners', []));
$control->save();

return redirect('/controls/'.$request->id);
return redirect('/bob/show/'.$request->id);
}

public function make(Request $request)
Expand Down Expand Up @@ -811,7 +810,7 @@ public function save(Request $request)

$control->save();

return redirect('/control/show/' . $request->id);
return redirect('/bob/show/' . $request->id);
}

/**
Expand All @@ -835,7 +834,7 @@ public function draft(Request $request)

$control->save();

return redirect('/control/show/'.$id);
return redirect('/bob/show/'.$id);
}

public function export()
Expand Down
21 changes: 14 additions & 7 deletions app/Http/Controllers/MeasureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function create()
}
}
sort($values);
$values=array_unique($values);
$values = array_unique($values);
}

// store it in the response
Expand Down Expand Up @@ -136,7 +136,7 @@ public function store(Request $request)

$request->session()->put('domain', $measure->domain_id);

return redirect('/measures');
return redirect('/alice/index');
}

/**
Expand All @@ -146,9 +146,11 @@ public function store(Request $request)
*
* @return \Illuminate\Http\Response
*/
public function show(Measure $measure)
public function show(int $id)
{
return view('measures.show', compact('measure'));
$measure = Measure::where('id', $id)->get()->first();
return view('measures.show')
->with('measure', $measure);
}

/**
Expand All @@ -158,11 +160,16 @@ public function show(Measure $measure)
*
* @return \Illuminate\Http\Response
*/
public function edit(Measure $measure)
public function edit(int $id)
{
// Not for Auditor
abort_if(Auth::User()->role === 3, Response::HTTP_FORBIDDEN, '403 Forbidden');

$measure = Measure::find($id);

// not found
abort_if($measure === null, Response::HTTP_NOT_FOUND, '404 Not Found');

// get the list of domains
$domains = Domain::All();

Expand All @@ -179,7 +186,7 @@ public function edit(Measure $measure)
}
}
sort($values);
$values=array_unique($values);
$values = array_unique($values);

return view('measures.edit', compact('measure', 'values', 'domains'))->with('domains', $domains);
}
Expand Down Expand Up @@ -254,7 +261,7 @@ public function destroy(Measure $measure)

$measure->delete();

return redirect('/measures');
return redirect('/alice/index');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/ForceXForwardedProto.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function handle($request, Closure $next)

return $next($request);
}
}
}
2 changes: 1 addition & 1 deletion app/Models/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Control extends Model
'attributes',
'model',
'action_plan',
'realisation_date'
'realisation_date',
];

protected $dates = [
Expand Down
6 changes: 3 additions & 3 deletions resources/views/actions/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@foreach($actions as $action)
<tr>
<td valign="top">
<a id="{{ $action->clause }}" href="/measures/{{$action->measure_id}}">
<a id="{{ $action->clause }}" href="/alice/show/{{$action->measure_id}}">
{{ $action->clause }}
</a>
</td>
Expand All @@ -38,8 +38,8 @@
<pre>{{ $action->action_plan }}</pre>
</td>
<td>{{ $action->scope }}</td>
<td><a id="{{ $action->plan_date }}" href="/controls/{{ $action->id }}">{{ $action->plan_date }}</a></td>
<td><a id="{{ $action->next_date }}" href="/controls/{{ $action->next_id }}">{{ $action->next_date }}</a></td>
<td><a id="{{ $action->plan_date }}" href="/bob/show/{{ $action->id }}">{{ $action->plan_date }}</a></td>
<td><a id="{{ $action->next_date }}" href="/bob/show/{{ $action->next_id }}">{{ $action->next_date }}</a></td>
<td>
<center id="{{ $action->score }}">
@if ($action->score==1)
Expand Down
6 changes: 2 additions & 4 deletions resources/views/controls/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
@endif

<form method="POST" action="/control/save">
<form method="POST" action="/bob/save">
@csrf
<input type="hidden" name="id" value="{{ $control->id }}"/>

Expand Down Expand Up @@ -98,8 +98,6 @@
<div class="row">
<div class="cell-1">
<strong>{{ trans("cruds.control.fields.evidence") }}</strong>
<br>
<a target="_new" href="/control/template/{{ $control->id }}">{{ trans("cruds.control.fields.model") }}</a>
</div>
<div class="cell-6">
<div class="dropzone dropzone-previews" id="dropzoneFileUpload"></div>
Expand Down Expand Up @@ -187,7 +185,7 @@
</button>
</form>
&nbsp;
<form action="/controls/{{$control->id}}">
<form action="/bob/show/{{$control->id}}">
<button type="submit" class="button cancel">
<span class="mif-cancel"></span>
&nbsp;
Expand Down
8 changes: 4 additions & 4 deletions resources/views/controls/history.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
?>
<tr>
<td align="center">
<a href="/controls?period={{$i+$delta}}&domain=0&scope=none&status=0">
<a href="/bob/index?period={{$i+$delta}}&domain=0&scope=none&status=0">
<?php
echo $first->format("m/Y");
?>
Expand Down Expand Up @@ -145,7 +145,7 @@
?>
<tr>
<td align="center">
<a href="/controls?period={{$i+$delta}}&domain=0&scope=none&status=0">
<a href="/bob/index?period={{$i+$delta}}&domain=0&scope=none&status=0">
<?php
echo $first->format("m/Y");
?>
Expand Down Expand Up @@ -432,15 +432,15 @@
onClick: (event, elements, chart) => {
var activePoints = window.myBar.getElementsAtEvent(event);
var firstPoint = activePoints[0];
window.location.href="/control/history?date="+(barChartData.labels[firstPoint._index]);
window.location.href="/bob/history?date="+(barChartData.labels[firstPoint._index]);
}
},
});
};
window.addEventListener('load', function(){
document.getElementById('date').addEventListener('change', function(){
window.location = '/control/history?date=' + this.value;
window.location = '/bob/history?date=' + this.value;
}, false);
}, false);
Expand Down
Loading

0 comments on commit 47a5f7a

Please sign in to comment.