/**
  * Displays the specified computers patches.
  *
  * @param int|string $computerId
  *
  * @return mixed
  */
 public function index($computerId)
 {
     $computer = $this->computer->findOrFail($computerId);
     $navbar = $this->presenter->navbar($computer);
     $patches = $this->presenter->table($computer);
     return view('pages.computers.patches.index', compact('computer', 'navbar', 'patches'));
 }
 /**
  * Catches and runs operations when a computer is deleted.
  *
  * @param Computer $computer
  */
 public function deleting(Computer $computer)
 {
     if (!$computer->deleted_at) {
         $statuses = $computer->statuses()->get();
         foreach ($statuses as $status) {
             $status->delete();
         }
     }
 }
 /**
  * Checks the specified computers online status.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function check($id)
 {
     $computer = $this->computer->findOrFail($id);
     if ($this->dispatch(new CreateStatus($computer))) {
         flash()->success('Success!', 'Successfully updated status.');
         return redirect()->back();
     }
     flash()->error('Error!', 'There was an issue updating this computers status. Please try again.');
     return redirect()->back();
 }
Exemple #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $computers = $this->computer->get();
     $checked = 0;
     foreach ($computers as $computer) {
         // Check the computers status.
         $this->dispatch(new CreateStatus($computer));
         $checked++;
     }
     $this->info("Successfully checked {$checked} computers.");
 }
Exemple #5
0
 /**
  * Creates and returns a new Computer.
  *
  * @param Computer $model
  *
  * @return bool|Computer
  */
 public function handle(Computer $model)
 {
     $computer = $model->firstOrNew(['dn' => $this->dn]);
     $computer->type_id = $this->typeId;
     $computer->os_id = $this->osId;
     $computer->name = $this->name;
     $computer->description = $this->description;
     $computer->model = $this->model;
     $computer->save();
     return $computer;
 }
Exemple #6
0
 /**
  * Execute the job.
  *
  * @return Computer|bool
  */
 public function handle()
 {
     $this->computer->os_id = OperatingSystem::findOrFail($this->request->input('os'))->id;
     $this->computer->type_id = ComputerType::findOrFail($this->request->input('type'))->id;
     $this->computer->name = $this->request->input('name');
     $this->computer->ip = $this->request->input('ip');
     $this->computer->model = $this->request->input('model');
     $this->computer->description = $this->request->input('description');
     if ($this->computer->save()) {
         return $this->computer;
     }
     return false;
 }
Exemple #7
0
 /**
  * Creates a new computer status.
  *
  * @param ComputerStatus $status
  *
  * @return ComputerStatus|bool
  */
 public function handle(ComputerStatus $status)
 {
     $status->computer_id = $this->computer->id;
     $latency = $this->computer->ping();
     if ($latency) {
         $status->online = true;
         $status->latency = $latency;
     } else {
         $status->online = false;
     }
     if ($status->save()) {
         return $status;
     }
     return false;
 }
 /**
  * Returns a new form of the specified patch computers.
  *
  * @param Patch $patch
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(Patch $patch)
 {
     return $this->form->of('patches.computers', function (FormGrid $form) use($patch) {
         $form->attributes(['method' => 'POST', 'url' => route('resources.patches.computers.store', [$patch->id])]);
         $form->with($patch);
         $form->layout('components.form-modal');
         $form->fieldset(function (Fieldset $fieldset) {
             $fieldset->control('input:text', 'patched')->label('Patched On')->attributes(['class' => 'date-picker', 'placeholder' => 'Click to select a date / time when the patch was applied.']);
             $fieldset->control('input:select', 'computers[]')->label('Computers')->attributes(['class' => 'select-multiple', 'multiple' => true, 'data-placeholder' => 'Select Computers'])->options(function (Patch $patch) {
                 $computers = $patch->computers()->get()->pluck('id');
                 return Computer::whereNotIn('id', $computers)->pluck('name', 'id');
             });
         });
     });
 }
 /**
  * Returns a new table of all of the specified computers patches.
  *
  * @param Computer $computer
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Computer $computer)
 {
     return (new PatchPresenter($this->form, $this->table))->table($computer->patches());
 }
Exemple #10
0
 /**
  * Execute the job.
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function handle()
 {
     return $this->computer->patches()->create(['title' => $this->request->input('title'), 'description' => $this->request->input('description')]);
 }
 /**
  * Returns a calendar chart of the graph of the specified computer's statuses.
  *
  * @param Computer $computer
  *
  * @return mixed
  */
 public function graphOfStatus(Computer $computer)
 {
     $statuses = $computer->statuses()->thisMonth()->get();
     $dataTable = Lava::DataTable();
     $dataTable->addDateColumn('Date')->addNumberColumn('Status');
     foreach ($statuses as $status) {
         $dataTable->addRow([$status->created_at, $status->online]);
     }
     return Lava::LineChart('Status')->setOptions(['title' => "{$computer->name} Status This Month Over Time", 'datatable' => $dataTable, 'legend' => (new Legend())->position('bottom'), 'vAxis' => (new VerticalAxis())->title('Offline / Online')]);
 }
 /**
  * Creates a new computer from a request.
  *
  * @param ComputerRequest $request
  *
  * @return Computer|bool
  */
 protected function storeFromRequest(ComputerRequest $request)
 {
     $computer = $this->computer->newInstance();
     return $this->dispatch(new Store($request, $computer));
 }