mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #8 from wwelling/tslint-warnings
Looks good, merging
This commit is contained in:
@@ -27,7 +27,3 @@ Currently this contains the [Angular 2 Universal Starter](https://github.com/ang
|
||||
|
||||
## AoT and Prod
|
||||
- `npm run build:prod:ngc` to compile the ngfactory files and build prod
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -3,5 +3,5 @@
|
||||
"dist",
|
||||
"src/index.html"
|
||||
],
|
||||
"ext" : "js ts json html"
|
||||
"ext": "js ts json html"
|
||||
}
|
||||
|
@@ -8,14 +8,14 @@ let __compiler__ = require('@angular/compiler');
|
||||
import { __platform_browser_private__ } from '@angular/platform-browser';
|
||||
import { __core_private__ } from '@angular/core';
|
||||
if (!__core_private__['ViewUtils']) {
|
||||
__core_private__['ViewUtils'] = __core_private__['view_utils'];
|
||||
__core_private__['ViewUtils'] = __core_private__['view_utils'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
|
||||
(__compiler__).__compiler_private__ = {
|
||||
SelectorMatcher: __compiler__.SelectorMatcher,
|
||||
CssSelector: __compiler__.CssSelector
|
||||
}
|
||||
(__compiler__).__compiler_private__ = {
|
||||
SelectorMatcher: __compiler__.SelectorMatcher,
|
||||
CssSelector: __compiler__.CssSelector
|
||||
}
|
||||
}
|
||||
|
@@ -9,25 +9,25 @@ import { __platform_browser_private__ } from '@angular/platform-browser';
|
||||
import { __core_private__ } from '@angular/core';
|
||||
let patch = false;
|
||||
if (!__core_private__['ViewUtils']) {
|
||||
patch = true;
|
||||
__core_private__['ViewUtils'] = __core_private__['view_utils'];
|
||||
patch = true;
|
||||
__core_private__['ViewUtils'] = __core_private__['view_utils'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
|
||||
patch = true;
|
||||
(__compiler__).__compiler_private__ = {
|
||||
SelectorMatcher: __compiler__.SelectorMatcher,
|
||||
CssSelector: __compiler__.CssSelector
|
||||
}
|
||||
patch = true;
|
||||
(__compiler__).__compiler_private__ = {
|
||||
SelectorMatcher: __compiler__.SelectorMatcher,
|
||||
CssSelector: __compiler__.CssSelector
|
||||
}
|
||||
}
|
||||
|
||||
if (patch) {
|
||||
var __universal__ = require('angular2-platform-node/__private_imports__');
|
||||
__universal__.ViewUtils = __core_private__['view_utils'];
|
||||
__universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector;
|
||||
__universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher;
|
||||
var __universal__ = require('angular2-platform-node/__private_imports__');
|
||||
__universal__.ViewUtils = __core_private__['view_utils'];
|
||||
__universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector;
|
||||
__universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher;
|
||||
}
|
||||
|
||||
// Fix Material Support
|
||||
|
@@ -6,9 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable} from '@angular/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
// es6-modules are used here
|
||||
import {DomAdapter, getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import { DomAdapter, getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
||||
/**
|
||||
* Represent meta element.
|
||||
@@ -69,7 +69,7 @@ export class Meta {
|
||||
* @param tags
|
||||
* @returns {HTMLMetaElement[]}
|
||||
*/
|
||||
addTags(...tags: Array<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] {
|
||||
addTags(...tags: Array<MetaDefinition | MetaDefinition[]>): HTMLMetaElement[] {
|
||||
const presentTags = this._flattenArray(tags);
|
||||
if (presentTags.length === 0) return [];
|
||||
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));
|
||||
|
@@ -8,7 +8,7 @@ import { AppComponent } from './app.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [ AppComponent ],
|
||||
declarations: [AppComponent],
|
||||
imports: [
|
||||
SharedModule,
|
||||
HomeModule,
|
||||
|
@@ -4,7 +4,7 @@ import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
encapsulation: ViewEncapsulation.Emulated,
|
||||
selector: 'ds-home',
|
||||
styleUrls: [ './home.component.css' ],
|
||||
styleUrls: ['./home.component.css'],
|
||||
templateUrl: './home.component.html'
|
||||
})
|
||||
export class HomeComponent {
|
||||
|
@@ -11,9 +11,9 @@ export class ApiService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* whatever domain/feature method name
|
||||
*/
|
||||
/**
|
||||
* whatever domain/feature method name
|
||||
*/
|
||||
get(url: string, options?: any) {
|
||||
return this._http.get(url, options)
|
||||
.map(res => res.json())
|
||||
|
@@ -4,7 +4,7 @@ import { Inject, Injectable, isDevMode } from '@angular/core';
|
||||
export class CacheService {
|
||||
static KEY = 'CacheService';
|
||||
|
||||
constructor(@Inject('LRU') public _cache: Map<string, any>) {
|
||||
constructor( @Inject('LRU') public _cache: Map<string, any>) {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -23,14 +23,14 @@ export function hashCodeString(str: string): string {
|
||||
// domain/feature service
|
||||
@Injectable()
|
||||
export class ModelService {
|
||||
// This is only one example of one Model depending on your domain
|
||||
// This is only one example of one Model depending on your domain
|
||||
constructor(public _api: ApiService, public _cache: CacheService) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* whatever domain/feature method name
|
||||
*/
|
||||
/**
|
||||
* whatever domain/feature method name
|
||||
*/
|
||||
get(url) {
|
||||
// you want to return the cache if there is a response in it.
|
||||
// This would cache the first response so if your API isn't idempotent
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
@@ -1,9 +1,9 @@
|
||||
var util = require('util');
|
||||
var {Router} = require('express');
|
||||
var { Router } = require('express');
|
||||
|
||||
// Our API for demos only
|
||||
import {fakeDataBase} from './db';
|
||||
import {fakeDemoRedisCache} from './cache';
|
||||
import { fakeDataBase } from './db';
|
||||
import { fakeDemoRedisCache } from './cache';
|
||||
|
||||
// you would use cookies/token etc
|
||||
var USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example
|
||||
@@ -32,9 +32,9 @@ export function serverApi(req, res) {
|
||||
var COUNT = 4;
|
||||
var TODOS = [
|
||||
{ id: 0, value: 'finish example', created_at: new Date(), completed: false },
|
||||
{ id: 1, value: 'add tests', created_at: new Date(), completed: false },
|
||||
{ id: 1, value: 'add tests', created_at: new Date(), completed: false },
|
||||
{ id: 2, value: 'include development environment', created_at: new Date(), completed: false },
|
||||
{ id: 3, value: 'include production environment', created_at: new Date(), completed: false }
|
||||
{ id: 3, value: 'include production environment', created_at: new Date(), completed: false }
|
||||
];
|
||||
|
||||
export function createTodoApi() {
|
||||
@@ -51,7 +51,7 @@ export function createTodoApi() {
|
||||
|
||||
})
|
||||
.post(function(req, res) {
|
||||
console.log('POST', util.inspect(req.body, {colors: true}));
|
||||
console.log('POST', util.inspect(req.body, { colors: true }));
|
||||
var todo = req.body;
|
||||
if (todo) {
|
||||
TODOS.push({
|
||||
@@ -81,12 +81,12 @@ export function createTodoApi() {
|
||||
|
||||
router.route('/todos/:todo_id')
|
||||
.get(function(req, res) {
|
||||
console.log('GET', util.inspect(req.todo, {colors: true}));
|
||||
console.log('GET', util.inspect(req.todo, { colors: true }));
|
||||
|
||||
res.json(req.todo);
|
||||
})
|
||||
.put(function(req, res) {
|
||||
console.log('PUT', util.inspect(req.body, {colors: true}));
|
||||
console.log('PUT', util.inspect(req.body, { colors: true }));
|
||||
|
||||
var index = TODOS.indexOf(req.todo);
|
||||
var todo = TODOS[index] = req.body;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>DSpace</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -10,6 +11,7 @@
|
||||
<base href="/">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<ds-app>
|
||||
@@ -18,4 +20,5 @@
|
||||
|
||||
<script async src="/main.bundle.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@@ -55,11 +55,11 @@ app.set('json spaces', 2);
|
||||
app.use(cookieParser('Angular 2 Universal'));
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.use(interceptor((req, res)=>({
|
||||
app.use(interceptor((req, res) => ({
|
||||
// don't compress responses with this request header
|
||||
isInterceptable: () => (!req.headers['x-no-compression']),
|
||||
intercept: ( body, send ) => {
|
||||
const encodings = new Set(accepts(req).encodings());
|
||||
intercept: (body, send) => {
|
||||
const encodings = new Set(accepts(req).encodings());
|
||||
const bodyBuffer = new Buffer(body);
|
||||
// url specific key for response cache
|
||||
const key = '__response__' + req.originalUrl || req.url;
|
||||
@@ -71,12 +71,12 @@ app.use(interceptor((req, res)=>({
|
||||
// brotli
|
||||
res.setHeader('Content-Encoding', 'br');
|
||||
output = compressSync(bodyBuffer);
|
||||
mcache.put(key, {output, encoding: 'br'});
|
||||
mcache.put(key, { output, encoding: 'br' });
|
||||
} else if (encodings.has('gzip')) {
|
||||
// gzip
|
||||
res.setHeader('Content-Encoding', 'gzip');
|
||||
output = gzipSync(bodyBuffer);
|
||||
mcache.put(key, {output, encoding: 'gzip'});
|
||||
mcache.put(key, { output, encoding: 'gzip' });
|
||||
}
|
||||
} else {
|
||||
const { output, encoding } = mcache.get(key);
|
||||
@@ -87,7 +87,7 @@ app.use(interceptor((req, res)=>({
|
||||
}
|
||||
})));
|
||||
|
||||
const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', {flags: 'a'})
|
||||
const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', { flags: 'a' })
|
||||
|
||||
app.use(morgan('common', {
|
||||
skip: (req, res) => res.statusCode < 400,
|
||||
@@ -100,8 +100,8 @@ function cacheControl(req, res, next) {
|
||||
next();
|
||||
}
|
||||
// Serve static files
|
||||
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
|
||||
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false}));
|
||||
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
|
||||
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
|
||||
|
||||
//
|
||||
/////////////////////////
|
||||
@@ -120,7 +120,7 @@ function ngApp(req, res) {
|
||||
preboot: false,
|
||||
baseUrl: '/',
|
||||
requestUrl: req.originalUrl,
|
||||
originUrl: `http://localhost:${ app.get('port') }`
|
||||
originUrl: `http://localhost:${app.get('port')}`
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -57,8 +57,8 @@ function cacheControl(req, res, next) {
|
||||
next();
|
||||
}
|
||||
// Serve static files
|
||||
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
|
||||
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false}));
|
||||
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
|
||||
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
|
||||
|
||||
//
|
||||
/////////////////////////
|
||||
@@ -77,7 +77,7 @@ function ngApp(req, res) {
|
||||
preboot: false,
|
||||
baseUrl: '/',
|
||||
requestUrl: req.originalUrl,
|
||||
originUrl: `http://localhost:${ app.get('port') }`
|
||||
originUrl: `http://localhost:${app.get('port')}`
|
||||
});
|
||||
}
|
||||
|
||||
|
8
src/typings.d.ts
vendored
8
src/typings.d.ts
vendored
@@ -39,7 +39,7 @@ interface SystemJS {
|
||||
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
||||
declare var ENV: string;
|
||||
declare var HMR: boolean;
|
||||
declare var Zone: {current: any};
|
||||
declare var Zone: { current: any };
|
||||
interface GlobalEnvironment {
|
||||
ENV;
|
||||
HMR;
|
||||
@@ -68,6 +68,6 @@ interface WebpackRequire {
|
||||
}
|
||||
|
||||
// Extend typings
|
||||
interface NodeRequire extends WebpackRequire {}
|
||||
interface NodeModule extends WebpackModule {}
|
||||
interface Global extends GlobalEnvironment {}
|
||||
interface NodeRequire extends WebpackRequire { }
|
||||
interface NodeModule extends WebpackModule { }
|
||||
interface Global extends GlobalEnvironment { }
|
||||
|
@@ -24,5 +24,7 @@
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false,
|
||||
"atom": { "rewriteTsconfig": false }
|
||||
"atom": {
|
||||
"rewriteTsconfig": false
|
||||
}
|
||||
}
|
||||
|
@@ -23,5 +23,7 @@
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false,
|
||||
"atom": { "rewriteTsconfig": false }
|
||||
"atom": {
|
||||
"rewriteTsconfig": false
|
||||
}
|
||||
}
|
||||
|
@@ -6,13 +6,13 @@
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"dspace",
|
||||
"ds",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"dspace",
|
||||
"ds",
|
||||
"kebab-case"
|
||||
],
|
||||
"use-input-property-decorator": true,
|
||||
@@ -27,7 +27,7 @@
|
||||
"pipe-naming": [
|
||||
true,
|
||||
"camelCase",
|
||||
"dspace"
|
||||
"ds"
|
||||
],
|
||||
"component-class-suffix": true,
|
||||
"directive-class-suffix": true,
|
||||
|
@@ -4,7 +4,7 @@ const clone = require('js.clone');
|
||||
const webpackMerge = require('webpack-merge');
|
||||
const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
import webpackConfig, { root, includeClientPackages } from './webpack.config';
|
||||
import webpackConfig, { root, includeClientPackages } from './webpack.config';
|
||||
// const CompressionPlugin = require('compression-webpack-plugin');
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@ export const serverConfig = {
|
||||
|
||||
export default [
|
||||
// Client
|
||||
webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, {plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }),
|
||||
webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, { plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }),
|
||||
|
||||
// Server
|
||||
webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, {plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) })
|
||||
webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, { plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) })
|
||||
];
|
||||
|
Reference in New Issue
Block a user