Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Overview

As the DSpace 7 User Interface is built on Angular.io, it aligns with many of the best practices of that platform & the surrounding community.  One example is that Configuration files (along with much of the UI code) use the TypeScript language.  That said, you do NOT need to be deeply familiar with TypeScript to edit the configuration files. Much of the syntax is very similar to JSON, which is a common configuration format.

You must rebuild after any configuration change

At this time, you must rebuild the UI anytime you modify a configuration setting.  This is because the currently active configuration is in your ./src/environments/environment.ts which is the compiled/deduped version of your configuration after applying all overrides.

Configuration Override

The UI configuration files reside in the ./src/environments/ folder in the Angular UI source code.  The default configuration are in environment.common.ts in that directory.

To change the default configuration values, you simply create (one or more) local files that override the parameters you need to modify. You can use  environment.template.ts  as a starting point.

  • For example, create a new  environment.dev.ts  file in  src/environments/  for a  development  environment;
  • For example, create a new  environment.prod.ts  file in  src/environments/  for a  production  environment;

The "ui" and "rest" sections of the configuration may also be overridden separately via one of the following

  • By setting any of the following environment variables in your system:

    # "ui" settings environment variables
    DSPACE_HOST # The host name of the angular application
    DSPACE_PORT # The port number of the angular application
    DSPACE_NAMESPACE # The namespace of the angular application
    DSPACE_SSL # Whether the angular application uses SSL [true/false]
    
    # "rest" settings environment variables
    DSPACE_REST_HOST # The host name of the REST application
    DSPACE_REST_PORT # The port number of the REST application
    DSPACE_REST_NAMESPACE # The namespace of the REST application
    DSPACE_REST_SSL # Whether the angular REST uses SSL [true/false]
  • Or, by creating a .env (environment) file in the project root directory and setting the environment variables in that location.

The override priority ordering is as follows (with items listed at the top overriding all other settings)

  1. Environment variables
  2. The ".env" file
  3. The "environment.prod.ts", "environment.dev.ts" or "environment.test.ts"
  4. The "environment.common.ts"

Configuration Reference

The following configurations are available in ./src/environments/environment.common.ts These settings may be overridden as described above

Production Mode

When Production mode is enabled, this enables Angular's runtime production mode and compresses the built application. This should always be enabled in Production scenarios.

production: true

UI Core Settings

The "ui" (user interface) section defines where you want Node.js to run/respond. It may correspond to your primary/public URL, but it also may not (if you are running behind a proxy). In this example, we are setting up our UI to just use localhost, port 4000. This is a common setup for when you want to use Apache or Nginx to handle HTTPS and proxy requests to Node.js running on port 4000.

ui: {
  ssl: false,
  host: 'localhost',
  port: 4000,
  // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
  nameSpace: '/',
  // The rateLimiter settings limit each IP to a "max" of 500 requests per "windowMs" (1 minute).
  rateLimiter: {
    windowMs: 1 * 60 * 1000,   // 1 minute
    max: 500 // limit each IP to 500 requests per windowMs
  }
},

The "rateLimiter" sub-section can be used to protect against a DOS (denial of service) attack when the UI is processed on the server side (i.e. server-side rendering).  Default settings are usually OK. In Angular, server-side rendering occurs to support better Search Engine Optimization (SEO), as well as to support clients which cannot use Javascript.   See also Angular's docs on Server-side rendering.

REST API Settings

The "rest" (REST API) section defines which REST API the UI will use. The REST settings MUST correspond to the primary URL of the backend. Usually, this means they must be kept in sync
with the value of dspace.server.url in the backend's local.cfg

This example is valid if your Backend is publicly available at https://api.mydspace.edu/server/  . Keep in mind that the "port" must always be specified even if it's a standard port (i.e. port 80 for HTTP and port 443 for HTTPS).

rest: {
  ssl: true,
  host: 'api.mydspace.edu',
  port: 443,
  // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
  nameSpace: '/server'
},

Cache Settings

The "cache" section controls how long objects/responses will remain in the UI cache.  The defaults should be OK for most sites.

cache: {
  // NOTE: how long should objects be cached for by default
  msToLive: {
    default: 15 * 60 * 1000, // 15 minutes
  },
  control: 'max-age=60', // revalidate browser
  autoSync: {
    defaultTime: 0,
    maxBufferSize: 100,
    timePerMethod: {[RestRequestMethod.PATCH]: 3} as any // time in seconds
  }
},

Authentication Settings

The "auth" section provides some basic authentication-related settings.  Currently, it's primarily settings related to when a session timeout warning will be showed to your users, etc.

auth: {
  // Authentication UI settings
  ui: {
    // the amount of time before the idle warning is shown
    timeUntilIdle: 15 * 60 * 1000, // 15 minutes
    // the amount of time the user has to react after the idle warning is shown before they are logged out.
    idleGracePeriod: 5 * 60 * 1000, // 5 minutes
  },
  // Authentication REST settings
  rest: {
    // If the rest token expires in less than this amount of time, it will be refreshed automatically.
    // This is independent from the idle warning.     
    timeLeftBeforeTokenRefresh: 2 * 60 * 1000, // 2 minutes
  },
},

Form Settings

The "form" section provides basic settings for any forms displayed in the UI. At this time, these settings only include a validatorMap, which is not necessary to modify for most sites

form: {
  // NOTE: Map server-side validators to comparative Angular form validators
  validatorMap: {
    required: 'required',
    regex: 'pattern'
  }
},

Notification Settings

The "notifications" section provides options related to where user notifications will appear in your UI.  By default, they appear in the top right corner, and timeout after 5 seconds.

notifications: {
  rtl: false,
  position: ['top', 'right'],
  maxStack: 8,
  // NOTE: after how many seconds notification is closed automatically. If set to zero notifications are not closed automatically
  timeOut: 5000, // 5 second
  clickToClose: true,
  // NOTE: 'fade' | 'fromTop' | 'fromRight' | 'fromBottom' | 'fromLeft' | 'rotate' | 'scale'
  animate: NotificationAnimationsType.Scale
},

The set of valid animations can be found in the NotificationAnimationsType, and are implemented in ./src/shared/animations/ 

Submission Settings

The "submission" section provides some basic Submission/Deposit UI options.  These allow you to optionally enable an autosave (disabled by default), and custom styles/icons for metadata fields or authority confidence values.

submission: {
    autosave: {
      // NOTE: which metadata trigger an autosave
      metadata: [],
      /**
       * NOTE: after how many time (milliseconds) submission is saved automatically
       * eg. timer: 5 * (1000 * 60); // 5 minutes
       */
      timer: 0
    },
    icons: {
      metadata: [
        /**
         * NOTE: example of configuration
         * {
         *    // NOTE: metadata name
         *    name: 'dc.author',
         *    // NOTE: fontawesome (v5.x) icon classes and bootstrap utility classes can be used
         *    style: 'fa-user'
         * }
         */
        {
          name: 'dc.author',
          style: 'fas fa-user'
        },
        // default configuration
        {
          name: 'default',
          style: ''
        }
      ],
      authority: {
        confidence: [
          /**
           * NOTE: example of configuration
           * {
           *    // NOTE: confidence value
           *    value: 'dc.author',
           *    // NOTE: fontawesome (v4.x) icon classes and bootstrap utility classes can be used
           *    style: 'fa-user'
           * }
           */
          {
            value: 600,
            style: 'text-success'
          },
          {
            value: 500,
            style: 'text-info'
          },
          {
            value: 400,
            style: 'text-warning'
          },
          // default configuration
          {
            value: 'default',
            style: 'text-muted'
          },

        ]
      }
    }
  },

Universal (Server-side Rendering) Settings

The "universal" section pertains to enabling/disabling Angular Universal for Server-side rendering.  DSpace requires server-side rendering to support Search Engine Optimization. When it's turned off, your site may not be able to be indexed in Google, Google Scholar and other search engines.

// Angular Universal settings
universal: {
  preboot: true,
  async: true,
  time: false
},

Debug Settings

The "debug" property allows you to turn on debugging in the Angular UI.  When enabled, your environment and all Redux actions/transfers are logged to the console.  This is only ever needed if you are debugging a tricky issue.

// NOTE: will log all redux actions and transfers in console
debug: false


Language Settings

The "defaultLanguage" and "languages" sections allow you to customize which languages to support in your User Interface.  See also Multilingual Support.

// Default Language in which the UI will be rendered if the user's browser language is not an active language
defaultLanguage: 'en',
// Languages. DSpace Angular holds a message catalog for each of the following languages.
// When set to active, users will be able to switch to the use of this language in the user interface.
languages: [{
  code: 'en',
  label: 'English',
  active: true,
}, {
  code: 'de',
  label: 'Deutsch',
  active: true,
}, 
...
],

The DSpace UI requires that a corresponding language pack file (named with the language code and ending in ".json5") be placed in ./src/assets/i18n/.  See also DSpace 7 Translation - Internationalization (i18n) - Localization (l10n) for information about how to create and contribute these files.

Browse By Settings

The "browseBy" section allows you to customize which "Browse by" options appear in the "All of DSpace" header menu at the top of your DSpace site.  The "id" MUST correspond to the name of a valid Browse index available from your REST API (see documentation on the REST API /api/discover/browses endpoint).  It is possible to configure additional indexes on the Backend using Discovery, and any configured index appears in your REST API.

browseBy: {
  // Amount of years to display using jumps of one year (current year - oneYearLimit)
  oneYearLimit: 10,
  // Limit for years to display using jumps of five years (current year - fiveYearLimit)
  fiveYearLimit: 30,
  // The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
  defaultLowerLimit: 1900,
  // List of all the active Browse-By types
  // Adding a type will activate their Browse-By page and add them to the global navigation menu,
  // as well as community and collection pages
  // Allowed fields and their purpose:
  //    id:             The browse id to use for fetching info from the rest api
  //    type:           The type of Browse-By page to display
  //    metadataField:  The metadata-field used to create starts-with options (only necessary when the type is set to 'date')
  types: [
    {
      id: 'title',
      type: BrowseByType.Title,
    },
    {
      id: 'dateissued',
      type: BrowseByType.Date,
      metadataField: 'dc.date.issued'
    },
    {
      id: 'author',
      type: BrowseByType.Metadata
    },
    {
      id: 'subject',
      type: BrowseByType.Metadata
    }
  ]
},

Undo Settings

Both the "item" edit and "collection" edit screens allow you to undo changes within a specific time.  This is controlled by these settings:

item: {
  edit: {
    undoTimeout: 10000 // 10 seconds
  }
},
collection: {
  edit: {     
    undoTimeout: 10000 // 10 seconds
  }
},

Theme Settings

The "themes" section allows you to configure which theme(s) are enabled for your DSpace site (with the default theme being the "dspace" one).  You can enable a single theme across all pages, and/or enable specific alternative themes based on a specific Community, Collection or Item (by UUID or Handle), or based on a Regex match of a URL pattern.  This allows you fine grained control over how your site looks, including the ability to customize it per Community or Collection or even per specific pages in the site.

themes: [
  // Add additional themes here. In the case where multiple themes match a route, the first one
  // in this list will get priority. It is advisable to always have a theme that matches
  // every route as the last one

  // {
  //   // A theme with a handle property will match the community, collection or item with the given
  //   // handle, and all collections and/or items within it
  //   name: 'custom',
  //   handle: '10673/1233'
  // },
  // {
  //   // A theme with a regex property will match the route using a regular expression. If it
  //   // matches the route for a community or collection it will also apply to all collections
  //   // and/or items within it
  //   name: 'custom',
  //   regex: 'collections\/e8043bc2.*'
  // },
  // {
  //   // A theme with a uuid property will match the community, collection or item with the given
  //   // ID, and all collections and/or items within it
  //   name: 'custom',
  //   uuid: '0958c910-2037-42a9-81c7-dca80e3892b4'
  // },
  // {
  //   // A theme with only a name will match every route
  //   name: 'custom'
  // },
  // {
  //   // This theme will use the default bootstrap styling for DSpace components
  //   name: BASE_THEME_NAME
  // },
  {
    // The default dspace theme
    name: 'dspace'
  },
],

Media Viewer Settings

The DSpace UI comes with a basic, out-of-the-box Media Viewer (disabled by default).  You can choose to enable it for "image/*" or "video/*" MIME types, or both.

// Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with "image" or "video").
// For images, this enables a gallery viewer where you can zoom or page through images.
// For videos, this enables embedded video streaming
mediaViewer: {
  image: false,
  video: false,
},
  • No labels