Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

feature (app): add app config #260

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"test": "environments/environment.test.ts",
"mock": "environments/environment.mock.ts",
"beol": "environments/environment.beol.ts",
"it": "environments/environment.integration.ts"
"deploy": "environments/environment.deploy.ts"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ script:
- ng test --reporters=spec --browser=ChromeHeadless --single-run=true
# this should really be fixed in the package itself (https://github.com/dhlab-basel/JDNConvertibleCalendarDateAdapter/issues/5)
- cp fixes/jdnconvertiblecalendardateadapter/index.d.ts node_modules/jdnconvertiblecalendardateadapter/dist/index.d.ts
- ng build --prod --build-optimizer
- ng build --target=production --environment=dev --build-optimizer

notifications:
slack:
Expand Down
44 changes: 44 additions & 0 deletions docs/jekyll/_docs/02-developer-hints/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,47 @@ Project-specific templates for own project presentation pages. This will be obso

#### - test
Test component environment to test single components in a quick way.

### Runtime Configuration and Application Constants

Any environment specific configuration needs to go in `src/app/assets/config/config.dev.json`. The corresponding model definition is defined in `src/app/app-config.model.ts`.
To access a specific configuration value from anywhere in the code, write `AppConfig.getConfig.apiURL`. Any additions to `config.dev.json` need to be reflected in `app-config.model.ts`.

Any application wide constants should go into `src/app/app.config.ts`

#### Configuration Description

This is the default configuration, used during local development:

```
{
"env": {
"name": "dev"
},
"ontologyIRI": "http://0.0.0.0:3333",
"apiURL": "http://0.0.0.0:3333",
"iiifURL": "http://localhost:1024/knora",
"appURL": "http://localhost:4200",
"localData": "data",
"pagingLimit": 25,
"startComponent": "dasch",
"firebase": {
"apiKey": "AIzaSyAGr-TWw1NaycUrL3IaJQ63D2YguVafYTA",
"authDomain": "test-5034c.firebaseapp.com",
"databaseURL": "https://test-5034c.firebaseio.com",
"projectId": "test-5034c",
"storageBucket": "test-5034c.appspot.com",
"messagingSenderId": "44326559957"
}
}
```


- `ontologyIRI`: used in Gravsearch templates. Needs to always start with `http` and corespond to the hostname and port defined in `apiURL`.
- `apiURL`: the URL to the Knora API service.
- `iiifURL`: the URL to the IIIF (Sipi) service.
- `appURL`: the URL of this application.
- `localData`: path to the local data storage.
- `pagingLimit`: the paging limit for displaying resources.
- `startComponent`: the component which will be shown at `/`.
- `firebase`: firebase settings.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.0",
"angular-tree-component": "^6.1.0",
"angularfire2": "^5.0.0-rc.6",
"angularfire2": "5.0.0-rc.7",
"core-js": "^2.5.1",
"firebase": "^4.9.1",
"hammerjs": "^2.0.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
* License along with SALSAH. If not, see <http://www.gnu.org/licenses/>.
*/

// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=mock` then `environment.mock.ts` will be used instead.
// The list of which env maps to which file can be found in `..angular-cli.json`.
export interface IAppConfig {

export const environment = {
type: 'mock-api',
production: false,
media: 'http://localhost/sipi_mockups',
apiExternal: 'http://0.0.0.0:3333',
api: 'http://localhost/salsah/v2/knora_mockups/v1',
url: 'http://localhost:4200',
dataPool: 'data-pool',
pagingLimit: 25,
firebase: {}
};
env: {
name: string;
};
ontologyIRI: string;
apiURL: string;
iiifURL: string;
appURL: string;
localData: string;
pagingLimit: number;
startComponent: string;
firebase: {
apiKey: string;
authDomain: string;
databaseURL: string;
projectId: string;
storageBucket: string;
messagingSenderId: string;

};
}
226 changes: 18 additions & 208 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright © 2016 Lukas Rosenthaler, André Kilchenmann, Andreas Aeschlimann,
/*
* Copyright © 2016 Lukas Rosenthaler, André Kilchenmann, Andreas Aeschlimann,
* Sofia Georgakopoulou, Ivan Subotic, Benjamin Geer, Tobias Schweizer.
* This file is part of SALSAH.
* SALSAH is free software: you can redistribute it and/or modify
Expand All @@ -10,218 +11,27 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* You should have received a copy of the GNU Affero General Public
* License along with SALSAH. If not, see <http://www.gnu.org/licenses/>.
* */
*/

