Starts in:
2 DAYS
0 HR
47 MIN
35 SEC
Starts in:
2 D
0 H
47 M
35 S
Open Closed

Defining custom setting which is of type image file #2708


User avatar
0
bozkan created

https://docs.abp.io/en/abp/latest/Settings

Is it possible to define a setting for storing the logo image and making it configurable over the settings page for each tenant? So that it can be changed in the settings page via a file browser dialog.


  • ABP Framework version: v4.4.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

1 Answer(s)
  • User Avatar
    0
    muhammedaltug created

    Hello,

    Setting definitions does not support blob types. You can make this feature by following the steps below.

    1. Make an endpoint for file upload.
    2. Create your setting class like in the document (Note: You need to create SettingDefinition with IsVisibleToClients parameter's value true)
    3. Add your component to the settings tab like in the document
    4. Make an input file and upload the file with your file upload endpoint in your setting component.
    5. Update setting value with image path
    6. Create logo component and replace logo component with existing, like the following example
    import { ConfigStateService } from '@abp/ng.core';
    import { Component } from '@angular/core';
    
    @Component({
      selector: 'app-my-logo',
      template: `<a
        class="navbar-brand"
        routerLink="/"
        alt="logo"
        [style.backgroundImage]="bgUrl"
      ></a>`,
    })
    export class MyLogoComponent {
      bgUrl = `url("${this.configState.getSetting('YOUR_SETTING')}”)`;
      constructor(private configState: ConfigStateService) {
      }
    }
    
    
    //app.component.ts
    import { Component } from '@angular/core';
    import { eThemeLeptonComponents } from '@volo/abp.ng.theme.lepton';
    import { MyLogoComponent } from './my-logo.component';
    @Component({
      selector: 'app-root',
      template: `
        <abp-loader-bar></abp-loader-bar>
        <abp-dynamic-layout></abp-dynamic-layout>
      `,
    })
    export class AppComponent {
      constructor(
        private replaceableComponentsService: ReplaceableComponentsService
      ) {
        replaceableComponentsService.add({
          component: MyLogoComponent,
          key: eThemeLeptonComponents.Logo,
        });
      }
    }
    
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06