Skip to content

Commit

Permalink
Merge branch 'master' into improved-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Dec 14, 2023
2 parents 71e151d + 6391711 commit 38c8ea7
Show file tree
Hide file tree
Showing 53 changed files with 51,502 additions and 44,070 deletions.
8 changes: 7 additions & 1 deletion desktop/src/app/components/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { UtilTranslations } from '../util/util-translations';
import { AppController } from '../services/app-controller';
import { ImageUrlMaker } from '../services/imagestore/image-url-maker';
import { ConfigurationChangeNotifications } from './configuration/notifications/configuration-change-notifications';
import { MenuModalLauncher } from '../services/menu-modal-launcher';

const remote = typeof window !== 'undefined' ? window.require('@electron/remote') : undefined;
const ipcRenderer = typeof window !== 'undefined' ? window.require('electron').ipcRenderer : undefined;
Expand Down Expand Up @@ -38,7 +39,8 @@ export class AppComponent {
private i18n: I18n,
private utilTranslations: UtilTranslations,
private settingsProvider: SettingsProvider,
private changeDetectorRef: ChangeDetectorRef) {
private changeDetectorRef: ChangeDetectorRef,
private menuModalLauncher: MenuModalLauncher) {

// To get rid of stale messages when changing routes.
// Note that if you want show a message to the user
Expand All @@ -61,6 +63,10 @@ export class AppComponent {
AppComponent.preventDefaultDragAndDropBehavior();
this.initializeUtilTranslations();
this.listenToSettingsChangesFromMenu();

if (!Settings.hasUsername(settingsProvider.getSettings())) {
this.menuModalLauncher.openUpdateUsernameModal(true);
}
}


Expand Down
10 changes: 5 additions & 5 deletions desktop/src/app/components/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { ProjectModule } from './project/project.module';
import { FsAdapter } from '../services/imagestore/fs-adapter';
import { RemoteImageStore } from '../services/imagestore/remote-image-store';
import { ConfigurationIndex } from '../services/configuration/index/configuration-index';
import { ProjectModalLauncher } from '../services/project-modal-launcher';
import { MenuModalLauncher } from '../services/menu-modal-launcher';
import { ViewModalLauncher } from './viewmodal/view-modal-launcher';
import { NavbarModule } from './navbar/navbar.module';
import { WarningsService } from '../services/warnings/warnings-service';
Expand Down Expand Up @@ -93,7 +93,7 @@ registerLocaleData(localeUk, 'uk');
],
declarations: [
AppComponent,
HelpComponent,
HelpComponent
],
providers: [
Modals,
Expand Down Expand Up @@ -258,9 +258,9 @@ registerLocaleData(localeUk, 'uk');
Menus,
MenuNavigator,
UtilTranslations,
ProjectModalLauncher,
ViewModalLauncher,
WarningsService
WarningsService,
MenuModalLauncher,
ViewModalLauncher
],
bootstrap: [AppComponent]
})
Expand Down
16 changes: 8 additions & 8 deletions desktop/src/app/components/menu-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ObserverUtil } from 'idai-field-core';
import { reloadAndSwitchToHomeRoute } from '../services/reload';
import { SettingsService } from '../services/settings/settings-service';
import { Menus } from '../services/menus';
import { ProjectModalLauncher } from '../services/project-modal-launcher';
import { MenuModalLauncher } from '../services/menu-modal-launcher';

const ipcRenderer = typeof window !== 'undefined' ? window.require('electron').ipcRenderer : require('electron').ipcRenderer;

Expand All @@ -23,7 +23,7 @@ export class MenuNavigator {
private zone: NgZone,
private settingsService: SettingsService,
private menuService: Menus,
private projectModalLauncher: ProjectModalLauncher) {}
private menuModalLauncher: MenuModalLauncher) {}


