diff --git a/module/Application/src/Controller/FormsController.php b/module/Application/src/Controller/FormsController.php deleted file mode 100644 index b2d12fe..0000000 --- a/module/Application/src/Controller/FormsController.php +++ /dev/null @@ -1,26 +0,0 @@ -searchService = $searchService; + $this->searchForm = $searchForm; } public function dashboardAction() @@ -56,8 +60,41 @@ public function detailAction() $viewModel = new ViewModel(); $jobDetail = $this->searchService->searchById($jobId); -// var_dump($jobDetail); + $viewModel->job = $jobDetail; return $viewModel; } + + public function manualSearchAction() + { + $viewModel = new ViewModel(); + $viewModel->form = $this->searchForm; + + $request = $this->getRequest(); + if(!$request->isPost()) { + return $viewModel; + } + + + $postData = $request->getPost(); + + $this->searchForm->setData($postData); + if(!$this->searchForm->isValid()) { + return $viewModel; + } + + $formData = $this->searchForm->getData(); + $position = $formData['position']; + $location = $formData['location']; + + try { + + $viewModel->result = $this->searchService->searchByCombinedParams($position, $location); + } catch (\Exception $ex) { + $viewModel->error = true; + return $viewModel; + } + + return $viewModel; + } } diff --git a/module/Application/src/Factory/IndexControllerFactory.php b/module/Application/src/Factory/IndexControllerFactory.php index 063beed..f75086a 100644 --- a/module/Application/src/Factory/IndexControllerFactory.php +++ b/module/Application/src/Factory/IndexControllerFactory.php @@ -4,6 +4,7 @@ use Application\Controller\IndexController; +use Application\Form\SearchForm; use Github\Service\SearchService; use Interop\Container\ContainerInterface; use Interop\Container\Exception\ContainerException; @@ -28,6 +29,8 @@ class IndexControllerFactory implements FactoryInterface */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { - return new IndexController($container->get(SearchService::class)); + $searchForm = $container->get('FormElementManager')->get(SearchForm::class); + + return new IndexController($container->get(SearchService::class), $searchForm); } } \ No newline at end of file diff --git a/module/Application/src/Form/SearchForm.php b/module/Application/src/Form/SearchForm.php new file mode 100644 index 0000000..1f2f743 --- /dev/null +++ b/module/Application/src/Form/SearchForm.php @@ -0,0 +1,32 @@ +setAttributes([ + 'class' => 'form-control has-feedback-left', + 'maxlength' => 10, + 'placeholder' => "PHP, JAVA, ...", + ]); + + $this->add($position); + + $location = new Text('location'); + $location->setAttributes([ + 'class' => 'form-control has-feedback-left', + 'maxlength' => 20, + 'placeholder' => "London, Berlin, ...", + ]); + + $this->add($location); + } +} \ No newline at end of file diff --git a/module/Application/view/application/index/dashboard.phtml b/module/Application/view/application/index/dashboard.phtml index 867a02b..a066e29 100755 --- a/module/Application/view/application/index/dashboard.phtml +++ b/module/Application/view/application/index/dashboard.phtml @@ -84,23 +84,25 @@ inlineScript()->captureStart(); +//echo $this->inlineScript()->captureStart(); echo $this->headScript() -// ->appendFile($this->basePath('vendors/Chart.js/dist/Chart.min.js')) -// ->appendFile($this->basePath('vendors/gauge.js/dista/gauge.min.js')) -// ->appendFile($this->basePath('vendors/bootstrap-progressbar/bootstrap-progressbar.min.js')) -// ->appendFile($this->basePath('vendors/iCheck/icheck.min.js')) -// ->appendFile($this->basePath('vendors/skycons/skycons.js')) -// ->appendFile($this->basePath('vendors/Flot/jquery.flot.js')) -// ->appendFile($this->basePath('vendors/Flot/jquery.flot.pie.js')) -// ->appendFile($this->basePath('vendors/Flot/jquery.flot.time.js')) -// ->appendFile($this->basePath('vendors/Flot/jquery.flot.stack.js')) -// ->appendFile($this->basePath('vendors/Flot/jquery.flot.resize.js')) -// ->appendFile($this->basePath('vendors/flot.orderbars/js/jquery.flot.orderBars.js')) -// ->appendFile($this->basePath('ve ndors/flot-spline/js/jquery.flot.spline.min.js')) -// ->appendFile($this->basePath('vendors/flot.curvedlines/curvedLines.js')) -// ->appendFile($this->basePath('vendors/DateJS/build/date.js')) +//// ->appendFile($this->basePath('vendors/Chart.js/dist/Chart.min.js')) +//// ->appendFile($this->basePath('vendors/gauge.js/dista/gauge.min.js')) +//// ->appendFile($this->basePath('vendors/bootstrap-progressbar/bootstrap-progressbar.min.js')) +//// ->appendFile($this->basePath('vendors/iCheck/icheck.min.js')) +//// ->appendFile($this->basePath('vendors/skycons/skycons.js')) +//// ->appendFile($this->basePath('vendors/Flot/jquery.flot.js')) +//// ->appendFile($this->basePath('vendors/Flot/jquery.flot.pie.js')) +//// ->appendFile($this->basePath('vendors/Flot/jquery.flot.time.js')) +//// ->appendFile($this->basePath('vendors/Flot/jquery.flot.stack.js')) +//// ->appendFile($this->basePath('vendors/Flot/jquery.flot.resize.js')) +//// ->appendFile($this->basePath('vendors/flot.orderbars/js/jquery.flot.orderBars.js')) +//// ->appendFile($this->basePath('ve ndors/flot-spline/js/jquery.flot.spline.min.js')) +//// ->appendFile($this->basePath('vendors/flot.curvedlines/curvedLines.js')) +//// ->appendFile($this->basePath('vendors/DateJS/build/date.js')) ->appendFile($this->basePath('build/js/custom.min.js')); -$this->inlineScript()->captureEnd(); \ No newline at end of file +//echo $this->headScript()->offsetSetScript(10, $this->basePath('build/js/custom.min.js'), 'text/javascript'); + +//echo $this->inlineScript()->captureEnd(); \ No newline at end of file diff --git a/module/Application/view/application/index/manual-search.phtml b/module/Application/view/application/index/manual-search.phtml new file mode 100644 index 0000000..dd9c79e --- /dev/null +++ b/module/Application/view/application/index/manual-search.phtml @@ -0,0 +1,99 @@ + + + + + + + + + + + +form; +$form->setAttribute('action', $this->url() . '/manual-search'); +$form->setAttribute('method', 'POST'); +$form->setAttribute('class', 'form-horizontal form-label-left input_mask col-md-offset-1'); +$form->prepare(); +?> + +
+
+
+
+ +
+ form()->openTag($form); + ?> +
+ formElement($form->get('position')); ?> + +
+
+ formElement($form->get('location')); ?> + +
+ +
+ +
+ form()->closeTag(); + ?> +
+
+ result) : ?> + + + + + + + + + + + + result as $k => $res) : + + ?> + + + + + + + + + + +
CompanyTitleLocationType
+ + More +
+ +
+
+
+ +headScript() + ->appendFile($this->basePath('vendors/datatables.net/js/jquery.dataTables.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-bs/js/dataTables.bootstrap.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons/js/dataTables.buttons.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons/js/buttons.flash.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons/js/buttons.html5.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons/js/buttons.print.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-buttons/js/buttons.print.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-keytable/js/dataTables.keyTable.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-responsive/js/dataTables.responsive.min.js')) + ->appendFile($this->basePath('vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js')) + ->appendFile($this->basePath('vendors/datatables.net-scroller/js/dataTables.scroller.min.js')) + ->appendFile($this->basePath('build/js/custom.min.js')); +?> diff --git a/module/Application/view/layout/layout.phtml b/module/Application/view/layout/layout.phtml index 83c71a9..41989de 100755 --- a/module/Application/view/layout/layout.phtml +++ b/module/Application/view/layout/layout.phtml @@ -22,6 +22,15 @@ ->prependStylesheet($this->basePath('vendors/bootstrap/dist/css/bootstrap.min.css')) ?> + + headScript() + ->prependFile($this->basePath('vendors/nprogress/nprogress.js')) + ->prependFile($this->basePath('vendors/fastclick/lib/fastclick.js')) + ->prependFile($this->basePath('vendors/bootstrap/dist/js/bootstrap.min.js')) + ->prependFile($this->basePath('vendors/jquery/dist/jquery.min.js')) + + ?> + @@ -44,20 +53,6 @@ - - - -headScript() - ->prependFile($this->basePath('vendors/nprogress/nprogress.js')) - ->prependFile($this->basePath('vendors/fastclick/lib/fastclick.js')) - ->prependFile($this->basePath('vendors/bootstrap/dist/js/bootstrap.min.js')) - ->prependFile($this->basePath('vendors/jquery/dist/jquery.min.js')) - -?> - - - - inlineScript() ?> diff --git a/module/Application/view/partials/left-sidebar.phtml b/module/Application/view/partials/left-sidebar.phtml index fe92c37..c6282ff 100644 --- a/module/Application/view/partials/left-sidebar.phtml +++ b/module/Application/view/partials/left-sidebar.phtml @@ -14,6 +14,9 @@
  • Home
  • +
  • + Manual Search +
  • diff --git a/module/Github/src/Service/SearchService.php b/module/Github/src/Service/SearchService.php index 836d9bc..498fd74 100644 --- a/module/Github/src/Service/SearchService.php +++ b/module/Github/src/Service/SearchService.php @@ -63,7 +63,20 @@ public function searchByCombinedParams( $fullTime = false ) { - // TODO: Implement searchByCombinedParams() method. + $url = self::GITHUB_JOBS_URL . 'positions.json'; + + $params = [ + 'description' => $description, + 'location' => $location, + ]; + + $response = HostService::makeApiCall($url, $params); + + try { + return Json::decode($response, true); + } catch (\Exception $ex) { + return null; + } } /** diff --git a/module/Utils/src/Service/HostService.php b/module/Utils/src/Service/HostService.php index 1d73646..4bc7c41 100644 --- a/module/Utils/src/Service/HostService.php +++ b/module/Utils/src/Service/HostService.php @@ -26,12 +26,21 @@ public static function makeApiCall($url, $params = null, $isPost = false, $cont if(false == $isPost) { + if(is_array($params)) { + $requestStr = '?'; foreach ($params as $key => $param) { + if(empty($params)) { + continue; + } + $requestStr .= $key . '=' . $param . '&'; } $url .= $requestStr; + + } + } else { $request->setMethod(Request::METHOD_POST); } @@ -47,8 +56,6 @@ public static function makeApiCall($url, $params = null, $isPost = false, $cont } elseif($contentType == 'application/json') { $request->setContent(json_encode($params)); - } else { - $request->setContent($params); } $response = $client->dispatch($request);