Browse Source

Added active flag to endpoints

master
Shyim 7 years ago
parent
commit
e271d1bfb4
  1. 2
      README.md
  2. 7
      public/theme/src/components/ReCast/Endpoints/EditEndpoint.vue
  3. 2
      public/theme/src/components/ReCast/Streams/EditStream.vue
  4. 2
      public/theme/src/components/ReCast/Streams/List.vue
  5. 1
      src/Controller/Streams.php
  6. 24
      src/Entity/Endpoint.php
  7. 13
      src/Repository/StreamsRepository.php

2
README.md

@ -10,7 +10,7 @@ ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. Yo @@ -10,7 +10,7 @@ ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. Yo
* Checkout this project, copy .env.dist to .env and adjust the settings
* Run ```composer install --no-dev -o```
* Generate JWT Keys, following [Documentation](https://github.com/lexik/LexikJWTAuthenticationBundle/blob/HEAD/Resources/doc/index.md#installation)
* Create the database ```php bin/console doctrine:schema:create```
* Create the database ```php bin/console doctrine:migrations:migrate```
* Go to ``public/theme``, run ``npm install`` and copy the generated files to public (``cp -R static ..``)
* Create a new crontab entry which runs every minute ```php bin/console recast:cron```
* Create a new user with ```php bin/console recast:create:user```

7
public/theme/src/components/ReCast/Endpoints/EditEndpoint.vue

@ -9,6 +9,10 @@ @@ -9,6 +9,10 @@
<card>
<fg-input label="Name" v-model="endpoint.name"></fg-input>
<div class="form-group">
<p-checkbox v-model="endpoint.active">Active</p-checkbox>
</div>
<div class="form-group">
<label class="control-label">
Type
@ -51,6 +55,7 @@ @@ -51,6 +55,7 @@
return {
endpoint: {
name: '',
active: false,
type: 'Mixer',
server: '',
streamKey: '',
@ -74,7 +79,7 @@ @@ -74,7 +79,7 @@
methods: {
save: function () {
this.axios.post('/streams/' + this.$route.params.streamId + '/endpoints/update', this.endpoint).then(() => {
this.$router.push('/ucp/streams/' + this.$route.params.streamId + '/endpoints');
this.$router.push('/ucp/streams/' + this.$route.params.streamId + '/');
})
}
},

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

@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
<table class="table">
<thead class="thead-dark">
<tr>
<th>Active</th>
<th>Name</th>
<th>Service</th>
<th>Location</th>
@ -32,6 +33,7 @@ @@ -32,6 +33,7 @@
</thead>
<tbody>
<tr v-for="endpoint in endpoints">
<td><i class="fa fa-circle" :class="endpoint.active ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td>{{ endpoint.name }}</td>
<td>{{ endpoint.type }}</td>
<td>{{ endpoint.server }}</td>

2
public/theme/src/components/ReCast/Streams/List.vue

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
<thead class="thead-dark">
<tr>
<th>Live</th>
<th>Active</th>
<th>Name</th>
<th>Endpoints</th>
<th>Action</th>
@ -18,6 +19,7 @@ @@ -18,6 +19,7 @@
<tbody>
<tr v-for="stream in streams">
<td><i class="fa fa-circle" :class="stream.live ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td><i class="fa fa-circle" :class="stream.active ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td>{{ stream.name }}</td>
<td>{{ getProviders(stream) }}</td>
<td>

1
src/Controller/Streams.php

@ -208,6 +208,7 @@ class Streams extends Controller @@ -208,6 +208,7 @@ class Streams extends Controller
$endpoint = !empty($requestBody['id']) ? $this->endpointRepository->find($requestBody['id']) : new Endpoint();
$endpoint->setName($requestBody['name']);
$endpoint->setActive($requestBody['active']);
$endpoint->setType($requestBody['type']);
$endpoint->setServer($requestBody['server']);
$endpoint->setStreamKey($requestBody['streamKey']);

24
src/Entity/Endpoint.php

@ -21,6 +21,12 @@ class Endpoint implements \JsonSerializable @@ -21,6 +21,12 @@ class Endpoint implements \JsonSerializable
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default": true})
* @var bool
*/
private $active;
/**
* @ORM\Column(type="string", length=255)
* @var string
@ -60,6 +66,24 @@ class Endpoint implements \JsonSerializable @@ -60,6 +66,24 @@ class Endpoint implements \JsonSerializable
return $this->id;
}
/**
* @return bool
* @author Soner Sayakci <shyim@posteo.de>
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
* @author Soner Sayakci <shyim@posteo.de>
*/
public function setActive(bool $active): void
{
$this->active = $active;
}
/**
* @return string
* @author Soner Sayakci <shyim@posteo.de>

13
src/Repository/StreamsRepository.php

@ -42,8 +42,17 @@ class StreamsRepository extends ServiceEntityRepository @@ -42,8 +42,17 @@ class StreamsRepository extends ServiceEntityRepository
* @return Streams[]
* @author Soner Sayakci <shyim@posteo.de>
*/
public function getActiveStreams()
public function getActiveStreams(): array
{
return $this->findBy(['active' => true]);
$qb = $this->createQueryBuilder('streams')
->addSelect('endpoints')
->addSelect('user')
->leftJoin('streams.endpoints', 'endpoints')
->leftJoin('streams.user', 'user')
->andWhere('streams.active = true')
->andWhere('endpoints.active = true')
->getQuery();
return $qb->getResult();
}
}

Loading…
Cancel
Save