@if(autoConnectedDone) {
diff --git a/front/src/app-edge/app.component.ts b/front/src/app-edge/app.component.ts
index 20c1261..a645c72 100644
--- a/front/src/app-edge/app.component.ts
+++ b/front/src/app-edge/app.component.ts
@@ -5,11 +5,7 @@
*/
import { Component, OnInit } from '@angular/core';
-import { EventOnMenu } from 'common/component/top-menu/top-menu';
-import { UserService } from 'common/service/user';
-import { SessionService } from 'common/service/session';
-import { MenuItem, MenuPosition } from 'common/model/menu-item';
-import { SSOService } from 'common/service';
+import { MenuItem, UserService, SessionService, SSOService, MenuPosition, EventOnMenu } from '@kangaroo-and-rabbit/kar-cw';
import { environment } from 'environments/environment';
enum MenuEventType {
diff --git a/front/src/app-edge/app.module.ts b/front/src/app-edge/app.module.ts
index 85af61f..d01e71a 100644
--- a/front/src/app-edge/app.module.ts
+++ b/front/src/app-edge/app.module.ts
@@ -26,49 +26,14 @@ import {
ApplicationsScene,
ApplicationEditScene,
} from 'base/scene';
-import {
- BddService,
- CookiesService,
- HttpWrapperService,
- NotificationService,
- OnlyAdminGuard,
- OnlyUnregisteredGuardHome,
- OnlyUsersGuard,
- OnlyUsersGuardHome,
- PopInService,
- SessionService,
- SSOService,
- StorageService,
- UserService,
-} from 'common/service';
import { CommonModule } from '@angular/common';
-import { ErrorComponent, PopInComponent, SpinerComponent, TopMenuComponent, UploadFileComponent, PasswordEntryComponent, EntryComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, EntryValidatorComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from 'common/component';
-import { ForbiddenScene } from 'common/scene';
-import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
-import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
+import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
+import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
+import { environment } from 'environments/environment';
@NgModule({
declarations: [
AppComponent,
- TopMenuComponent,
- UploadFileComponent,
- ErrorComponent,
- PasswordEntryComponent,
- EntryComponent,
- EntryValidatorComponent,
- SpinerComponent,
- AsyncActionStatusComponent,
- ErrorMessageStateComponent,
- CheckboxComponent,
- BurgerPropertyComponent,
- RenderSettingsComponent,
- RenderFormComponent,
- EntryNumberComponent,
-
- PopInComponent,
- PopInUploadProgress,
- PopInDeleteConfirm,
-
SignInScene,
SignUpScene,
SignOutScene,
@@ -78,7 +43,6 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
HelpScene,
ForgotPasswordScene,
SettingsScene,
- ForbiddenScene,
ChangePasswordScene,
HomeUnregisteredScene,
ManageAccountsScene,
@@ -93,42 +57,19 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
FormsModule,
ReactiveFormsModule,
CommonModule,
+ KarCWModule,
],
// injectable element
providers: [
+ { provide: 'ENVIRONMENT', useValue: environment },
// application
AdminUserService,
ApplicationService,
ApplicationTokenService,
- // common
- BddService,
- CookiesService,
- HttpWrapperService,
- StorageService,
- PopInService,
- SessionService,
- UserService,
- SSOService,
- NotificationService,
- SettingsService,
- OnlyUsersGuard,
- OnlyAdminGuard,
- OnlyUsersGuardHome,
- OnlyUnregisteredGuardHome,
],
exports: [
AppComponent,
- TopMenuComponent,
- PasswordEntryComponent,
- UploadFileComponent,
- ErrorComponent,
- BurgerPropertyComponent,
-
- BurgerPropertyComponent,
- PopInComponent,
- PopInUploadProgress,
- PopInDeleteConfirm,
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
diff --git a/front/src/app-root/app-routing.module.ts b/front/src/app-root/app-routing.module.ts
index 63d13a0..b1f9986 100644
--- a/front/src/app-root/app-routing.module.ts
+++ b/front/src/app-root/app-routing.module.ts
@@ -22,8 +22,7 @@ import {
ApplicationUserEditScene,
applicationUserRightEditScene,
} from '../base/scene';
-import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
-import { ForbiddenScene, NotFound404Scene } from 'common/scene';
+import { ForbiddenScene, NotFound404Scene, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from '@kangaroo-and-rabbit/kar-cw';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
diff --git a/front/src/app-root/app.component.html b/front/src/app-root/app.component.html
index aa8ed03..581beec 100644
--- a/front/src/app-root/app.component.html
+++ b/front/src/app-root/app.component.html
@@ -1,5 +1,5 @@
-
+
@if(autoConnectedDone) {
diff --git a/front/src/app-root/app.component.ts b/front/src/app-root/app.component.ts
index d1ccf8a..a77ade8 100644
--- a/front/src/app-root/app.component.ts
+++ b/front/src/app-root/app.component.ts
@@ -5,12 +5,8 @@
*/
import { Component, OnInit } from '@angular/core';
-import { EventOnMenu } from 'common/component/top-menu/top-menu';
-import { UserService } from 'common/service/user';
-import { SessionService, UserRoles222 } from 'common/service/session';
-import { MenuItem, MenuPosition } from 'common/model/menu-item';
-import { SSOService } from 'common/service';
-import { environment } from 'environments/environment';
+import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService } from '@kangaroo-and-rabbit/kar-cw';
+import { environmentKarso } from 'environments/environment';
@Component({
selector: 'app-root',
@@ -18,7 +14,7 @@ import { environment } from 'environments/environment';
styleUrls: ['./app.component.less'],
})
export class AppComponent implements OnInit {
- title: string = environment.edgeMode ? 'Karso-edge' : 'Karso';
+ title: string = environmentKarso.edgeMode ? 'Karso-edge' : 'Karso';
autoConnectedDone: boolean = false;
isConnected: boolean = false;
signUpEnable: boolean = true;
diff --git a/front/src/app-root/app.module.ts b/front/src/app-root/app.module.ts
index 1cbb717..92ca680 100644
--- a/front/src/app-root/app.module.ts
+++ b/front/src/app-root/app.module.ts
@@ -28,65 +28,15 @@ import {
ApplicationUserEditScene,
applicationUserRightEditScene,
} from 'base/scene';
-import {
- BddService,
- CookiesService,
- HttpWrapperService,
- NotificationService,
- OnlyAdminGuard,
- OnlyUnregisteredGuardHome,
- OnlyUsersGuard,
- OnlyUsersGuardHome,
- PopInService,
- SessionService,
- SSOService,
- StorageService,
- UserService,
-} from 'common/service';
import { CommonModule } from '@angular/common';
-import {
- ErrorComponent,
- PopInComponent,
- SpinerComponent,
- TopMenuComponent,
- UploadFileComponent,
- PasswordEntryComponent,
- EntryComponent,
- AsyncActionStatusComponent,
- ErrorMessageStateComponent,
- CheckboxComponent,
- BurgerPropertyComponent,
- EntryValidatorComponent,
- RenderSettingsComponent,
- RenderFormComponent,
- EntryNumberComponent,
-} from 'common/component';
-import { ForbiddenScene } from 'common/scene';
-import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
-import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
+
+import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
import { environment } from 'environments/environment';
+import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
@NgModule({
declarations: [
AppComponent,
- TopMenuComponent,
- UploadFileComponent,
- ErrorComponent,
- PasswordEntryComponent,
- EntryComponent,
- EntryValidatorComponent,
- SpinerComponent,
- AsyncActionStatusComponent,
- ErrorMessageStateComponent,
- CheckboxComponent,
- BurgerPropertyComponent,
- RenderSettingsComponent,
- RenderFormComponent,
- EntryNumberComponent,
-
- PopInComponent,
- PopInUploadProgress,
- PopInDeleteConfirm,
SignInScene,
SignUpScene,
@@ -97,7 +47,6 @@ import { environment } from 'environments/environment';
HelpScene,
ForgotPasswordScene,
SettingsScene,
- ForbiddenScene,
ChangePasswordScene,
HomeUnregisteredScene,
ManageAccountsScene,
@@ -114,42 +63,19 @@ import { environment } from 'environments/environment';
FormsModule,
ReactiveFormsModule,
CommonModule,
+ KarCWModule,
],
// injectable element
providers: [
+ { provide: 'ENVIRONMENT', useValue: environment },
// application
AdminUserService,
ApplicationService,
ApplicationTokenService,
- // common
- BddService,
- CookiesService,
- HttpWrapperService,
- StorageService,
- PopInService,
- SessionService,
- UserService,
- SSOService,
- NotificationService,
- SettingsService,
- OnlyUsersGuard,
- OnlyAdminGuard,
- OnlyUsersGuardHome,
- OnlyUnregisteredGuardHome,
],
exports: [
AppComponent,
- TopMenuComponent,
- PasswordEntryComponent,
- UploadFileComponent,
- ErrorComponent,
- BurgerPropertyComponent,
-
- BurgerPropertyComponent,
- PopInComponent,
- PopInUploadProgress,
- PopInDeleteConfirm,
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
diff --git a/front/src/back-api/application-resource.ts b/front/src/back-api/application-resource.ts
new file mode 100644
index 0000000..250ddee
--- /dev/null
+++ b/front/src/back-api/application-resource.ts
@@ -0,0 +1,252 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ Application,
+ RightDescription,
+ Long,
+ ClientToken,
+ ApplicationSmall,
+ AddUserData,
+ isApplication,
+ isRightDescription,
+ isLong,
+ isClientToken,
+ isApplicationSmall,
+} from "./model"
+export namespace ApplicationResource {
+
+ export function remove({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise
{
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/application/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ },
+ restConfig,
+ params,
+ });
+ };
+ export function get({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isApplication);
+ };
+ export function create({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: Application,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application",
+ requestType: HTTPRequestModel.POST,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isApplication);
+ };
+ export function patch({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Application,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isApplication);
+ };
+ export function gets({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/application",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isApplication);
+ };
+ export function getApplicationUsers({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/application/{id}/users",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isLong);
+ };
+ export function getApplicationsSmall({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/application/small",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isApplicationSmall);
+ };
+ export function addUser({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: AddUserData,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/application/{id}/users",
+ requestType: HTTPRequestModel.POST,
+ },
+ restConfig,
+ params,
+ data,
+ });
+ };
+ export function removeUser({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ userId: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/application/{id}/users/${userId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ },
+ restConfig,
+ params,
+ });
+ };
+ export function getRightsDescription({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/application/{id}/rights",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isRightDescription);
+ };
+ export function getClientToken({
+ restConfig,
+ queries,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ application?: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application/get_token",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ queries,
+ }, isClientToken);
+ };
+ export function logOut({
+ restConfig,
+ queries,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ application?: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application/return",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ queries,
+ }, null);
+ };
+}
diff --git a/front/src/back-api/application-token-resource.ts b/front/src/back-api/application-token-resource.ts
new file mode 100644
index 0000000..4941040
--- /dev/null
+++ b/front/src/back-api/application-token-resource.ts
@@ -0,0 +1,84 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ ApplicationToken,
+ Integer,
+ Long,
+ CreateRequest,
+ isApplicationToken,
+} from "./model"
+export namespace ApplicationTokenResource {
+
+ export function remove({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ tokenId: Integer,
+ applicationId: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/application_token/{applicationId}/{tokenId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ },
+ restConfig,
+ params,
+ });
+ };
+ export function create({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ applicationId: Long,
+ },
+ data: CreateRequest,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/application_token//{applicationId}/create",
+ requestType: HTTPRequestModel.POST,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isApplicationToken);
+ };
+ export function gets({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ applicationId: Long,
+ },
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/application_token/{applicationId}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isApplicationToken);
+ };
+}
diff --git a/front/src/back-api/data-resource.ts b/front/src/back-api/data-resource.ts
new file mode 100644
index 0000000..2304d5d
--- /dev/null
+++ b/front/src/back-api/data-resource.ts
@@ -0,0 +1,132 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ UUID,
+} from "./model"
+export namespace DataResource {
+
+ /**
+ * Get a thumbnail of from the data environment (if resize is possible)
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataThumbnailId({
+ restConfig,
+ queries,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization?: string,
+ },
+ params: {
+ uuid: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/thumbnail/{uuid}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+ /**
+ * Get back some data from the data environment (with a beautiful name (permit download with basic name)
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataFull({
+ restConfig,
+ queries,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization?: string,
+ },
+ params: {
+ name: string,
+ uuid: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/{uuid}/{name}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+ /**
+ * Insert a new data in the data environment
+ */
+ export function uploadFile({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: {
+ file: File,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data//upload/",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ },
+ restConfig,
+ data,
+ });
+ };
+ /**
+ * Get back some data from the data environment
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataId({
+ restConfig,
+ queries,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization?: string,
+ },
+ params: {
+ uuid: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/{uuid}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+}
diff --git a/front/src/back-api/front.ts b/front/src/back-api/front.ts
new file mode 100644
index 0000000..f7e397d
--- /dev/null
+++ b/front/src/back-api/front.ts
@@ -0,0 +1,18 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+} from "./model"
+export namespace Front {
+
+}
diff --git a/front/src/back-api/index.ts b/front/src/back-api/index.ts
new file mode 100644
index 0000000..1999009
--- /dev/null
+++ b/front/src/back-api/index.ts
@@ -0,0 +1,12 @@
+/**
+ * Global import of the package
+ */
+export * from "./model";
+export * from "./front";
+export * from "./data-resource";
+export * from "./application-resource";
+export * from "./application-token-resource";
+export * from "./public-key-resource";
+export * from "./right-resource";
+export * from "./user-resource";
+export * from "./system-config-resource";
diff --git a/front/src/back-api/model.ts b/front/src/back-api/model.ts
new file mode 100644
index 0000000..1742120
--- /dev/null
+++ b/front/src/back-api/model.ts
@@ -0,0 +1,549 @@
+/**
+ * Interface of the server (auto-generated code)
+ */
+import { z as zod } from "zod";
+
+export const ZodUUID = zod.string().uuid();
+export type UUID = zod.infer;
+export function isUUID(data: any): data is UUID {
+ try {
+ ZodUUID.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLong = zod.number();
+export type Long = zod.infer;
+export function isLong(data: any): data is Long {
+ try {
+ ZodLong.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodInteger = zod.number().safe();
+export type Integer = zod.infer;
+export function isInteger(data: any): data is Integer {
+ try {
+ ZodInteger.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodFloat = zod.number();
+export type Float = zod.infer;
+export function isFloat(data: any): data is Float {
+ try {
+ ZodFloat.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodInstant = zod.string();
+export type Instant = zod.infer;
+export function isInstant(data: any): data is Instant {
+ try {
+ ZodInstant.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodDate = zod.date();
+export type Date = zod.infer;
+export function isDate(data: any): data is Date {
+ try {
+ ZodDate.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodTimestamp = zod.date();
+export type Timestamp = zod.infer;
+export function isTimestamp(data: any): data is Timestamp {
+ try {
+ ZodTimestamp.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLocalDate = zod.date();
+export type LocalDate = zod.infer;
+export function isLocalDate(data: any): data is LocalDate {
+ try {
+ ZodLocalDate.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLocalTime = zod.date();
+export type LocalTime = zod.infer;
+export function isLocalTime(data: any): data is LocalTime {
+ try {
+ ZodLocalTime.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodRestErrorResponse = zod.object({
+ uuid: ZodUUID.optional(),
+ name: zod.string().max(255).optional(),
+ message: zod.string().max(255).optional(),
+ time: zod.string().max(255).optional(),
+ status: ZodInteger,
+ statusMessage: zod.string().max(255).optional()
+});
+export type RestErrorResponse = zod.infer;
+export function isRestErrorResponse(data: any): data is RestErrorResponse {
+ try {
+ ZodRestErrorResponse.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericTiming = zod.object({
+ // Create time of the object
+ createdAt: ZodDate.readonly().optional(),
+ // When update the object
+ updatedAt: ZodDate.readonly().optional()
+});
+export type GenericTiming = zod.infer;
+export function isGenericTiming(data: any): data is GenericTiming {
+ try {
+ ZodGenericTiming.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericData = ZodGenericTiming.extend({
+ // Unique Id of the object
+ id: ZodLong.readonly().optional()
+});
+export type GenericData = zod.infer;
+export function isGenericData(data: any): data is GenericData {
+ try {
+ ZodGenericData.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericDataSoftDelete = ZodGenericData.extend({
+ // Deleted state
+ deleted: zod.boolean().readonly().optional()
+});
+export type GenericDataSoftDelete = zod.infer;
+export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
+ try {
+ ZodGenericDataSoftDelete.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodApplication = ZodGenericDataSoftDelete.extend({
+ name: zod.string().max(256).optional(),
+ description: zod.string().max(2048).optional(),
+ redirect: zod.string().max(2048).optional(),
+ redirectDev: zod.string().max(2048).optional(),
+ notification: zod.string().max(2048).optional(),
+ // Expiration time
+ ttl: ZodInteger.optional(),
+ // Right is manage with Karso
+ manageRight: zod.boolean().optional()
+});
+export type Application = zod.infer;
+export function isApplication(data: any): data is Application {
+ try {
+ ZodApplication.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodApplicationSmall = zod.object({
+ id: ZodLong.optional(),
+ name: zod.string().max(255).optional(),
+ description: zod.string().max(255).optional(),
+ redirect: zod.string().max(255).optional()
+});
+export type ApplicationSmall = zod.infer;
+export function isApplicationSmall(data: any): data is ApplicationSmall {
+ try {
+ ZodApplicationSmall.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodAddUserData = zod.object({
+ userId: ZodLong
+});
+export type AddUserData = zod.infer;
+export function isAddUserData(data: any): data is AddUserData {
+ try {
+ ZodAddUserData.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
+ // Application id that have the reference of the right
+ applicationId: ZodLong.optional(),
+ // Key of the property
+ key: zod.string().max(64).optional(),
+ // Title of the right
+ title: zod.string().max(1024).optional(),
+ // Description of the right
+ description: zod.string().max(1024).optional(),
+ // default value if Never set
+ defaultValue: zod.string().max(1024).optional(),
+ // Type of the property
+ type: zod.string().max(16).optional()
+});
+export type RightDescription = zod.infer;
+export function isRightDescription(data: any): data is RightDescription {
+ try {
+ ZodRightDescription.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodClientToken = zod.object({
+ url: zod.string().max(255).optional(),
+ jwt: zod.string().max(255).optional()
+});
+export type ClientToken = zod.infer;
+export function isClientToken(data: any): data is ClientToken {
+ try {
+ ZodClientToken.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
+ parentId: ZodLong.optional(),
+ name: zod.string().optional(),
+ endValidityTime: ZodTimestamp.optional(),
+ token: zod.string().optional()
+});
+export type GenericToken = zod.infer;
+export function isGenericToken(data: any): data is GenericToken {
+ try {
+ ZodGenericToken.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodApplicationToken = ZodGenericToken.extend({
+});
+export type ApplicationToken = zod.infer;
+export function isApplicationToken(data: any): data is ApplicationToken {
+ try {
+ ZodApplicationToken.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodCreateRequest = zod.object({
+ name: zod.string().max(255).optional(),
+ validity: ZodInteger.optional()
+});
+export type CreateRequest = zod.infer;
+export function isCreateRequest(data: any): data is CreateRequest {
+ try {
+ ZodCreateRequest.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodPublicKey = zod.object({
+ key: zod.string().max(255).optional()
+});
+export type PublicKey = zod.infer;
+export function isPublicKey(data: any): data is PublicKey {
+ try {
+ ZodPublicKey.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodRight = ZodGenericDataSoftDelete.extend({
+ // application-ID that have the reference of the right
+ applicationId: ZodLong.optional(),
+ // user-ID
+ userId: ZodLong.optional(),
+ // rightDescription-ID of the right description
+ rightDescriptionId: ZodLong.optional(),
+ // Value of the right
+ value: zod.string().max(1024).optional()
+});
+export type Right = zod.infer;
+export function isRight(data: any): data is Right {
+ try {
+ ZodRight.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUser = ZodGenericDataSoftDelete.extend({
+ login: zod.string().max(128).optional(),
+ lastConnection: ZodTimestamp.optional(),
+ admin: zod.boolean(),
+ blocked: zod.boolean(),
+ removed: zod.boolean(),
+ covers: zod.array(ZodLong).optional()
+});
+export type User = zod.infer;
+export function isUser(data: any): data is User {
+ try {
+ ZodUser.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserAuthGet = ZodUser.extend({
+ email: zod.string().max(512).optional(),
+ avatar: zod.boolean().optional()
+});
+export type UserAuthGet = zod.infer;
+export function isUserAuthGet(data: any): data is UserAuthGet {
+ try {
+ ZodUserAuthGet.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserCreate = zod.object({
+ login: zod.string().max(255).optional(),
+ email: zod.string().max(255).optional(),
+ password: zod.string().max(255).optional()
+});
+export type UserCreate = zod.infer;
+export function isUserCreate(data: any): data is UserCreate {
+ try {
+ ZodUserCreate.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserAuth = ZodUser.extend({
+ password: zod.string().max(128).optional(),
+ email: zod.string().max(512).optional(),
+ emailValidate: ZodTimestamp.optional(),
+ newEmail: zod.string().max(512).optional(),
+ avatar: zod.boolean().optional(),
+ // List of accessible application (if not set the application is not available)
+ applications: zod.array(ZodLong).optional()
+});
+export type UserAuth = zod.infer;
+export function isUserAuth(data: any): data is UserAuth {
+ try {
+ ZodUserAuth.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserOut = zod.object({
+ id: ZodLong,
+ login: zod.string().max(255).optional()
+});
+export type UserOut = zod.infer;
+export function isUserOut(data: any): data is UserOut {
+ try {
+ ZodUserOut.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodChangePassword = zod.object({
+ method: zod.string().max(32).optional(),
+ login: zod.string().max(512).optional(),
+ time: zod.string().max(64).optional(),
+ password: zod.string().max(128).optional(),
+ newPassword: zod.string().max(128).optional()
+});
+export type ChangePassword = zod.infer;
+export function isChangePassword(data: any): data is ChangePassword {
+ try {
+ ZodChangePassword.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGetToken = zod.object({
+ jwt: zod.string().optional()
+});
+export type GetToken = zod.infer;
+export function isGetToken(data: any): data is GetToken {
+ try {
+ ZodGetToken.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodDataGetToken = zod.object({
+});
+export type DataGetToken = zod.infer;
+export function isDataGetToken(data: any): data is DataGetToken {
+ try {
+ ZodDataGetToken.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGetSignUpAvailable = zod.object({
+ signup: zod.boolean()
+});
+export type GetSignUpAvailable = zod.infer;
+export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
+ try {
+ ZodGetSignUpAvailable.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodSettings = ZodGenericDataSoftDelete.extend({
+ key: zod.string().max(512).optional(),
+ // Right for the specific element(ADMIN [rw] USER [rw] other [rw])
+ right: zod.string().max(6).optional(),
+ // Type Of the data
+ type: zod.string().max(10).optional(),
+ // Value of the configuration
+ value: zod.string().max(255).optional()
+});
+export type Settings = zod.infer;
+export function isSettings(data: any): data is Settings {
+ try {
+ ZodSettings.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
diff --git a/front/src/back-api/public-key-resource.ts b/front/src/back-api/public-key-resource.ts
new file mode 100644
index 0000000..9633bb0
--- /dev/null
+++ b/front/src/back-api/public-key-resource.ts
@@ -0,0 +1,48 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ PublicKey,
+ isPublicKey,
+} from "./model"
+export namespace PublicKeyResource {
+
+ export function getKey({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/public_key",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isPublicKey);
+ };
+ export function getKeyPem({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/public_key//pem",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, null);
+ };
+}
diff --git a/front/src/back-api/rest-tools.ts b/front/src/back-api/rest-tools.ts
new file mode 100644
index 0000000..d818f57
--- /dev/null
+++ b/front/src/back-api/rest-tools.ts
@@ -0,0 +1,373 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2024, Edouard DUPIN, all right reserved
+ * @license MPL-2
+ */
+
+import { RestErrorResponse } from "./model"
+
+export enum HTTPRequestModel {
+ DELETE = 'DELETE',
+ GET = 'GET',
+ PATCH = 'PATCH',
+ POST = 'POST',
+ PUT = 'PUT',
+}
+export enum HTTPMimeType {
+ ALL = '*/*',
+ CSV = 'text/csv',
+ IMAGE = 'image/*',
+ IMAGE_JPEG = 'image/jpeg',
+ IMAGE_PNG = 'image/png',
+ JSON = 'application/json',
+ MULTIPART = 'multipart/form-data',
+ OCTET_STREAM = 'application/octet-stream',
+ TEXT_PLAIN = 'text/plain',
+}
+
+export interface RESTConfig {
+ // base of the server: http(s)://my.server.org/plop/api/
+ server: string;
+ // Token to access of the data.
+ token?: string;
+}
+
+export interface RESTModel {
+ // base of the local API request: "sheep/{id}".
+ endPoint: string;
+ // Type of the request.
+ requestType?: HTTPRequestModel;
+ // Input type requested.
+ accept?: HTTPMimeType;
+ // Content of the local data.
+ contentType?: HTTPMimeType;
+ // Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
+ tokenInUrl?: boolean;
+}
+
+export interface ModelResponseHttp {
+ status: number;
+ data: any;
+}
+
+export function isArrayOf(
+ data: any,
+ typeChecker: (subData: any) => subData is TYPE,
+ length?: number
+): data is TYPE[] {
+ if (!Array.isArray(data)) {
+ return false;
+ }
+ if (!data.every(typeChecker)) {
+ return false;
+ }
+ if (length !== undefined && data.length != length) {
+ return false;
+ }
+ return true;
+}
+
+function isNullOrUndefined(data: any): data is undefined | null {
+ return data === undefined || data === null;
+}
+
+// generic progression callback
+export type ProgressCallback = (count: number, total: number) => void;
+
+export interface RESTAbort {
+ abort?: () => boolean
+}
+
+
+// Rest generic callback have a basic model to upload and download advancement.
+export interface RESTCallbacks {
+ progressUpload?: ProgressCallback,
+ progressDownload?: ProgressCallback,
+ abortHandle?: RESTAbort,
+};
+
+export interface RESTRequestType {
+ restModel: RESTModel,
+ restConfig: RESTConfig,
+ data?: any,
+ params?: object,
+ queries?: object,
+ callback?: RESTCallbacks,
+};
+
+function removeTrailingSlashes(input: string): string {
+ if (isNullOrUndefined(input)) {
+ return "undefined";
+ }
+ return input.replace(/\/+$/, '');
+}
+function removeLeadingSlashes(input: string): string {
+ if (isNullOrUndefined(input)) {
+ return "";
+ }
+ return input.replace(/^\/+/, '');
+}
+
+export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
+ // Create the URL PATH:
+ let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
+ if (params !== undefined) {
+ for (let key of Object.keys(params)) {
+ generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
+ }
+ }
+ if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
+ return generateUrl;
+ }
+ const searchParams = new URLSearchParams();
+ if (queries !== undefined) {
+ for (let key of Object.keys(queries)) {
+ const value = queries[key];
+ if (Array.isArray(value)) {
+ for (let iii = 0; iii < value.length; iii++) {
+ searchParams.append(`${key}`, `${value[iii]}`);
+ }
+ } else {
+ searchParams.append(`${key}`, `${value}`);
+ }
+ }
+ }
+ if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
+ searchParams.append('Authorization', `Bearer ${restConfig.token}`);
+ }
+ return generateUrl + "?" + searchParams.toString();
+}
+
+
+export function fetchProgress(generateUrl: string, { method, headers, body }: {
+ method: HTTPRequestModel,
+ headers: any,
+ body: any,
+}, { progressUpload, progressDownload, abortHandle }: RESTCallbacks): Promise {
+ const xhr = {
+ io: new XMLHttpRequest()
+ }
+ return new Promise((resolve, reject) => {
+ // Stream the upload progress
+ if (progressUpload) {
+ xhr.io.upload.addEventListener("progress", (dataEvent) => {
+ if (dataEvent.lengthComputable) {
+ //console.log(` ==> has a progress event: ${dataEvent.loaded} / ${dataEvent.total}`);
+ progressUpload(dataEvent.loaded, dataEvent.total);
+ }
+ });
+ }
+ // Stream the download progress
+ if (progressDownload) {
+ xhr.io.addEventListener("progress", (dataEvent) => {
+ if (dataEvent.lengthComputable) {
+ //console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
+ progressUpload(dataEvent.loaded, dataEvent.total);
+ }
+ });
+ }
+ if (abortHandle) {
+ abortHandle.abort = () => {
+ if (xhr.io) {
+ console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
+ xhr.io.abort();
+ return true;
+ }
+ console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
+ return false;
+ }
+ }
+ // Check if we have an internal Fail:
+ xhr.io.addEventListener('error', () => {
+ xhr.io = undefined;
+ reject(new TypeError('Failed to fetch'))
+ });
+
+ // Capture the end of the stream
+ xhr.io.addEventListener("loadend", () => {
+ if (xhr.io.readyState !== XMLHttpRequest.DONE) {
+ //console.log(` ==> READY state`);
+ return;
+ }
+ if (xhr.io.status === 0) {
+ //the stream has been aborted
+ reject(new TypeError('Fetch has been aborted'));
+ return;
+ }
+ // Stream is ended, transform in a generic response:
+ const response = new Response(xhr.io.response, {
+ status: xhr.io.status,
+ statusText: xhr.io.statusText
+ });
+ const headersArray = xhr.io.getAllResponseHeaders().trim().replaceAll("\r\n", "\n").split('\n');
+ headersArray.forEach(function (header) {
+ const firstColonIndex = header.indexOf(':');
+ if (firstColonIndex !== -1) {
+ var key = header.substring(0, firstColonIndex).trim();
+ var value = header.substring(firstColonIndex + 1).trim();
+ response.headers.set(key, value);
+ } else {
+ response.headers.set(header, "");
+ }
+ });
+ xhr.io = undefined;
+ resolve(response);
+ });
+ xhr.io.open(method, generateUrl, true);
+ if (!isNullOrUndefined(headers)) {
+ for (const [key, value] of Object.entries(headers)) {
+ xhr.io.setRequestHeader(key, value as string);
+ }
+ }
+ xhr.io.send(body);
+ });
+}
+
+export function RESTRequest({ restModel, restConfig, data, params, queries, callback }: RESTRequestType): Promise {
+ // Create the URL PATH:
+ let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
+ let headers: any = {};
+ if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
+ headers['Authorization'] = `Bearer ${restConfig.token}`;
+ }
+ if (restModel.accept !== undefined) {
+ headers['Accept'] = restModel.accept;
+ }
+ if (restModel.requestType !== HTTPRequestModel.GET) {
+ // if Get we have not a content type, the body is empty
+ if (restModel.contentType !== HTTPMimeType.MULTIPART) {
+ // special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
+ headers['Content-Type'] = restModel.contentType;
+ }
+ }
+ let body = data;
+ if (restModel.contentType === HTTPMimeType.JSON) {
+ body = JSON.stringify(data);
+ } else if (restModel.contentType === HTTPMimeType.MULTIPART) {
+ const formData = new FormData();
+ for (const name in data) {
+ formData.append(name, data[name]);
+ }
+ body = formData
+ }
+ return new Promise((resolve, reject) => {
+ let action: undefined | Promise = undefined;
+ if (isNullOrUndefined(callback)
+ || (isNullOrUndefined(callback.progressDownload)
+ && isNullOrUndefined(callback.progressUpload)
+ && isNullOrUndefined(callback.abortHandle))) {
+ // No information needed: call the generic fetch interface
+ action = fetch(generateUrl, {
+ method: restModel.requestType,
+ headers,
+ body,
+ });
+ } else {
+ // need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
+ action = fetchProgress(generateUrl, {
+ method: restModel.requestType ?? HTTPRequestModel.GET,
+ headers,
+ body,
+ }, callback);
+ }
+ action.then((response: Response) => {
+ if (response.status >= 200 && response.status <= 299) {
+ const contentType = response.headers.get('Content-Type');
+ if (restModel.accept !== contentType) {
+ reject({
+ time: Date().toString(),
+ status: 901,
+ error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
+ statusMessage: "Fetch error",
+ message: "rest-tools.ts Wrong type in the message return type"
+ } as RestErrorResponse);
+ } else if (contentType === HTTPMimeType.JSON) {
+ response
+ .json()
+ .then((value: any) => {
+ //console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
+ resolve({ status: response.status, data: value });
+ })
+ .catch((reason: any) => {
+ reject({
+ time: Date().toString(),
+ status: 902,
+ error: `REST parse json fail: ${reason}`,
+ statusMessage: "Fetch parse error",
+ message: "rest-tools.ts Wrong message model to parse"
+ } as RestErrorResponse);
+ });
+ } else {
+ resolve({ status: response.status, data: response.body });
+ }
+ } else {
+ reject({
+ time: Date().toString(),
+ status: response.status,
+ error: `${response.body}`,
+ statusMessage: "Fetch code error",
+ message: "rest-tools.ts Wrong return code"
+ } as RestErrorResponse);
+ }
+ }).catch((error: any) => {
+ reject({
+ time: Date(),
+ status: 999,
+ error: error,
+ statusMessage: "Fetch catch error",
+ message: "rest-tools.ts detect an error in the fetch request"
+ });
+ });
+ });
+}
+
+
+
+export function RESTRequestJson(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ if (checker(value.data)) {
+ resolve(value.data);
+ } else {
+ reject({
+ time: Date().toString(),
+ status: 950,
+ error: "REST Fail to verify the data",
+ statusMessage: "API cast ERROR",
+ message: "api.ts Check type as fail"
+ } as RestErrorResponse);
+ }
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
+export function RESTRequestJsonArray(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ if (isArrayOf(value.data, checker)) {
+ resolve(value.data);
+ } else {
+ reject({
+ time: Date().toString(),
+ status: 950,
+ error: "REST Fail to verify the data",
+ statusMessage: "API cast ERROR",
+ message: "api.ts Check type as fail"
+ } as RestErrorResponse);
+ }
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
+
+export function RESTRequestVoid(request: RESTRequestType): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ resolve();
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
diff --git a/front/src/back-api/right-resource.ts b/front/src/back-api/right-resource.ts
new file mode 100644
index 0000000..6cd6562
--- /dev/null
+++ b/front/src/back-api/right-resource.ts
@@ -0,0 +1,114 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ Right,
+ Long,
+ isRight,
+} from "./model"
+export namespace RightResource {
+
+ export function remove({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/right/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ },
+ restConfig,
+ params,
+ });
+ };
+ export function get({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/right/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isRight);
+ };
+ export function patch({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Right,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/right/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isRight);
+ };
+ export function post({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: Right,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/right",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isRight);
+ };
+ export function gets({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/right",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isRight);
+ };
+}
diff --git a/front/src/back-api/system-config-resource.ts b/front/src/back-api/system-config-resource.ts
new file mode 100644
index 0000000..56c6383
--- /dev/null
+++ b/front/src/back-api/system-config-resource.ts
@@ -0,0 +1,75 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ GetSignUpAvailable,
+ isGetSignUpAvailable,
+} from "./model"
+export namespace SystemConfigResource {
+
+ export function getKey({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ key: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/system_config/key/{key}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, null);
+ };
+ export function isSignUpAvailable({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/system_config/is_sign_up_availlable",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isGetSignUpAvailable);
+ };
+ export function setKey({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ key: string,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/system_config/key/{key}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ });
+ };
+}
diff --git a/front/src/back-api/user-resource.ts b/front/src/back-api/user-resource.ts
new file mode 100644
index 0000000..72dd5a8
--- /dev/null
+++ b/front/src/back-api/user-resource.ts
@@ -0,0 +1,279 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import {
+ HTTPMimeType,
+ HTTPRequestModel,
+ ModelResponseHttp,
+ RESTCallbacks,
+ RESTConfig,
+ RESTRequestJson,
+ RESTRequestJsonArray,
+ RESTRequestVoid
+} from "./rest-tools"
+import {
+ GetToken,
+ Long,
+ UserOut,
+ UserAuthGet,
+ DataGetToken,
+ UserCreate,
+ ChangePassword,
+ UserAuth,
+ isGetToken,
+ isUserOut,
+ isUserAuthGet,
+ isUserAuth,
+} from "./model"
+export namespace UserResource {
+
+ export function create({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: UserCreate,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isUserAuthGet);
+ };
+ export function getUsers({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/users",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isUserAuthGet);
+ };
+ export function getUser({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isUserAuthGet);
+ };
+ export function linkApplication({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ applicationId: Long,
+ userId: Long,
+ },
+ data: boolean,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/{userId}/application/{applicationId}/link",
+ requestType: HTTPRequestModel.POST,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isUserAuth);
+ };
+ export function getApplicationRight({
+ restConfig,
+ params,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ applicationId: Long,
+ userId: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/{userId}/application/{applicationId}/rights",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, null);
+ };
+ export function patchApplicationRight({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ applicationId: Long,
+ userId: Long,
+ },
+ data: any,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/{userId}/application/{applicationId}/rights",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, null);
+ };
+ export function setAdmin({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: boolean,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/users/{id}/set_admin",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ });
+ };
+ export function setBlocked({
+ restConfig,
+ params,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: boolean,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/users/{id}/set_blocked",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ });
+ };
+ export function getMe({
+ restConfig,
+ }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/me",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isUserOut);
+ };
+ export function changePassword({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: ChangePassword,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/users/password",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ });
+ };
+ export function isLoginExist({
+ restConfig,
+ queries,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ login?: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/is_login_exist",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ queries,
+ }, null);
+ };
+ export function isEmailExist({
+ restConfig,
+ queries,
+ }: {
+ restConfig: RESTConfig,
+ queries: {
+ email?: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/is_email_exist",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ queries,
+ }, null);
+ };
+ export function getToken({
+ restConfig,
+ data,
+ }: {
+ restConfig: RESTConfig,
+ data: DataGetToken,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/get_token",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isGetToken);
+ };
+}
diff --git a/front/src/base/scene/application-edit/application-edit.ts b/front/src/base/scene/application-edit/application-edit.ts
index 07496de..e84c0f0 100644
--- a/front/src/base/scene/application-edit/application-edit.ts
+++ b/front/src/base/scene/application-edit/application-edit.ts
@@ -4,14 +4,11 @@
* @license PROPRIETARY (see license file)
*/
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { ApplicationService, ApplicationModel, ApplicationTokenService } from 'base/service';
-import { ApplicationTokenModel } from 'base/service/application-token';
-import { AsyncActionState } from 'common/component';
-import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
-import { NotificationService, PopInService } from 'common/service';
-import { isNumber, isNumeric, isString } from 'common/utils';
+import { PopInService, NotificationService, isString, AsyncActionState, isNumber, SettingsItem, CheckerParameterType, SettingType } from '@kangaroo-and-rabbit/kar-cw';
+import { Application, ApplicationToken } from 'back-api';
+import { ApplicationService, ApplicationTokenService } from 'base/service';
@Component({
selector: 'application-setting-edit',
@@ -21,9 +18,9 @@ import { isNumber, isNumeric, isString } from 'common/utils';
})
export class ApplicationEditScene implements OnInit {
id: number = undefined
- application: ApplicationModel = undefined;
- applicationRef: ApplicationModel = undefined;
- tokens: ApplicationTokenModel[] = [];
+ application: Application = undefined;
+ applicationRef: Application = undefined;
+ tokens: ApplicationToken[] = [];
constructor(
private applicationService: ApplicationService,
@@ -39,7 +36,7 @@ export class ApplicationEditScene implements OnInit {
let self = this;
this.applicationService
.get(this.id)
- .then((response: ApplicationModel) => {
+ .then((response: Application) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.application = response;
self.checkName(self.application.name);
@@ -51,7 +48,7 @@ export class ApplicationEditScene implements OnInit {
});
this.applicationTokenService
.gets(this.id)
- .then((response: ApplicationTokenModel[]) => {
+ .then((response: ApplicationToken[]) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.tokens = response;
})
@@ -170,7 +167,7 @@ export class ApplicationEditScene implements OnInit {
let self = this;
this.applicationService.update(this.id, this.dataUpdate)
.then(
- (data: ApplicationModel) => {
+ (data: Application) => {
self.updateState = AsyncActionState.DONE;
console.log(`Get new application data: ${JSON.stringify(data, null, 2)}`);
self.application = data;
@@ -193,7 +190,7 @@ export class ApplicationEditScene implements OnInit {
let self = this;
this.applicationTokenService
.create(this.id, this.dataCreateApplication["name"], this.dataCreateApplication["ttl"])
- .then((response: ApplicationTokenModel) => {
+ .then((response: ApplicationToken) => {
//console.log(`??? get fullllllll response: ${JSON.stringify(response, null, 4)}`);
self.tokens.push(response);
response.token = `"${response.id}:${response.token}"`
@@ -204,13 +201,13 @@ export class ApplicationEditScene implements OnInit {
});
}
- onRemoveApplicationToken(_event: any, token: ApplicationTokenModel) {
+ onRemoveApplicationToken(_event: any, token: ApplicationToken) {
this.confirmDeleteComment = `Delete the application token ID: [${this.application.id}/${token.id}] ${token.name}`;
this.confirmDeleteApplicationToken = token;
this.popInService.open('popin-delete-confirm');
}
- removeApplicationConfirm(token: ApplicationTokenModel) {
+ removeApplicationConfirm(token: ApplicationToken) {
let self = this;
this.applicationTokenService.remove(self.application.id, token.id)
.then(
@@ -227,8 +224,8 @@ export class ApplicationEditScene implements OnInit {
}
);
}
- confirmDeleteComment: string = undefined;
- confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
+ confirmDeleteComment?: string;
+ confirmDeleteApplicationToken?: ApplicationToken;
deleteConfirmed() {
if (this.confirmDeleteApplicationToken !== undefined) {
diff --git a/front/src/base/scene/application-user-edit/application-user-edit.ts b/front/src/base/scene/application-user-edit/application-user-edit.ts
index 45c2069..c743f95 100644
--- a/front/src/base/scene/application-user-edit/application-user-edit.ts
+++ b/front/src/base/scene/application-user-edit/application-user-edit.ts
@@ -6,12 +6,9 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
-import { ApplicationService, ApplicationModel, ApplicationTokenService, AdminUserService } from 'base/service';
-import { ApplicationTokenModel } from 'base/service/application-token';
-import { AsyncActionState } from 'common/component';
-import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
-import { ModelResponseHttp, NotificationService, PopInService } from 'common/service';
-import { isNumber, isNumeric, isString } from 'common/utils';
+import { PopInService, NotificationService, isString, isNumber, CheckerParameterType, SettingType, SettingsItem } from '@kangaroo-and-rabbit/kar-cw';
+import { Application, ApplicationToken } from 'back-api';
+import { ApplicationService, ApplicationTokenService, AdminUserService } from 'base/service';
@Component({
selector: 'application-setting-user-edit',
@@ -24,8 +21,8 @@ export class ApplicationUserEditScene implements OnInit {
users: any[] = undefined;
notUsers: any[] = undefined;
applicationName: string = undefined;
- applicationRef: ApplicationModel = undefined;
- tokens: ApplicationTokenModel[] = [];
+ applicationRef: Application = undefined;
+ tokens: ApplicationToken[] = [];
constructor(
private adminUserService: AdminUserService,
@@ -44,7 +41,7 @@ export class ApplicationUserEditScene implements OnInit {
// get local information of the application
this.applicationService
.get(this.id)
- .then((response: ApplicationModel) => {
+ .then((response: Application) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.applicationName = response.name;
self.applicationRef = response;
@@ -86,16 +83,12 @@ export class ApplicationUserEditScene implements OnInit {
onRemoveApplicationUser(value: boolean, user: any) {
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
const self = this;
- this.applicationService.rmUser(this.id, user.id)
- .then((response: boolean) => {
- if (response === true) {
- self.notUsers.push(user);
- const index = self.users.indexOf(user, 0);
- if (index > -1) {
- self.users.splice(index, 1);
- }
- } else {
- // TODO: manage error
+ this.applicationService.removeUser(this.id, user.id)
+ .then(() => {
+ self.notUsers.push(user);
+ const index = self.users.indexOf(user, 0);
+ if (index > -1) {
+ self.users.splice(index, 1);
}
})
.catch((error: any) => {
@@ -106,15 +99,11 @@ export class ApplicationUserEditScene implements OnInit {
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
const self = this;
this.applicationService.addUser(this.id, user.id)
- .then((response: boolean) => {
- if (response === true) {
- self.users.push(user);
- const index = self.notUsers.indexOf(user, 0);
- if (index > -1) {
- self.notUsers.splice(index, 1);
- }
- } else {
- // TODO: manage error
+ .then(() => {
+ self.users.push(user);
+ const index = self.notUsers.indexOf(user, 0);
+ if (index > -1) {
+ self.notUsers.splice(index, 1);
}
})
.catch((error: any) => {
@@ -128,7 +117,7 @@ export class ApplicationUserEditScene implements OnInit {
- removeApplicationConfirm(token: ApplicationTokenModel) {
+ removeApplicationConfirm(token: ApplicationToken) {
let self = this;
/*
this.applicationTokenService.remove(self.application.id, token.id)
@@ -148,7 +137,7 @@ export class ApplicationUserEditScene implements OnInit {
*/
}
confirmDeleteComment: string = undefined;
- confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
+ confirmDeleteApplicationToken: ApplicationToken = undefined;
deleteConfirmed() {
if (this.confirmDeleteApplicationToken !== undefined) {
diff --git a/front/src/base/scene/application-user-right-edit/application-user-right-edit.ts b/front/src/base/scene/application-user-right-edit/application-user-right-edit.ts
index b074226..4be93e9 100644
--- a/front/src/base/scene/application-user-right-edit/application-user-right-edit.ts
+++ b/front/src/base/scene/application-user-right-edit/application-user-right-edit.ts
@@ -6,14 +6,9 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { AdminUserService, ApplicationModel, ApplicationService, ApplicationUserRight, SettingsService } from 'base/service';
-import { ApplicationRightModel } from 'base/service/application';
-import { SettingType, SettingsItem } from '../manage-accounts/manage-accounts';
-import { UserService } from 'common/service';
-import { isNullOrUndefined, isUndefined } from 'common/utils';
-import { AsyncActionState } from 'common/component';
-
-
+import { AdminUserService, ApplicationService } from 'base/service';
+import { isNullOrUndefined, AsyncActionState, SettingsItem, SettingType } from '@kangaroo-and-rabbit/kar-cw';
+import { Application, RightDescription } from 'back-api';
@Component({
@@ -25,17 +20,15 @@ export class applicationUserRightEditScene implements OnInit {
page = '';
applicationId: number = undefined;
userId: number = undefined;
- application: ApplicationModel;
- rowRight: ApplicationRightModel[] = [];
+ application: Application;
+ rowRight: RightDescription[] = [];
applicationName: string;
userName: string;
- userRights: ApplicationUserRight = {};
+ userRights: any = {};
constructor(
- private settingService: SettingsService,
private applicationService: ApplicationService,
- private userService: UserService,
- private userAdminService: AdminUserService,
+ private adminUserService: AdminUserService,
private activatedRoute: ActivatedRoute,
private cdr: ChangeDetectorRef,
) { }
@@ -47,7 +40,7 @@ export class applicationUserRightEditScene implements OnInit {
let self = this;
this.applicationService
.get(this.applicationId)
- .then((response: ApplicationModel) => {
+ .then((response: Application) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.applicationName = response.name;
self.application = response;
@@ -70,7 +63,7 @@ export class applicationUserRightEditScene implements OnInit {
*/
this.applicationService
.getRights(this.applicationId)
- .then((response: ApplicationRightModel[]) => {
+ .then((response: RightDescription[]) => {
console.log(`getRights OK response: ${JSON.stringify(response, null, 4)}`);
self.rowRight = response;
self.configureEditInput();
@@ -79,9 +72,9 @@ export class applicationUserRightEditScene implements OnInit {
console.log(`getRights ERROR response: ${JSON.stringify(error, null, 4)}`);
});
- this.userAdminService
+ this.adminUserService
.getApplicationRights(this.userId, this.applicationId)
- .then((userRights: ApplicationUserRight) => {
+ .then((userRights: any) => {
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
self.userRights = userRights;
self.configureEditInput();
@@ -168,9 +161,9 @@ export class applicationUserRightEditScene implements OnInit {
this.updateState = AsyncActionState.LOADING;
let self = this;
console.log(`update requested: : ${JSON.stringify(this.dataUpdate, null, 2)}`);
- this.userAdminService
+ this.adminUserService
.updateApplicationRights(this.userId, this.applicationId, this.dataUpdate)
- .then((userRights: ApplicationUserRight[]) => {
+ .then((userRights: any[]) => {
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
self.userRights = userRights;
self.updateState = AsyncActionState.DONE;
diff --git a/front/src/base/scene/application/applications.ts b/front/src/base/scene/application/applications.ts
index c3d6032..aa9c57d 100644
--- a/front/src/base/scene/application/applications.ts
+++ b/front/src/base/scene/application/applications.ts
@@ -6,11 +6,9 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
-import { ApplicationService, ApplicationModel } from 'base/service';
-import { AsyncActionState } from 'common/component';
-import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
-import { NotificationService, PopInService } from 'common/service';
-import { isString } from 'common/utils';
+import { AsyncActionState, CheckerParameterType, NotificationService, PopInService, SettingType, SettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
+import { Application } from 'back-api';
+import { ApplicationService } from 'base/service';
@Component({
selector: 'application-setting',
@@ -19,7 +17,7 @@ import { isString } from 'common/utils';
changeDetection: ChangeDetectionStrategy.Default,
})
export class ApplicationsScene implements OnInit {
- applications: ApplicationModel[] = [];
+ applications: Application[] = [];
constructor(
private applicationService: ApplicationService,
@@ -34,7 +32,7 @@ export class ApplicationsScene implements OnInit {
this.configureInput();
this.applicationService
.gets()
- .then((response: ApplicationModel[]) => {
+ .then((response: Application[]) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.applications = response;
})
@@ -43,13 +41,13 @@ export class ApplicationsScene implements OnInit {
});
}
- onRemoveApplication(_event: any, application: ApplicationModel) {
+ onRemoveApplication(_event: any, application: Application) {
this.confirmDeleteComment = `Delete the application ID: [${application.id}] ${application.name}`;
this.confirmDeleteApplication = application;
this.popInService.open('popin-delete-confirm');
}
- removeApplicationConfirm(application: ApplicationModel) {
+ removeApplicationConfirm(application: Application) {
const self = this;
this.applicationService.remove(application.id)
.then(
@@ -67,7 +65,7 @@ export class ApplicationsScene implements OnInit {
);
}
confirmDeleteComment: string = undefined;
- confirmDeleteApplication: ApplicationModel = undefined;
+ confirmDeleteApplication: Application = undefined;
deleteConfirmed() {
if (this.confirmDeleteApplication !== undefined) {
@@ -77,10 +75,10 @@ export class ApplicationsScene implements OnInit {
}
}
- onEditApplication(_event: any, application: ApplicationModel) {
+ onEditApplication(_event: any, application: Application) {
this.router.navigate(['application-edit', application.id]);
}
- onEditRightApplication(_event: any, application: ApplicationModel) {
+ onEditRightApplication(_event: any, application: Application) {
this.router.navigate(['application-user-edit', application.id]);
}
@@ -157,7 +155,7 @@ export class ApplicationsScene implements OnInit {
const self = this;
this.applicationService.create(this.dataCreateApplication['name'], this.dataCreateApplication['redirect'])
.then(
- (data: ApplicationModel) => {
+ (data: Application) => {
self.createState = AsyncActionState.DONE;
console.log(`Get new user: ${JSON.stringify(data, null, 2)}`);
self.applications.push(data);
diff --git a/front/src/base/scene/change-password/change-password.ts b/front/src/base/scene/change-password/change-password.ts
index 4c2f199..5435c2b 100644
--- a/front/src/base/scene/change-password/change-password.ts
+++ b/front/src/base/scene/change-password/change-password.ts
@@ -6,8 +6,8 @@
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
-import { createPasswordState } from 'common/utils';
import { AdminUserService } from 'base/service';
+import { createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
export enum PasswordState {
FILLING = "filling",
@@ -104,6 +104,7 @@ export class ChangePasswordScene {
this.updateState = PasswordState.DONE;
})
.catch((error: any) => {
+ console.log(`Catch error: ${JSON.stringify(error, null, 2)}`);
this.updateState = PasswordState.ERROR;
this.error = error;
});
diff --git a/front/src/base/scene/forgot-password/forgot-password.ts b/front/src/base/scene/forgot-password/forgot-password.ts
index a72ccfd..d1b7af9 100644
--- a/front/src/base/scene/forgot-password/forgot-password.ts
+++ b/front/src/base/scene/forgot-password/forgot-password.ts
@@ -7,8 +7,8 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
-import { UserService } from 'common/service';
import { AdminUserService } from 'base/service';
+import { UserService } from '@kangaroo-and-rabbit/kar-cw';
export function checkLoginValidity(value: string): boolean {
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
@@ -108,7 +108,7 @@ export class ForgotPasswordScene implements OnInit {
onRetreive(): void {
let self = this;
this.adminUserService
- .retreivePassword(this.login)
+ .retrievePassword(this.login)
.then(() => {
// go to the retreive page
self.router.navigate(['retreive']);
diff --git a/front/src/base/scene/home/home.ts b/front/src/base/scene/home/home.ts
index fa59ad0..18c7dfd 100644
--- a/front/src/base/scene/home/home.ts
+++ b/front/src/base/scene/home/home.ts
@@ -5,9 +5,9 @@
*/
import { Component, OnInit } from '@angular/core';
+import { UserService } from '@kangaroo-and-rabbit/kar-cw';
+import { ApplicationSmall, ClientToken } from 'back-api';
import { ApplicationService } from 'base/service';
-import { GetApplicationSmallResponse, SpecificTokenResponse } from 'base/service/application';
-import { UserService } from 'common/service';
@Component({
selector: 'app-home',
@@ -16,26 +16,27 @@ import { UserService } from 'common/service';
})
export class HomeScene implements OnInit {
error = '';
- dataList: GetApplicationSmallResponse[];
- constructor(private applicationService: ApplicationService, private userService: UserService) { }
+ dataList: ApplicationSmall[];
+ constructor(private applicationService: ApplicationService,
+ private userService: UserService) { }
ngOnInit() {
let self = this;
this.applicationService
.getApplicationsSmall()
- .then((data: GetApplicationSmallResponse[]) => {
+ .then((data: ApplicationSmall[]) => {
self.dataList = data;
})
.catch(error => {
console.log(`fail to keep data : ${error}`);
});
}
- onClick(_event: any, data: GetApplicationSmallResponse): void {
+ onClick(_event: any, data: ApplicationSmall): void {
//window.location.href = data.redirect;
let self = this;
this.applicationService
.getApplicationSpecificToken(data.name)
- .then((result: SpecificTokenResponse) => {
+ .then((result: ClientToken) => {
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
})
.catch((error: any) => {
diff --git a/front/src/base/scene/manage-accounts/manage-accounts.ts b/front/src/base/scene/manage-accounts/manage-accounts.ts
index 5a2adf8..142f10a 100644
--- a/front/src/base/scene/manage-accounts/manage-accounts.ts
+++ b/front/src/base/scene/manage-accounts/manage-accounts.ts
@@ -5,97 +5,9 @@
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
+import { SessionService, AsyncActionState, createPasswordState, createLoginState, checkEmailValidity } from '@kangaroo-and-rabbit/kar-cw';
import { AdminUserService } from 'base/service';
-import { AsyncActionState } from 'common/component';
-import { SessionService } from 'common/service';
-import {
- checkEmailValidity,
- checkLoginValidity,
- createLoginState,
- createPasswordState,
- isBoolean,
- isInArray,
- isNullOrUndefined,
- isNumber,
- isObject,
- isOptionalArrayOf,
- isOptionalOf,
- isString,
-} from 'common/utils';
-export enum SettingType {
- TITLE = 'TITLE',
- GROUP = 'GROUP',
- LINE = 'LINE',
- BOOLEAN = 'BOOLEAN',
- STRING = 'STRING',
- PASSWORD = 'PASSWORD',
-}
-export function isSettingType(data: any): data is SettingType {
- return isInArray(data, ['TITLE', 'GROUP', 'LINE', 'BOOLEAN', 'STRING', 'PASSWORD']);
-}
-
-export interface SettingsItem {
- // Type of the menu Node
- type: SettingType;
- // Displayed Title
- title?: string;
- // Description of the parameter
- description?: string;
- // Image to dsplay that describe the parameter
- image?: string;
- // If true the parameter is applied directly to the backend
- directApply?: boolean;
- // Parameter key to SET/GET
- key?: string;
- // Parameter key to SET/GET or the sub-menu
- value?: SettingsItem[] | boolean | string | Number;
- // whendata is change the value is set here:
- newValue?: boolean | string | Number;
-}
-
-export function isSettingsItem(data: any): data is SettingsItem {
- if (isNullOrUndefined(data)) {
- return false;
- }
- if (!isObject(data)) {
- return false;
- }
- if (!isSettingType(data.type)) {
- return false;
- }
- if (!isOptionalOf(data.title, isString)) {
- return false;
- }
- if (!isOptionalOf(data.description, isString)) {
- return false;
- }
- if (!isOptionalOf(data.image, isString)) {
- return false;
- }
- if (!isOptionalOf(data.directApply, isBoolean)) {
- return false;
- }
- if (!isOptionalOf(data.key, isString)) {
- return false;
- }
- if (
- !isOptionalOf(data.value, isBoolean) &&
- !isOptionalOf(data.value, isString) &&
- !isOptionalOf(data.value, isNumber) &&
- !isOptionalArrayOf(data.value, isSettingsItem)
- ) {
- return false;
- }
- if (
- !isOptionalOf(data.newValue, isBoolean) &&
- !isOptionalOf(data.newValue, isString) &&
- !isOptionalOf(data.newValue, isNumber)
- ) {
- return false;
- }
- return true;
-}
@Component({
selector: 'app-settings',
@@ -226,7 +138,7 @@ export class ManageAccountsScene implements OnInit {
console.log(`create user:`);
this.createState = AsyncActionState.LOADING;
const self = this;
- this.adminUserService.createUsers(this.email, this.login, this.password)
+ this.adminUserService.createUser(this.email, this.login, this.password)
.then(
(user_data: any) => {
self.createState = AsyncActionState.DONE;
diff --git a/front/src/base/scene/settings/settings.ts b/front/src/base/scene/settings/settings.ts
index 10e5188..317923a 100644
--- a/front/src/base/scene/settings/settings.ts
+++ b/front/src/base/scene/settings/settings.ts
@@ -5,16 +5,8 @@
*/
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+import { SettingType, SettingsItem, isNullOrUndefined, isObject, isOptionalArrayOf, isOptionalOf, isSettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
import { SettingsService } from 'base/service';
-import { isSettingsItem, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
-import {
- isNullOrUndefined,
- isObject,
- isOptionalArrayOf,
- isOptionalOf,
- isString,
-} from 'common/utils';
export interface SettingsItem222 {
diff --git a/front/src/base/scene/sign-in/sign-in.ts b/front/src/base/scene/sign-in/sign-in.ts
index 364b00f..9afaa4a 100644
--- a/front/src/base/scene/sign-in/sign-in.ts
+++ b/front/src/base/scene/sign-in/sign-in.ts
@@ -7,10 +7,9 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';
-import { SessionService } from 'common/service';
-import { createLoginState, createPasswordState, getLoginType, isNullOrUndefined } from 'common/utils';
import { AdminUserService, ApplicationService } from 'base/service';
-import { SpecificTokenResponse } from 'base/service/application';
+import { SessionService, isNullOrUndefined, createLoginState, getLoginType, createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
+import { ClientToken } from 'back-api';
@Component({
@@ -62,7 +61,7 @@ export class SignInScene implements OnInit {
}
// TODO: check auto-reconnection !!!
let self = this;
- if (this.sessionService.islogged() == true && self.loginButtonIsClicked === false) {
+ if (this.sessionService.isLogged() == true && self.loginButtonIsClicked === false) {
// in theory it is the inly one case possible, the system loading page after retreiving session ....
if (!isNullOrUndefined(self.ssoApplicationId)) {
// detect an auto-relog...
@@ -137,7 +136,7 @@ export class SignInScene implements OnInit {
let self = this;
this.applicationService
.getApplicationSpecificToken(this.ssoApplicationId)
- .then((result: SpecificTokenResponse) => {
+ .then((result: ClientToken) => {
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
})
.catch((error: any) => {
diff --git a/front/src/base/scene/sign-out/sign-out.ts b/front/src/base/scene/sign-out/sign-out.ts
index caf5b28..900bb5c 100644
--- a/front/src/base/scene/sign-out/sign-out.ts
+++ b/front/src/base/scene/sign-out/sign-out.ts
@@ -7,10 +7,8 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';
-import { UserService } from 'common/service/user';
-import { isNullOrUndefined } from 'common/utils';
import { AdminUserService, ApplicationService } from 'base/service';
-import { SpecificReturnResponse } from 'base/service/application';
+import { UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
export function checkLoginValidity(value: string): boolean {
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
@@ -85,8 +83,8 @@ export class SignOutScene implements OnInit {
} else {
this.applicationService
.getApplicationReturn(this.ssoApplicationId)
- .then((result: SpecificReturnResponse) => {
- self.transferToApplicationThatRequiredTheSSO2(result.url);
+ .then((url: string) => {
+ self.transferToApplicationThatRequiredTheSSO2(url);
})
.catch((error: any) => {
// TODO: self.error = `Can not retreive the application interface`;
diff --git a/front/src/base/scene/sign-up/sign-up.ts b/front/src/base/scene/sign-up/sign-up.ts
index f74a6e1..a1315e4 100644
--- a/front/src/base/scene/sign-up/sign-up.ts
+++ b/front/src/base/scene/sign-up/sign-up.ts
@@ -6,9 +6,9 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
-import { SSOService, UserService } from 'common/service';
import { AdminUserService } from 'base/service';
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../forgot-password/forgot-password';
+import { UserService, SSOService } from '@kangaroo-and-rabbit/kar-cw';
@Component({
selector: 'app-sign-up',
diff --git a/front/src/base/service/admin-user.ts b/front/src/base/service/admin-user.ts
index c2fc20c..3079ccc 100644
--- a/front/src/base/service/admin-user.ts
+++ b/front/src/base/service/admin-user.ts
@@ -5,49 +5,30 @@
*/
import { Injectable } from '@angular/core';
-
-import {
- SessionService,
- StorageService,
- HTTPMimeType,
- HTTPRequestModel,
- HttpWrapperService,
- ModelResponseHttp,
- UserService,
-} from 'common/service';
-import { sha512 } from 'common/utils';
-
-interface MessageLogIn {
- login: string;
- method: string;
- time: string;
- password: string;
-}
-/*
-interface MessageAnswer_USER_CONNECT {
- sessionId: string;
- login: string;
- eMail: string;
- role: string;
- avatar: string;
-}
-*/
-export type ApplicationUserRight = Object;
+import { UserService, SessionService, sha512 } from '@kangaroo-and-rabbit/kar-cw';
+import { DataGetToken, GetToken, Long, UserAuthGet, UserResource } from 'back-api';
+import { RESTConfig } from 'back-api/rest-tools';
+import { environment } from 'environments/environment';
@Injectable()
export class AdminUserService {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karso,
+ token: this.session.getToken()
+ }
+ }
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
constructor(
private userService: UserService,
- private sessionService: SessionService,
- private http: HttpWrapperService) {
+ private session: SessionService) {
console.log('Start AdminUserService');
}
/**
* Log-in with a clear password
- * @param _login Loggin of the user (or e-mail)
+ * @param _login Login of the user (or e-mail)
* @param _password clear password to send at the Oauth server
* @returns promise on connection
*/
@@ -59,7 +40,7 @@ export class AdminUserService {
this.userService.removeSession();
const self = this;
return new Promise((resolve, reject) => {
- self.getTocken(login, password)
+ self.getToken(login, password)
.then((value: any) => {
console.log(' =====> We connect on the system...');
self.userService
@@ -78,14 +59,14 @@ export class AdminUserService {
});
}
- getTocken(login: string, password: string): Promise {
+ getToken(login: string, password: string): Promise {
console.log(`AuthService.getToken ... '${login}':'${password}'`);
// TODO: skip this part if the token is valid !!!
// this is here we need to route to the SSO on external system.
const currentDate: string = new Date().toISOString();
- let data: MessageLogIn;
+ let data: DataGetToken;
// create request:
if (this.identificationVersion === 1) {
data = {
@@ -101,215 +82,111 @@ export class AdminUserService {
console.log(`call users/connect data=${JSON.stringify(data, null, 2)}`);
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'users/get_token',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: data,
- disableTocken: true,
- })
- .then((response: ModelResponseHttp) => {
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.getToken({
+ restConfig: this.getRestConfig(),
+ data
});
}
- getUsers(): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'users',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON
- })
- .then((response: ModelResponseHttp) => {
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getUsers(): Promise {
+ return UserResource.getUsers({
+ restConfig: this.getRestConfig(),
});
}
setAdmin(userId: number, state: boolean): Promise {
- const body = state;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `users/${userId}/set_admin`,
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: ModelResponseHttp) => {
- resolve();
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.setAdmin({
+ restConfig: this.getRestConfig(),
+ params: {
+ id: userId
+ },
+ data: state,
});
}
setBlocked(userId: number, state: boolean): Promise {
- const body = state;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `users/${userId}/set_blocked`,
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: ModelResponseHttp) => {
- resolve();
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.setBlocked({
+ restConfig: this.getRestConfig(),
+ params: {
+ id: userId
+ },
+ data: state,
});
}
- createUsers(email: string, login: string, password: string): Promise {
- const body = {
- email,
- login,
- password: sha512(password)
- };
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'users/create_new_user',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: ModelResponseHttp) => {
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ createUser(email: string, login: string, password: string): Promise {
+ return UserResource.create({
+ restConfig: this.getRestConfig(),
+ data: {
+ login,
+ email,
+ password: sha512(password)
+ },
});
}
-
- create(login: string, email: string, password: string) {
- return this.createSha(login, email, sha512(password));
- }
- createSha(login: string, email: string, password: string) {
- const data = {
- method: 'v?',
- login: login,
- email: email,
- password: password,
- };
- console.log(`call users data=${JSON.stringify(data, null, 2)}`);
-
- if (this.identificationVersion === 1) {
- data.method = 'v1';
+ /*
+ create(login: string, email: string, password: string) {
+ return this.createSha(login, email, sha512(password));
}
-
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'users',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: data,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
- });
- }
+ createSha(login: string, email: string, password: string) {
+ const data = {
+ method: 'v?',
+ login: login,
+ email: email,
+ password: password,
+ };
+ console.log(`call users data=${JSON.stringify(data, null, 2)}`);
+
+ if (this.identificationVersion === 1) {
+ data.method = 'v1';
+ }
+
+ return new Promise((resolve, reject) => {
+ this.http
+ .requestJson({
+ server: 'karso',
+ endPoint: 'users',
+ requestType: HTTPRequestModel.POST,
+ accept: HTTPMimeType.JSON,
+ contentType: HTTPMimeType.JSON,
+ body: data,
+ })
+ .then((response: ModelResponseHttp) => {
+ // TODO: check type ...
+ console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
+ resolve(response.data);
+ })
+ .catch((error: any) => {
+ reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
+ });
+ });
+ }
+ */
checkLogin(login: string): Promise {
- const params = {
- login: login,
- };
- return new Promise((resolve, reject) => {
- this.http
- .request({
- server: 'karso',
- endPoint: 'users/check_login',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params,
- })
- .then((response: Response) => {
- if (response.status >= 200 && response.status <= 299) {
- console.log(`checkLogin : The login already exist`);
- resolve(false);
- } else if (response.status >= 404) {
- resolve(true);
- } else {
- reject(`return ERROR fail in verifiing the login`);
- }
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.isLoginExist({
+ restConfig: this.getRestConfig(),
+ queries: {
+ login
+ },
});
}
checkEMail(email: string): Promise {
- const params = {
- email: email,
- };
- return new Promise((resolve, reject) => {
- this.http
- .request({
- server: 'karso',
- endPoint: 'users/check_email',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params,
- })
- .then((response: Response) => {
- if (response.status >= 200 && response.status <= 299) {
- console.log(`check_email : The login already exist`);
- resolve(false);
- } else if (response.status >= 404) {
- resolve(true);
- } else {
- reject(`return ERROR fail in verifiing the email`);
- }
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.isEmailExist({
+ restConfig: this.getRestConfig(),
+ queries: {
+ email
+ },
});
}
- retreivePassword(login: string): Promise {
- throw new Error('retreivePassword: Method not implemented.');
+ retrievePassword(login: string): Promise {
+ throw new Error('retrievePassword: Method not implemented.');
}
changePassword(oldPassword: string, newPassword: string): Promise {
const time: string = new Date().toISOString();
- const login: string = this.sessionService.getLogin();
+ const login: string = this.session.getLogin();
let method = null;
let password = null;
if (this.identificationVersion === 1) {
@@ -320,82 +197,36 @@ export class AdminUserService {
reject(`Internal Fail (contact administrator).`);
});
}
- const body = {
- method,
- time,
- login,
- password,
- newPassword: sha512(newPassword),
- };
- const self = this;
- return new Promise((resolve, reject) => {
- self.http
- .request({
- server: 'karso',
- endPoint: 'users/password',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: Response) => {
- if (response.status >= 200 && response.status <= 299) {
- console.log(`Update password done with sucess`);
- resolve();
- } else {
- reject(`return ERROR to change password: ${response.status}`);
- }
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return UserResource.changePassword({
+ restConfig: this.getRestConfig(),
+ data: {
+ method,
+ time,
+ login,
+ password,
+ newPassword: sha512(newPassword),
+ },
});
}
- getApplicationRights(userId: number, applicationId: number): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `users/${userId}/application/${applicationId}/rights`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- console.log(
- `Get user Rights: ${JSON.stringify(response.data)}`
- );
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(error);
- });
+ getApplicationRights(userId: Long, applicationId: Long): Promise {
+ return UserResource.getApplicationRight({
+ restConfig: this.getRestConfig(),
+ params: {
+ applicationId,
+ userId,
+ }
});
}
- updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `users/${userId}/application/${applicationId}/rights`,
- requestType: HTTPRequestModel.PATCH,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: dataUpdate
- })
- .then((response: ModelResponseHttp) => {
- console.log(
- `Get user Rights: ${JSON.stringify(response.data)}`
- );
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise {
+ return UserResource.patchApplicationRight({
+ restConfig: this.getRestConfig(),
+ params: {
+ applicationId,
+ userId,
+ },
+ data: dataUpdate
});
}
}
diff --git a/front/src/base/service/application-token.ts b/front/src/base/service/application-token.ts
index 0bdb31e..e629c57 100644
--- a/front/src/base/service/application-token.ts
+++ b/front/src/base/service/application-token.ts
@@ -5,92 +5,53 @@
*/
import { Injectable } from '@angular/core';
-
-import {
- SessionService,
- HTTPMimeType,
- HTTPRequestModel,
- HttpWrapperService,
- ModelResponseHttp,
-} from 'common/service';
-
-export interface ApplicationTokenModel {
- id: number;
- name: string;
- endValidityTime: string;
- token?: string;
-}
+import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
+import { ApplicationToken, ApplicationTokenResource, Long } from 'back-api';
+import { RESTConfig } from 'back-api/rest-tools';
+import { environment } from 'environments/environment';
@Injectable()
export class ApplicationTokenService {
- constructor(private http: HttpWrapperService) {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karso,
+ token: this.session.getToken()
+ }
+ }
+
+ constructor(
+ private session: SessionService) {
console.log('Start ApplicationTokenService');
}
- gets(applicationId: number): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application_token/${applicationId}`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retreive Token for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ gets(applicationId: Long): Promise {
+ return ApplicationTokenResource.gets({
+ restConfig: this.getRestConfig(),
+ params: {
+ applicationId
+ }
});
}
- create(applicationId: number, name: string, validity: number): Promise {
- let body = {
- name,
- validity,
- };
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application_token/${applicationId}/create`,
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: ModelResponseHttp) => {
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ create(applicationId: number, name: string, validity: number): Promise {
+ return ApplicationTokenResource.create({
+ restConfig: this.getRestConfig(),
+ params: {
+ applicationId
+ },
+ data: {
+ name,
+ validity
+ }
});
}
remove(applicationId: number, tokenId: number): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .request({
- server: 'karso',
- endPoint: `application_token/${applicationId}/${tokenId}`,
- requestType: HTTPRequestModel.DELETE,
- accept: HTTPMimeType.ALL,
- contentType: HTTPMimeType.JSON,
- })
- .then(() => {
- resolve();
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return ApplicationTokenResource.remove({
+ restConfig: this.getRestConfig(),
+ params: {
+ applicationId,
+ tokenId
+ }
});
}
}
diff --git a/front/src/base/service/application.ts b/front/src/base/service/application.ts
index b5f4d7d..c4436b2 100644
--- a/front/src/base/service/application.ts
+++ b/front/src/base/service/application.ts
@@ -5,342 +5,123 @@
*/
import { Injectable } from '@angular/core';
-
-import {
- SessionService,
- StorageService,
- HTTPMimeType,
- HTTPRequestModel,
- HttpWrapperService,
- ModelResponseHttp,
-} from 'common/service';
-
-interface MessageLogIn {
- login: string;
- method: string;
- time: number;
- password: string;
-}
-
-export interface SpecificTokenResponse {
- jwt: string;
- url: string;
-}
-export interface SpecificReturnResponse {
- url: string;
-}
-export interface GetApplicationSmallResponse {
- id: number;
- name: string;
- description: string;
- redirect: string;
-}
-
-export interface ApplicationModel {
- id: number;
- name: string;
- description: string;
- redirect: string;
- redirectDev: string;
- notification: string;
- ttl: number;
-}
-export interface ApplicationRightModel {
- id: number;
- applicationId: number;
- title: string;
- description: string;
- key: string;
- type: string;
-}
+import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
+import { RightDescription, ApplicationSmall, Application, ApplicationResource, ClientToken, Long } from 'back-api';
+import { RESTConfig } from 'back-api/rest-tools';
+import { environment } from 'environments/environment';
@Injectable()
export class ApplicationService {
- constructor(private http: HttpWrapperService, private sessionService: SessionService) {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karso,
+ token: this.session.getToken()
+ }
+ }
+
+ constructor(private session: SessionService) {
console.log('Start ApplicationService');
}
- getRights(applicationId: number): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${applicationId}/rights`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getRights(id: Long): Promise {
+ return ApplicationResource.getRightsDescription({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ }
});
}
- getApplicationSpecificToken(applicationId: string): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'application/get_token',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params: {
- application: applicationId,
- },
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getApplicationSpecificToken(application: string): Promise {
+ return ApplicationResource.getClientToken({
+ restConfig: this.getRestConfig(),
+ queries: {
+ application
+ }
});
}
- addUser(applicationId: number, userId: number): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${applicationId}/users`,
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: {
- userId,
- },
- })
- .then((response: ModelResponseHttp) => {
- console.log(
- `User has been added: ${JSON.stringify(response.data)}`
- );
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ addUser(id: Long, userId: Long): Promise {
+ return ApplicationResource.addUser({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ },
+ data: {
+ userId
+ }
});
}
- rmUser(applicationId: number, userId: number): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${applicationId}/users`,
- requestType: HTTPRequestModel.DELETE,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: {
- userId,
- },
- })
- .then((response: ModelResponseHttp) => {
- console.log(
- `User has been added: ${JSON.stringify(response.data)}`
- );
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ removeUser(id: Long, userId: Long): Promise {
+ return ApplicationResource.removeUser({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ userId
+ },
});
}
- getApplicationReturn(applicationId: string): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'application/return',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params: {
- application: applicationId,
- },
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getApplicationReturn(application: string): Promise {
+ return ApplicationResource.logOut({
+ restConfig: this.getRestConfig(),
+ queries: {
+ application
+ },
});
}
- getApplicationsSmall(): Promise {
- const self = this;
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'application/small',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getApplicationsSmall(): Promise {
+ return ApplicationResource.getApplicationsSmall({
+ restConfig: this.getRestConfig(),
});
}
- getUsers(id: number): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${id}/users`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // TODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ getUsers(id: number): Promise {
+ return ApplicationResource.getApplicationUsers({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ }
});
}
- gets(): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'application',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- console.log(
- `retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
- );
- // tODO: check the format...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ gets(): Promise {
+ return ApplicationResource.gets({
+ restConfig: this.getRestConfig(),
});
}
- get(id: number): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${id}`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ get(id: number): Promise {
+ return ApplicationResource.get({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ }
});
}
- update(id: number, updateState: object): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: `application/${id}`,
- requestType: HTTPRequestModel.PATCH,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: updateState,
- })
- .then((response: ModelResponseHttp) => {
- // TODO: check type ...
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ update(id: number, updateState: Application): Promise {
+ return ApplicationResource.patch({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ },
+ data: updateState
});
}
- create(name: string, redirect: string): Promise {
- let body = {
- name,
- redirect,
- };
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- server: 'karso',
- endPoint: 'application',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body,
- })
- .then((response: ModelResponseHttp) => {
- resolve(response.data);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ create(name: string, redirect: string): Promise {
+ return ApplicationResource.create({
+ restConfig: this.getRestConfig(),
+ data: {
+ name,
+ redirect,
+ }
});
}
remove(id: number): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .request({
- server: 'karso',
- endPoint: `application/${id}`,
- requestType: HTTPRequestModel.DELETE,
- accept: HTTPMimeType.ALL,
- contentType: HTTPMimeType.JSON,
- })
- .then(() => {
- resolve();
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
+ return ApplicationResource.remove({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ },
});
}
}
diff --git a/front/src/base/service/index.ts b/front/src/base/service/index.ts
index db98b98..370171a 100644
--- a/front/src/base/service/index.ts
+++ b/front/src/base/service/index.ts
@@ -1,6 +1,5 @@
-import { AdminUserService, ApplicationUserRight } from './admin-user';
-import { ApplicationModel, ApplicationService } from './application';
-import { ApplicationTokenService } from './application-token';
-import { SettingsService } from './settings';
+export { AdminUserService } from './admin-user';
+export { ApplicationService } from './application';
+export { ApplicationTokenService } from './application-token';
+export { SettingsService } from './settings';
-export { AdminUserService, ApplicationService, SettingsService, ApplicationModel, ApplicationTokenService, ApplicationUserRight };
diff --git a/front/src/base/service/settings.ts b/front/src/base/service/settings.ts
index 116490d..1806d14 100644
--- a/front/src/base/service/settings.ts
+++ b/front/src/base/service/settings.ts
@@ -5,8 +5,11 @@
*/
import { Injectable } from '@angular/core';
-import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service';
-import { isUndefined } from 'common/utils';
+import { isUndefined, SessionService } from '@kangaroo-and-rabbit/kar-cw';
+import { SystemConfigResource } from 'back-api';
+import { RESTConfig } from 'back-api/rest-tools';
+import { environment } from 'environments/environment';
+
class MultipleRequest {
requestDone: number = 0;
@@ -44,52 +47,45 @@ class MultipleRequest {
@Injectable()
export class SettingsService {
- constructor(private http: HttpWrapperService) { }
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karso,
+ token: this.session.getToken()
+ }
+ }
+ constructor(private session: SessionService) { }
/**
* Get a generic setting (Key value)
* @returns a promise of the data value
*/
get(key: string): Promise {
return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- endPoint: `system_config/key/${key}`,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
+ SystemConfigResource.getKey(
+ {
+ restConfig: this.getRestConfig(),
+ params: {
+ key
+ }
})
- .then((response: ModelResponseHttp) => {
- resolve(response.data.value);
+ .then((response: any) => {
+ resolve(response.value);
})
.catch((error: any) => {
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
});
- return;
});
}
/**
* Set a generic setting (Key value)
* @returns a promise when set is done
*/
- set(key: string, value: string | Number | boolean): Promise {
- return new Promise((resolve, reject) => {
- this.http
- .requestJson({
- endPoint: `system_config/key/${key}`,
- requestType: HTTPRequestModel.PATCH,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: {
- value,
- },
- })
- .then((response: ModelResponseHttp) => {
- resolve(true);
- })
- .catch((error: any) => {
- reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
- });
- return;
+ set(key: string, value: string | Number | boolean): Promise {
+ return SystemConfigResource.setKey({
+ restConfig: this.getRestConfig(),
+ params: {
+ key
+ },
+ data: `${value}`
});
}
/**
@@ -121,8 +117,8 @@ export class SettingsService {
let multipleResponse = new MultipleRequest(resolve, reject, keys.length);
for (let key of keys) {
this.set(key, data[key])
- .then((result: boolean) => {
- multipleResponse.add(key, result);
+ .then(() => {
+ multipleResponse.add(key, true);
})
.catch((error: any) => {
multipleResponse.fail(key, error);
diff --git a/front/src/common b/front/src/common
deleted file mode 160000
index 147a955..0000000
--- a/front/src/common
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 147a955b195eb7c90e445d404f043d9a363087ca
diff --git a/front/src/environments/environment.edge.prod.ts b/front/src/environments/environment.edge.prod.ts
index 6cf3da0..503c2f3 100644
--- a/front/src/environments/environment.edge.prod.ts
+++ b/front/src/environments/environment.edge.prod.ts
@@ -3,7 +3,9 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
-export const environment = {
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
+export const environment: Environment = {
production: true,
// URL of development API
applName: 'karso',
@@ -11,7 +13,6 @@ export const environment = {
server: {
karso: `${location.origin}/karso/api`,
},
- edgeMode: true,
// set to undefined sso* in case of internal authentication model
ssoSite: `${location.origin}/karso-edge`,
ssoSignIn: undefined,
@@ -19,3 +20,7 @@ export const environment = {
ssoSignUp: undefined,
tokenStoredInPermanentStorage: true,
};
+
+export const environmentKarso = {
+ edgeMode: true,
+};
diff --git a/front/src/environments/environment.edge.ts b/front/src/environments/environment.edge.ts
index 02f8209..3683cab 100644
--- a/front/src/environments/environment.edge.ts
+++ b/front/src/environments/environment.edge.ts
@@ -3,7 +3,9 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
-export const environment = {
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
+export const environment: Environment = {
production: false,
// URL of development API
applName: 'karso-edge',
@@ -11,7 +13,6 @@ export const environment = {
server: {
karso: 'http://localhost:15080/karso-edge/api',
},
- edgeMode: true,
// set to undefined sso* in case of internal authentication model
ssoSite: 'http://localhost:15080/karso',
ssoSignIn: undefined,
@@ -19,3 +20,7 @@ export const environment = {
ssoSignUp: undefined,
tokenStoredInPermanentStorage: true,
};
+
+export const environmentKarso = {
+ edgeMode: true,
+};
\ No newline at end of file
diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts
index 691dc07..905b7e3 100644
--- a/front/src/environments/environment.prod.ts
+++ b/front/src/environments/environment.prod.ts
@@ -3,7 +3,9 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
-export const environment = {
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
+export const environment: Environment = {
production: true,
// URL of development API
applName: 'karso',
@@ -11,7 +13,6 @@ export const environment = {
server: {
karso: `${location.origin}/karso/api`,
},
- edgeMode: false,
// set to undefined sso* in case of internal authentication model
ssoSite: undefined,
ssoSignIn: undefined,
@@ -19,3 +20,7 @@ export const environment = {
ssoSignUp: undefined,
tokenStoredInPermanentStorage: true,
};
+
+export const environmentKarso = {
+ edgeMode: false,
+};
diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts
index f3c8e9e..5da4ab9 100644
--- a/front/src/environments/environment.ts
+++ b/front/src/environments/environment.ts
@@ -3,7 +3,9 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
-export const environment = {
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
+export const environment: Environment = {
production: false,
// URL of development API
applName: 'karso',
@@ -11,7 +13,6 @@ export const environment = {
server: {
karso: 'http://localhost:15080/karso/api',
},
- edgeMode: false,
// set to undefined sso* in case of internal authentication model
ssoSite: undefined,
ssoSignIn: undefined,
@@ -19,3 +20,7 @@ export const environment = {
ssoSignUp: undefined,
tokenStoredInPermanentStorage: true,
};
+
+export const environmentKarso = {
+ edgeMode: false,
+};
diff --git a/front/tsconfig.json b/front/tsconfig.json
index 6d60e4e..8d29977 100644
--- a/front/tsconfig.json
+++ b/front/tsconfig.json
@@ -9,12 +9,12 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "target": "es2018",
+ "target": "ES2022",
"typeRoots": [
"node_modules/@types"
],
"lib": [
- "es2018",
+ "ES2022",
"dom"
],
"module": "es2020",
@@ -33,5 +33,13 @@
"./src/common/"
]
}
+ },
+ "angularCompilerOptions": {
+ "_enabledBlockTypes": [
+ "if",
+ "switch",
+ "for",
+ "defer"
+ ]
}
}
\ No newline at end of file