mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Allow notify user if update checking not explicitly set
This commit is contained in:
		| @@ -765,12 +765,25 @@ PAPERLESS_OCR_LANGUAGES=<list> | ||||
|  | ||||
|     Defaults to none, which does not install any additional languages. | ||||
|  | ||||
|  | ||||
| .. _configuration-update-checking: | ||||
|  | ||||
| Update Checking | ||||
| ############### | ||||
|  | ||||
| PAPERLESS_ENABLE_UPDATE_CHECK=<bool> | ||||
|     Enable (or disable) the automatic check for available updates. This works by | ||||
|     pinging the releases endpoint of the Github API for the project e.g. | ||||
|     Enable (or disable) the automatic check for available updates. This feature is disabled | ||||
|     by default but if it is not explicitly set Paperless-ngx will show a message about this. | ||||
|  | ||||
|     If enabled, the feature works by pinging the the Github API for the latest release e.g. | ||||
|     https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | ||||
|     to determine whether a new version is available. Actual updating of the app must be done manually. | ||||
|     to determine whether a new version is available. | ||||
|  | ||||
|     No tracking data is collected by the app in any way. | ||||
|     Actual updating of the app must still be performed manually. | ||||
|  | ||||
|     Defaults to true. | ||||
|     Note that for users of thirdy-party containers e.g. linuxserver.io this notification | ||||
|     may be 'ahead' of a new release from the third-party maintainers. | ||||
|  | ||||
|     In either case, no tracking data is collected by the app in any way. | ||||
|  | ||||
|     Defaults to none, which disables the feature. | ||||
|   | ||||
| @@ -185,17 +185,30 @@ | ||||
|           <li class="nav-item mt-2"> | ||||
|             <div class="px-3 py-2 text-muted small d-flex align-items-center flex-wrap"> | ||||
|               <div class="me-3">{{ versionString }}</div> | ||||
|               <div *ngIf="appRemoteVersion?.update_available" class="version-check"> | ||||
|                 <ng-template #updatePopContent> | ||||
|               <div *ngIf="appRemoteVersion" class="version-check"> | ||||
|                 <ng-template #updateAvailablePopContent> | ||||
|                   <span class="small">Paperless-ngx v{{ appRemoteVersion.version }} <ng-container i18n>is available.</ng-container><br/><ng-container i18n>Click to view.</ng-container></span> | ||||
|                 </ng-template> | ||||
|                 <a class="small text-decoration-none" target="_blank" rel="noopener noreferrer" href="https://github.com/paperless-ngx/paperless-ngx/releases" | ||||
|                 [ngbPopover]="updatePopContent" popoverClass="shadow" triggers="mouseenter:mouseleave" container="body"> | ||||
|                 <ng-template #updateCheckingNotEnabledPopContent> | ||||
|                   <span class="small"><ng-container i18n>Checking for updates is disabled.</ng-container><br/><ng-container i18n>Click for more information.</ng-container></span> | ||||
|                 </ng-template> | ||||
|                 <ng-container *ngIf="appRemoteVersion.feature_is_set; else updateCheckNotSet"> | ||||
|                   <a *ngIf="appRemoteVersion.update_available" class="small text-decoration-none" target="_blank" rel="noopener noreferrer" href="https://github.com/paperless-ngx/paperless-ngx/releases" | ||||
|                   [ngbPopover]="updateAvailablePopContent" popoverClass="shadow" triggers="mouseenter:mouseleave" container="body"> | ||||
|                     <svg fill="currentColor" class="me-1" width="1.2em" height="1.2em" style="vertical-align: text-top;" viewBox="0 0 16 16"> | ||||
|                       <use xlink:href="assets/bootstrap-icons.svg#info-circle" /> | ||||
|                     </svg> | ||||
|                   <ng-container i18n>Update available</ng-container> | ||||
|                     <ng-container *ngIf="appRemoteVersion?.update_available" i18n>Update available</ng-container> | ||||
|                   </a> | ||||
|                 </ng-container> | ||||
|                 <ng-template #updateCheckNotSet> | ||||
|                   <a class="small text-decoration-none" target="_blank" rel="noopener noreferrer" href="https://paperless-ngx.readthedocs.io/en/latest/configuration.html#update-checking" | ||||
|                   [ngbPopover]="updateCheckingNotEnabledPopContent" popoverClass="shadow" triggers="mouseenter:mouseleave" container="body"> | ||||
|                     <svg fill="currentColor" class="me-1" width="1.2em" height="1.2em" style="vertical-align: text-top;" viewBox="0 0 16 16"> | ||||
|                       <use xlink:href="assets/bootstrap-icons.svg#info-circle" /> | ||||
|                     </svg> | ||||
|                   </a> | ||||
|                 </ng-template> | ||||
|               </div> | ||||
|             </div> | ||||
|           </li> | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import { environment } from 'src/environments/environment' | ||||
| export interface AppRemoteVersion { | ||||
|   version: string | ||||
|   update_available: boolean | ||||
|   feature_is_set: boolean | ||||
| } | ||||
|  | ||||
| @Injectable({ | ||||
|   | ||||
| @@ -675,8 +675,10 @@ class BulkDownloadView(GenericAPIView): | ||||
| class RemoteVersionView(GenericAPIView): | ||||
|     def get(self, request, format=None): | ||||
|         remote_version = "0.0.0" | ||||
|         is_greater = False | ||||
|         if settings.ENABLE_UPDATE_CHECK: | ||||
|         is_greater_than_current = False | ||||
|         # TODO: this can likely be removed when frontend settings are saved to DB | ||||
|         feature_is_set = settings.ENABLE_UPDATE_CHECK != "default" | ||||
|         if feature_is_set and settings.ENABLE_UPDATE_CHECK: | ||||
|             try: | ||||
|                 with urllib.request.urlopen( | ||||
|                     "https://api.github.com/repos/" | ||||
| @@ -692,7 +694,7 @@ class RemoteVersionView(GenericAPIView): | ||||
|                 logger.debug("An error occured checking for available updates") | ||||
|  | ||||
|             current_version = ".".join([str(_) for _ in version.__version__[:3]]) | ||||
|             is_greater = packaging_version.parse( | ||||
|             is_greater_than_current = packaging_version.parse( | ||||
|                 remote_version, | ||||
|             ) > packaging_version.parse( | ||||
|                 current_version, | ||||
| @@ -701,6 +703,7 @@ class RemoteVersionView(GenericAPIView): | ||||
|         return Response( | ||||
|             { | ||||
|                 "version": remote_version, | ||||
|                 "update_available": is_greater, | ||||
|                 "update_available": is_greater_than_current, | ||||
|                 "feature_is_set": feature_is_set, | ||||
|             }, | ||||
|         ) | ||||
|   | ||||
| @@ -567,4 +567,6 @@ if os.getenv("PAPERLESS_IGNORE_DATES", ""): | ||||
|         if d: | ||||
|             IGNORE_DATES.add(d.date()) | ||||
|  | ||||
| ENABLE_UPDATE_CHECK = os.getenv("PAPERLESS_ENABLE_UPDATE_CHECK", "default") | ||||
| if ENABLE_UPDATE_CHECK != "default": | ||||
|     ENABLE_UPDATE_CHECK = __get_boolean("PAPERLESS_ENABLE_UPDATE_CHECK", "true") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon