Skip to content

Commit

Permalink
Integrate knora-api-js-lib (#215)
Browse files Browse the repository at this point in the history
* chore: First steps to use knora-api-js-lib and new core module

* chore(landing page): Update knora app title

* Revert "chore(landing page): Update knora app title"

This reverts commit 8a9482b.

* refactor(main): Update app title

* chore(main): New method to get projecs

* fix(help): Get knora version with new config

* chore(project): New method to get projec

* chore(project): New method to get project

* refactor(project): Clean up

* feat(header): Login / logout

* refactor: Clean up @knora/api imports

* chore(user): Update user status

* chore: More on knora-api-js-lib integration

* chore: More on knora-api-js-lib integration

* chore: Update config

* chore: More on knora-api-js-lib integration

* chore: More on knora-api-js-lib integration

* chore: More on knora-api-js-lib integration

* refactor: Response instead of result

* refactor: Clean up imports

* test: Refactor test settings

* test: Refactor test settings

* chore: Using latest knora-ui/core module

* chore: Using latest knora-ui/core module

* chore: Project form

* refactor: Delete unused session validation

* test: Update travis config

* test: Update travis config

* test: Update travis config

* test: Try to fix test

* style(user): No margin in tab

* fix: Make service method angular conform

* chore: Set title with "Knora App"

* fix: Update project (hack)

* fix: Update project (hack)

* fix: Session validation

* refactor(user): Remove console.log

* refactor: Remove @knora/authentication

* chore(admin): Try to create or edit user and project

* fix(user): Create / update user

* fix: Using @knora/api wip/100-optional-properties

* fix: Project form to edit / create projects

* fix: Project form to edit / create projects

* test: Update travis and circleci config

* test: Fix some tests

* refactor: Clean up code

* style: Fix header style issue on mobile device

* chore(workspace): Show res toolbar

* docs: Update README and config

* test: Improve tests

* style(search): Style fix for FF

* feat: Project admin is able to add existing users

* fix: Disable project admin to create system admin

* chore: Fix new @knora/core implementation

* fix: Bug fix in user profile

* feat: Show sysAdmin info on user profile

* test: Fix tests

* feat: Show own project admin status in list of projects

* fix: Bug fix after deactivate own account

* chore: Update footer

* test: Fix broken tests

* fix: Fix typo error
  • Loading branch information
kilchenmann authored and Flavie L committed Dec 12, 2019
1 parent 8dcd8ac commit 6d2da29
Show file tree
Hide file tree
Showing 94 changed files with 1,859 additions and 2,674 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ jobs:
working_directory: ~/repo

steps:
- run: sudo npm install yalc -g
- run: cd ~ && git clone -b master https://github.com/dasch-swiss/knora-api-js-lib.git && cd knora-api-js-lib && npm install && npm run yalc-publish
- run: cd ~ && git clone -b api-js-lib/develop https://github.com/dasch-swiss/knora-ui.git && cd knora-ui && yalc add @knora/api && yarn install && yarn build-and-publish-prod
- run: cd ~/repo
- checkout

# Download and cache dependencies
Expand All @@ -21,6 +25,7 @@ jobs:
&& yarn --version \
&& git --version
- run: yarn yalc-add-modules
- run: yarn install

- save_cache:
Expand Down
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ cache:
addons:
chrome: stable

install: yarn install --prod=false
install:
  - yarn global add @angular/cli
  - yarn global add yalc
- cd ~ && git clone -b master https://github.com/dasch-swiss/knora-api-js-lib.git && cd knora-api-js-lib && npm install && npm run yalc-publish
- cd ~ && git clone -b api-js-lib/develop https://github.com/dasch-swiss/knora-ui.git && cd knora-ui && yalc add @knora/api && yarn install && yarn build-and-publish-prod
- cd $TRAVIS_BUILD_DIR

script:
- yarn yalc-add-modules
- yarn test-ci
- docker build .
- docker build .
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Knora app

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ddfe61cdc2a14c3b89e34d2f49cd64fa)](https://www.codacy.com/manual/dasch-swiss/Knora-app?utm_source=github.com&utm_medium=referral&utm_content=dasch-swiss/knora-app&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ddfe61cdc2a14c3b89e34d2f49cd64fa)](https://www.codacy.com/manual/dasch-swiss/Knora-app?utm_source=github.com&utm_medium=referral&utm_content=dasch-swiss/knora-app&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.com/dasch-swiss/knora-app.svg?branch=master)](https://travis-ci.com/dasch-swiss/knora-app)
[![CircleCI](https://circleci.com/gh/dasch-swiss/knora-app.svg?style=svg)](https://circleci.com/gh/dasch-swiss/knora-app)

Expand All @@ -12,14 +12,13 @@ It's a system for annotation and linkage of sources in arts and humanities.
This project was generated with
[Angular CLI](https://github.com/angular/angular-cli) version 8.0.6 and [Node](https://nodejs.org/en/) version 10.13.0.

**Required version of Knora: ^[9.0.0](https://github.com/dhlab-basel/Knora/releases/tag/v9.0.0)**
**Required version of Knora: ^[10.0.0](https://github.com/dhlab-basel/Knora/releases/tag/v10.0.0)**

Developed by the [DaSCH Team](https://dasch.swiss) in Basel.


## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app
Run `ng serve` for a dev server. Navigate to `http://0.0.0.0:4200/`. The app
will automatically reload if you change any of the source files.

## Code scaffolding
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"e2e": "ng e2e",
"build-prod": "ng build --prod --build-optimizer",
"test-ci": "ng test --watch=false --browsers=ChromeHeadless",
"yalc-add-modules": "rm -rf .yalc/@knora && yalc add @knora/action && yalc add @knora/authentication && yalc add @knora/core && yalc add @knora/search && yalc add @knora/viewer && yarn install --prod=false"
"yalc-add-modules": "rm -rf .yalc/@knora && yalc add @knora/api && yalc add @knora/action && yalc add @knora/core && yalc add @knora/search && yalc add @knora/viewer && yarn install --prod=false"
},
"private": true,
"dependencies": {
Expand All @@ -30,11 +30,11 @@
"@angular/platform-browser": "~8.2.7",
"@angular/platform-browser-dynamic": "~8.2.7",
"@angular/router": "~8.2.7",
"@knora/action": "9.4.0",
"@knora/authentication": "9.4.0",
"@knora/core": "9.4.0",
"@knora/search": "9.4.0",
"@knora/viewer": "9.4.0",
"@knora/action": "file:.yalc/@knora/action",
"@knora/api": "file:.yalc/@knora/api",
"@knora/core": "file:.yalc/@knora/core",
"@knora/search": "file:.yalc/@knora/search",
"@knora/viewer": "file:.yalc/@knora/viewer",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"core-js": "^2.5.4",
Expand Down
9 changes: 1 addition & 8 deletions src/app/app-global.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { MenuItem } from './main/declarations/menu-item';
import { StringLiteral } from '@knora/core';
import { StringLiteral } from '@knora/api';

export class AppGlobal {

// iri base url TODO: should we move this base to the KnoraConstants in knora-ui core?
public static iriBase: string = 'http://rdfh.ch/';
public static iriProjectsBase: string = AppGlobal.iriBase + 'projects/';
public static iriUsersBase: string = AppGlobal.iriBase + 'users/';
public static iriListsBase: string = AppGlobal.iriBase + 'lists/';


// project navigation
public static projectNav: MenuItem[] = [
{
Expand Down
106 changes: 70 additions & 36 deletions src/app/app-init.service.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,87 @@
import { Injectable } from '@angular/core';
import { KuiCoreConfig } from '@knora/core';


export interface IAppConfig {

env: {
name: string;
};
ontologyIRI: string;
apiURL: string;
externalApiURL: string;
iiifURL: string;
appURL: string;
appName: string;
localData: string;
pagingLimit: number;
startComponent: string;
}
import { KnoraApiConfig, KnoraApiConnection } from '@knora/api';
import { KuiConfig } from '@knora/core';

@Injectable()
export class AppInitService {

static settings: IAppConfig;
static coreConfig: KuiCoreConfig;
static knoraApiConnection: KnoraApiConnection;

constructor() {
}
static knoraApiConfig: KnoraApiConfig;

static kuiConfig: KuiConfig;

Init() {
constructor() { }

init() {

return new Promise<void>((resolve, reject) => {
// console.log('AppInitService.init() called');
// do your initialisation stuff here

const data = <IAppConfig>window['tempConfigStorage'];
// console.log('AppInitService: json', data);
AppInitService.settings = data;
// init knora-ui configuration
AppInitService.kuiConfig = window['tempConfigStorage'] as KuiConfig;

AppInitService.coreConfig = <KuiCoreConfig>{
name: AppInitService.settings.appName,
api: AppInitService.settings.apiURL,
media: AppInitService.settings.iiifURL,
app: AppInitService.settings.appURL,
ontologyIRI: AppInitService.settings.ontologyIRI
};
// init knora-api configuration
AppInitService.knoraApiConfig = new KnoraApiConfig(
AppInitService.kuiConfig.knora.apiProtocol,
AppInitService.kuiConfig.knora.apiHost,
AppInitService.kuiConfig.knora.apiPort
);

// console.log('AppInitService: finished');
// set knora-api connection configuration
AppInitService.knoraApiConnection = new KnoraApiConnection(AppInitService.knoraApiConfig);

resolve();
});
}
}



// import { Injectable } from '@angular/core';
// import { KnoraApiConfig, KnoraApiConnection } from '@knora/api';
// import { KuiConfig } from '@knora/core';

// @Injectable()
// export class AppInitService {

// // we cannot make readonly properties because we assign them later, so make properties that are only accessible in this class!
// private _knoraApiConnection: KnoraApiConnection;
// get knoraApiConnection(): KnoraApiConnection {
// return this._knoraApiConnection;
// }

// private _knoraApiConfig: KnoraApiConfig;
// get knoraApiConfig(): KnoraApiConfig {
// return this._knoraApiConfig;
// }

// private _kuiConfig: KuiConfig;
// get kuiConfig(): KuiConfig {
// return this._kuiConfig;
// }

// constructor() { }

// // small i, TypeScript convention
// init() {

// return new Promise<void>((resolve, reject) => {

// // init knora-ui configuration
// this._kuiConfig = window['tempConfigStorage'] as KuiConfig;
// // consider the use of json2typescript here, it can throw errors for you if there is a config issue

// // init knora-api configuration
// this._knoraApiConfig = new KnoraApiConfig(
// this._kuiConfig.knora.apiProtocol,
// this._kuiConfig.knora.apiHost,
// this._kuiConfig.knora.apiPort
// );

// // set knora-api connection configuration
// this._knoraApiConnection = new KnoraApiConnection(this._knoraApiConfig);

// resolve();
// });
// }
// }
19 changes: 12 additions & 7 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '@knora/authentication';

import { AuthGuard } from './main/guard/auth.guard';
import { ErrorComponent } from './main/error/error.component';
import { LoginComponent } from './main/login/login.component';
import { MainComponent } from './main/main.component';
import { HelpComponent } from './main/help/help.component';
import { CookiePolicyComponent } from './main/cookie-policy/cookie-policy.component';

// project
import { BoardComponent } from './project/board/board.component';
import { CollaborationComponent } from './project/collaboration/collaboration.component';
import { OntologyComponent } from './project/ontology/ontology.component';
import { ProjectComponent } from './project/project.component';
import { PermissionComponent } from './project/permission/permission.component';
import { ListComponent } from './project/list/list.component';

// user
import { ProfileComponent } from './user/profile/profile.component';
import { UserComponent } from './user/user.component';
Expand All @@ -19,18 +25,17 @@ import { DashboardComponent } from './user/dashboard/dashboard.component';
import { AdvancedSearchComponent } from './workspace/search/advanced-search/advanced-search.component';
import { ExpertSearchComponent } from './workspace/search/expert-search/expert-search.component';
import { ResultsComponent } from './workspace/results/results.component';
import { ResourceComponent } from './workspace/resource/resource.component';

import { DesignQuestionComponent } from './dev/design-question/design-question.component';
// system
import { SystemComponent } from './system/system.component';
import { ProjectsComponent } from './system/projects/projects.component';
import { UsersComponent } from './system/users/users.component';
import { StatusComponent } from './system/status/status.component';
import { ResourceComponent } from './workspace/resource/resource.component';
import { CookiePolicyComponent } from './main/cookie-policy/cookie-policy.component';
import { GroupsComponent } from './system/groups/groups.component';
import { PermissionComponent } from './project/permission/permission.component';
import { ListComponent } from './project/list/list.component';
import { HelpComponent } from './main/help/help.component';

// developer
import { DesignQuestionComponent } from './dev/design-question/design-question.component';

const routes: Routes = [
{
Expand Down
15 changes: 12 additions & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import { MatMenuModule } from '@angular/material/menu';
import { MatToolbarModule } from '@angular/material/toolbar';
import { RouterTestingModule } from '@angular/router/testing';
import { KuiActionModule } from '@knora/action';
import { KuiCoreConfig, KuiCoreConfigToken } from '@knora/core';
import { KnoraApiConnection } from '@knora/api';
import { KnoraApiConfigToken, KnoraApiConnectionToken } from '@knora/core';
import { KuiSearchModule } from '@knora/search';
import { TranslateModule } from '@ngx-translate/core';
import { TestConfig } from 'test.config';
import { AppInitService } from './app-init.service';
import { AppComponent } from './app.component';
import { HeaderComponent } from './main/header/header.component';
import { SelectLanguageComponent } from './main/select-language/select-language.component';
import { UserMenuComponent } from './user/user-menu/user-menu.component';

describe('AppComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
Expand All @@ -35,9 +39,14 @@ describe('AppComponent', () => {
TranslateModule.forRoot()
],
providers: [
AppInitService,
{
provide: KnoraApiConfigToken,
useValue: TestConfig.ApiConfig
},
{
provide: KuiCoreConfigToken,
useValue: KuiCoreConfig
provide: KnoraApiConnectionToken,
useValue: new KnoraApiConnection(TestConfig.ApiConfig)
}
]
}).compileComponents();
Expand Down
8 changes: 3 additions & 5 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { AuthenticationService } from '@knora/authentication';

@Component({
selector: 'app-root',
Expand All @@ -11,13 +10,12 @@ export class AppComponent implements OnInit {

session: boolean = false;

constructor (private _titleService: Title,
private _auth: AuthenticationService) {
constructor(
private _titleService: Title) {

// set the page title
this._titleService.setTitle('Knora User Interface | Research Layer');
this._titleService.setTitle('Knora App | DaSCH\'s generic user interface');

this.session = this._auth.session();
}

ngOnInit() {
Expand Down
20 changes: 13 additions & 7 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { KuiActionModule } from '@knora/action';
import { KuiAuthenticationModule, JwtInterceptor, WithCredentialsInterceptor } from '@knora/authentication';
import { KuiCoreConfigToken, KuiCoreModule } from '@knora/core';
import { KuiCoreModule, KuiConfigToken, KnoraApiConfigToken, KnoraApiConnectionToken } from '@knora/core';
import { KuiSearchModule } from '@knora/search';
import { KuiViewerModule } from '@knora/viewer';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
Expand Down Expand Up @@ -79,7 +78,7 @@ export function HttpLoaderFactory(httpClient: HttpClient) {

export function initializeApp(appInitService: AppInitService) {
return (): Promise<any> => {
return appInitService.Init();
return appInitService.init();
};
}

Expand Down Expand Up @@ -150,7 +149,6 @@ export function initializeApp(appInitService: AppInitService) {
FlexLayoutModule,
HttpClientModule,
KuiActionModule,
KuiAuthenticationModule,
KuiCoreModule,
KuiSearchModule,
KuiViewerModule,
Expand All @@ -175,8 +173,16 @@ export function initializeApp(appInitService: AppInitService) {
multi: true
},
{
provide: KuiCoreConfigToken,
useFactory: () => AppInitService.coreConfig
provide: KuiConfigToken,
useFactory: () => AppInitService.kuiConfig
},
{
provide: KnoraApiConfigToken,
useFactory: () => AppInitService.knoraApiConfig
},
{
provide: KnoraApiConnectionToken,
useFactory: () => AppInitService.knoraApiConnection
}
],
bootstrap: [AppComponent]
Expand Down
Loading

0 comments on commit 6d2da29

Please sign in to comment.