diff --git a/.vscode/launch.json b/.vscode/launch.json
index 2b6a589..712806d 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -30,7 +30,7 @@
"ASSETS": "projects/aas-server/src/assets",
// "USER_STORAGE": "mongodb://localhost:27017/aasportal-users",
// "TEMPLATE_STORAGE": "http://localhost:8080/templates",
- "AAS_INDEX": "mysql://localhost:3306",
+ // "AAS_INDEX": "mysql://localhost:3306",
"ENDPOINTS": "[\"file:///endpoints/samples?name=Samples\"]",
}
},
diff --git a/projects/aas-lib/src/lib/auth/login-form/login-form.component.html b/projects/aas-lib/src/lib/auth/login-form/login-form.component.html
index 5502240..96a70c5 100644
--- a/projects/aas-lib/src/lib/auth/login-form/login-form.component.html
+++ b/projects/aas-lib/src/lib/auth/login-form/login-form.component.html
@@ -30,14 +30,12 @@
placeholder="name">
- @if (!passwordPerEMail) {
- }
- @else {
+ @if (passwordPerEMail()) {
diff --git a/projects/aas-server/src/app/aas-index/aas-index.ts b/projects/aas-server/src/app/aas-index/aas-index.ts
index b3a9df2..ab8ee38 100644
--- a/projects/aas-server/src/app/aas-index/aas-index.ts
+++ b/projects/aas-server/src/app/aas-index/aas-index.ts
@@ -52,6 +52,8 @@ export abstract class AASIndex {
public abstract remove(endpoint?: string, id?: string): Promise;
+ public abstract clear(): Promise;
+
public abstract reset(): Promise;
protected toAbbreviation(referable: aas.Referable): string {
diff --git a/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts b/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts
index 788c9e7..eabb1cd 100644
--- a/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts
+++ b/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts
@@ -179,11 +179,15 @@ export class LowDbIndex extends AASIndex {
return true;
}
- public async reset(): Promise {
+ public override async clear(): Promise {
this.db.data.documents = [];
this.db.data.elements = [];
- this.db.data.endpoints = this.variable.ENDPOINTS.map(endpoint => urlToEndpoint(endpoint));
+ this.db.data.endpoints = [];
+ await this.db.write();
+ }
+ public override async reset(): Promise {
+ this.db.data.endpoints = this.variable.ENDPOINTS.map(endpoint => urlToEndpoint(endpoint));
await this.db.write();
}
diff --git a/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts b/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts
index e5e93fd..cc6d03c 100644
--- a/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts
+++ b/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts
@@ -224,13 +224,24 @@ export class MySqlIndex extends AASIndex {
}
}
- public override async reset(): Promise {
+ public override async clear(): Promise {
const connection = await this.connection;
try {
await connection.beginTransaction();
await connection.query('DELETE FROM `elements`;');
await connection.query('DELETE FROM `documents`;');
await connection.query('DELETE FROM `endpoints`;');
+ await connection.commit();
+ } catch (error) {
+ await connection.rollback();
+ throw error;
+ }
+ }
+
+ public override async reset(): Promise {
+ const connection = await this.connection;
+ try {
+ await connection.beginTransaction();
await this.addDefaultEndpoints(connection);
await connection.commit();
} catch (error) {
@@ -463,7 +474,14 @@ export class MySqlIndex extends AASIndex {
const result = await connection.query('SELECT * FROM `endpoints`');
if (result[0].length === 0) {
- await this.addDefaultEndpoints(connection);
+ try {
+ connection.beginTransaction();
+ await this.addDefaultEndpoints(connection);
+ connection.commit();
+ } catch (error) {
+ connection.rollback();
+ throw error;
+ }
}
return connection;
diff --git a/projects/aas-server/src/app/aas-provider/aas-provider.ts b/projects/aas-server/src/app/aas-provider/aas-provider.ts
index fea749b..cb80c07 100644
--- a/projects/aas-server/src/app/aas-provider/aas-provider.ts
+++ b/projects/aas-server/src/app/aas-provider/aas-provider.ts
@@ -226,9 +226,16 @@ export class AASProvider {
}
this.resetRequested = true;
+ await this.index.clear();
+ this.wsServer.notify('IndexChange', {
+ type: 'AASServerMessage',
+ data: {
+ type: 'Reset',
+ } as AASServerMessage,
+ });
if (this.taskHandler.empty(this)) {
- await this.doResetAsync();
+ await this.restart();
}
}
@@ -367,18 +374,10 @@ export class AASProvider {
return nodes;
}
- private async doResetAsync(): Promise {
- await this.index.reset();
-
- this.wsServer.notify('IndexChange', {
- type: 'AASServerMessage',
- data: {
- type: 'Reset',
- } as AASServerMessage,
- });
-
+ private async restart(): Promise {
this.resetRequested = false;
- this.startScan();
+ await this.index.reset();
+ await this.startScan();
this.logger.info('AAS Server configuration restored.');
}
@@ -444,8 +443,10 @@ export class AASProvider {
}
this.taskHandler.delete(result.taskId);
- const endpoint = await this.index.getEndpoint(task.name);
- setTimeout(this.scanContainer, this.timeout, result.taskId, endpoint);
+ if ((await await this.index.hasEndpoint(task.name)) === true) {
+ const endpoint = await this.index.getEndpoint(task.name);
+ setTimeout(this.scanContainer, this.timeout, result.taskId, endpoint);
+ }
if (result.messages) {
this.logger.start(`scan ${task.name ?? 'undefined'}`);
@@ -453,10 +454,8 @@ export class AASProvider {
this.logger.stop();
}
- if (this.resetRequested) {
- if (this.taskHandler.empty(this)) {
- await this.doResetAsync();
- }
+ if (this.resetRequested && this.taskHandler.empty(this)) {
+ await this.restart();
}
};