mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Merge branch 'master' into w2p-38248_PageNotFound-component
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -5,6 +5,11 @@
|
|||||||
/tsd_typings/
|
/tsd_typings/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
|
/config/environment.dev.js
|
||||||
|
/config/environment.prod.js
|
||||||
|
|
||||||
|
/coverage
|
||||||
|
|
||||||
/dist/
|
/dist/
|
||||||
/coverage/
|
/coverage/
|
||||||
|
|
||||||
|
24
README.md
24
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)
|
* [Introduction to the technology](#introduction-to-the-technology)
|
||||||
* [Requirements](#requirements)
|
* [Requirements](#requirements)
|
||||||
* [Installing](#installing)
|
* [Installing](#installing)
|
||||||
|
* [Configuring](#configuring)
|
||||||
* [Running the app](#running-the-app)
|
* [Running the app](#running-the-app)
|
||||||
* [Running in production mode](#running-in-production-mode)
|
* [Running in production mode](#running-in-production-mode)
|
||||||
* [Cleaning](#cleaning)
|
* [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 run global` to install the required global dependencies
|
||||||
* `npm install` to install the local 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
|
## 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`.
|
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`.
|
||||||
@@ -131,6 +143,7 @@ and run:
|
|||||||
|
|
||||||
## Other commands
|
## Other commands
|
||||||
There are many more commands in the `scripts` section of `package.json`. Most of these are executed by one of the commands mentioned above.
|
There are many more commands in the `scripts` section of `package.json`. Most of these are executed by one of the commands mentioned above.
|
||||||
|
|
||||||
A command with a name that starts with `pre` or `post` will be executed automatically before or after the script with the matching name. e.g. if you type `npm run start` the `prestart` script will run first, then the `start` script will trigger.
|
A command with a name that starts with `pre` or `post` will be executed automatically before or after the script with the matching name. e.g. if you type `npm run start` the `prestart` script will run first, then the `start` script will trigger.
|
||||||
|
|
||||||
|
|
||||||
@@ -155,9 +168,12 @@ See [the guide on the wiki](https://wiki.duraspace.org/display/DSPACE/DSpace+7+-
|
|||||||
dspace-angular
|
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
|
||||||
|
│ └── environment.default.js * Default 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
|
||||||
|
├── npm-shrinkwrap.json * Npm dependency lockfile (https://docs.npmjs.com/cli/shrinkwrap)
|
||||||
├── package.json * This file describes the npm package for this project, its dependencies, scripts, etc.
|
├── package.json * This file describes the npm package for this project, its dependencies, scripts, etc.
|
||||||
├── postcss.config.json * PostCSS (http://postcss.org/) configuration file
|
├── postcss.config.json * PostCSS (http://postcss.org/) configuration file
|
||||||
├── protractor.conf.js * E2E tests configuration file
|
├── protractor.conf.js * E2E tests configuration file
|
||||||
@@ -172,6 +188,7 @@ dspace-angular
|
|||||||
│ ├── browser.module.ts * The root module for the client
|
│ ├── browser.module.ts * The root module for the client
|
||||||
│ ├── client.aot.ts * The bootstrap file for the client, in production
|
│ ├── client.aot.ts * The bootstrap file for the client, in production
|
||||||
│ ├── client.ts * The bootstrap file for the client, during development
|
│ ├── 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-aot.html * The index.html file, for production
|
||||||
│ ├── index.html * The index.html file, for development
|
│ ├── index.html * The index.html file, for development
|
||||||
│ ├── node.module.ts * The root module for the server
|
│ ├── node.module.ts * The root module for the server
|
||||||
@@ -226,6 +243,13 @@ If you're importing a module that uses CommonJS you need to import as
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## npm-shrinkwrap
|
||||||
|
This project makes use of [npm-shrinkwrap](https://docs.npmjs.com/cli/shrinkwrap) to ensure that the exact same dependency versions are used every time you install it.
|
||||||
|
|
||||||
|
npm-shrinkwrap creates the file `npm-shrinkwrap.json` to track those versions. That file is updated automatically every time you install a new dependency from the commandline (by using `npm install some-lib --save` or `npm install some-lib --save-dev`).
|
||||||
|
|
||||||
|
If you manually add a package or change a version in `package.json` you'll have to update npm-shrinkwrap's lock file as well. You can do so by running `npm run rewrap`
|
||||||
|
|
||||||
## Frequently asked questions
|
## Frequently asked questions
|
||||||
* Why is my service, aka provider, is not injecting a parameter correctly?
|
* Why is my service, aka provider, is not injecting a parameter correctly?
|
||||||
* Please use `@Injectable()` for your service for typescript to correctly attach the metadata
|
* Please use `@Injectable()` for your service for typescript to correctly attach the metadata
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
6561
npm-shrinkwrap.json
generated
Normal file
6561
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -21,7 +21,7 @@
|
|||||||
"clean:prod": "npm run clean:ngc && npm run clean:json && npm run clean:css && npm run clean:css:ts && npm run clean:scss:ts && npm run clean:css:shim:ts && npm run clean:scss:shim:ts && npm run clean:dist",
|
"clean:prod": "npm run clean:ngc && npm run clean:json && npm run clean:css && npm run clean:css:ts && npm run clean:scss:ts && npm run clean:css:shim:ts && npm run clean:scss:shim:ts && npm run clean:dist",
|
||||||
"clean": "npm run clean:log && npm run clean:prod && npm run clean:coverage && npm run clean:node",
|
"clean": "npm run clean:log && npm run clean:prod && npm run clean:coverage && npm run clean:node",
|
||||||
"sass": "node-sass src -o src --include-path node_modules --output-style compressed -q",
|
"sass": "node-sass src -o src --include-path node_modules --output-style compressed -q",
|
||||||
"postcss": "node_modules/postcss-cli/bin/postcss -c postcss.config.json",
|
"postcss": "node node_modules/postcss-cli/bin/postcss -c postcss.config.json",
|
||||||
"style": "npm run sass && npm run postcss",
|
"style": "npm run sass && npm run postcss",
|
||||||
"style:watch": "nodemon -e scss -w src -x \"npm run style\"",
|
"style:watch": "nodemon -e scss -w src -x \"npm run style\"",
|
||||||
"rollup": "rollup -c rollup-server.js && rollup -c rollup-client.js",
|
"rollup": "rollup -c rollup-server.js && rollup -c rollup-client.js",
|
||||||
@@ -36,11 +36,12 @@
|
|||||||
"ngc": "ngc -p tsconfig.aot.json",
|
"ngc": "ngc -p tsconfig.aot.json",
|
||||||
"prestart": "npm run build:prod:ngc:json",
|
"prestart": "npm run build:prod:ngc:json",
|
||||||
"server": "node dist/server/build.js",
|
"server": "node dist/server/build.js",
|
||||||
"server:dev": "nodemon --debug dist/server/index.js",
|
"server:dev": "node dist/server/index.js",
|
||||||
|
"server:dev:watch": "nodemon --debug dist/server/index.js",
|
||||||
"start": "npm run server",
|
"start": "npm run server",
|
||||||
"start:dev": "npm run clean:prod && npm run build && npm run server",
|
"start:dev": "npm run clean:prod && npm run build && npm run server:dev",
|
||||||
"watch": "webpack -w & npm run style:watch",
|
"watch": "webpack -w & npm run style:watch",
|
||||||
"watch:dev:server": "concurrently \"npm run server:dev\" \"npm run watch\"",
|
"watch:dev:server": "concurrently \"npm run server:dev:watch\" \"npm run watch\"",
|
||||||
"watch:dev": "npm run clean:prod && npm run build && npm run watch:dev:server",
|
"watch:dev": "npm run clean:prod && npm run build && npm run watch:dev:server",
|
||||||
"watch:prod:server": "concurrently \"npm run server\" \"npm run watch\"",
|
"watch:prod:server": "concurrently \"npm run server\" \"npm run watch\"",
|
||||||
"watch:prod": "npm run build:prod:ngc:json && npm run watch:prod:server",
|
"watch:prod": "npm run build:prod:ngc:json && npm run watch:prod:server",
|
||||||
@@ -59,7 +60,8 @@
|
|||||||
"test:watch": "karma start --no-single-run --auto-watch",
|
"test:watch": "karma start --no-single-run --auto-watch",
|
||||||
"coverage": "http-server -c-1 -o -p 9875 ./coverage",
|
"coverage": "http-server -c-1 -o -p 9875 ./coverage",
|
||||||
"webdriver:start": "node node_modules/protractor/bin/webdriver-manager start --seleniumPort 4444",
|
"webdriver:start": "node node_modules/protractor/bin/webdriver-manager start --seleniumPort 4444",
|
||||||
"webdriver:update": "node node_modules/protractor/bin/webdriver-manager update --standalone"
|
"webdriver:update": "node node_modules/protractor/bin/webdriver-manager update --standalone",
|
||||||
|
"rewrap": "npm run clean && npm install --no-optional && npm shrinkwrap --dev"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "2.2.3",
|
"@angular/common": "2.2.3",
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
<main>
|
<main>
|
||||||
<p>{{ 'example.with.data' | translate:data }}</p>
|
<p>{{ 'example.with.data' | translate:data }}</p>
|
||||||
<p>{{ example }}</p>
|
<p>{{ example }}</p>
|
||||||
|
<h2 *ngIf="!env" style="color:green">development</h2>
|
||||||
|
<h2 *ngIf="env" style="color:red">production</h2>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -9,6 +9,7 @@ import { TranslateService } from "ng2-translate";
|
|||||||
import { HostWindowState } from "./shared/host-window.reducer";
|
import { HostWindowState } from "./shared/host-window.reducer";
|
||||||
import { Store } from "@ngrx/store";
|
import { Store } from "@ngrx/store";
|
||||||
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
||||||
|
import { GlobalConfig } from "../config";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
@@ -27,6 +28,12 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
recipient: 'World'
|
recipient: 'World'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
env: string = GlobalConfig.production;
|
||||||
|
|
||||||
|
styles = {
|
||||||
|
color: 'red'
|
||||||
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private store: Store<HostWindowState>
|
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