Component error handling
This commit is contained in:
@@ -64,9 +64,17 @@ class ComponentView {
|
|||||||
$scope.reloading = true;
|
$scope.reloading = true;
|
||||||
let previouslyValid = $scope.componentValid;
|
let previouslyValid = $scope.componentValid;
|
||||||
|
|
||||||
$scope.offlineRestricted = component.offlineOnly && !isDesktopApplication();
|
var expired, offlineRestricted, urlError;
|
||||||
|
|
||||||
$scope.componentValid = !$scope.offlineRestricted && (!component.valid_until || (component.valid_until && component.valid_until > new Date()));
|
offlineRestricted = component.offlineOnly && !isDesktopApplication();
|
||||||
|
urlError = !isDesktopApplication() && (!component.url || component.hosted_url);
|
||||||
|
expired = component.valid_until && component.valid_until <= new Date();
|
||||||
|
|
||||||
|
$scope.componentValid = !offlineRestricted && !urlError && !expired;
|
||||||
|
|
||||||
|
if(offlineRestricted) $scope.error = 'offline-restricted';
|
||||||
|
if(urlError) $scope.error = 'url-missing';
|
||||||
|
if(expired) $scope.error = 'expired';
|
||||||
|
|
||||||
if($scope.componentValid !== previouslyValid) {
|
if($scope.componentValid !== previouslyValid) {
|
||||||
if($scope.componentValid) {
|
if($scope.componentValid) {
|
||||||
|
|||||||
@@ -6,6 +6,5 @@
|
|||||||
.header
|
.header
|
||||||
%h1.title
|
%h1.title
|
||||||
{{component.name}}
|
{{component.name}}
|
||||||
%span.subtle.subtitle{"ng-if" => "component.runningLocally"} | Desktop Mode
|
|
||||||
%a.close-button.info{"ng-click" => "dismiss()"} Close
|
%a.close-button.info{"ng-click" => "dismiss()"} Close
|
||||||
%component-view.component-view{"component" => "component"}
|
%component-view.component-view{"component" => "component"}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.sn-component{"ng-if" => "!componentValid && !offlineRestricted"}
|
.sn-component{"ng-if" => "error == 'expired'"}
|
||||||
.panel.static
|
.panel.static
|
||||||
.content
|
.content
|
||||||
.panel-section.stretch
|
.panel-section.stretch
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
%a{"href" => "https://standardnotes.org/help", "target" => "_blank"} Help
|
%a{"href" => "https://standardnotes.org/help", "target" => "_blank"} Help
|
||||||
page.
|
page.
|
||||||
|
|
||||||
.sn-component{"ng-if" => "offlineRestricted"}
|
.sn-component{"ng-if" => "error == 'offline-restricted'"}
|
||||||
.panel.static
|
.panel.static
|
||||||
.content
|
.content
|
||||||
.panel-section.stretch
|
.panel-section.stretch
|
||||||
@@ -50,8 +50,15 @@
|
|||||||
.label Reload
|
.label Reload
|
||||||
.spinner.info.small{"ng-if" => "reloading"}
|
.spinner.info.small{"ng-if" => "reloading"}
|
||||||
|
|
||||||
|
.sn-component{"ng-if" => "error == 'url-missing'"}
|
||||||
|
.panel.static
|
||||||
|
.content
|
||||||
|
.panel-section.stretch
|
||||||
|
%h2.title This extension is not installed correctly.
|
||||||
|
%p Please uninstall {{component.name}}, then re-install it.
|
||||||
|
|
||||||
%iframe{"ng-if" => "component && componentValid && !offlineRestricted",
|
|
||||||
|
%iframe{"ng-if" => "component && componentValid",
|
||||||
"ng-attr-id" => "component-{{component.uuid}}",
|
"ng-attr-id" => "component-{{component.uuid}}",
|
||||||
"ng-src" => "{{getUrl() | trusted}}", "frameBorder" => "0",
|
"ng-src" => "{{getUrl() | trusted}}", "frameBorder" => "0",
|
||||||
"sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-modals allow-forms",
|
"sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-modals allow-forms",
|
||||||
|
|||||||
Reference in New Issue
Block a user