Browse Source

Added active toggle button to endpoints

master
Shyim 6 years ago
parent
commit
1acc9fded4
  1. 10
      README.md
  2. 8
      public/theme/src/components/ReCast/Streams/EditStream.vue
  3. 27
      src/Controller/Streams.php

10
README.md

@ -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)

8
public/theme/src/components/ReCast/Streams/EditStream.vue

@ -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;
});
});
} }
} }
} }

27
src/Controller/Streams.php

@ -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>

Loading…
Cancel
Save