1
0
mirror of https://github.com/r4sas/recastin-panel synced 2025-08-26 13:31:47 +00:00

Added active toggle button to endpoints

This commit is contained in:
Shyim 2018-04-26 10:35:17 +02:00
parent b5731a28d9
commit 1acc9fded4
3 changed files with 41 additions and 4 deletions

View File

@ -20,10 +20,12 @@ ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. Yo
## Screenshots ## Screenshots
![Dashboard](https://i.imgur.com/CJFRqFM.png) ![Dashboard](https://i.imgur.com/6gcqWTh.png)
![List Streams](https://i.imgur.com/xRi6eQT.png) ![List Streams](https://i.imgur.com/E5FVy9K.png)
![Add Endpoint](https://i.imgur.com/OvLihhw.png) ![Edit Stream](https://i.imgur.com/PHYjnQn.png)
![Setup](https://i.imgur.com/gPDnIfr.png) ![Add Endpoint](https://i.imgur.com/bYteEQR.png)
![Setup](https://i.imgur.com/ZfP7Tpv.png)

View File

@ -39,6 +39,7 @@
<td>{{ endpoint.server }}</td> <td>{{ endpoint.server }}</td>
<td> <td>
<a :href="'#/ucp/streams/' + $route.params.id + '/endpoints/' + endpoint.id" class="btn btn-secondary">Edit</a> <a :href="'#/ucp/streams/' + $route.params.id + '/endpoints/' + endpoint.id" class="btn btn-secondary">Edit</a>
<a v-on:click="toggleEndpoint(endpoint)" class="btn btn-info">{{ endpoint.active ? 'Disable' : 'Enable' }}</a>
<a v-on:click="deleteEndpoint(endpoint)" class="btn btn-danger">Delete</a> <a v-on:click="deleteEndpoint(endpoint)" class="btn btn-danger">Delete</a>
</td> </td>
</tr> </tr>
@ -101,6 +102,13 @@
deleteEndpoint: function (endpoint) { deleteEndpoint: function (endpoint) {
this.endpoints.splice(this.endpoints.indexOf(endpoint), 1); this.endpoints.splice(this.endpoints.indexOf(endpoint), 1);
this.axios.post('/streams/deleteEndpoint', {id: endpoint.id}); this.axios.post('/streams/deleteEndpoint', {id: endpoint.id});
},
toggleEndpoint: function (endpoint) {
this.axios.post('/streams/toggleEndpoint', {id: endpoint.id}).then(response => {
this.axios.get('/streams/' + this.$route.params.id + '/endpoints/').then(response => {
this.endpoints = response.data;
});
});
} }
} }
} }

View File

@ -241,6 +241,33 @@ class Streams extends Controller
return new JsonResponse($endpoint); return new JsonResponse($endpoint);
} }
/**
* @Route(path="/toggleEndpoint")
* @param Request $request
* @return JsonResponse
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @author Soner Sayakci <shyim@posteo.de>
*/
public function toggleEndpoint(Request $request) : JsonResponse
{
$id = $request->request->get('id');
$endpoint = $this->endpointRepository->find($id);
if ($endpoint === null || $endpoint->getStream()->getUserId() !== $this->getUser()->getId()) {
return new JsonResponse([]);
}
$endpoint->setActive(!$endpoint->isActive());
$manager = $this->get('doctrine.orm.entity_manager');
$manager->persist($endpoint);
$manager->flush();
return new JsonResponse($endpoint);
}
/** /**
* @Route(path="/deleteEndpoint") * @Route(path="/deleteEndpoint")
* @author Soner Sayakci <shyim@posteo.de> * @author Soner Sayakci <shyim@posteo.de>