Commit 4a8a9412 authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

add fetch project

parent db34b0ab
...@@ -53,9 +53,36 @@ class PatchEdit extends Component ...@@ -53,9 +53,36 @@ class PatchEdit extends Component
$this->patchId = $editPid; $this->patchId = $editPid;
$this->loadPatchData(); $this->loadPatchData();
} }
public function updatedSearchProject()
{
$this->fetchProjects();
}
public function fetchProjects()
{
$client = new Client([
'headers' => [
'Authorization' => 'Bearer ' . env('GITLAB_API_TOKEN'),
'Accept' => 'application/json',
],
'verify' => false,
]);
$page = 1;
$perPage = 100;
$response = $client->get(env('GITLAB_API_URL') . '/projects', [
'query' => [
'membership' => true,
'min_access_level' => 30,
'search' => $this->searchProject,
'per_page' => $perPage,
],
]);
$this->projects = json_decode($response->getBody(), true);
$this->dispatchBrowserEvent('projects-fetched');
}
public function getChangedFiles() public function getChangedFiles()
{ {
// dd($this->selectedProject);die();
$this->fileChangesTemp = []; $this->fileChangesTemp = [];
$client = new Client([ $client = new Client([
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
console.log(result) console.log(result)
progress = result; progress = result;
if (progress >= 100) { if (progress >= 100) {
progress = 0 ;
clearInterval(interval); clearInterval(interval);
} }
}); });
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
isLoading: false, isLoading: false,
fetchProjects() { fetchProjects() {
this.isLoading = true; this.isLoading = true;
this.selectedProject = '60'; {{-- this.selectedProject = '60'; --}}
this.$wire.set('searchProject', this.searchQuery); this.$wire.set('searchProject', this.searchQuery);
}, },
fetchBranches() { fetchBranches() {
...@@ -81,7 +82,7 @@ ...@@ -81,7 +82,7 @@
<div x-show="isLoading" class="mx-auto mt-2"> <div x-show="isLoading" class="mx-auto mt-2">
<span>Loading...</span> <span>Loading...</span>
</div> </div>
<select x-model="selectedProject" x-show="!isLoading" @change="fetchBranches" <select x-model="selectedProject" x-show="!isLoading"
id="project" class="ml-2 w-64 h-8 mt-1 border border-gray-300 rounded-md"> id="project" class="ml-2 w-64 h-8 mt-1 border border-gray-300 rounded-md">
<option value="">Choose Project</option> <option value="">Choose Project</option>
<template x-for="project in projects" :key="project.id"> <template x-for="project in projects" :key="project.id">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment