mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Default configuration file added
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -5,9 +5,8 @@
|
|||||||
/tsd_typings/
|
/tsd_typings/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
/config/environment.common.json
|
/config/environment.dev.js
|
||||||
/config/environment.prod.json
|
/config/environment.prod.js
|
||||||
/config/environment.dev.json
|
|
||||||
|
|
||||||
/coverage
|
/coverage
|
||||||
|
|
||||||
|
14
README.md
14
README.md
@@ -59,14 +59,11 @@ If you have [`nvm`](https://github.com/creationix/nvm#install-script) or [`nvm-w
|
|||||||
* `npm install` to install the local dependencies
|
* `npm install` to install the local dependencies
|
||||||
|
|
||||||
## Configuring
|
## Configuring
|
||||||
Templates for environmental and shareable configuration files are located in `config/` folder in json format.
|
Default configuration file is located in `config/` folder.
|
||||||
|
|
||||||
To make the configuration:
|
To change the default configuration values, create local files that override the parameters you need to change:
|
||||||
* Create a new `environment.common.json` file in `config/` folder using `environment.common.default.json` as template;
|
* Create a new `environment.dev.js` file in `config/` for `devel` environment;
|
||||||
* Create a new `environment.dev.json` file in `config/` folder using `environment.default.json` as template;
|
* Create a new `environment.prod.js` file in `config/` for `production` environment;
|
||||||
* Create a new `environment.prod.json` file in `config/` folder using `environment.default.json` as template;
|
|
||||||
|
|
||||||
Note: JSON standard does not allow comments so you need to remove them whether you are copying from templates.
|
|
||||||
|
|
||||||
To use the configuration parameters in your component:
|
To use the configuration parameters in your component:
|
||||||
```bash
|
```bash
|
||||||
@@ -171,8 +168,7 @@ dspace-angular
|
|||||||
├── README.md * This document
|
├── README.md * This document
|
||||||
├── app.json * Application manifest file
|
├── app.json * Application manifest file
|
||||||
├── config * Folder for configuration files
|
├── config * Folder for configuration files
|
||||||
│ ├── environment.common.default.json * Template for general configuration file
|
│ └── environment.default.js * Default configuration files
|
||||||
│ └── environment.default.json * Template for the dev and prod configuration files
|
|
||||||
├── e2e * Folder for e2e test files
|
├── e2e * Folder for e2e test files
|
||||||
├── karma.conf.js * Unit Test configuration file
|
├── karma.conf.js * Unit Test configuration file
|
||||||
├── nodemon.json * Nodemon (https://nodemon.io/) configuration
|
├── nodemon.json * Nodemon (https://nodemon.io/) configuration
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": ""
|
|
||||||
}
|
|
14
config/environment.default.js
Normal file
14
config/environment.default.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
module.exports = {
|
||||||
|
"production": false,
|
||||||
|
// The REST API Location.
|
||||||
|
"rest": {
|
||||||
|
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||||
|
"nameSpace": "/api",
|
||||||
|
"baseURL": "http://localhost:3000"
|
||||||
|
},
|
||||||
|
// Path and Port in use for this Angular2 UI
|
||||||
|
"ui": {
|
||||||
|
"nameSpace": "/",
|
||||||
|
"baseURL": "http://localhost:3000"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"production": false,
|
|
||||||
// Location of REST API
|
|
||||||
"rest": {
|
|
||||||
// By default, we are currently using a local proxy running on port 5050.
|
|
||||||
// This is necessary because our actual REST API doesn't provide CORS headers yet!
|
|
||||||
// The actual REST API path is in the 'proxy' settings below.
|
|
||||||
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
|
||||||
"nameSpace": "",
|
|
||||||
"baseURL": ""
|
|
||||||
},
|
|
||||||
// REST Location that we are proxying (see src/proxy.ts)
|
|
||||||
// (Since we are using a proxy at this time, the actual REST API goes here)
|
|
||||||
"proxy": {
|
|
||||||
"nameSpace": "",
|
|
||||||
"baseURL": ""
|
|
||||||
// E.g. to use demo.dspace.org REST API, use the below values *instead*
|
|
||||||
//nameSpace: '/rest',
|
|
||||||
//baseURL: 'https://demo.dspace.org'
|
|
||||||
},
|
|
||||||
// Path and Port in use for this Angular2 UI
|
|
||||||
"ui": {
|
|
||||||
"nameSpace": "",
|
|
||||||
"baseURL": ""
|
|
||||||
}
|
|
||||||
}
|
|
@@ -59,7 +59,6 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
private onResize(event): void {
|
private onResize(event): void {
|
||||||
console.log(GlobalConfig.rest.baseURL);
|
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
HostWindowActions.resize(event.target.innerWidth, event.target.innerHeight)
|
HostWindowActions.resize(event.target.innerWidth, event.target.innerHeight)
|
||||||
);
|
);
|
||||||
|
@@ -2,33 +2,33 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
let configContext = require.context("../config", false, /json$/);
|
let configContext = require.context("../config", false, /js$/);
|
||||||
let EnvConfig : any = {};
|
let EnvConfig : any = {};
|
||||||
let EnvConfigFile : string;
|
let EnvConfigFile : string;
|
||||||
let CommonConfig : any = {};
|
let DefaultConfig : any = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommonConfig = configContext('./environment.common.json');
|
DefaultConfig = configContext('./environment.default.js');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Cannot find file "${path.resolve('config', './environment.common.json')}"`);
|
throw new Error(`Cannot find file "${path.resolve('config', './environment.default.js')}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (process.env.NODE_ENV) {
|
switch (process.env.NODE_ENV) {
|
||||||
case 'prod':
|
case 'prod':
|
||||||
case 'production':
|
case 'production':
|
||||||
EnvConfigFile = './environment.prod.json';
|
EnvConfigFile = './environment.prod.js';
|
||||||
break;
|
break;
|
||||||
case 'dev':
|
case 'dev':
|
||||||
case 'development':
|
case 'development':
|
||||||
default:
|
default:
|
||||||
EnvConfigFile = './environment.dev.json';
|
EnvConfigFile = './environment.dev.js';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
EnvConfig = configContext(EnvConfigFile);
|
EnvConfig = configContext(EnvConfigFile);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Cannot find file "${path.resolve('config', EnvConfigFile)}"`);
|
EnvConfig = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const GlobalConfig = Object.assign(CommonConfig, EnvConfig);
|
const GlobalConfig = Object.assign(DefaultConfig, EnvConfig);
|
||||||
|
|
||||||
export {GlobalConfig}
|
export {GlobalConfig}
|
||||||
|
Reference in New Issue
Block a user