Skip to content

Commit 8f753b4

Browse files
author
dularion
committed
fix "undefined" error for non-accessible localFiles directory (when setting isnt set)
1 parent a45fb92 commit 8f753b4

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

grails-app/assets/javascripts/streama/controllers/modal-file-ctrl.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
angular.module('streama').controller('modalFileCtrl', [
4-
'$scope', '$uibModalInstance', 'apiService', 'uploadService', 'video', 'localStorageService',
5-
function ($scope, $uibModalInstance, apiService, uploadService, video, localStorageService) {
4+
'$scope', '$uibModalInstance', 'apiService', 'uploadService', 'video', 'localStorageService', '$rootScope',
5+
function ($scope, $uibModalInstance, apiService, uploadService, video, localStorageService, $rootScope) {
66
$scope.loading = false;
77
$scope.localFilesEnabled = false;
88
$scope.localFiles = [];
@@ -38,6 +38,9 @@ angular.module('streama').controller('modalFileCtrl', [
3838
}
3939

4040
function loadLocalFiles(path) {
41+
if(!_.get($rootScope.getSetting('Local Video Files'), 'value')){
42+
return;
43+
}
4144
apiService.file.localFiles(path).then(function(response) {
4245
localStorageService.set('localFileLastPath', path);
4346
$scope.localFilesEnabled = true;

grails-app/assets/javascripts/streama/templates/modal--manage-files.tpl.htm

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,59 @@
3939
</div>
4040
<div class="tab-pane" ng-class="{'active': activeTab == 'local'}">
4141

42-
<div>
43-
<div class="form-group">
44-
<input type="text" ng-model="localFileSearch" class="form-control input-sm" placeholder="Search current directory...">
42+
<p ng-if="!$root.getSetting('Local Video Files').value" class="alert alert-warning" role="alert">You dont have a local Directory set up. As an admin, go to the settings page to configure it now.</p>
43+
44+
<div ng-if="$root.getSetting('Local Video Files').value">
45+
<div>
46+
<div class="form-group">
47+
<input type="text" ng-model="localFileSearch" class="form-control input-sm" placeholder="Search current directory...">
48+
</div>
4549
</div>
46-
</div>
4750

48-
<div style="overflow-y: auto; max-height: 200px;">
51+
<div style="overflow-y: auto; max-height: 200px;">
4952
<span class="btn btn-default btn-sm" ng-click="backLocalDirectory()" ng-if="localDir.length > 0">
5053
<span class="ion-android-arrow-back"></span>
5154
</span>
52-
<span>{{ localDir.join('/') }}</span>
55+
<span>{{ localDir.join('/') }}</span>
5356

54-
<table class="table table-striped">
55-
<tr ng-repeat="file in localFiles | orderBy: ['-directory', 'name'] | filter:localFileSearch">
56-
<td>
57+
<table class="table table-striped">
58+
<tr ng-repeat="file in localFiles | orderBy: ['-directory', 'name'] | filter:localFileSearch">
59+
<td>
5760
<span ng-if="file.directory" ng-click="openLocalDirectory(file)">
5861
<span class="ion-folder"></span>
5962
{{ file.name }}
6063
</span>
6164

62-
<span ng-if="!file.directory">
65+
<span ng-if="!file.directory">
6366
<span class="ion-document"></span>
6467
{{ file.name }}
6568
</span>
66-
</td>
69+
</td>
6770

68-
<td>
71+
<td>
6972
<span class="btn btn-success btn-xs" ng-click="addLocalFile(file.path)" ng-if="!file.directory">
7073
Choose
7174
</span>
72-
</td>
73-
</tr>
74-
</table>
75-
</div>
75+
</td>
76+
</tr>
77+
</table>
78+
</div>
7679

77-
<div class="checkbox">
78-
<label>
79-
<input type="checkbox" ng-model="closeOnSelect" ng-click="toggleCloseOnSelect()"> Close Modal on Select
80-
</label>
80+
<div class="checkbox">
81+
<label>
82+
<input type="checkbox" ng-model="closeOnSelect" ng-click="toggleCloseOnSelect()"> Close Modal on Select
83+
</label>
84+
</div>
8185
</div>
86+
8287
</div>
8388
</div>
8489

8590
<h4>Video Files</h4>
8691
<table class="table table-striped" style="font-size: 14px;" ng-show="video.videoFiles.length">
8792
<thead>
8893
<tr>
94+
<th>ID</th>
8995
<th>Name </th>
9096
<th>Type</th>
9197
<th style="width: 86px;">is Default</th>
@@ -95,6 +101,7 @@ <h4>Video Files</h4>
95101
</thead>
96102
<tbody>
97103
<tr ng-repeat="file in video.videoFiles">
104+
<td>{{file.id}}</td>
98105
<td>{{file.originalFilename}}</td>
99106
<td>{{file.contentType}}</td>
100107
<td class="text-center">
@@ -122,6 +129,7 @@ <h4>Subtitles</h4>
122129
<table class="table table-striped" style="font-size: 14px;">
123130
<thead>
124131
<tr>
132+
<th>ID</th>
125133
<th>Name</th>
126134
<th>Type</th>
127135
<th>Label</th>
@@ -131,6 +139,7 @@ <h4>Subtitles</h4>
131139
</thead>
132140
<tbody>
133141
<tr ng-repeat="file in video.subtitles">
142+
<td>{{file.id}}</td>
134143
<td>{{file.originalFilename}}</td>
135144
<td>{{file.contentType}}</td>
136145
<th>

0 commit comments

Comments
 (0)