Skip to content

Commit

Permalink
Merge branch 'main' into stable to update fotorom de en
Browse files Browse the repository at this point in the history
  • Loading branch information
friebsch committed Jan 27, 2025
2 parents 52cd0a4 + 9107d32 commit 1376812
Show file tree
Hide file tree
Showing 31 changed files with 10,124 additions and 20,874 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:

- name: Checkout repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@ public Map<String,String> register(@RequestBody Map<String,String> formData, Htt

user.setFirstname(getFormData(formData, "firstname", true, "ui.register."));
user.setLastname(getFormData(formData, "lastname", true, "ui.register."));
user.setStreet(getFormData(formData, "street", true, "ui.register."));
user.setZip(getFormData(formData, "zip", true, "ui.register."));
user.setPlace(getFormData(formData, "place", true, "ui.register."));
user.setCountry(getFormData(formData, "country", true, "ui.register."));
user.setInstitution(getFormData(formData, "institution", false, "ui.register."));
user.setHomepage(getFormData(formData, "homepage", false, "ui.register."));
user.setTelephone(getFormData(formData, "telephone", false, "ui.register."));
user.setAll_groups(false);
user.setGroupID(500);
if(isTestUser(user)){
Expand All @@ -285,10 +279,10 @@ public Map<String,String> register(@RequestBody Map<String,String> formData, Htt
if(!isTestUser(user)){

// mail to user
String messageBody = "Ihre Anmeldung bei Arachne ist eingegangen und wird in Kürze von uns bearbeitet "
+ "werden." + newLine + newLine + "Mit freundlichen Grüßen" + newLine + "das Arachne-Team";
String messageBody = "Your registration was successful and will be reviewed shortly."
+ newLine + newLine + "Mit freundlichen Grüßen" + newLine + "das Arachne-Team";

if (!mailService.sendMail(user.getEmail(), "Ihre Anmeldung bei Arachne", messageBody)) {
if (!mailService.sendMail(user.getEmail(), "Your registration with iDAI.objects/Arachne", messageBody)) {
LOGGER.error("Unable to send registration eMail to user.");
throw new FormDataException("ui.registration.emailFailed");
}
Expand Down Expand Up @@ -427,31 +421,19 @@ public Map<String,String> reset(@RequestBody Map<String,String> userCredentials,

if (userRightsService.isSignedInUser()) return result;

final String userName = getFormData(userCredentials, "username", true, "ui.passwordreset.");
final String eMailAddress = getFormData(userCredentials, "email", true, "ui.passwordreset.");
final String firstName = getFormData(userCredentials, "firstname", true, "ui.passwordreset.");
final String lastName = getFormData(userCredentials, "lastname", true, "ui.passwordreset.");

User userByName = userDao.findByName(userName);
if (userByName == null) {
LOGGER.info("User not found: {}", userName);
return result;
}
if (!userByName.getEmail().equals(eMailAddress)) {
LOGGER.info("Wrong eMail provided for user '{}': {}", userName, eMailAddress);
return result;
}
if (!userByName.getFirstname().equals(firstName) ||
!userByName.getLastname().equals(lastName)) {
LOGGER.info("Wrong first or last name provided for user '{}': {}, {}", userName, firstName, lastName);
User userByEmail = userDao.findByEMailAddress(eMailAddress);
if (userByEmail == null) {
LOGGER.info("User not found: {}", eMailAddress);
return result;
}

resetPasswordRequestDao.deleteExpiredRequests(); // get rid of all expired requests
// if there is already a request pending do not allow to add a new one
if (resetPasswordRequestDao.getByUserId(userByName.getId()) != null) {
if (resetPasswordRequestDao.getByUserId(userByEmail.getId()) != null) {
result.put("message", "ui.passwordreset.already_present");
LOGGER.info("A non-expired password request is already present in the database for user: {}", userName);
LOGGER.info("A non-expired password request is already present in the database for user: {}", eMailAddress);
return result;
}

Expand All @@ -465,22 +447,22 @@ public Map<String,String> reset(@RequestBody Map<String,String> userCredentials,

ResetPasswordRequest request = new ResetPasswordRequest();
request.setToken(token);
request.setUserId(userByName.getId());
request.setUserId(userByEmail.getId());
request.setExpirationDate(expirationDate);
resetPasswordRequestDao.save(request);

// sent mail with activation link to user
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
final String nowString = dateFormat.format(now);
final String expirationDateString = dateFormat.format(expirationDate);
final String linkString = "http://" + serverAddress + "/user/activation/" + token;
final String linkString = "https://" + serverAddress + "/user/activation/" + token;

final String messageBody = "Sie haben ihr Passwort bei Arachne am " + nowString + " zurückgesetzt."
+ newLine + "Bitte folgen sie diesem Link um den Prozess abzuschließen: " + linkString
+ newLine + "Dieser Link ist bis zum " + expirationDateString + " gültig.";
final String messageBody = "A password reset was requested for iDAI.objects/Arachne on " + nowString + "."
+ newLine + "You can use the following link to reset your password: " + linkString
+ newLine + "The link is valid until " + expirationDateString + ".";

if (!isTestUser(userByName) && !mailService.sendMail(userByName.getEmail(), "Passwort zurückgesetzt bei Arachne", messageBody)) {
LOGGER.error("Unable to send password activation eMail to user: " + userByName.getEmail());
if (!isTestUser(userByEmail) && !mailService.sendMail(userByEmail.getEmail(), "Passwort reset for iDAI.objects/Arachne", messageBody)) {
LOGGER.error("Unable to send password activation eMail to user: " + userByEmail.getEmail());
resetPasswordRequestDao.delete(request);
result.put("success", "false");
response.setStatus(400);
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ services:
- com.centurylinklabs.watchtower.enable=true
user: "${UID}:${GID}"
restart: always
hac_via:
image: ghcr.io/dainst/hac_via:latest
volumes:
- ${HAC_VIA_ARCHIVE_DIR}:/archive
- ${HAC_VIA_PREVIEW_DIR}:/previews
- ${ARCHAEOCLOUD_PATH}/aronscans/objectscans/:/published_jpg
- ${ARCHAEOCLOUD_PATH}/S-Arachne/arachne4scans/arachne4webimages/objectscans/:/published_ptif
environment:
- PHX_HOST=images.${SERVER_ADDRESS}
- DATABASE_URL=ecto://arachne:${DB_PASSWORD}@arachne4_db/arachne
- SECRET_KEY_BASE=${HAC_VIA_KEY_BASE}
- ARACHNE_BASE_URL=https://${SERVER_ADDRESS}
labels:
- traefik.enable=true
- traefik.http.routers.hac_via.rule=Host(`images.${SERVER_ADDRESS}`)
- traefik.http.routers.hac_via.entrypoints=websecure
- traefik.http.routers.hac_via.tls.certresolver=myresolver
- traefik.http.services.hac_via.loadbalancer.server.port=4000
- com.centurylinklabs.watchtower.enable=true
restart: always

traefik:
image: traefik:v2.5
Expand Down
48 changes: 0 additions & 48 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,16 @@ npm install && npm run build && npm start

## Development

The repository includes a [gulp](http://gulpjs.com/) configuration for setting up a local server, preconfigured with:
* proxying to the backend running on the development server
* url rewriting for AngularJS' HTML5 mode
* live reloading

### Prerequisites

You need the following components in order for the local server to work:
* [NodeJS](https://nodejs.org/)
* [gulp](https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md)

To install the necessary dependencies for the app run the following command in the working directory:
```bash
npm install
```

On Debian-based systems, if you have trouble installing dependencies use the 'nodejs-legacy'-package instead of 'nodejs'. Also gulp needs to be installed globally to run 'gulp server'.

```bash
sudo apt-get install nodejs-legacy
sudo npm install -g gulp
```

### Deployment

Build the application by running
Expand All @@ -43,18 +30,8 @@ npm run build

The static files representing the project pages are stored in the directory `con10t`.

The `con10t`-repository (https://github.com/dainst/con10t) is automatically checked out when building Arachne 4 Frontend with "npm run build" if the con10t-folder doesn't already exist.

The con10t submodule provides many valuable widgets which can be used on project pages. You can find a demonstration of the widgets at https://arachne.dainst.org/project/widgetsdemo.

#### Updating the submodule con10t

Within the folder of the submodule execute
```bash
git pull origin master
```
to get the latest con10t version.

### Configuring the Development Server

The Arachne 4 Frontend uses the development server configured in the config file template "dev-config.json.template" in the folder "/config".
Expand Down Expand Up @@ -94,28 +71,3 @@ export LC_NUMERIC="en_US.UTF-8" && npm run e2e
```

to run the e2e tests matching the filename pattern `e2e/*.spec.js`. Precondition for this to work is that you have the `dist` dir that gets served at `localhost:8080` by defaiöt, as is the case when you run `npm start`.

### Server Configuration

In order for AngularJS' HTML5 mode to work use the following configurations:

#### nginx
```
server {
listen 80;
root /usr/share/nginx/www;
try_files $uri $uri/ /index.html =404;
}
```

#### Apache

```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^(.*)$ %2index.html [QSA,L]
</IfModule>
```
1 change: 1 addition & 0 deletions frontend/app/_transl8.de.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ export default {
"facet_bennenungallg": "Benennung allgemein",
"ui.passwordchange.illegal": "Das alte und das neue Passwort dürfen nicht die selben sein!",
"edit_button": "Bearbeitung",
"image_archive_button": "Archiv",
"catalog_no_catalog_info": "Ein Katalog in Arachne ist geordnetes Verzeichnis von archäologischen Objekten.",
"catalog_no_catalog_help": "Mit einem Klick auf \"Neuen Katalog anlegen\", kann man einen eigenen persönlichen Katalog erstellen. Weitere Hilfe zum Bearbeiten von Einträgen findet man wenn man den Katalog öffnet.",
"catalog_no_catalog_hint_note": "Kataloge sind standardmäßig privat, sodass sie nicht öffentlich sichtar sind. Außerdem müssen weitere Bearbeiter gesondert freigeschaltet werden.",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/_transl8.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export default {
"facet_bennenungallg": "General designation",
"ui.passwordchange.illegal": "The old and new password can't be the same!",
"edit_button": "Edit",
"image_archive_button": "Archive",
"undefined": "undefined",
"catalog_no_catalog_info": "A catalog in Arachne is an ordered list of archaeological objects.",
"general_hint": "Note:",
Expand Down
9 changes: 6 additions & 3 deletions frontend/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const lazyLoadService = ($ocLazyLoad) => (importPromise) =>
});

angular.module('arachne', [
'angulartics',
'angulartics',
'angulartics.piwik',
'ui.bootstrap',
'ui.bootstrap.tpls',
Expand Down Expand Up @@ -148,8 +148,8 @@ angular.module('arachne', [
'editUser.**': { url: '/editUser', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'contact.**': { url: '/contact', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'pwdreset.**': { url: '/pwdreset', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'pwdchange.**': { url: '/pwdchange', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'userActivation.**': { url: '/user/activation/:token', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'pwdchange.**': { url: '/pwdchange', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'userActivation.**': { url: '/user/activation/:token', lazyLoad: lazyLoad(import('./users/users.module.js'))},
'login.**': { url: '/login?redirectTo',lazyLoad: lazyLoad(import('./users/users.module.js'))},
'dataimport': { url: '/admin/dataimport', template: require('./admin/dataimport.html')},
'dataexport': { url: '/admin/dataexport', template: require('./admin/dataexport.html')},
Expand Down Expand Up @@ -191,6 +191,9 @@ angular.module('arachne', [
.constant('arachneSettings', {
arachneUrl: 'https://arachne.dainst.org',
dataserviceUri: "//" + document.location.host + "/data",
hacViaUrl: function () {
return document.location.host == "arachne.dainst.org" ? "//images.arachne.dainst.org" : "//images.arachne.test.dainst.org"
}(),
limit: 50,
facetLimit: 20,
openFacets : ["facet_kategorie", "facet_image", "facet_bestandsname", "facet_subkategoriebestand"], // order is important for sorting of default facets
Expand Down
28 changes: 13 additions & 15 deletions frontend/app/catalog/ar-catalog-occurrences.directive.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export default function (arachneSettings, $http, $uibModal, Catalog, CatalogEntry) {
console.log('construct catalog-occurrences.directive.js');
return {
scope: {
entity: '='
},
template: require('./ar-catalog-occurrences.html'),
link: function (scope, element, attrs) {
console.log('link catalog-occurrences.directive.js');
scope.catalogEntries = [];
scope.catalogEntrySets = [];

Expand Down Expand Up @@ -37,7 +35,7 @@ export default function (arachneSettings, $http, $uibModal, Catalog, CatalogEntr
editEntryModal.close = function (newEntry) {
CatalogEntry.save([newEntry], function (data) {
if (data.error_message) {
console.log(data.error_message);
console.error(data.error_message);
} else {
scope.loadOccurences();
}
Expand All @@ -61,46 +59,46 @@ export default function (arachneSettings, $http, $uibModal, Catalog, CatalogEntr
scope.arrangeEntries();

}).catch(function (result) {
console.log("Error Arachne dataservice not reachable");
console.error("Error Arachne dataservice not reachable");
});
}
};

scope.arrangeEntries = function() {
scope.arrangeEntries = function () {
var i, j, n, len = scope.catalogEntries.length, curi, curj, curk, duplicateAlreadyAdded, newCatalog;

for(i = 0; i < len; i++) {
for (i = 0; i < len; i++) {
curi = scope.catalogEntries[i];
scope.loadParentLabel(curi.entry);
if(curi.duplicate)
if (curi.duplicate)
continue;
duplicateAlreadyAdded = false;
for(j = i; j < len; j++) {
for (j = i; j < len; j++) {
curj = scope.catalogEntries[j];
if(curi.entry.catalogId === curj.entry.catalogId) {
if(!duplicateAlreadyAdded) {
if (curi.entry.catalogId === curj.entry.catalogId) {
if (!duplicateAlreadyAdded) {
scope.catalogEntrySets.push(scope.getNewCatalogEntrySet(curi));
duplicateAlreadyAdded = true;
} else {
for(n = 0; n < scope.catalogEntrySets.length; n++) {
for (n = 0; n < scope.catalogEntrySets.length; n++) {
curk = scope.catalogEntrySets[n];
if(curk.catalogId === curj.entry.catalogId)
if (curk.catalogId === curj.entry.catalogId)
scope.catalogEntrySets[n].entries.push(curj.entry);
}
}
curi.duplicate = curj.duplicate = true;
}
}
if(!curi.duplicate) {
if (!curi.duplicate) {
scope.catalogEntrySets.push(scope.getNewCatalogEntrySet(curi));
}
}
};

// used to load the parent label in order to distinguish entries when multiple
// entries for the same entity are present in the same catalog
scope.loadParentLabel = function(entry) {
CatalogEntry.get({id:entry.parentId, limit:1, full:false}, function(result) {
scope.loadParentLabel = function (entry) {
CatalogEntry.get({ id: entry.parentId, limit: 1, full: false }, function (result) {
entry.parentLabel = result.label;
});
};
Expand Down
Loading

0 comments on commit 1376812

Please sign in to comment.