import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {environment} from '../environments/environment';
import {IAppConfig} from './app-config.model';

@Injectable()
export class AppConfig {

public static FileServer: string = environment.media;
public static AdminFileServer: string = environment.media + '/server/admin';
static settings: IAppConfig;

public static KnoraOntologyPath: string = 'http://www.knora.org/ontology';
public static KnoraBase: string = AppConfig.KnoraOntologyPath + '/knora-base';

public static SystemProject: string = AppConfig.KnoraBase + '#SystemProject';
public static SystemAdminGroup: string = AppConfig.KnoraBase + '#SystemAdmin';
public static ProjectAdminGroup: string = AppConfig.KnoraBase + '#ProjectAdmin';
public static ProjectMemberGroup: string = AppConfig.KnoraBase + '#ProjectMember';

public static KnoraApi: string = 'http://api.knora.org/ontology/knora-api';

public static PathSeparator = '#';

public static KnoraApiV2WithValueObjectPath: string = AppConfig.KnoraApi + '/v2' + AppConfig.PathSeparator;

public static KnoraApiV2SimplePath: string = AppConfig.KnoraApi + '/simple/v2' + AppConfig.PathSeparator;

public static isEditable: string = AppConfig.KnoraApiV2WithValueObjectPath + 'isEditable';
public static isLinkProperty: string = AppConfig.KnoraApiV2WithValueObjectPath + 'isLinkProperty';
public static isLinkValueProperty: string = AppConfig.KnoraApiV2WithValueObjectPath + 'isLinkValueProperty';


public static ResourceIcon: string = AppConfig.KnoraApiV2WithValueObjectPath + 'resourceIcon';

public static RdfProperty: string = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property';

public static OwlClass: string = 'http://www.w3.org/2002/07/owl#Class';
public static OwlObjectProperty: string = 'http://www.w3.org/2002/07/owl#ObjectProperty';
public static OwlDatatypeProperty: string = 'http://www.w3.org/2002/07/owl#DatatypeProperty';
public static OwlAnnotationProperty: string = 'http://www.w3.org/2002/07/owl#AnnotationProperty';
public static OwlOnProperty: string = 'http://www.w3.org/2002/07/owl#onProperty';
public static OwlMaxCardinality: string = 'http://www.w3.org/2002/07/owl#maxCardinality';
public static OwlMinCardinality: string = 'http://www.w3.org/2002/07/owl#minCardinality';
public static OwlCardinality: string = 'http://www.w3.org/2002/07/owl#cardinality';
public static ObjectType = AppConfig.KnoraApiV2WithValueObjectPath + 'objectType';
public static OwlRestriction = 'http://www.w3.org/2002/07/owl#Restriction';

public static creationDate = AppConfig.KnoraApiV2WithValueObjectPath + 'creationDate';
public static hasPermissions = AppConfig.KnoraApiV2WithValueObjectPath + 'hasPermissions';

public static Region = AppConfig.KnoraApiV2WithValueObjectPath + 'Region';

public static Resource: string = AppConfig.KnoraApiV2WithValueObjectPath + 'Resource';
public static TextValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'TextValue';
public static IntValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'IntValue';
public static BooleanValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'BooleanValue';
public static UriValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'UriValue';
public static DecimalValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'DecimalValue';
public static DateValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'DateValue';
public static ColorValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'ColorValue';
public static GeomValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'GeomValue';
public static ListValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'ListValue';
public static IntervalValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'IntervalValue';
public static LinkValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'LinkValue';
public static GeonameValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'GeonameValue';
public static FileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'FileValue';
public static AudioFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'AudioFileValue';
public static DDDFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'DDDFileValue';
public static DocumentFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'DocumentFileValue';
public static StillImageFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'StillImageFileValue';
public static MovingImageFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'MovingImageFileValue';
public static TextFileValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'TextFileValue';
public static IsResourceClass: string = AppConfig.KnoraApiV2WithValueObjectPath + 'isResourceClass';
public static IsValueClass: string = AppConfig.KnoraApiV2WithValueObjectPath + 'isValueClass';
public static ForbiddenResource: string = AppConfig.KnoraApiV2WithValueObjectPath + 'ForbiddenResource';
public static XMLToStandoffMapping: string = AppConfig.KnoraApiV2WithValueObjectPath + 'XMLToStandoffMapping';
public static ListNode: string = AppConfig.KnoraApiV2WithValueObjectPath + 'ListNode';

public static StandoffOntology = 'http://api.knora.org/ontology/standoff/v2';
public static SalsahGuiOntology = 'http://api.knora.org/ontology/salsah-gui/v2';

public static ReadTextValueAsHtml: string = 'ReadTextValueAsHtml';
public static ReadTextValueAsString: string = 'ReadTextValueAsString';
public static ReadTextValueAsXml: string = 'ReadTextValueAsXml';
public static ReadDateValue: string = 'ReadDateValue';
public static ReadLinkValue: string = 'ReadLinkValue';
public static ReadIntegerValue: string = 'ReadIntegerValue';
public static ReadDecimalValue: string = 'ReadDecimalValue';
public static ReadStillImageFileValue: string = 'ReadStillImageFileValue';
public static ReadGeomValue: string = 'ReadGeomValue';
public static ReadColorValue: string = 'ReadColorValue';
public static ReadUriValue: string = 'ReadUriValue';
public static ReadBooleanValue: string = 'ReadBooleanValue';
public static ReadIntervalValue: string = 'ReadIntervalValue';
public static ReadListValue: string = 'ReadListValue';

public static valueAsString: string = AppConfig.KnoraApiV2WithValueObjectPath + 'valueAsString';

public static textValueAsHtml: string = AppConfig.KnoraApiV2WithValueObjectPath + 'textValueAsHtml';
public static textValueAsXml: string = AppConfig.KnoraApiV2WithValueObjectPath + 'textValueAsXml';
public static textValueHasMapping: string = AppConfig.KnoraApiV2WithValueObjectPath + 'textValueHasMapping';

public static hasStandoffLinkToValue: string = AppConfig.KnoraApiV2WithValueObjectPath + 'hasStandoffLinkToValue';

public static dateValueHasStartYear: string = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasStartYear';
public static dateValueHasEndYear: string = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasEndYear';
public static dateValueHasStartEra: string = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasStartEra';
public static dateValueHasEndEra: string = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasEndEra';
public static dateValueHasStartMonth = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasStartMonth';
public static dateValueHasEndMonth = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasEndMonth';
public static dateValueHasStartDay = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasStartDay';
public static dateValueHasEndDay = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasEndDay';
public static dateValueHasCalendar = AppConfig.KnoraApiV2WithValueObjectPath + 'dateValueHasCalendar';

public static linkValueHasTarget = AppConfig.KnoraApiV2WithValueObjectPath + 'linkValueHasTarget';
public static linkValueHasSource = AppConfig.KnoraApiV2WithValueObjectPath + 'linkValueHasSource';
public static linkValueHasSourceIri = AppConfig.KnoraApiV2WithValueObjectPath + 'linkValueHasSourceIri';
public static linkValueHasTargetIri = AppConfig.KnoraApiV2WithValueObjectPath + 'linkValueHasTargetIri';

public static integerValueAsInteger = AppConfig.KnoraApiV2WithValueObjectPath + 'intValueAsInt';

public static decimalValueAsDecimal = AppConfig.KnoraApiV2WithValueObjectPath + 'decimalValueAsDecimal';

public static fileValueAsUrl = AppConfig.KnoraApiV2WithValueObjectPath + 'fileValueAsUrl';
public static fileValueIsPreview = AppConfig.KnoraApiV2WithValueObjectPath + 'fileValueIsPreview';
public static fileValueHasFilename = AppConfig.KnoraApiV2WithValueObjectPath + 'fileValueHasFilename';

public static hasStillImageFileValue = AppConfig.KnoraApiV2WithValueObjectPath + 'hasStillImageFileValue';

public static stillImageFileValueHasDimX = AppConfig.KnoraApiV2WithValueObjectPath + 'stillImageFileValueHasDimX';
public static stillImageFileValueHasDimY = AppConfig.KnoraApiV2WithValueObjectPath + 'stillImageFileValueHasDimY';
public static stillImageFileValueHasIIIFBaseUrl = AppConfig.KnoraApiV2WithValueObjectPath + 'stillImageFileValueHasIIIFBaseUrl';

public static colorValueAsColor = AppConfig.KnoraApiV2WithValueObjectPath + 'colorValueAsColor';
public static geometryValueAsGeometry = AppConfig.KnoraApiV2WithValueObjectPath + 'geometryValueAsGeometry';
public static uriValueAsUri = AppConfig.KnoraApiV2WithValueObjectPath + 'uriValueAsUri';
public static booleanValueAsBoolean = AppConfig.KnoraApiV2WithValueObjectPath + 'booleanValueAsBoolean';

public static intervalValueHasStart = AppConfig.KnoraApiV2WithValueObjectPath + 'intervalValueHasStart';
public static intervalValueHasEnd = AppConfig.KnoraApiV2WithValueObjectPath + 'intervalValueHasEnd';

public static listValueAsListNode = AppConfig.KnoraApiV2WithValueObjectPath + 'listValueAsListNode';
public static listValueAsListNodeLabel = AppConfig.KnoraApiV2WithValueObjectPath + 'listValueAsListNodeLabel';

public static hasGeometry = AppConfig.KnoraApiV2WithValueObjectPath + 'hasGeometry';

public static schemaName = 'http://schema.org/name';
public static schemaNumberOfItems = 'http://schema.org/numberOfItems';
public static schemaItemListElement = 'http://schema.org/itemListElement';

public static RdfsLabel = 'http://www.w3.org/2000/01/rdf-schema#label';
public static RdfsComment = 'http://www.w3.org/2000/01/rdf-schema#comment';
public static RdfsSubclassOf = 'http://www.w3.org/2000/01/rdf-schema#subClassOf';
public static subPropertyOf: string = 'http://www.w3.org/2000/01/rdf-schema#subPropertyOf';

public static SalsahLink = 'salsah-link'; // class on an HTML <a> element that indicates a link to a Knora resource
public static RefMarker = 'ref-marker'; // class on an HTML element that refers to another element in the same document

public static EqualsComparisonOperator = '=';
public static EqualsComparisonLabel = 'Equals';

public static NotEqualsComparisonOperator = '!=';
public static NotEqualsComparisonLabel = 'Not_Equals';

public static GreaterThanComparisonOperator = '>';
public static GreaterThanComparisonLabel = 'Greater_Than';

public static GreaterThanEqualsComparisonOperator = '>=';
public static GreaterThanEqualsComparisonLabel = 'Greater_Than_Equals';

public static LessThanComparisonOperator = '<';
public static LessThanComparisonLabel = 'Less_Than';

public static LessThanEqualsComparisonOperator = '<=';
public static LessThanQualsComparisonLabel = 'Less_Than_Equals';

public static ExistsComparisonOperator = 'E';
public static ExistsComparisonLabel = 'Exists';

public static LikeComparisonOperator = 'regex';
public static LikeComparisonLabel = 'Like';

public static MatchComparisonOperator = 'contains';
public static MatchComparisonLabel = 'Match';

public static Xsd = 'http://www.w3.org/2001/XMLSchema#';

public static xsdString = AppConfig.Xsd + 'string';
public static xsdBoolean = AppConfig.Xsd + 'boolean';
public static xsdInteger = AppConfig.Xsd + 'integer';
public static xsdDecimal = AppConfig.Xsd + 'decimal';
public static xsdUri = AppConfig.Xsd + 'anyURI';

public static resourceSimple = AppConfig.KnoraApiV2SimplePath + 'Resource';
public static dateSimple = AppConfig.KnoraApiV2SimplePath + 'Date';
public static intervalSimple = AppConfig.KnoraApiV2SimplePath + 'Interval';
public static geomSimple = AppConfig.KnoraApiV2SimplePath + 'Geom';
public static colorSimple = AppConfig.KnoraApiV2SimplePath + 'Color';
public static geonameSimple = AppConfig.KnoraApiV2SimplePath + 'Geoname';
public static fileSimple = AppConfig.KnoraApiV2SimplePath + 'File';

public static matchFunction = AppConfig.KnoraApiV2SimplePath + "match";

public static GNDPrefix = '(DE-588)';
public static GNDResolver = 'http://d-nb.info/gnd/';

public static VIAFPrefix = '(VIAF)';
public static VIAFResolver = 'https://viaf.org/viaf/';

// regular expression
public static RegexEmail = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
public static RegexUrl = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/i;
public static RegexPassword = /^(?=.*\d)(?=.*[a-zA-Z]).{8,}$/i;
public static RegexHex = /^[0-9A-Fa-f]+$/;
public static RegexShortname = /^[a-zA-Z]+\S*$/;
constructor(private http: HttpClient) { }

loadAppConfig() {
const jsonFile = `assets/config/config.${environment.name}.json`;
return this.http.get(jsonFile)
.toPromise()
.then(data => {
AppConfig.settings = <IAppConfig>data;
console.log('AppConfig.settings = ', AppConfig.settings);
});
}
}
Loading