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. |     Defaults to none, which does not install any additional languages. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | .. _configuration-update-checking: | ||||||
|  |  | ||||||
|  | Update Checking | ||||||
|  | ############### | ||||||
|  |  | ||||||
| PAPERLESS_ENABLE_UPDATE_CHECK=<bool> | PAPERLESS_ENABLE_UPDATE_CHECK=<bool> | ||||||
|     Enable (or disable) the automatic check for available updates. This works by |     Enable (or disable) the automatic check for available updates. This feature is disabled | ||||||
|     pinging the releases endpoint of the Github API for the project e.g. |     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 |     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"> |           <li class="nav-item mt-2"> | ||||||
|             <div class="px-3 py-2 text-muted small d-flex align-items-center flex-wrap"> |             <div class="px-3 py-2 text-muted small d-flex align-items-center flex-wrap"> | ||||||
|               <div class="me-3">{{ versionString }}</div> |               <div class="me-3">{{ versionString }}</div> | ||||||
|               <div *ngIf="appRemoteVersion?.update_available" class="version-check"> |               <div *ngIf="appRemoteVersion" class="version-check"> | ||||||
|                 <ng-template #updatePopContent> |                 <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> |                   <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> |                 </ng-template> | ||||||
|                 <a class="small text-decoration-none" target="_blank" rel="noopener noreferrer" href="https://github.com/paperless-ngx/paperless-ngx/releases" |                 <ng-template #updateCheckingNotEnabledPopContent> | ||||||
|                 [ngbPopover]="updatePopContent" popoverClass="shadow" triggers="mouseenter:mouseleave" container="body"> |                   <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"> |                     <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" /> |                       <use xlink:href="assets/bootstrap-icons.svg#info-circle" /> | ||||||
|                     </svg> |                     </svg> | ||||||
|                   <ng-container i18n>Update available</ng-container> |                     <ng-container *ngIf="appRemoteVersion?.update_available" i18n>Update available</ng-container> | ||||||
|                   </a> |                   </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> | ||||||
|             </div> |             </div> | ||||||
|           </li> |           </li> | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import { environment } from 'src/environments/environment' | |||||||
| export interface AppRemoteVersion { | export interface AppRemoteVersion { | ||||||
|   version: string |   version: string | ||||||
|   update_available: boolean |   update_available: boolean | ||||||
|  |   feature_is_set: boolean | ||||||
| } | } | ||||||
|  |  | ||||||
| @Injectable({ | @Injectable({ | ||||||
|   | |||||||
| @@ -675,8 +675,10 @@ class BulkDownloadView(GenericAPIView): | |||||||
| class RemoteVersionView(GenericAPIView): | class RemoteVersionView(GenericAPIView): | ||||||
|     def get(self, request, format=None): |     def get(self, request, format=None): | ||||||
|         remote_version = "0.0.0" |         remote_version = "0.0.0" | ||||||
|         is_greater = False |         is_greater_than_current = False | ||||||
|         if settings.ENABLE_UPDATE_CHECK: |         # 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: |             try: | ||||||
|                 with urllib.request.urlopen( |                 with urllib.request.urlopen( | ||||||
|                     "https://api.github.com/repos/" |                     "https://api.github.com/repos/" | ||||||
| @@ -692,7 +694,7 @@ class RemoteVersionView(GenericAPIView): | |||||||
|                 logger.debug("An error occured checking for available updates") |                 logger.debug("An error occured checking for available updates") | ||||||
|  |  | ||||||
|             current_version = ".".join([str(_) for _ in version.__version__[:3]]) |             current_version = ".".join([str(_) for _ in version.__version__[:3]]) | ||||||
|             is_greater = packaging_version.parse( |             is_greater_than_current = packaging_version.parse( | ||||||
|                 remote_version, |                 remote_version, | ||||||
|             ) > packaging_version.parse( |             ) > packaging_version.parse( | ||||||
|                 current_version, |                 current_version, | ||||||
| @@ -701,6 +703,7 @@ class RemoteVersionView(GenericAPIView): | |||||||
|         return Response( |         return Response( | ||||||
|             { |             { | ||||||
|                 "version": remote_version, |                 "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: |         if d: | ||||||
|             IGNORE_DATES.add(d.date()) |             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") |     ENABLE_UPDATE_CHECK = __get_boolean("PAPERLESS_ENABLE_UPDATE_CHECK", "true") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon