mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
5
.gitignore
vendored
5
.gitignore
vendored
@@ -5,6 +5,11 @@
|
||||
/tsd_typings/
|
||||
npm-debug.log
|
||||
|
||||
/config/environment.dev.js
|
||||
/config/environment.prod.js
|
||||
|
||||
/coverage
|
||||
|
||||
/dist/
|
||||
/coverage/
|
||||
|
||||
|
15
README.md
15
README.md
@@ -32,6 +32,7 @@ Then go to [http://localhost:3000](http://localhost:3000) in your browser
|
||||
* [Introduction to the technology](#introduction-to-the-technology)
|
||||
* [Requirements](#requirements)
|
||||
* [Installing](#installing)
|
||||
* [Configuring](#configuring)
|
||||
* [Running the app](#running-the-app)
|
||||
* [Running in production mode](#running-in-production-mode)
|
||||
* [Cleaning](#cleaning)
|
||||
@@ -57,6 +58,17 @@ If you have [`nvm`](https://github.com/creationix/nvm#install-script) or [`nvm-w
|
||||
* `npm run global` to install the required global dependencies
|
||||
* `npm install` to install the local dependencies
|
||||
|
||||
## Configuring
|
||||
Default configuration file is located in `config/` folder.
|
||||
|
||||
To change the default configuration values, create local files that override the parameters you need to change:
|
||||
* Create a new `environment.dev.js` file in `config/` for `devel` environment;
|
||||
* Create a new `environment.prod.js` file in `config/` for `production` environment;
|
||||
|
||||
To use the configuration parameters in your component:
|
||||
```bash
|
||||
import { GlobalConfig } from "../config";
|
||||
```
|
||||
|
||||
## Running the app
|
||||
After you have installed all dependencies you can now run the app. Run `npm run watch:dev` to start a local server which will watch for changes, rebuild the code, and reload the server for you. You can visit it at `http://localhost:3000`.
|
||||
@@ -156,6 +168,8 @@ See [the guide on the wiki](https://wiki.duraspace.org/display/DSPACE/DSpace+7+-
|
||||
dspace-angular
|
||||
├── README.md * This document
|
||||
├── app.json * Application manifest file
|
||||
├── config * Folder for configuration files
|
||||
│ └── environment.default.js * Default configuration files
|
||||
├── e2e * Folder for e2e test files
|
||||
├── karma.conf.js * Unit Test configuration file
|
||||
├── nodemon.json * Nodemon (https://nodemon.io/) configuration
|
||||
@@ -174,6 +188,7 @@ dspace-angular
|
||||
│ ├── browser.module.ts * The root module for the client
|
||||
│ ├── client.aot.ts * The bootstrap file for the client, in production
|
||||
│ ├── client.ts * The bootstrap file for the client, during development
|
||||
│ ├── config.ts * File that loads environmental and shareable settings and makes them available to app components
|
||||
│ ├── index-aot.html * The index.html file, for production
|
||||
│ ├── index.html * The index.html file, for development
|
||||
│ ├── node.module.ts * The root module for the server
|
||||
|
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"
|
||||
}
|
||||
}
|
@@ -4,6 +4,8 @@
|
||||
<main>
|
||||
<p>{{ 'example.with.data' | translate:data }}</p>
|
||||
<p>{{ example }}</p>
|
||||
<h2 *ngIf="!env" style="color:green">development</h2>
|
||||
<h2 *ngIf="env" style="color:red">production</h2>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
</div>
|
||||
|
@@ -9,6 +9,7 @@ import { TranslateService } from "ng2-translate";
|
||||
import { HostWindowState } from "./shared/host-window.reducer";
|
||||
import { Store } from "@ngrx/store";
|
||||
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
||||
import { GlobalConfig } from "../config";
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
@@ -27,6 +28,12 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
recipient: 'World'
|
||||
};
|
||||
|
||||
env: string = GlobalConfig.production;
|
||||
|
||||
styles = {
|
||||
color: 'red'
|
||||
};
|
||||
|
||||
constructor(
|
||||
private translate: TranslateService,
|
||||
private store: Store<HostWindowState>
|
||||
|
34
src/config.ts
Normal file
34
src/config.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// Look in ./config folder for config
|
||||
|
||||
const path = require('path');
|
||||
|
||||
let configContext = require.context("../config", false, /js$/);
|
||||
let EnvConfig : any = {};
|
||||
let EnvConfigFile : string;
|
||||
let DefaultConfig : any = {};
|
||||
|
||||
try {
|
||||
DefaultConfig = configContext('./environment.default.js');
|
||||
} catch (e) {
|
||||
throw new Error(`Cannot find file "${path.resolve('config', './environment.default.js')}"`);
|
||||
}
|
||||
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'prod':
|
||||
case 'production':
|
||||
EnvConfigFile = './environment.prod.js';
|
||||
break;
|
||||
case 'dev':
|
||||
case 'development':
|
||||
default:
|
||||
EnvConfigFile = './environment.dev.js';
|
||||
}
|
||||
try {
|
||||
EnvConfig = configContext(EnvConfigFile);
|
||||
} catch (e) {
|
||||
EnvConfig = {};
|
||||
}
|
||||
|
||||
const GlobalConfig = Object.assign(DefaultConfig, EnvConfig);
|
||||
|
||||
export {GlobalConfig}
|
Reference in New Issue
Block a user