public initialize() {
Expand All @@ -42,17 +42,17 @@ export class MenuNavigator {
await this.settingsService.selectProject(projectIdentifier);
reloadAndSwitchToHomeRoute();
} else if (menuItem === 'createProject') {
await this.zone.run(() => this.projectModalLauncher.createProject());
await this.zone.run(() => this.menuModalLauncher.createProject());
} else if (menuItem === 'editProject') {
await this.zone.run(() => this.projectModalLauncher.editProject());
await this.zone.run(() => this.menuModalLauncher.editProject());
} else if (menuItem === 'projectInformation') {
await this.zone.run(() => this.projectModalLauncher.openInformationModal());
await this.zone.run(() => this.menuModalLauncher.openInformationModal());
} else if (menuItem === 'projectImages') {
await this.zone.run(() => this.projectModalLauncher.openProjectImageViewModal());
await this.zone.run(() => this.menuModalLauncher.openProjectImageViewModal());
} else if (menuItem === 'deleteProject') {
await this.zone.run(() => this.projectModalLauncher.deleteProject(projectIdentifier));
await this.zone.run(() => this.menuModalLauncher.deleteProject(projectIdentifier));
} else if (menuItem === 'projectSynchronization') {
await this.zone.run(() => this.projectModalLauncher.openSynchronizationModal());
await this.zone.run(() => this.menuModalLauncher.openSynchronizationModal());
} else if (menuItem === 'projectLanguages' || menuItem === 'valuelists'
|| menuItem === 'importConfiguration') {
await this.zone.run(() => ObserverUtil.notify(this.configurationMenuObservers, menuItem));
Expand Down
18 changes: 12 additions & 6 deletions desktop/src/app/components/messages/m.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class M extends MD { // = Messages Dictionary. For reasons of brevity of
// Settings Package
public static SETTINGS_SUCCESS = 'settings.success';
public static SETTINGS_ERROR_MALFORMED_ADDRESS = 'settings.error.malformedAddress';
public static SETTINGS_ERROR_MISSING_USERNAME = 'settings.error.missingUsername';

// Projects Package
public static PROJECTS_DELETE_SUCCESS = 'projects.deleteSuccess';
Expand Down Expand Up @@ -319,7 +320,16 @@ export class M extends MD { // = Messages Dictionary. For reasons of brevity of
this.msgs[M.SETTINGS_ERROR_MALFORMED_ADDRESS] = {
content: i18n({
id: 'messages.settings.error.malformedAddress',
value: 'Die angegebene Serveradresse entspricht nicht dem angegebenen Format.'
value: 'Bitte geben Sie als Adresse eine gültige URL ein.'
}),
level: 'danger',
params: [],
hidden: false
};
this.msgs[M.SETTINGS_ERROR_MISSING_USERNAME] = {
content: i18n({
id: 'messages.settings.error.missingUsername',
value: 'Bitte geben Sie Ihren Namen im Feld "Name der Benutzerin/des Benutzers" ein.'
}),
level: 'danger',
params: [],
Expand Down Expand Up @@ -529,11 +539,7 @@ export class M extends MD { // = Messages Dictionary. For reasons of brevity of
value: '[0] Ressourcen wurden erfolgreich importiert.'
}),
level: 'success',
params: [
i18n({
id: 'messages.import.success.multiple.defaultParameter',
value: 'Mehrere'
})],
params: [],
hidden: false
};
this.msgs[M.IMPORT_WARNING_EMPTY] = {
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/app/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TabManager } from '../../services/tabs/tab-manager';
import { Tab } from '../../services/tabs/tab';
import { TabUtil } from '../../services/tabs/tab-util';
import { ViewFacade } from '../../components/resources/view/view-facade';
import { ProjectModalLauncher } from '../../services/project-modal-launcher';
import { MenuModalLauncher } from '../../services/menu-modal-launcher';


@Component({
Expand All @@ -31,11 +31,11 @@ export class NavbarComponent implements DoCheck {
constructor(public router: Router,
private viewFacade: ViewFacade,
private tabManager: TabManager,
private projectModalLauncher: ProjectModalLauncher,
private menuModalLauncher: MenuModalLauncher,
private i18n: I18n) {

this.router.events.subscribe(() => this.activeRoute = this.router.url);
this.projectModalLauncher.projectPropertiesNotifications().subscribe(() => this.onResize());
this.menuModalLauncher.projectPropertiesNotifications().subscribe(() => this.onResize());
}


Expand Down
14 changes: 9 additions & 5 deletions desktop/src/app/components/navbar/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $border-radius: 4px;
.navbar {
-webkit-app-region: drag;
padding: 0 10px;
height: 45px;
height: $navbar-height;

.nav-item {
-webkit-app-region: no-drag;
Expand Down Expand Up @@ -87,6 +87,7 @@ $border-radius: 4px;
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;
position: relative;
height: $navbar-height - 3px;

&:before,
&:after {
Expand All @@ -111,8 +112,10 @@ $border-radius: 4px;
}

.mdi-home {
position: relative;
top: 1px;
font-size: 22px;
line-height: 22px;
line-height: 25px;

&:hover {
color: inherit;
Expand Down Expand Up @@ -199,11 +202,12 @@ $border-radius: 4px;
}

a.nav-link {
height: $navbar-height - 3px;
padding-right: 9px !important;

.closable-tab-label {
display: inline-block;
position: relative;
top: 1px;
margin-left: 5px;
margin-right: 5px;
max-width: 425px;
Expand All @@ -214,7 +218,7 @@ $border-radius: 4px;

.mdi-close {
position: relative;
top: -7px;
top: -6px;
border-radius: 5px;
padding-left: 1px;
width: 16px;
Expand All @@ -223,7 +227,7 @@ $border-radius: 4px;
category-icon {
position: relative;
left: -4px;
top: -6px;
top: -5px;
}
}
}
Expand Down
21 changes: 15 additions & 6 deletions desktop/src/app/components/navbar/projects.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Labels } from 'idai-field-core';
import { ProjectModalLauncher } from '../../services/project-modal-launcher';
import { MenuModalLauncher } from '../../services/menu-modal-launcher';
import { SettingsProvider } from '../../services/settings/settings-provider';


Expand All @@ -15,14 +15,23 @@ import { SettingsProvider } from '../../services/settings/settings-provider';
export class ProjectsComponent implements OnInit {

public selectedProject: string;
public username: string;


constructor(private settingsProvider: SettingsProvider,
private projectModalLauncher: ProjectModalLauncher,
private labels: Labels) {}
private menuModalLauncher: MenuModalLauncher,
private labels: Labels) {

this.username = this.settingsProvider.getSettings().username;
this.settingsProvider.settingsChangesNotifications().subscribe((settings) => {
this.username = settings.username;
});
}


public openModal = () => this.projectModalLauncher.editProject();
public openModal = () => this.menuModalLauncher.editProject();

public openUsernameModal = () => this.menuModalLauncher.openUpdateUsernameModal();


ngOnInit() {
Expand All @@ -33,8 +42,8 @@ export class ProjectsComponent implements OnInit {

public getProjectName(): string {

return this.labels.getFromI18NString(
return this.labels.getFromI18NString(
this.settingsProvider.getSettings().projectNames[this.selectedProject]
) ?? this.selectedProject;
}
}
}
14 changes: 11 additions & 3 deletions desktop/src/app/components/navbar/projects.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a id="projects-badge" class="nav-link px-1" type="button" (click)="openModal()">
{{getProjectName()}}
</a>
<div id="projects-badge"
class="nav-link"
(click)="openModal()">
{{getProjectName()}}
</div>

<div id="username"
class="nav-link"
(click)="openUsernameModal()">
{{username}}
</div>
22 changes: 19 additions & 3 deletions desktop/src/app/components/navbar/projects.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#projects-badge {
padding: 0.5em !important;
max-width: 400px;
#projects-badge,
#username {
position: relative;
max-width: 300px;
padding: 0 !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: right;

&:hover {
color: #777;
}
}

#projects-badge {
top: 2px;
font-size: 14px;
font-weight: 600;
line-height: 18px;
}

#username {
top: 3px;
font-size: 13px;
line-height: 16px;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectorRef, Component } from '@angular/core';
import { SyncService, SyncStatus, ImageSyncService } from 'idai-field-core';
import { ProjectModalLauncher } from '../../services/project-modal-launcher';
import { MenuModalLauncher } from '../../services/menu-modal-launcher';


@Component({
Expand All @@ -17,7 +17,7 @@ export class TaskbarSyncStatusComponent {
constructor(private pouchSyncService: SyncService,
private imageSyncService: ImageSyncService,
private changeDetectorRef: ChangeDetectorRef,
private projectModalLauncher: ProjectModalLauncher) {
private menuModalLauncher: MenuModalLauncher) {

this.pouchSyncService.statusNotifications().subscribe(() => {
this.changeDetectorRef.detectChanges();
Expand Down Expand Up @@ -53,5 +53,5 @@ export class TaskbarSyncStatusComponent {
return SyncStatus.InSync;
}

public openSynchronizationModal = () => this.projectModalLauncher.openSynchronizationModal();
public openSynchronizationModal = () => this.menuModalLauncher.openSynchronizationModal();
}
7 changes: 4 additions & 3 deletions desktop/src/app/components/navbar/taskbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<taskbar-warnings></taskbar-warnings>
</li>

<li id="editor" class="nav-item pr-2">
</li>

<li *ngIf="showSyncStatus()" class="nav-item pr-2">
<taskbar-sync-status></taskbar-sync-status>
</li>

<li class="nav-item">
<li class="nav-item projects-nav-item">
<projects></projects>
</li>
</ul>


4 changes: 4 additions & 0 deletions desktop/src/app/components/navbar/taskbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@
top: 22px;
right: 0;
}

.projects-nav-item {
margin-left: 5px;
}
}
Loading

0 comments on commit 38c8ea7

Please sign in to comment.