Skip to content

Commit

Permalink
Only load iframe if URL variable exists
Browse files Browse the repository at this point in the history
  • Loading branch information
nook24 committed Aug 26, 2024
1 parent 3f2dba6 commit a7aad5a
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions webroot/js/scripts/directives/IframeDirective.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
angular.module('openITCOCKPIT').directive('iframeDirective', function($sce){
/*
* Copyright (C) <2015-present> <it-novum GmbH>
*
* This file is dual licensed
*
* 1.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 2.
* If you purchased an openITCOCKPIT Enterprise Edition you can use this file
* under the terms of the openITCOCKPIT Enterprise Edition license agreement.
* License agreement and license key will be shipped with the order
* confirmation.
*/

angular.module('openITCOCKPIT').directive('iframeDirective', function($sce) {
return {
restrict: 'E',
template: '<iframe src="{{trustedUrl}}" onload="this.height=(screen.height+15);" width="100%" frameborder="0"></iframe>',
template: '<iframe ng-if="trustedUrl" src="{{trustedUrl}}" onload="this.height=(screen.height+15);" width="100%" frameborder="0"></iframe>',
scope: {
'url': '='
},

controller: function($scope){
controller: function($scope) {

},

link: function($scope, element, attr){
$scope.$watch('url', function(){
link: function($scope, element, attr) {
$scope.$watch('url', function() {
$scope.trustedUrl = $sce.trustAsResourceUrl($scope.url);
});
}
Expand Down

0 comments on commit a7aad5a

Please sign in to comment.