From f148a38c5df0fc5d8232200b9ae86b07669a6de0 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 16 Dec 2022 00:57:53 +0100 Subject: [PATCH] [DEV] super update de generisation back et front ==> nearly stable --- Dockerfile | 2 +- back/pom.xml | 38 +- back/src/org/kar/karusic/WebLauncher.java | 68 +- .../src/org/kar/karusic/WebLauncherLocal.java | 4 +- .../src/org/kar/karusic/api/DataResource.java | 252 - .../org/kar/karusic/api/MediaStreamer.java | 71 - .../src/org/kar/karusic/api/UserResource.java | 153 - .../org/kar/karusic/model/DataGetToken.java | 8 - back/src/org/kar/karusic/model/Token.java | 57 - .../src/org/kar/karusic/model/UserExtern.java | 36 - back/src/org/kar/karusic/model/UserPerso.java | 42 - back/src/org/kar/karusic/model/UserSmall.java | 73 - .../org/kar/karusic/util/ConfigVariable.java | 2 +- front/angular.json | 13 + front/package-lock.json | 15508 +++++----------- front/package.json | 67 +- front/readme.md | 4 +- front/src/app/app-routing.module.ts | 149 +- front/src/app/app.component.html | 15 +- front/src/app/app.component.ts | 252 +- front/src/app/app.module.ts | 21 +- .../element-player-audio.ts | 9 +- .../element-season/element-season.ts | 2 +- .../src/app/component/top-menu/top-menu.html | 211 - .../src/app/component/top-menu/top-menu.less | 165 - front/src/app/component/top-menu/top-menu.ts | 215 - front/src/app/scene/album-edit/album-edit.ts | 4 - front/src/app/scene/album/album.ts | 11 +- front/src/app/scene/album/albums.ts | 6 +- .../src/app/scene/artist-edit/artist-edit.ts | 5 +- front/src/app/scene/artist/artist-album.ts | 11 +- front/src/app/scene/artist/artist.ts | 4 - front/src/app/scene/artist/artists.ts | 6 +- .../app/scene/error-viewer/error-viewer.ts | 5 +- front/src/app/scene/gender/gender.ts | 3 - front/src/app/scene/help/help.ts | 1 - front/src/app/scene/home/home.ts | 6 +- front/src/app/scene/playlist/playlist.ts | 6 +- front/src/app/scene/settings/settings.ts | 11 +- front/src/app/scene/track-edit/track-edit.ts | 4 - front/src/app/scene/track/track.ts | 5 +- front/src/app/scene/upload/upload.ts | 6 +- front/src/app/service/album.ts | 1 - front/src/app/service/ariane.ts | 267 +- front/src/app/service/data.ts | 2 +- .../src/assets/js_3rd_party/dateFormat.min.js | 27 - .../common/{ => component}/error/error.html | 0 .../common/{ => component}/error/error.less | 0 .../src/common/{ => component}/error/error.ts | 0 front/src/common/component/index.ts | 14 + .../common/component/top-menu/top-menu.html | 59 +- .../common/component/top-menu/top-menu.less | 32 +- .../src/common/component/top-menu/top-menu.ts | 64 +- front/src/common/model/index.ts | 4 +- front/src/common/model/menu-item.ts | 17 +- front/src/common/popin/index.ts | 8 + front/src/common/scene/404/404.html | 6 + front/src/common/scene/404/404.less | 50 + front/src/common/scene/404/404.ts | 16 + .../common/scene/error-viewer/error-viewer.ts | 6 +- .../src/common/scene/forbidden/forbidden.html | 2 +- front/src/common/scene/home-out/home-out.html | 6 + front/src/common/scene/home-out/home-out.less | 50 + front/src/common/scene/home-out/home-out.ts | 16 + front/src/common/scene/index.ts | 10 +- front/src/common/scene/sso/sso.ts | 17 +- front/src/common/service/http-wrapper.ts | 78 +- front/src/common/service/index.ts | 6 +- front/src/common/service/popin.ts | 4 +- front/src/common/service/session.ts | 85 +- front/src/common/service/sso.ts | 74 +- front/src/common/service/user.ts | 57 +- front/src/common/utils/applPath.ts | 17 + front/src/common/utils/dataInterface.ts | 3 +- front/src/common/utils/index.ts | 8 +- .../sha512.js => common/utils/sha512.ts} | 68 +- front/src/common/utils/validator.ts | 11 + front/src/environments/environment.prod.ts | 6 +- front/src/environments/environment.ts | 18 +- front/src/index.html | 4 - readme.md | 3 + 81 files changed, 6324 insertions(+), 12323 deletions(-) delete mode 100644 back/src/org/kar/karusic/api/DataResource.java delete mode 100644 back/src/org/kar/karusic/api/MediaStreamer.java delete mode 100644 back/src/org/kar/karusic/model/DataGetToken.java delete mode 100644 back/src/org/kar/karusic/model/Token.java delete mode 100644 back/src/org/kar/karusic/model/UserExtern.java delete mode 100644 back/src/org/kar/karusic/model/UserPerso.java delete mode 100644 back/src/org/kar/karusic/model/UserSmall.java delete mode 100644 front/src/app/component/top-menu/top-menu.html delete mode 100644 front/src/app/component/top-menu/top-menu.less delete mode 100644 front/src/app/component/top-menu/top-menu.ts delete mode 100644 front/src/assets/js_3rd_party/dateFormat.min.js rename front/src/common/{ => component}/error/error.html (100%) rename front/src/common/{ => component}/error/error.less (100%) rename front/src/common/{ => component}/error/error.ts (100%) create mode 100644 front/src/common/component/index.ts create mode 100644 front/src/common/popin/index.ts create mode 100644 front/src/common/scene/404/404.html create mode 100644 front/src/common/scene/404/404.less create mode 100644 front/src/common/scene/404/404.ts create mode 100644 front/src/common/scene/home-out/home-out.html create mode 100644 front/src/common/scene/home-out/home-out.less create mode 100644 front/src/common/scene/home-out/home-out.ts create mode 100644 front/src/common/utils/applPath.ts rename front/src/{assets/js_3rd_party/sha512.js => common/utils/sha512.ts} (87%) diff --git a/Dockerfile b/Dockerfile index af6e948..5f3781a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ RUN apk add --no-cache wget ENV LANG=C.UTF-8 COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar -COPY --from=buildFront /tmp/dist /application/karusic/ +COPY --from=buildFront /tmp/dist /application/front/ WORKDIR /application/ diff --git a/back/pom.xml b/back/pom.xml index c9c81fa..deb34a8 100644 --- a/back/pom.xml +++ b/back/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - kar + org.kar karusic 0.1.0 @@ -11,12 +11,18 @@ 3.1.1 + + + gitea + https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/maven + + - kar + kangaroo-and-rabbit archidata - 0.1.0 + 0.1.3 @@ -62,19 +68,19 @@ maven-surefire-plugin 3.0.0-M5 - - maven-assembly-plugin - - - - fully.qualified.MainClass - - - - jar-with-dependencies - - - + + maven-assembly-plugin + + + + fully.qualified.MainClass + + + + jar-with-dependencies + + + + + +
+ +
+
+
- You Must be connected to access @Karusic... + Auto-connection in progress
diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts index 1834f78..cff7a30 100644 --- a/front/src/app/app.component.ts +++ b/front/src/app/app.component.ts @@ -5,8 +5,23 @@ */ import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { UserService, SessionService } from 'common/service'; +import { EventOnMenu } from 'common/component/top-menu/top-menu'; +import { MenuItem, MenuPosition } from 'common/model'; +import { UserService, SessionService, SSOService } from 'common/service'; +import { isNullOrUndefined } from 'common/utils'; +import { ArianeService } from './service'; + +enum MenuEventType { + SSO_LOGIN = "SSO_CALL_LOGIN", + SSO_LOGOUT = "SSO_CALL_LOGOUT", + SSO_SIGNUP = "SSO_CALL_SIGNUP", + SEGMENT = "SEGMENT", + TYPE = "TYPE", + ARTIST = "ARTIST", + ALBUM = "ALBUM", + TRACK = "TRACK", + PLAYLIST = "PLAYLIST", +} @Component({ selector: 'app-root', @@ -19,23 +34,37 @@ export class AppComponent implements OnInit { title: string = 'Karideo'; autoConnectedDone: boolean = false; isConnected: boolean = false; + signUpEnable: boolean = true; + currentMenu: MenuItem[] = []; + location: string = "home"; constructor( - private router: Router, private userService: UserService, - private sessionService: SessionService) { - + private sessionService: SessionService, + private ssoService: SSOService, + private arianeService: ArianeService) { + } ngOnInit() { this.autoConnectedDone = false; this.isConnected = false; + this.updateMainMenu(); let self = this; this.sessionService.change.subscribe((isConnected) => { console.log(`receive event from session ...${ isConnected}`); self.isConnected = isConnected; self.autoConnectedDone = true; + self.updateMainMenu(); }); + this.ssoService.checkSignUpEnable() + .then((value: boolean) => { + console.log(`Get value signUp = ${value}`); + self.signUpEnable = value; + self.updateMainMenu(); + }).catch((error: any) => { + console.log(`Can not call the sso to check the sign-up_interface: ${error}`); + }); this.userService.checkAutoConnect().then(() => { console.log(` ==>>>>> Autoconnect THEN !!!`); @@ -47,6 +76,219 @@ export class AppComponent implements OnInit { console.log(` ==>>>>> Autoconnect FINALLY !!!`); self.autoConnectedDone = true; }); + + this.arianeService.segmentChange.subscribe((_segmentName: string) => { + //console.log(`>>> change typeId=${typeId}`); + self.updateMainMenu(); + }); + this.arianeService.typeChange.subscribe((_typeId: number) => { + //console.log(`>>> change typeId=${typeId}`); + self.updateMainMenu(); + }); + this.arianeService.playlistChange.subscribe((_universId: number) => { + //console.log(`>>> change universId=${universId}`); + self.updateMainMenu(); + }); + this.arianeService.artistChange.subscribe((_artistId: number) => { + //console.log(`>>> change artistId=${artistId}`); + self.updateMainMenu(); + }); + this.arianeService.albumChange.subscribe((_albumId: number) => { + //console.log(`>>> change albumId=${albumId}`); + self.updateMainMenu(); + }); + this.arianeService.trackChange.subscribe((_trackId: number) => { + //console.log(`>>> change trackId=${trackId}`); + self.updateMainMenu(); + }); + } + + eventOnMenu(data: EventOnMenu): void { + //console.log(`plopppppppppp ${JSON.stringify(this.route.snapshot.url)}`); + //console.log(`Get event on menu: ${JSON.stringify(data, null, 4)}`); + switch(data.menu.otherData) { + case MenuEventType.SSO_LOGIN: + this.ssoService.requestSignIn(); + break; + case MenuEventType.SSO_LOGOUT: + this.ssoService.requestSignOut(); + break; + case MenuEventType.SSO_SIGNUP: + this.ssoService.requestSignUp(); + break; + case MenuEventType.SEGMENT: + if(this.arianeService.getCurrrentSegment() === "artist") { + this.arianeService.navigateArtist({}); + } else if(this.arianeService.getCurrrentSegment() === "gender") { + this.arianeService.navigateGender({}); + } else if(this.arianeService.getCurrrentSegment() === "playlist") { + this.arianeService.navigatePlaylist({}); + } else if(this.arianeService.getCurrrentSegment() === "track") { + this.arianeService.navigateTrack({}); + } else if(this.arianeService.getCurrrentSegment() === "album") { + this.arianeService.navigateAlbum({}); + } + break; + case MenuEventType.TYPE: + + break; + case MenuEventType.ARTIST: + if(this.arianeService.getCurrrentSegment() === "artist") { + this.arianeService.navigateArtist({artistId: this.arianeService.getArtistId()}); + } + break; + case MenuEventType.ALBUM: + break; + case MenuEventType.TRACK: + break; + case MenuEventType.PLAYLIST: + break; + } + + } + updateMainMenu(): void { + console.log("update main menu :"); + if (this.isConnected) { + this.currentMenu = [ + { + position: MenuPosition.LEFT, + hover: `You are logged as: ${this.sessionService.getLogin()}`, + icon: "menu", + title: "Menu", + subMenu: [ + { + position: MenuPosition.LEFT, + hover: "Go to Home page", + icon: "home", + title: "Home", + navigateTo: "home", + }, { + position: MenuPosition.LEFT, + icon: "group_work", + title: this.getSegmentDisplayable(), + otherData: MenuEventType.SEGMENT, + callback: true, + enable: this.getSegmentDisplayable() !== "", + }, { + position: MenuPosition.LEFT, + icon: "piano", + title: this.getSegmentDisplayable(), + otherData: MenuEventType.TYPE, + callback: true, + enable: !isNullOrUndefined(this.arianeService.getTypeId()), + }, { + position: MenuPosition.LEFT, + icon: "person", + title: this.arianeService.getArtistName(), + otherData: MenuEventType.ARTIST, + callback: true, + enable: !isNullOrUndefined(this.arianeService.getArtistId()), + }, { + position: MenuPosition.LEFT, + icon: "album", + title: this.arianeService.getAlbumName(), + otherData: MenuEventType.ALBUM, + callback: true, + enable: !isNullOrUndefined(this.arianeService.getAlbumId()), + }, { + position: MenuPosition.LEFT, + icon: "music_note", + title: this.arianeService.getTrackName(), + otherData: MenuEventType.TRACK, + callback: true, + enable: !isNullOrUndefined(this.arianeService.getTrackId()), + }, { + position: MenuPosition.LEFT, + icon: "queue_music", + title: this.arianeService.getPlaylistName(), + otherData: MenuEventType.PLAYLIST, + callback: true, + enable: !isNullOrUndefined(this.arianeService.getPlaylistId()), + } + ], + },{ + position: MenuPosition.RIGHT, + image: "assets/images/avatar_generic.svg", + title: "", + subMenu: [ + { + position: MenuPosition.LEFT, + hover: `You are logged as: ${this.sessionService.getLogin()}`, + title: `Sign in as ${this.sessionService.getLogin()}`, + }, { + position: MenuPosition.LEFT, + icon: "add_circle", + title: "Add media", + navigateTo: "upload", + enable: this.sessionService.userAdmin === true, + }, { + position: MenuPosition.LEFT, + icon: "settings", + title: "Settings", + navigateTo: "settings", + }, { + position: MenuPosition.LEFT, + icon: "help", + title: "Help", + navigateTo: "help", + }, { + position: MenuPosition.LEFT, + hover: "Exit connection", + icon: "exit_to_app", + title: "Sign out", + callback: true, + otherData: MenuEventType.SSO_LOGOUT, + }, + ], + }, + ]; + } else { + this.currentMenu = [ + { + position: MenuPosition.LEFT, + hover: "Go to Home page", + icon: "home", + title: "Home", + navigateTo: "home", + }, { + position: MenuPosition.RIGHT, + hover: "Create a new account", + icon: "add_circle_outline", + title: "Sign-up", + callback: true, + model: this.signUpEnable?undefined:"disable", + otherData: MenuEventType.SSO_SIGNUP, + }, { + position: MenuPosition.RIGHT, + hover: "Login page", + icon: "account_circle", + title: "Sign-in", + callback: true, + otherData: MenuEventType.SSO_LOGIN, + }, + ]; + } + console.log(" ==> DONE"); + + } + getSegmentDisplayable(): string { + let segment = this.arianeService.getCurrrentSegment(); + if (segment === "artist") { + return "Artists" + } + if (segment === "gender") { + return "Genders" + } + if (segment === "album") { + return "Albums" + } + if (segment === "track") { + return "Tracks" + } + if (segment === "playlist") { + return "Playlistq" + } + return ""; } } diff --git a/front/src/app/app.module.ts b/front/src/app/app.module.ts index fada27b..7b5dd93 100644 --- a/front/src/app/app.module.ts +++ b/front/src/app/app.module.ts @@ -11,23 +11,19 @@ import { HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select import { AppRoutingModule } from './app-routing.module'; -import { UploadFileComponent } from '../common/component/upload-file/upload-file'; -import { TopMenuComponent } from './component/top-menu/top-menu'; +import { ErrorComponent, PopInComponent, TopMenuComponent, UploadFileComponent } from 'common/component/'; import { ElementDataImageComponent } from './component/data-image/data-image'; import { ElementTypeComponent } from './component/element-type/element-type'; -import { PopInComponent } from '../common/component/popin/popin'; import { PopInCreateType } from './popin/create-type/create-type'; -import { PopInUploadProgress } from '../common/popin/upload-progress/upload-progress'; -import { PopInDeleteConfirm } from '../common/popin/delete-confirm/delete-confirm'; +import { PopInDeleteConfirm, PopInUploadProgress } from 'common/popin'; import { AppComponent } from './app.component'; -import { ErrorComponent } from '../common/error/error'; import { HomeScene, HelpScene, GenderScene, PlaylistScene, ArtistScene, AlbumScene, AlbumsScene, TrackScene, SettingsScene, TrackEditScene, AlbumEditScene, ArtistEditScene, ArtistsScene, ArtistAlbumScene } from './scene'; import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service'; -import { BddService, CookiesService, HttpWrapperService, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service'; -import { ErrorViewerScene, SsoScene } from 'common/scene'; +import { BddService, CookiesService, HttpWrapperService, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service'; +import { ErrorViewerScene, ForbiddenScene, HomeOutScene, NotFound404Scene, SsoScene } from 'common/scene'; import { UploadScene } from './scene/upload/upload'; import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent } from './component'; @@ -67,6 +63,9 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, AlbumEditScene, ArtistEditScene, UploadScene, + ForbiddenScene, + HomeOutScene, + NotFound404Scene, ], imports: [ BrowserModule, @@ -93,7 +92,11 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ArtistService, AlbumService, TrackService, - ArianeService + ArianeService, + OnlyUsersGuard, + OnlyAdminGuard, + OnlyUsersGuardHome, + OnlyUnregisteredGuardHome, ], exports: [ AppComponent, diff --git a/front/src/app/component/element-player-audio/element-player-audio.ts b/front/src/app/component/element-player-audio/element-player-audio.ts index 97b22a6..77fdeeb 100644 --- a/front/src/app/component/element-player-audio/element-player-audio.ts +++ b/front/src/app/component/element-player-audio/element-player-audio.ts @@ -11,6 +11,8 @@ import { GenderService, DataService, PlayerService, TrackService, AlbumService, import { PlaylistCurrent } from 'app/service/player'; import { Media } from 'app/model'; import { HttpWrapperService } from 'common/service'; +import { Title } from '@angular/platform-browser'; +import { environment } from 'environments/environment'; export enum PlayMode { @@ -73,7 +75,8 @@ export class ElementPlayerAudioComponent implements OnInit { private albumService: AlbumService, private artistService: ArtistService, private httpService: HttpWrapperService, - private dataService: DataService) { + private dataService: DataService, + private titleService: Title) { // nothing to do... } private currentLMedia: Media; @@ -110,13 +113,15 @@ export class ElementPlayerAudioComponent implements OnInit { this.albumService.get(response.albumId) .then((response2: NodeData) => { self.nameData = response2.name + " - " + self.nameData; + this.titleService.setTitle(`${environment.applName} > ${self.nameData}`) }) .catch(() => {}); } if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) { this.artistService.get(response.artists[0]) .then((response2: NodeData) => { - self.nameData = self.nameData + " (" + response2.name + ")"; + self.nameData = `${self.nameData} (${response2.name})`; + this.titleService.setTitle(`${environment.applName} > ${self.nameData}`) }) .catch(() => {}); } diff --git a/front/src/app/component/element-season/element-season.ts b/front/src/app/component/element-season/element-season.ts index e82df7a..caba6b5 100644 --- a/front/src/app/component/element-season/element-season.ts +++ b/front/src/app/component/element-season/element-season.ts @@ -81,7 +81,7 @@ export class ElementSeasonComponent implements OnInit { } this.subValueData += response[kkk]; } - console.log(`get values: ${this.element.id} ==> ${self.subValueData}`) + //console.log(`get values: ${this.element.id} ==> ${self.subValueData}`) }).catch((response) => { self.count2 = undefined; }); diff --git a/front/src/app/component/top-menu/top-menu.html b/front/src/app/component/top-menu/top-menu.html deleted file mode 100644 index 63d2784..0000000 --- a/front/src/app/component/top-menu/top-menu.html +++ /dev/null @@ -1,211 +0,0 @@ -
- -
- - -
-
- -
- -
-
- -
-
-
diff --git a/front/src/app/component/top-menu/top-menu.less b/front/src/app/component/top-menu/top-menu.less deleted file mode 100644 index 8b9dfea..0000000 --- a/front/src/app/component/top-menu/top-menu.less +++ /dev/null @@ -1,165 +0,0 @@ - -.top { - .sub-menu { - - position: fixed; - - min-width:150px; - min-height:70px; - - display: block; - overflow: visible; - - box-shadow: none; - flex-direction: column; - flex-wrap: nowrap; - justify-content: flex-start; - box-sizing: border-box; - flex-shrink: 0; - margin: 0; - padding: 0 3px 0 3px; - border: none; - z-index: 300; - box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6); - - .item { - display:block; - float: top; - line-height: 56px; - z-index: 4; - margin: 3px 0px 3px 0px; - /*padding: 0px 3px 0px 3px;*/ - border: 0px; /*0px 3px 0px 3px solid transparent;*/ - /*text-transform: uppercase;*/ - font-weight: bold; - font-size: 17px; - width:100%; - } - - .material-icons { - vertical-align: middle; - } - /* Create an Arraw on the top ob the box ... */ - &:after, &:before { - bottom: 100%; - right: 13px; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - } - - &:after { - border-color: rgba(136, 183, 213, 0); - border-bottom-color: #263238; - border-width: 15px; - margin-left: -15px; - } - - } - .user-menu { - top:75px; - right:15px; - } - .edit-menu { - top:75px; - right:200px; - } - .edit-menu-mob { - top:75px; - right:25px; - } - - .fill-all { - position: absolute; - top: 0; - left: 0; - width:100%; - height:100%; - /* - background-color: #0F0; - */ - z-index:400; - } - - .main-menu { - position: fixed; - top:0px; - left:0px; - - display: block; - overflow: visible; - - box-shadow: none; - min-height: 56px; - flex-direction: column; - flex-wrap: nowrap; - justify-content: flex-start; - box-sizing: border-box; - flex-shrink: 0; - width: 100%; - margin: 0; - padding: 0 12px 0 12px; - border: none; - max-height: 1000px; - z-index: 3; - box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6); - - .item { - display:block; - float: left; - line-height: 56px; - z-index: 4; - margin: 0 3px 0 3px; - border: 0; - text-transform: uppercase; - font-weight: bold; - font-size: 17px; - .comment { - visibility: "hidden"; - } - @media all and (min-width: 700px) { - .comment { - visibility: "visible"; - } - } - } - - .ariane { - display:block; - float: left; - line-height: 56px; - z-index: 4; - padding: 0 0 0 15px; - margin: 0 3px 0 3px; - border: 0; - text-transform: uppercase; - font-weight: bold; - font-size: 15px; - .item_ariane_separator { - display:block; - float: left; - line-height: 56px; - z-index: 4; - margin: 0 3px 0 3px; - border: 0; - text-transform: uppercase; - font-weight: bold; - font-size: 30px; - } - } - - .material-icons { - vertical-align: middle; - } - - .avatar { - height:42px; - width:42px; - border-radius: 50%; - vertical-align: middle; - } - } -} diff --git a/front/src/app/component/top-menu/top-menu.ts b/front/src/app/component/top-menu/top-menu.ts deleted file mode 100644 index fbf9136..0000000 --- a/front/src/app/component/top-menu/top-menu.ts +++ /dev/null @@ -1,215 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2018, Edouard DUPIN, all right reserved - * @license PROPRIETARY (see license file) - */ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { UserService, SessionService, SSOService } from 'common/service'; -import { ArianeService } from 'app/service'; - -@Component({ - selector: 'app-top-menu', - templateUrl: './top-menu.html', - styleUrls: [ './top-menu.less' ] -}) -export class TopMenuComponent implements OnInit { - public login: string;// Session.getLogin(); - public avatar: string;// Session.getAvatar(); - public displayUserMenu: boolean = false; - public displayEditMenu: boolean = false; - - public arianeTypeId: number = null; - public arianeTypeName: string = null; - - public arianePlaylistId: number = null; - public arianePlaylistName: string = null; - - public arianeArtistId: number = null; - public arianeArtistName: string = null; - - public arianeAlbumId: number = null; - public arianeAlbumName: string = null; - - public arianeTrackId: number = null; - public arianeTrackName: string = null; - - public editShow: boolean = false; - - constructor(private router: Router, - private sessionService: SessionService, - private arianeService: ArianeService, - private userService: UserService, - private ssoService: SSOService) { - - } - - ngOnInit() { - let self = this; - this.sessionService.change.subscribe((isConnected) => { - console.log(`TOP-MENU: receive event from session ...${isConnected}`); - if(isConnected === false) { - self.login = undefined; - self.avatar = undefined; - self.displayUserMenu = false; - } else { - self.updateIsJusteLogged(); - } - }); - if (this.sessionService.islogged()) { - this.updateIsJusteLogged(); - } - this.arianeService.typeChange.subscribe((typeId: number) => { - this.arianeTypeId = typeId; - this.arianeTypeName = this.arianeService.getTypeName(); - this.updateEditShow(); - }); - this.arianeService.playlistChange.subscribe((universId) => { - this.arianePlaylistId = universId; - this.arianePlaylistName = this.arianeService.getPlaylistName(); - this.updateEditShow(); - }); - this.arianeService.artistChange.subscribe((artistId) => { - this.arianeArtistId = artistId; - this.arianeArtistName = this.arianeService.getArtistName(); - this.updateEditShow(); - }); - this.arianeService.albumChange.subscribe((albumId) => { - this.arianeAlbumId = albumId; - this.arianeAlbumName = this.arianeService.getAlbumName(); - this.updateEditShow(); - }); - this.arianeService.trackChange.subscribe((trackId) => { - this.arianeTrackId = trackId; - this.arianeTrackName = this.arianeService.getTrackName(); - this.updateEditShow(); - }); - } - - private updateIsJusteLogged(): void { - this.login = this.sessionService.getLogin(); - this.avatar = this.sessionService.getAvatar(); - this.displayUserMenu = false; - console.log(` login:${this.sessionService.getLogin()}`); - console.log(` avatar:${this.avatar}`); - - } - - onAvatar(): void { - console.log(`onAvatar() ${ this.displayUserMenu}`); - this.displayUserMenu = !this.displayUserMenu; - this.displayEditMenu = false; - } - - - onHome(event: any): void { - console.log('onHome()'); - this.router.navigate([ 'home' ]); - } - - onSignIn(event: any): void { - console.log('onSignIn()'); - this.ssoService.requestSignIn(); - } - - onSignUp(event: any): void { - console.log('onSignIn()'); - this.ssoService.requestSignUp(); - this.displayUserMenu = false; - } - - onLogout(event: any): void { - console.log('onLogout()'); - this.ssoService.requestSignOut(); - this.userService.logOut(); - this.router.navigate(['home']); - this.displayUserMenu = false; - } - - - onSetting(event: any): void { - console.log('onSetting()'); - this.router.navigate([ 'settings' ]); - this.displayUserMenu = false; - } - - onHelp(event: any): void { - console.log('onHelp()'); - this.router.navigate([ 'help' ]); - this.displayUserMenu = false; - } - - onOutUserProperty(): void { - console.log('onOutUserProperty ==> event...'); - this.displayUserMenu = false; - this.displayEditMenu = false; - } - - onArianeType(event: any): void { - console.log(`onArianeType(${ this.arianeTypeId })`); - //this.arianeService.navigateType(this.arianeTypeId, event.which === 2); - } - - onArianePlaylist(event: any): void { - console.log(`onArianePlaylist(${ this.arianePlaylistId })`); - //this.arianeService.navigatePlaylist(this.arianePlaylistId, event.which === 2); - } - - onArianeArtist(event: any): void { - console.log(`onArianeArtist(${ this.arianeArtistId })`); - this.arianeService.navigateArtist( {artistId: this.arianeArtistId, newWindows: event.which === 2 } ); - } - - onArianeAlbum(event: any): void { - console.log(`onArianeAlbum(${ this.arianeAlbumId })`); - //this.arianeService.navigateAlbum(this.arianeAlbumId, event.which === 2); - } - - updateEditShow():void { - this.editShow = /* this.arianeTypeId !== null - || this.arianePlaylistId !== null - ||*/ this.arianeArtistId !== null || - this.arianeAlbumId !== null || - this.arianeTrackId !== null; - } - onEdit(): void { - console.log('onEdit()'); - this.displayEditMenu = !this.displayEditMenu; - this.displayUserMenu = false; - } - onSubEditTrack(event: any): void { - console.log('onSubEdit()'); - this.displayEditMenu = false; - this.displayUserMenu = false; - //this.arianeService.navigateTrackEdit(this.arianeTrackId, event.which === 2); - } - onSubEditAlbum(event: any): void { - console.log('onSubEdit()'); - this.displayEditMenu = false; - this.displayUserMenu = false; - //this.arianeService.navigateAlbumEdit(this.arianeAlbumId, event.which === 2); - } - onSubEditArtist(event: any): void { - console.log('onSubEdit()'); - this.displayEditMenu = false; - this.displayUserMenu = false; - //this.arianeService.navigateArtistEdit(this.arianeArtistId, event.which === 2); - } - onSubEditPlaylist(event: any): void { - console.log('onSubEdit()'); - this.displayEditMenu = false; - this.displayUserMenu = false; - //this.arianeService.navigatePlaylistEdit(this.arianePlaylistId, event.which === 2); - } - onSubEditType(event: any): void { - console.log('onSubEditType()'); - this.displayEditMenu = false; - this.displayUserMenu = false; - //this.arianeService.navigateTypeEdit(this.arianeTypeId, event.which === 2); - } - onAddMedia(event: any): void { - console.log('onAddMedia()'); - this.router.navigate([ 'upload' ]); - this.displayUserMenu = false; - } -} diff --git a/front/src/app/scene/album-edit/album-edit.ts b/front/src/app/scene/album-edit/album-edit.ts index 615b6c0..c72b3c4 100644 --- a/front/src/app/scene/album-edit/album-edit.ts +++ b/front/src/app/scene/album-edit/album-edit.ts @@ -5,14 +5,12 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { AlbumService , ArianeService, DataService} from 'app/service'; import { NodeData } from 'common/model'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; import { PopInService } from 'common/service'; -import { isNumberFinite } from 'common/utils'; export interface ElementList { value: number; @@ -68,7 +66,6 @@ export class AlbumEditScene implements OnInit { constructor( - private route: ActivatedRoute, private albumService: AlbumService, private arianeService: ArianeService, private popInService: PopInService, @@ -77,7 +74,6 @@ export class AlbumEditScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); this.idAlbum = this.arianeService.getAlbumId(); let self = this; this.albumService.get(this.idAlbum) diff --git a/front/src/app/scene/album/album.ts b/front/src/app/scene/album/album.ts index 36532c7..f8f7dc0 100644 --- a/front/src/app/scene/album/album.ts +++ b/front/src/app/scene/album/album.ts @@ -5,12 +5,9 @@ */ import { Component, OnInit } from '@angular/core'; - import { ActivatedRoute } from '@angular/router'; import { Media } from 'app/model'; - import { AlbumModel, isAlbumModel } from 'app/model/album'; import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; - import { NodeData } from 'common/model'; @Component({ selector: 'app-album', @@ -31,7 +28,6 @@ public tracks: Media[] = undefined; constructor( - private route: ActivatedRoute, private artistService: ArtistService, private albumService: AlbumService, private trackService: TrackService, @@ -42,7 +38,6 @@ } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); this.idArtist = this.arianeService.getArtistId(); @@ -75,7 +70,7 @@ this.trackService.getWithAlbum(self.idAlbum) .then((response2: Media[]) => { self.tracks = response2; - console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`); + //console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`); }).catch((response) => { //console.log(`>>>>BBB plop`); self.tracks = undefined; @@ -92,9 +87,9 @@ let valuePlayed: number = undefined; for (let iii=0; iii< this.tracks.length; iii++) { elements.push(this.tracks[iii].id); - console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`); + //console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`); if (this.tracks[iii].id == idSelected) { - console.log(` ==> find`); + //console.log(` ==> find`); valuePlayed = iii; } } diff --git a/front/src/app/scene/album/albums.ts b/front/src/app/scene/album/albums.ts index dffa33d..849d42c 100644 --- a/front/src/app/scene/album/albums.ts +++ b/front/src/app/scene/album/albums.ts @@ -5,11 +5,9 @@ */ import { Component, OnInit } from '@angular/core'; - import { ActivatedRoute } from '@angular/router'; import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service'; import { NodeData } from 'common/model'; - import { isNullOrUndefined } from 'common/utils'; @Component({ selector: 'app-albums', @@ -27,7 +25,6 @@ getArtistsString: (id: number) => Promise; constructor( - private route: ActivatedRoute, private albumService: AlbumService, private artistService: ArtistService, private arianeService: ArianeService, @@ -42,13 +39,12 @@ } getArtistsStringCallback(albumId: number) : Promise { - console.log(`request all artist for album: {albumId}`) + //console.log(`request all artist for album: {albumId}`) return this.albumService.getArtists(albumId); } ngOnInit() { this.getArtistsString = (id:number) => {return self.getArtistsStringCallback(id);}; this.countTrack = (id:number) => {return self.countTrackCallback(id);}; - this.arianeService.updateManual(this.route.snapshot.paramMap); let self = this; self.name = "All Albums"; self.description = "View all albums (no specific artist)"; diff --git a/front/src/app/scene/artist-edit/artist-edit.ts b/front/src/app/scene/artist-edit/artist-edit.ts index 1566c44..9febb53 100644 --- a/front/src/app/scene/artist-edit/artist-edit.ts +++ b/front/src/app/scene/artist-edit/artist-edit.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { ArtistService, DataService, GenderService, ArianeService } from 'app/service'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; @@ -74,8 +73,7 @@ export class ArtistEditScene implements OnInit { } - constructor(private route: ActivatedRoute, - private dataService: DataService, + constructor(private dataService: DataService, private typeService: GenderService, private artistService: ArtistService, private arianeService: ArianeService, @@ -84,7 +82,6 @@ export class ArtistEditScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); this.idArtist = this.arianeService.getArtistId(); let self = this; this.listType = [ { value: null, label: '---' } ]; diff --git a/front/src/app/scene/artist/artist-album.ts b/front/src/app/scene/artist/artist-album.ts index 79a82b5..3515529 100644 --- a/front/src/app/scene/artist/artist-album.ts +++ b/front/src/app/scene/artist/artist-album.ts @@ -5,12 +5,9 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { Media } from 'app/model'; -import { AlbumModel, isAlbumModel } from 'app/model/album'; import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; -import { NodeData } from 'common/model'; @Component({ selector: 'app-artist-album', @@ -31,7 +28,6 @@ export class ArtistAlbumScene implements OnInit { public tracks: Media[] = undefined; constructor( - private route: ActivatedRoute, private artistService: ArtistService, private albumService: AlbumService, private trackService: TrackService, @@ -42,7 +38,6 @@ export class ArtistAlbumScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); this.idArtist = this.arianeService.getArtistId(); @@ -75,7 +70,7 @@ export class ArtistAlbumScene implements OnInit { this.trackService.getWithAlbum(self.idAlbum) .then((response2: Media[]) => { self.tracks = response2; - console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`); + //console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`); }).catch((response) => { //console.log(`>>>>BBB plop`); self.tracks = undefined; @@ -92,9 +87,9 @@ export class ArtistAlbumScene implements OnInit { let valuePlayed: number = undefined; for (let iii=0; iii< this.tracks.length; iii++) { elements.push(this.tracks[iii].id); - console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`); + //console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`); if (this.tracks[iii].id == idSelected) { - console.log(` ==> find`); + //console.log(` ==> find`); valuePlayed = iii; } } diff --git a/front/src/app/scene/artist/artist.ts b/front/src/app/scene/artist/artist.ts index 8767e30..430ba59 100644 --- a/front/src/app/scene/artist/artist.ts +++ b/front/src/app/scene/artist/artist.ts @@ -5,11 +5,9 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { ArtistService, DataService, ArianeService, AlbumService, PlayerService } from 'app/service'; import { NodeData } from 'common/model'; -import { isNullOrUndefined } from 'common/utils'; @Component({ selector: 'app-artist', @@ -27,7 +25,6 @@ export class ArtistScene implements OnInit { countTrack: (id: number) => Promise; constructor( - private route: ActivatedRoute, private albumService: AlbumService, private artistService: ArtistService, private playerService: PlayerService, @@ -42,7 +39,6 @@ export class ArtistScene implements OnInit { ngOnInit() { this.countTrack = (id:number) => {return self.countTrackCallback(id);}; - this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); this.idArtist = this.arianeService.getArtistId(); diff --git a/front/src/app/scene/artist/artists.ts b/front/src/app/scene/artist/artists.ts index d9180e6..6e846f8 100644 --- a/front/src/app/scene/artist/artists.ts +++ b/front/src/app/scene/artist/artists.ts @@ -5,11 +5,9 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; +import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; import { NodeData } from 'common/model'; -import { isNullOrUndefined } from 'common/utils'; @Component({ selector: 'app-artists', @@ -26,7 +24,6 @@ export class ArtistsScene implements OnInit { countAlbum: (id: number) => Promise; constructor( - private route: ActivatedRoute, private artistService: ArtistService, private albumService: AlbumService, private trackService: TrackService, @@ -39,7 +36,6 @@ export class ArtistsScene implements OnInit { let self = this; this.countTrack = (id:number) => {return self.countTrackCallback(id);}; this.countAlbum = (id:number) => {return self.countAlbumCallback(id);}; - this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); this.artistService.getOrder() diff --git a/front/src/app/scene/error-viewer/error-viewer.ts b/front/src/app/scene/error-viewer/error-viewer.ts index 4b6f743..6571deb 100644 --- a/front/src/app/scene/error-viewer/error-viewer.ts +++ b/front/src/app/scene/error-viewer/error-viewer.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { ArianeService } from '../../service/ariane'; @Component({ @@ -14,11 +13,9 @@ import { ArianeService } from '../../service/ariane'; styleUrls: [ './error-viewer.less' ] }) export class ErrorViewerScene implements OnInit { - constructor(private route: ActivatedRoute, - private arianeService: ArianeService) { } + constructor(private arianeService: ArianeService) { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); } } diff --git a/front/src/app/scene/gender/gender.ts b/front/src/app/scene/gender/gender.ts index 8a6ad2e..89a539d 100644 --- a/front/src/app/scene/gender/gender.ts +++ b/front/src/app/scene/gender/gender.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { GenderService, DataService, ArianeService } from 'app/service'; @@ -26,7 +25,6 @@ export class GenderScene implements OnInit { tracksError = ''; tracks = []; constructor( - private route: ActivatedRoute, private genderService: GenderService, private arianeService: ArianeService, private dataService: DataService) { @@ -34,7 +32,6 @@ export class GenderScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); this.genderId = this.arianeService.getTypeId(); let self = this; console.log(`get gender global id: ${ this.genderId}`); diff --git a/front/src/app/scene/help/help.ts b/front/src/app/scene/help/help.ts index 11d5260..511c113 100644 --- a/front/src/app/scene/help/help.ts +++ b/front/src/app/scene/help/help.ts @@ -20,7 +20,6 @@ export class HelpScene implements OnInit { private arianeService: ArianeService) { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); const page = this.route.snapshot.paramMap.get('page'); if (page == null) { this.page = undefined; diff --git a/front/src/app/scene/home/home.ts b/front/src/app/scene/home/home.ts index 6684a6e..4f2962e 100644 --- a/front/src/app/scene/home/home.ts +++ b/front/src/app/scene/home/home.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { ArianeService, GenderService } from 'app/service'; @@ -34,14 +33,11 @@ export class HomeScene implements OnInit { }, ]; error = ''; - constructor(private route: ActivatedRoute, - private genderService: GenderService, - private arianeService: ArianeService) { + constructor(private arianeService: ArianeService) { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); let self = this; /* this.genderService.getData() diff --git a/front/src/app/scene/playlist/playlist.ts b/front/src/app/scene/playlist/playlist.ts index 692587e..5c3275a 100644 --- a/front/src/app/scene/playlist/playlist.ts +++ b/front/src/app/scene/playlist/playlist.ts @@ -5,7 +5,7 @@ */ import { Component, OnInit } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router'; +import { Router } from '@angular/router'; import { ArianeService } from 'app/service/ariane'; import { environment } from 'environments/environment'; @@ -20,14 +20,12 @@ export class PlaylistScene implements OnInit { playlistId = -1; tracksError = ''; tracks = []; - constructor(private route: ActivatedRoute, - private router: Router, + constructor(private router: Router, private arianeService: ArianeService) { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); this.playlistId = this.arianeService.getPlaylistId(); console.log(`get parameter id: ${ this.playlistId}`); diff --git a/front/src/app/scene/settings/settings.ts b/front/src/app/scene/settings/settings.ts index f0acdd6..3d6848a 100644 --- a/front/src/app/scene/settings/settings.ts +++ b/front/src/app/scene/settings/settings.ts @@ -5,8 +5,7 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { ArianeService, DataService } from 'app/service'; +import { ArianeService } from 'app/service'; @Component({ selector: 'app-settings', @@ -17,19 +16,11 @@ export class SettingsScene implements OnInit { page = ''; constructor( - private route: ActivatedRoute, private arianeService: ArianeService) { // nothing to do. } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); - const page = this.route.snapshot.paramMap.get('page'); - if (page == null) { - this.page = undefined; - } else { - this.page = page; - } console.error(`MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`); console.error(`get parameter update: ${this.page}`); console.error(`MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`); diff --git a/front/src/app/scene/track-edit/track-edit.ts b/front/src/app/scene/track-edit/track-edit.ts index 013d218..0a4be92 100644 --- a/front/src/app/scene/track-edit/track-edit.ts +++ b/front/src/app/scene/track-edit/track-edit.ts @@ -5,12 +5,10 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; -import { NodeData } from 'common/model'; import { PopInService } from 'common/service'; import { Media } from 'app/model'; import { isNullOrUndefined } from 'common/utils'; @@ -99,7 +97,6 @@ export class TrackEditScene implements OnInit { { value: undefined, label: '---' }, ]; constructor( - private route: ActivatedRoute, private genderService: GenderService, private albumService: AlbumService, private artistService: ArtistService, @@ -134,7 +131,6 @@ export class TrackEditScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); this.idTrack = this.arianeService.getTrackId(); let self = this; this.listGender = [ { value: null, label: '---' } ]; diff --git a/front/src/app/scene/track/track.ts b/front/src/app/scene/track/track.ts index 4a508d2..c688d35 100644 --- a/front/src/app/scene/track/track.ts +++ b/front/src/app/scene/track/track.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { DataService, TrackService, ArtistService, AlbumService, ArianeService } from 'app/service'; import { HttpWrapperService } from 'common/service'; import { isNullOrUndefined } from 'common/utils'; @@ -73,8 +72,7 @@ export class TrackScene implements OnInit { displayNeedHide:boolean = false; timeLeft: number = 10; interval = null; - constructor(private route: ActivatedRoute, - private trackService: TrackService, + constructor(private trackService: TrackService, private artistService: ArtistService, private albumService: AlbumService, private httpService: HttpWrapperService, @@ -190,7 +188,6 @@ export class TrackScene implements OnInit { ngOnInit() { let self = this; this.startHideTimer(); - this.arianeService.updateManual(this.route.snapshot.paramMap); this.idTrack = this.arianeService.getTrackId(); this.arianeService.trackChange.subscribe((trackId) => { console.log(`Detect trackId change...${ trackId}`); diff --git a/front/src/app/scene/upload/upload.ts b/front/src/app/scene/upload/upload.ts index 4c5f653..25fe989 100644 --- a/front/src/app/scene/upload/upload.ts +++ b/front/src/app/scene/upload/upload.ts @@ -5,9 +5,8 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { GenderService, PlaylistService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service'; +import { GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service'; import { NodeData } from 'common/model'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; import { PopInService } from 'common/service'; @@ -95,7 +94,7 @@ export class UploadScene implements OnInit { globalGender: string = null; globalArtist: string = null; globalAlbum: string = null; - constructor(private route: ActivatedRoute, + constructor( private genderService: GenderService, private artistService: ArtistService, private albumService: AlbumService, @@ -125,7 +124,6 @@ export class UploadScene implements OnInit { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); let self = this; this.listGender = [ { value: null, label: '---' } ]; this.listArtist = [ { value: null, label: '---' } ]; diff --git a/front/src/app/service/album.ts b/front/src/app/service/album.ts index 0620435..457765e 100644 --- a/front/src/app/service/album.ts +++ b/front/src/app/service/album.ts @@ -5,7 +5,6 @@ */ import { Injectable } from '@angular/core'; -import { AlbumModel } from 'app/model/album'; import { NodeData } from 'common/model'; import { HttpWrapperService, BddService } from 'common/service'; diff --git a/front/src/app/service/ariane.ts b/front/src/app/service/ariane.ts index 5adb07d..e5e2314 100644 --- a/front/src/app/service/ariane.ts +++ b/front/src/app/service/ariane.ts @@ -6,7 +6,7 @@ import { Injectable, Output, EventEmitter } from '@angular/core'; -import { Router } from '@angular/router'; +import { NavigationEnd, NavigationError, NavigationStart, Router } from '@angular/router'; import { GenderService } from './gender'; import { PlaylistService } from './playlist'; @@ -15,38 +15,43 @@ import { AlbumService } from './album'; import { TrackService } from './track'; import { environment } from 'environments/environment'; import { NodeData } from 'common/model'; -import { isNullOrUndefined, isUndefined } from 'common/utils'; +import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils'; export class InputOrders { - public genderId: number = null; - public playlistId: number = null; - public artistId: number = null; - public albumId: number = null; - public trackId: number = null; + public genderId: number = undefined; + public playlistId: number = undefined; + public artistId: number = undefined; + public albumId: number = undefined; + public trackId: number = undefined; } @Injectable() export class ArianeService { - public genderId: number = null; - public typeName: string = null; + public genderId: number = undefined; + public typeName: string = undefined; @Output() typeChange: EventEmitter = new EventEmitter(); - public playlistId: number = null; - public playlistName: string = null; + public playlistId: number = undefined; + public playlistName: string = undefined; @Output() playlistChange: EventEmitter = new EventEmitter(); - public artistId: number = null; - public artistName: string = null; + public artistId: number = undefined; + public artistName: string = undefined; @Output() artistChange: EventEmitter = new EventEmitter(); - public albumId: number = null; - public albumName: string = null; + public albumId: number = undefined; + public albumName: string = undefined; @Output() albumChange: EventEmitter = new EventEmitter(); - public trackId: number = null; - public trackName: string = null; + public trackId: number = undefined; + public trackName: string = undefined; @Output() trackChange: EventEmitter = new EventEmitter(); + @Output() update: EventEmitter = new EventEmitter(); + + public segment: string = ""; + @Output() segmentChange: EventEmitter = new EventEmitter(); + constructor(private router: Router, private typeService: GenderService, private playlistService: PlaylistService, @@ -54,125 +59,113 @@ export class ArianeService { private albumService: AlbumService, private trackService: TrackService) { //console.log('Start ArianeService'); - } - updateParams(params) { - console.log(`sparams ${ params}`); - console.log(`sparams['genderId'] ${ params.genderId}`); - if(params.genderId) { - this.setType(params.genderId); - } else { - this.setType(null); - } + //this.route. + let self = this; + this.router.events.subscribe((event: any) => { + if (event instanceof NavigationStart) { + // Show progress spinner or progress bar + //console.log('>>>>>>>>>>>>>> Route change detected'); + } + + if (event instanceof NavigationEnd) { + // Hide progress spinner or progress bar + //this.currentRoute = event.url; + //console.log(`>>>>>>>>>>>> ${event}`); + self.updateProperties(); + } + + if (event instanceof NavigationError) { + // Hide progress spinner or progress bar + + // Present error to user + //console.log(`<<<<<<<<<<<<< ${event.error}`); + } + + }); + } - updateManual(params) { - let genderId = params.get('genderId'); - if(genderId === null || genderId === undefined || genderId === 'null' || genderId === 'NULL' || genderId === '') { - genderId = null; - } else { - genderId = parseInt(genderId, 10); - } - console.log(`genderId = ${ genderId } ${ params.get('genderId')}`); + getCurrrentSegment(): string|undefined { + return this.segment; + } - let playlistId = params.get('playlistId'); - if(playlistId === null || playlistId === undefined || playlistId === 'null' || playlistId === 'NULL' || playlistId === '') { - playlistId = null; - } else { - playlistId = parseInt(playlistId, 10); + getIsParam(params: any, name: string): undefined|number { + let valueStr = params.get(name); + if(isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) { + return undefined; } - console.log(`playlistId = ${ playlistId } ${ params.get('universId')}`); + return parseInt(valueStr, 10); - let artistId = params.get('artistId'); - if(artistId === null || artistId === undefined || artistId === 'null' || artistId === 'NULL' || artistId === '') { - artistId = null; - } else { - artistId = parseInt(artistId, 10); - } - console.log(`artistId = ${ artistId } ${ params.get('artistId')}`); + } - let albumId = params.get('albumId'); - if(albumId === null || albumId === undefined || albumId === 'null' || albumId === 'NULL' || albumId === '') { - albumId = null; - } else { - albumId = parseInt(albumId, 10); - } - console.log(`albumId = ${ albumId } ${ params.get('albumId')}`); - - let trackId = params.get('trackId'); - if(trackId === null || trackId === undefined || trackId === 'null' || trackId === 'NULL' || trackId === '') { - trackId = null; - } else { - trackId = parseInt(trackId, 10); - } - console.log(`trackId = ${ trackId } ${ params.get('trackId')}`); + updateProperties() { + let elem = this.router.routerState.root; + while (!isNullOrUndefined(elem.firstChild)) { + elem = elem.firstChild; + } + //console.log(`!!!!!!!!!!!!!!!!!!!!!!!!!! ${JSON.stringify(elem.snapshot.paramMap)}`); + let params = elem.snapshot.paramMap; + let segment: string[] = location.pathname.split("/"); + while (segment.length > 1 && (segment[0] === "" || segment[0] === environment.applName)) { + segment = segment.slice(1); + } + if (segment.length > 0) { + if (this.segment !== segment[0]) { + this.segment = segment[0]; + this.segmentChange.emit(this.segment) + } + } else { + if (this.segment !== "") { + this.segment = ""; + this.segmentChange.emit(this.segment) + } + } + console.log(`segment: ${JSON.stringify(this.segment)}`); + console.log(`params: ${JSON.stringify(params)}`); + let genderId = this.getIsParam(params, 'genderId'); + let playlistId = this.getIsParam(params, 'playlistId'); + let artistId = this.getIsParam(params, 'artistId'); + let albumId = this.getIsParam(params, 'albumId'); + let trackId = this.getIsParam(params, 'trackId'); this.setType(genderId); this.setPlaylist(playlistId); this.setArtist(artistId); this.setAlbum(albumId); this.setTrack(trackId); + this.update.emit({ + genderId: this.genderId, + playlistId: this.playlistId, + artistId: this.artistId, + albumId: this.albumId, + trackId: this.trackId, + }); } reset():void { - this.genderId = null; - this.typeName = null; + this.genderId = undefined; + this.typeName = undefined; this.typeChange.emit(this.genderId); - this.playlistId = null; - this.playlistName = null; + this.playlistId = undefined; + this.playlistName = undefined; this.playlistChange.emit(this.playlistId); - this.artistId = null; - this.artistName = null; + this.artistId = undefined; + this.artistName = undefined; this.artistChange.emit(this.artistId); - this.albumId = null; - this.albumName = null; + this.albumId = undefined; + this.albumName = undefined; this.albumChange.emit(this.albumId); - this.trackId = null; - this.trackName = null; + this.trackId = undefined; + this.trackName = undefined; this.trackChange.emit(this.trackId); } - /* - getCurrentRoute():InputOrders { - let out = new InputOrders() - out.genderId = parseInt(this.route.snapshot.paramMap.get('genderId')); - if (out.genderId === 0){ - out.genderId = undefined; - } - out.playlistId = parseInt(this.route.snapshot.paramMap.get('universId')); - if (out.playlistId === 0){ - out.playlistId = undefined; - } - out.artistId = parseInt(this.route.snapshot.paramMap.get('artistId')); - if (out.artistId === 0){ - out.artistId = undefined; - } - out.albumId = parseInt(this.route.snapshot.paramMap.get('albumId')); - if (out.albumId === 0){ - out.albumId = undefined; - } - out.trackId = parseInt(this.route.snapshot.paramMap.get('trackId')); - if (out.trackId === 0){ - out.trackId = undefined; - } - return out; - } - - routeTo(data:InputOrders, destination:string = null) { - routeTo = "" - //if ( - this.router.navigate(['/type/' + this.genderId + '/artist/' + this.idArtist + '/album/' + IdSelected ]); - } - */ - setType(id:number):void { if(this.genderId === id) { return; } - if(id === undefined) { - return; - } this.genderId = id; this.typeName = '??--??'; - if(this.genderId === null) { + if(isUndefined(this.genderId)) { this.typeChange.emit(this.genderId); return; } @@ -185,23 +178,20 @@ export class ArianeService { self.typeChange.emit(self.genderId); }); } - getTypeId():number { + getTypeId():number|undefined { return this.genderId; } - getTypeName():string { + getTypeName():string|undefined { return this.typeName; } - setPlaylist(id:number) { + setPlaylist(id:number|undefined) { if(this.playlistId === id) { return; } - if(id === undefined) { - return; - } this.playlistId = id; this.playlistName = '??--??'; - if(this.playlistId === null) { + if(isUndefined(this.playlistId)) { this.playlistChange.emit(this.playlistId); return; } @@ -214,23 +204,20 @@ export class ArianeService { self.playlistChange.emit(self.playlistId); }); } - getPlaylistId():number { + getPlaylistId():number|undefined { return this.playlistId; } - getPlaylistName():string { + getPlaylistName():string|undefined { return this.playlistName; } - setArtist(id:number):void { + setArtist(id:number|undefined):void { if(this.artistId === id) { return; } - if(id === undefined) { - return; - } this.artistId = id; this.artistName = '??--??'; - if(this.artistId === null) { + if(isUndefined(this.artistId)) { this.artistChange.emit(this.artistId); return; } @@ -243,23 +230,20 @@ export class ArianeService { self.artistChange.emit(self.artistId); }); } - getArtistId():number { + getArtistId():number|undefined { return this.artistId; } - getArtistName():string { + getArtistName():string|undefined { return this.artistName; } - setAlbum(id:number):void { + setAlbum(id:number|undefined):void { if(this.albumId === id) { return; } - if(id === undefined) { - return; - } this.albumId = id; this.albumName = '??--??'; - if(this.albumId === null) { + if(isUndefined(this.albumId)) { this.albumChange.emit(this.albumId); return; } @@ -273,23 +257,20 @@ export class ArianeService { self.albumChange.emit(self.albumId); }); } - getAlbumId():number { + getAlbumId():number|undefined { return this.albumId; } - getAlbumName():string { + getAlbumName():string|undefined { return this.albumName; } - setTrack(id:number):void { + setTrack(id:number|undefined):void { if(this.trackId === id) { return; } - if(id === undefined) { - return; - } this.trackId = id; this.trackName = '??--??'; - if(this.trackId === null) { + if(isUndefined(this.trackId)) { this.trackChange.emit(this.trackId); return; } @@ -304,10 +285,10 @@ export class ArianeService { self.trackChange.emit(self.trackId); }); } - getTrackId():number { + getTrackId():number|undefined { return this.trackId; } - getTrackName():string { + getTrackName():string|undefined { return this.trackName; } @@ -344,15 +325,15 @@ export class ArianeService { id:number, newWindows?:boolean, replaceCurrentPage: boolean = false): void { - let addressOffset = `${destination }-edit/${ id }`; + let addressOffset = `${destination }/${ id }`; if(!isNullOrUndefined(newWindows) && newWindows === true) { if(isNullOrUndefined(environment.frontBaseUrl) || environment.frontBaseUrl === '') { - window.open(`/${ addressOffset}`); + window.open(`/${ addressOffset}/edit`); } else { - window.open(`/${ environment.frontBaseUrl }/${ addressOffset}`); + window.open(`/${ environment.frontBaseUrl }/${ addressOffset}/edit`); } } else { - this.router.navigate([ addressOffset ], { replaceUrl: replaceCurrentPage }); + this.router.navigate([ `${addressOffset}/edit` ], { replaceUrl: replaceCurrentPage }); } } diff --git a/front/src/app/service/data.ts b/front/src/app/service/data.ts index be549b9..56fe496 100644 --- a/front/src/app/service/data.ts +++ b/front/src/app/service/data.ts @@ -15,7 +15,7 @@ export class DataService { private serviceName:string = 'data'; constructor(private http: HttpWrapperService) { - console.log('Start GenderService'); + console.log('Start DataService'); } getData():any { diff --git a/front/src/assets/js_3rd_party/dateFormat.min.js b/front/src/assets/js_3rd_party/dateFormat.min.js deleted file mode 100644 index cdb588c..0000000 --- a/front/src/assets/js_3rd_party/dateFormat.min.js +++ /dev/null @@ -1,27 +0,0 @@ -; function dateFormat(g, c, k) { - function l(a, b) { a.setHours(a.getHours() + parseFloat(b)); return a } function m(a, b) { var c = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "); return b ? c[a.getDay()].substr(0, 3) : c[a.getDay()] } function n(a, b) { var c = "January February March April May June July August September October November December".split(" "); return b ? c[a.getMonth()].substr(0, 3) : c[a.getMonth()] } var d = { - d: function () { var a = this.getDate(); return 9 < a ? a : "0" + a }, D: function () { return m(this, !0) }, j: function () { return this.getDate() }, - l: function () { return m(this) }, N: function () { return this.getDay() + 1 }, S: function () { var a = this.getDate(); return /^1[0-9]$/.test(a) ? "th" : /1$/.test(a) ? "st" : /2$/.test(a) ? "nd" : /3$/.test(a) ? "rd" : "th" }, w: function () { return this.getDay() }, z: function () { return Math.round(Math.abs((this.getTime() - (new Date("1/1/" + this.getFullYear())).getTime()) / 864E5)) }, W: function () { var a = new Date(this.getFullYear(), 0, 1); return Math.ceil(((this - a) / 864E5 + a.getDay() + 1) / 7) }, F: function () { return n(this) }, m: function () { - var a = this.getMonth() + - 1; return 9 < a ? a : "0" + a - }, M: function () { return n(this, !0) }, n: function () { return this.getMonth() + 1 }, t: function () { return (new Date(this.getFullYear(), this.getMonth() + 1, 0)).getDate() }, L: function () { var a = this.getFullYear(); return 0 == a % 4 && 0 != a % 100 || 0 == a % 400 }, o: function () { return parseInt(this.getFullYear()) }, Y: function () { return parseInt(this.getFullYear()) }, y: function () { return parseInt((this.getFullYear() + "").substr(-2)) }, a: function () { return 12 <= this.getHours() ? "pm" : "am" }, A: function () { - return 12 <= this.getHours() ? - "PM" : "AM" - }, B: function () { return "@" + ("00" + Math.floor((60 * ((this.getHours() + 1) % 24 * 60 + this.getMinutes()) + this.getSeconds() + .001 * this.getMilliseconds()) / 86.4)).slice(-3) }, g: function () { var a = this.getHours(); return 0 == a ? 12 : 12 >= a ? a : a - 12 }, G: function () { return this.getHours() }, h: function () { var a = this.getHours(), a = 12 >= a ? a : a - 12; return 0 == a ? 12 : 9 < a ? a : "0" + a }, H: function () { var a = this.getHours(); return 9 < a ? a : "0" + a }, i: function () { var a = this.getMinutes(); return 9 < a ? a : "0" + a }, s: function () { - var a = this.getSeconds(); return 9 < - a ? a : "0" + a - }, u: function () { return this.getMilliseconds() }, e: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 1 < a.length ? a[1] : "" }, I: function () { var a = new Date(this.getFullYear(), 0, 1), b = new Date(this.getFullYear(), 6, 1), a = Math.max(a.getTimezoneOffset(), b.getTimezoneOffset()); return this.getTimezoneOffset() < a ? 1 : 0 }, O: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 2 < a.length ? a[2] : "" }, P: function () { - var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); - return 2 < a.length ? a[2].substr(0, 3) + ":" + a[2].substr(3, 2) : "" - }, T: function () { return this.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop() }, Z: function () { return 60 * this.getTimezoneOffset() }, c: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, r: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, U: function () { return this.getTime() / 1E3 | 0 } - }, e = { - commonLogFormat: "d/M/Y:G:i:s", exif: "Y:m:d G:i:s", isoYearWeek: "Y\\WW", isoYearWeek2: "Y-\\WW", - isoYearWeekDay: "Y\\WWj", isoYearWeekDay2: "Y-\\WW-j", mySQL: "Y-m-d h:i:s", postgreSQL: "Y.z", postgreSQL2: "Yz", soap: "Y-m-d\\TH:i:s.u", soap2: "Y-m-d\\TH:i:s.uP", unixTimestamp: "@U", xmlrpc: "Ymd\\TG:i:s", xmlrpcCompact: "Ymd\\tGis", wddx: "Y-n-j\\TG:i:s" - }, h = { - AMERICAN: "F j, Y", AMERICANSHORT: "m/d/Y", AMERICANSHORTWTIME: "m/d/Y h:i:sA", ATOM: "Y-m-d\\TH:i:sP", COOKIE: "l, d-M-Y H:i:s T", EUROPEAN: "j F Y", EUROPEANSHORT: "d.m.Y", EUROPEANSHORTWTIME: "d.m.Y H:i:s", ISO8601: "Y-m-d\\TH:i:sO", LEGAL: "j F Y", RFC822: "D, d M y H:i:s O", - RFC850: "l, d-M-y H:i:s T", RFC1036: "D, d M y H:i:s O", RFC1123: "D, d M Y H:i:s O", RFC2822: "D, d M Y H:i:s O", RFC3339: "Y-m-d\\TH:i:sP", RSS: "D, d M Y H:i:s O", W3C: "Y-m-d\\TH:i:sP" - }, f = { "pretty-a": "g:i.sA l jS \\o\\f F, Y", "pretty-b": "g:iA l jS \\o\\f F, Y", "pretty-c": "n/d/Y g:iA", "pretty-d": "n/d/Y", "pretty-e": "F jS - g:ia", "pretty-f": "g:iA", "pretty-g": "F jS, Y", "pretty-h": "F jS, Y g:mA" }; if (c) { - if ("compound" == c) { if (!1 === k) return e; var d = {}, b; for (b in e) d[b] = dateFormat(g, e[b]); return d } if (e[c]) return dateFormat(g, - e[c], k); if ("constants" == c) { if (!1 === k) return h; d = {}; for (b in h) d[b] = dateFormat(g, h[b]); return d } if (h[c]) return dateFormat(g, h[c], k); if ("pretty" == c) { if (!1 === k) return f; d = {}; for (b in f) d[b] = dateFormat(g, f[b]); return d } if (f[c]) return dateFormat(g, f[c], k); e = c.split(""); h = ""; for (b in e) (f = e[b]) && /[a-z]/i.test(f) && !/\\/.test(h + f) && (e[b] = d[f] ? d[f].apply(g) : f), h = e[b]; return e.join("").replace(/\\/g, "") - } return g -}; diff --git a/front/src/common/error/error.html b/front/src/common/component/error/error.html similarity index 100% rename from front/src/common/error/error.html rename to front/src/common/component/error/error.html diff --git a/front/src/common/error/error.less b/front/src/common/component/error/error.less similarity index 100% rename from front/src/common/error/error.less rename to front/src/common/component/error/error.less diff --git a/front/src/common/error/error.ts b/front/src/common/component/error/error.ts similarity index 100% rename from front/src/common/error/error.ts rename to front/src/common/component/error/error.ts diff --git a/front/src/common/component/index.ts b/front/src/common/component/index.ts new file mode 100644 index 0000000..c207617 --- /dev/null +++ b/front/src/common/component/index.ts @@ -0,0 +1,14 @@ +import { ErrorComponent } from "./error/error"; +import { PopInComponent } from "./popin/popin"; +import { TopMenuComponent } from "./top-menu/top-menu"; +import { UploadFileComponent } from "./upload-file/upload-file"; + + +export { + PopInComponent, + TopMenuComponent, + UploadFileComponent, + ErrorComponent, +}; + + diff --git a/front/src/common/component/top-menu/top-menu.html b/front/src/common/component/top-menu/top-menu.html index a046d04..542fb59 100644 --- a/front/src/common/component/top-menu/top-menu.html +++ b/front/src/common/component/top-menu/top-menu.html @@ -1,11 +1,10 @@
- -
\ No newline at end of file +
diff --git a/front/src/common/component/top-menu/top-menu.less b/front/src/common/component/top-menu/top-menu.less index 9da7d0d..5f37a8e 100644 --- a/front/src/common/component/top-menu/top-menu.less +++ b/front/src/common/component/top-menu/top-menu.less @@ -13,6 +13,15 @@ float: none; } +.model_happy { + color:yellow; +} +.model_disable { + color:rgb(100, 100, 100); +} +.model_error { + color:darkred; +} .top { .sub-menu { @@ -138,6 +147,18 @@ } + .inert_element { + display:block; + float: left; + line-height: 56px; + z-index: 4; + margin: 0 3px 0 3px; + border: 0; + //text-transform: uppercase; + font-weight: bold; + font-size: 17px; + } + .ariane { display:block; float: left; @@ -149,17 +170,6 @@ text-transform: uppercase; font-weight: bold; font-size: 15px; - .item_ariane_separator { - display:block; - float: left; - line-height: 56px; - z-index: 4; - margin: 0 3px 0 3px; - border: 0; - text-transform: uppercase; - font-weight: bold; - font-size: 30px; - } } .material-icons { diff --git a/front/src/common/component/top-menu/top-menu.ts b/front/src/common/component/top-menu/top-menu.ts index e0519ca..5661034 100644 --- a/front/src/common/component/top-menu/top-menu.ts +++ b/front/src/common/component/top-menu/top-menu.ts @@ -3,13 +3,20 @@ * @copyright 2018, Edouard DUPIN, all right reserved * @license PROPRIETARY (see license file) */ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; import { Router } from '@angular/router'; -import { isNullOrUndefined } from '../../utils'; -import { MenuItem } from '../../model/menu-item'; +import { isNullOrUndefined } from 'common/utils'; +import { MenuItem } from 'common/model/menu-item'; + +export interface EventOnMenu { + menu: MenuItem; + newWindows: boolean; + ctrl: boolean; +} + @Component({ selector: 'app-top-menu', templateUrl: './top-menu.html', @@ -17,11 +24,25 @@ import { MenuItem } from '../../model/menu-item'; }) export class TopMenuComponent implements OnInit { @Input() menu: MenuItem[]; - subMenu: MenuItem[] = null; + subMenu: MenuItem[] = undefined; + subMenuPosition: String = undefined; + @Output() callback: EventEmitter = new EventEmitter(); constructor(private router: Router) { } + + isNotButton(data: MenuItem) { + return isNullOrUndefined(data.navigateTo) + && (isNullOrUndefined(data.callback) || data.callback === false) + && isNullOrUndefined(data.subMenu); + } + isEnable(data: MenuItem) { + if (!isNullOrUndefined(data) && !isNullOrUndefined(data.enable) && data.enable === false) { + return false; + } + return true; + } getPosition(data: string) : string { return `float: ${data}`; @@ -31,37 +52,58 @@ export class TopMenuComponent implements OnInit { } onOutUserProperty(): void { - console.log('onOutUserProperty ==> event...'); + //console.log('onOutUserProperty ==> event...'); this.subMenu = undefined; } - + getClassMenuPosition(): string { + if (isNullOrUndefined(this.subMenuPosition)) { + return "menu-left"; + } + return 'menu-' + this.subMenuPosition; + } + getClassModel(data?:string): string { + if (isNullOrUndefined(data)) { + return ""; + } + return 'model_' + data; + } onGeneric(data: MenuItem, event: any): void { - console.log(`onGeneric()`); + //console.log(`onGeneric()`); // check if we need to navigate if (!isNullOrUndefined(data.navigateTo)) { // remove in every case the subMenu: - console.log("Navigate request !!!"); this.subMenu = undefined + this.subMenuPosition = undefined; this.router.navigate([ data.navigateTo ]); return; } + if (!isNullOrUndefined(data.callback) && data.callback === true) { + //console.log(`Emit message on ${JSON.stringify(data)}`); + this.callback.emit({ + menu: data, + newWindows: event.which === 2, + ctrl: event.ctrlKey, + }); + return; + } // check if we need to display a submenu if (isNullOrUndefined(data.subMenu)) { - console.log("No menu !!!"); //just a toggle mode: data.subMenu = undefined; + this.subMenuPosition = undefined; return; } if (this.subMenu === data.subMenu) { - console.log("Toggle menu"); //just a toggle mode: this.subMenu = undefined; + this.subMenuPosition = undefined; return; } - console.log(`Set Menu: ${JSON.stringify(data.subMenu)}`); + //console.log(`Set Menu: ${JSON.stringify(data.subMenu)}`); // set the requested menu this.subMenu = data.subMenu; + this.subMenuPosition = data.position; } } diff --git a/front/src/common/model/index.ts b/front/src/common/model/index.ts index af5aba0..9c10c56 100644 --- a/front/src/common/model/index.ts +++ b/front/src/common/model/index.ts @@ -1,6 +1,8 @@ +import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from "./menu-item"; import { NodeData, isNodeData } from "./node"; export { NodeData, isNodeData, -} \ No newline at end of file + MenuPosition, isMenuPosition, MenuItem, isMenuItem, +} diff --git a/front/src/common/model/menu-item.ts b/front/src/common/model/menu-item.ts index ca5354d..6ada30b 100644 --- a/front/src/common/model/menu-item.ts +++ b/front/src/common/model/menu-item.ts @@ -1,4 +1,4 @@ -import { isNumberFinite, isObject, isOptionalOf, isString, isNullOrUndefined, isOptionalArrayOf } from "../utils"; +import { isObject, isOptionalOf, isString, isNullOrUndefined, isOptionalArrayOf } from "common/utils"; export enum MenuPosition { LEFT = "left", @@ -20,10 +20,20 @@ export interface MenuItem { hover?: string; // Icon of the menue (need to be a meterial-icon name icon?: string; + // If we want to display an image instead of an icon + image?: string; // Displayed Title title: string; // Jump Link (If undefined: it is considered as text and not a button) + model?: string; + // Jump Link (If undefined: it is considered as text and not a button) navigateTo?: string; + // if it request a callbak with the curent element: (not compatible with the previous) + callback?: boolean; + // Other data that want to be set by the user + otherData?: any; + // Enable or not the elemnt + enable?: boolean; // Menu model For a subList of elements subMenu?: MenuItem[]; }; @@ -45,6 +55,9 @@ export function isMenuItem(data: any): data is MenuItem { if (!isOptionalOf(data.icon, isString)) { return false; } + if (!isOptionalOf(data.image, isString)) { + return false; + } if (!isString(data.title)) { return false; } @@ -55,4 +68,4 @@ export function isMenuItem(data: any): data is MenuItem { return false; } return true; -} \ No newline at end of file +} diff --git a/front/src/common/popin/index.ts b/front/src/common/popin/index.ts new file mode 100644 index 0000000..ba9ced4 --- /dev/null +++ b/front/src/common/popin/index.ts @@ -0,0 +1,8 @@ +import { PopInDeleteConfirm } from "./delete-confirm/delete-confirm"; +import { PopInUploadProgress } from "./upload-progress/upload-progress"; + + +export { + PopInDeleteConfirm, + PopInUploadProgress, +} \ No newline at end of file diff --git a/front/src/common/scene/404/404.html b/front/src/common/scene/404/404.html new file mode 100644 index 0000000..aabf82e --- /dev/null +++ b/front/src/common/scene/404/404.html @@ -0,0 +1,6 @@ +
+
+
+
+
+
\ No newline at end of file diff --git a/front/src/common/scene/404/404.less b/front/src/common/scene/404/404.less new file mode 100644 index 0000000..6e566e1 --- /dev/null +++ b/front/src/common/scene/404/404.less @@ -0,0 +1,50 @@ + +.full-mode{ + width:100%; + height:100%; + top:0; + left:0; + margin:0; + padding:0; + border:0; + float:left; + display:block; +} + +.centered { + position:relative; + max-width:75%; + padding: 16px 32px 16px 32px; + + top: 50%; + transform: ~"translate(0, -50%)"; + font-size: 30px; + + font-weight: 600; + text-align: center; + line-height: 200%; +} + +.error { + font-size: 55px; + background-size: 45px; + /*background-attachment: fixed;*/ + background-position: 0% 50%; + padding: 0 0 0 58px; + margin: 17px 0 17px 0; + text-shadow:0px 0px 4px #000000; + color: rgb(160, 44, 44); + i { + font-size: 55px; + } +} + +.comment { + background-size: 45px; + /*background-attachment: fixed;*/ + background-position: 0% 50%; + padding: 0 0 0 58px; + margin: 17px 0 17px 0; + text-shadow:0px 0px 4px #07213a; + color: white; +} diff --git a/front/src/common/scene/404/404.ts b/front/src/common/scene/404/404.ts new file mode 100644 index 0000000..601f188 --- /dev/null +++ b/front/src/common/scene/404/404.ts @@ -0,0 +1,16 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2018, Edouard DUPIN, all right reserved + * @license PROPRIETARY (see license file) + */ + +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-404-not-found', + templateUrl: './404.html', + styleUrls: [ './404.less' ] +}) +export class NotFound404Scene { + constructor() { } +} diff --git a/front/src/common/scene/error-viewer/error-viewer.ts b/front/src/common/scene/error-viewer/error-viewer.ts index 4970b65..e798a66 100644 --- a/front/src/common/scene/error-viewer/error-viewer.ts +++ b/front/src/common/scene/error-viewer/error-viewer.ts @@ -6,7 +6,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ArianeService } from 'app/service/ariane'; @Component({ selector: 'app-error-viewer', @@ -14,11 +13,10 @@ import { ArianeService } from 'app/service/ariane'; styleUrls: [ './error-viewer.less' ] }) export class ErrorViewerScene implements OnInit { - constructor(private route: ActivatedRoute, - private arianeService: ArianeService) { } + constructor(private route: ActivatedRoute) { } ngOnInit() { - this.arianeService.updateManual(this.route.snapshot.paramMap); + } } diff --git a/front/src/common/scene/forbidden/forbidden.html b/front/src/common/scene/forbidden/forbidden.html index eb22c03..f0ad92f 100644 --- a/front/src/common/scene/forbidden/forbidden.html +++ b/front/src/common/scene/forbidden/forbidden.html @@ -1,6 +1,6 @@
-
+
\ No newline at end of file diff --git a/front/src/common/scene/home-out/home-out.html b/front/src/common/scene/home-out/home-out.html new file mode 100644 index 0000000..8be721f --- /dev/null +++ b/front/src/common/scene/home-out/home-out.html @@ -0,0 +1,6 @@ +
+
+
+
+
+
\ No newline at end of file diff --git a/front/src/common/scene/home-out/home-out.less b/front/src/common/scene/home-out/home-out.less new file mode 100644 index 0000000..6e566e1 --- /dev/null +++ b/front/src/common/scene/home-out/home-out.less @@ -0,0 +1,50 @@ + +.full-mode{ + width:100%; + height:100%; + top:0; + left:0; + margin:0; + padding:0; + border:0; + float:left; + display:block; +} + +.centered { + position:relative; + max-width:75%; + padding: 16px 32px 16px 32px; + + top: 50%; + transform: ~"translate(0, -50%)"; + font-size: 30px; + + font-weight: 600; + text-align: center; + line-height: 200%; +} + +.error { + font-size: 55px; + background-size: 45px; + /*background-attachment: fixed;*/ + background-position: 0% 50%; + padding: 0 0 0 58px; + margin: 17px 0 17px 0; + text-shadow:0px 0px 4px #000000; + color: rgb(160, 44, 44); + i { + font-size: 55px; + } +} + +.comment { + background-size: 45px; + /*background-attachment: fixed;*/ + background-position: 0% 50%; + padding: 0 0 0 58px; + margin: 17px 0 17px 0; + text-shadow:0px 0px 4px #07213a; + color: white; +} diff --git a/front/src/common/scene/home-out/home-out.ts b/front/src/common/scene/home-out/home-out.ts new file mode 100644 index 0000000..40367f2 --- /dev/null +++ b/front/src/common/scene/home-out/home-out.ts @@ -0,0 +1,16 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2018, Edouard DUPIN, all right reserved + * @license PROPRIETARY (see license file) + */ + +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-home-out', + templateUrl: './home-out.html', + styleUrls: [ './home-out.less' ] +}) +export class HomeOutScene { + constructor() { } +} diff --git a/front/src/common/scene/index.ts b/front/src/common/scene/index.ts index 74f0187..0421ef5 100644 --- a/front/src/common/scene/index.ts +++ b/front/src/common/scene/index.ts @@ -1,11 +1,17 @@ import { ErrorViewerScene } from "./error-viewer/error-viewer"; +import { ForbiddenScene } from "./forbidden/forbidden"; import { SsoScene } from "./sso/sso"; -import { UploadScene } from "../../app/scene/upload/upload"; +//import { UploadScene } from "../../app/scene/upload/upload"; +import { HomeOutScene } from "./home-out/home-out"; +import { NotFound404Scene } from "./404/404"; export { ErrorViewerScene, SsoScene, - UploadScene, + //UploadScene, + ForbiddenScene, + HomeOutScene, + NotFound404Scene, }; diff --git a/front/src/common/scene/sso/sso.ts b/front/src/common/scene/sso/sso.ts index 691b2f6..3bca6f3 100644 --- a/front/src/common/scene/sso/sso.ts +++ b/front/src/common/scene/sso/sso.ts @@ -29,7 +29,7 @@ export class SsoScene implements OnInit { ngOnInit() { let self = this; - console.error("retreive data after SSO back"); + console.log(`call after SSO back: ${window.location.href}`); const ssoData = this.route.snapshot.paramMap.get('data'); if (ssoData == null) { this.ssoData = undefined; @@ -48,20 +48,19 @@ export class SsoScene implements OnInit { } else { this.keepConnected = keepConnected === 'true'; } - console.error(`ssoData: '${ssoData}'`); - console.error(`token: '${token}'`); - console.error(`keepConnected: '${keepConnected}'`); + console.log(`ssoData: '${ssoData}'`); + console.log(`token: '${token}'`); + console.log(`keepConnected: '${keepConnected}'`); if (this.token !== '__CANCEL__' && this.token !== '__FAIL__' && this.token !== '__LOGOUT__') { const destination = (this.ssoData); - console.error(`ssoData (decoded): '${destination}'`); - // sample : ZZ**DST:home + console.log(`ssoData (decoded): '${destination}'`); const realDst = this.ssoService.unHashLocalData(destination); - console.error(`realDst: '${realDst}'`); + console.log(`realDst: '${realDst}'`); this.userService.startSession(this.token, this.keepConnected).then((userName: string) => { self.userName = userName; setTimeout(function(){ self.router.navigate([ realDst ], { replaceUrl:true }); - }, 2000); // 2 seconds + }, 500); // 2 seconds }).catch(() => { this.token = "ERROR_ME"; }) @@ -74,7 +73,7 @@ export class SsoScene implements OnInit { console.error(`realDst: '${realDst}'`); setTimeout(function(){ self.router.navigate([ realDst ], { replaceUrl:true }); - }, 2000); // 2 seconds + }, 500); // 2 seconds } else { this.userService.removeSession(); } diff --git a/front/src/common/service/http-wrapper.ts b/front/src/common/service/http-wrapper.ts index 2701004..d951d82 100644 --- a/front/src/common/service/http-wrapper.ts +++ b/front/src/common/service/http-wrapper.ts @@ -62,9 +62,10 @@ export class HttpWrapperService { } addTokenIfNeeded(headerOption:any): any { - if(!isNullOrUndefined(this.session.getToken())) { + const token = this.session.getToken(); + if(!isNullOrUndefined(token)) { if(headerOption.Authorization === undefined) { - headerOption.Authorization = `Yota ${this.session.getToken()}`; + headerOption.Authorization = `Yota ${token}`; } } return headerOption; @@ -72,7 +73,7 @@ export class HttpWrapperService { request(properties: HTTPRequest) : Promise { //uriRest:string, headerOption:any, params:any): Promise<{status:number, data:any}> { - console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ properties.endPoint }'\n\t\tparams=${ JSON.stringify(properties, null, 2)}`); + //console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ properties.endPoint }'\n\t\tparams=${ JSON.stringify(properties, null, 2)}`); let connectionAdresse = this.createRESTCall2({ server: properties.server, @@ -89,11 +90,11 @@ export class HttpWrapperService { if (properties.requestType !== HTTPRequestModel.GET) { headers['Content-Type'] = properties.contentType; } - console.log(`disble tocken : ${JSON.stringify(properties)} properties.disableTocken=${properties.disableTocken}`); - if (properties.disableTocken === undefined || properties.disableTocken === null || properties.disableTocken === true) { + //console.log(`disble tocken : ${JSON.stringify(properties)} properties.disableTocken=${properties.disableTocken}`); + if (properties.disableTocken === undefined || properties.disableTocken === null || properties.disableTocken === false) { headers = this.addTokenIfNeeded(headers); } - console.log(`header: ${JSON.stringify(headers)}`); + //console.log(`header: ${JSON.stringify(headers)}`); let body = properties.body; if (properties.contentType === HTTPMimeType.JSON) { body = JSON.stringify(properties.body); @@ -167,7 +168,10 @@ export class HttpWrapperService { server = environment.defaultServer; } const basePage = environment.server[server]; - let addressServerRest = `${basePage }/`; + let addressServerRest = basePage; + if (!basePage.endsWith("/")) { + addressServerRest = `${basePage}/`; + } let options = inputOptions; if(isNullOrUndefined(options)) { options = {}; @@ -176,7 +180,11 @@ export class HttpWrapperService { if (isArrayOfs(api, isString, isNumber, isBoolean)) { for (let iii=0; iii { if(self.displayReturn === true) { @@ -290,7 +298,7 @@ export class HttpWrapperService { } // Deprecated ... old model stream uploadMultipart(base:string, multipart:FormData, progress: ProgressCallback): any { - console.log(`Upload multipart to ${ base}`); + //console.log(`Upload multipart to ${ base}`); let url = base; let self = this; @@ -301,7 +309,7 @@ export class HttpWrapperService { self.post(url, headers, multipart, progress) .then((response: any) => { - console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`); + //console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`); if(response.status >= 200 && response.status <= 299) { resolve(response.data.body); return; diff --git a/front/src/common/service/index.ts b/front/src/common/service/index.ts index 14c9d04..87020ac 100644 --- a/front/src/common/service/index.ts +++ b/front/src/common/service/index.ts @@ -3,7 +3,7 @@ import { CookiesService } from "./cookies"; import { HttpWrapperService, ModelResponseHttp, HTTPRequest, HTTPMimeType, HTTPRequestModel } from "./http-wrapper"; import { StorageService } from "./local-storage"; import { PopInService } from "./popin"; -import { SessionService } from "./session"; +import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome, SessionService } from "./session"; import { SSOService } from "./sso"; import { UserService } from "./user"; @@ -20,6 +20,10 @@ export { SessionService, UserService, SSOService, + OnlyUsersGuard, + OnlyUsersGuardHome, + OnlyUnregisteredGuardHome, + OnlyAdminGuard, }; diff --git a/front/src/common/service/popin.ts b/front/src/common/service/popin.ts index 263c1f9..5ddeae3 100644 --- a/front/src/common/service/popin.ts +++ b/front/src/common/service/popin.ts @@ -30,11 +30,11 @@ export class PopInService { } open(_id: string) { - //console.log("Try to open pop-in: '" + _id + "'"); + // console.log("Try to open pop-in: '" + _id + "'"); // open popin specified by id for(let iii = 0; iii < this.popins.length; iii++) { if(this.popins[iii].id === _id) { - //console.log(" ==>find it ..."); + // console.log(" ==>find it ..."); this.popins[iii].open(); return; } diff --git a/front/src/common/service/session.ts b/front/src/common/service/session.ts index 4fef44d..b4fc551 100644 --- a/front/src/common/service/session.ts +++ b/front/src/common/service/session.ts @@ -5,6 +5,7 @@ */ import { Injectable, Output, EventEmitter } from '@angular/core'; +import { CanActivate, Router } from '@angular/router'; export enum UserRoles222 { admin = 10000, @@ -38,14 +39,19 @@ export class SessionService { * @param userAdmin - * @param userAvatar - */ - create(sessionId, - userId: string, - userLogin: string, - userEMail: string, - userAdmin: boolean, - userAvatar: string) { - console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} sessionId = ${sessionId}`); - this.tokenJwt = undefined; + create({ sessionId, userId, userLogin, userEMail, userAdmin, userAvatar, tokenJwt }: { + sessionId; + userId: string; + userLogin: string; + userEMail: string; + userAdmin: boolean; + userBlocked: boolean; + userRemoved: boolean; + userAvatar: string; + tokenJwt: string; + }) { + console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} sessionId = ${sessionId} tokenJwt = ${tokenJwt}`); + this.tokenJwt = tokenJwt; this.sessionId = sessionId; this.userId = userId; this.userLogin = userLogin; @@ -70,9 +76,6 @@ export class SessionService { this.userAvatar = null; this.change.emit(false); } - setToken(jwt: string) { - this.tokenJwt = jwt; - } getToken(): string | undefined { return this.tokenJwt; } @@ -110,3 +113,63 @@ export class SessionService { */ } } + +@Injectable() +export class OnlyUsersGuard implements CanActivate { + constructor(private sessionService: SessionService, + private router: Router) {}; + + canActivate() { + console.log("OnlyLoggedInUsers"); + if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) { + return true; + } else { + this.router.navigateByUrl('/forbidden'); + return false; + } + } +} + +@Injectable() +export class OnlyUsersGuardHome implements CanActivate { + constructor(private sessionService: SessionService, + private router: Router) {}; + + canActivate() { + if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) { + return true; + } else { + this.router.navigateByUrl('/unregistered'); + return false; + } + } +} +@Injectable() +export class OnlyUnregisteredGuardHome implements CanActivate { + constructor(private sessionService: SessionService, + private router: Router) {}; + + canActivate() { + if (!this.sessionService.islogged() ) { + return true; + } else { + this.router.navigateByUrl('/home'); + return false; + } + } +} + +@Injectable() +export class OnlyAdminGuard implements CanActivate { + constructor(private sessionService: SessionService, + private router: Router) {}; + + canActivate() { + if (this.sessionService.hasRight(UserRoles222.user)) { + return true; + } else { + this.router.navigateByUrl('/forbidden'); + return false; + } + } +} diff --git a/front/src/common/service/sso.ts b/front/src/common/service/sso.ts index a097c2e..49b52cf 100644 --- a/front/src/common/service/sso.ts +++ b/front/src/common/service/sso.ts @@ -6,50 +6,56 @@ import { Injectable } from '@angular/core'; import { environment } from 'environments/environment'; +import { getApplicationLocation, isInArray, isNullOrUndefined } from 'common/utils'; +import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service'; @Injectable() export class SSOService { + signUpEnable: boolean = undefined; - constructor() { + constructor( + private http: HttpWrapperService, + ) { console.log('Start SSOService'); } utf8_to_b64( str:string ): string { // remove unneeded "=" padding - return window.btoa(unescape(encodeURIComponent( str ))).replace("=", ""); + return window.btoa(encodeURIComponent( str )).replace("=", ""); } b64_to_utf8( str:string ): string { - return decodeURIComponent(escape(window.atob( str ))); + return decodeURIComponent(window.atob( str )); } /** * Request SSO connection */ hashLocalData(data?: string): string { - if (data != undefined) { + if (!isNullOrUndefined(data) && !isInArray(data, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) { return this.utf8_to_b64(data); } - let pathName = window.location.pathname; - console.log("start Path-name: '" + pathName + "'"); - console.log("check with: '" + environment.applName + "/sso/" + "'"); - if (pathName.startsWith("/sso/") || pathName.startsWith(environment.applName + "/sso/")) { + let pathName = getApplicationLocation(); + if (isInArray(pathName, ["sso", "/sso", "/sso/"])) { return this.utf8_to_b64('home'); } - if (pathName.startsWith('/' + environment.applName + '/')) { - pathName = pathName.substring(environment.applName.length+2); - } else if (pathName.startsWith('/' + environment.applName)) { - pathName = pathName.substring(environment.applName.length + 1); - } else if (pathName.startsWith(environment.applName + '/')) { - pathName = pathName.substring(environment.applName.length+1); - } else if (pathName.startsWith(environment.applName)) { - pathName = pathName.substring(environment.applName.length); + if (!isNullOrUndefined(pathName) && !isInArray(pathName, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) { + return this.utf8_to_b64(pathName); } - return this.utf8_to_b64(pathName); + return this.utf8_to_b64('home'); } /** * Request SSO connection */ - unHashLocalData(data: string): string { - return this.b64_to_utf8(data); + unHashLocalData(data: string): string | undefined { + if (isNullOrUndefined(data) || isInArray(data, ["", "null", "NULL", "undefined", "---"])) { + return undefined; + } + try { + return this.b64_to_utf8(data); + } + catch (ex) { + console.error(`Can not convert the data: ${data}`); + } + return undefined; } /** * Request SSO connection @@ -61,9 +67,6 @@ export class SSOService { * Request SSO Disconnect */ requestSignOut(name?: string): void { - if (name === undefined) { - name = 'home'; - } window.location.href = environment.ssoSignOut + this.hashLocalData(name); } /** @@ -72,5 +75,32 @@ export class SSOService { requestSignUp(name?: string): void { window.location.href = environment.ssoSignUp + this.hashLocalData(name); } + /** + * Checo if the signUp is authorized (generate by te SSO) + * @returns a promise of the State for sign-up + */ + checkSignUpEnable(): Promise { + let self = this; + return new Promise((resolve, reject) => { + if (isNullOrUndefined(self.signUpEnable)) { + this.http.requestJson({ + server: 'karauth', + endPoint: 'system_config/is_sign_up_availlable', + requestType: HTTPRequestModel.GET, + accept: HTTPMimeType.JSON, + contentType: HTTPMimeType.JSON, + }).then((response: ModelResponseHttp) =>{ + self.signUpEnable = response.data.signup; + resolve(self.signUpEnable); + }).catch((error:any) => { + reject(`return ERROR ${ JSON.stringify(error, null, 2)}`); + }); + return; + } + resolve(self.signUpEnable); + }); + + } + } diff --git a/front/src/common/service/user.ts b/front/src/common/service/user.ts index 7a19551..eb993c9 100644 --- a/front/src/common/service/user.ts +++ b/front/src/common/service/user.ts @@ -5,12 +5,14 @@ */ import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; import { environment } from 'environments/environment'; import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper'; import { StorageService } from 'common/service/local-storage'; import { SessionService } from './session'; import { SSOService } from './sso'; +import { getApplicationLocation, isNullOrUndefined, sha512 } from 'common/utils'; interface MessageLogIn { login: string; @@ -27,7 +29,6 @@ interface MessageAnswer_USER_CONNECT { avatar: string } -declare function SHA512(param1: any): any; @Injectable() export class UserService { @@ -37,6 +38,7 @@ export class UserService { private cookiesToken = 'token'; constructor( + private router: Router, private storageService: StorageService, private http: HttpWrapperService, private sessionService: SessionService, @@ -55,6 +57,7 @@ export class UserService { removeSession(): void { this.storageService.remove(this.cookiesRememberMe); this.storageService.removeSession(this.cookiesToken); + this.storageService.remove(this.cookiesToken); this.sessionService.destroy(); } @@ -67,11 +70,11 @@ export class UserService { if (elems.length !== 3 ) { return false; } - const tokenHeader = decodeURIComponent(escape(window.atob( elems[0] ))); - const tokenData = decodeURIComponent(escape(window.atob( elems[1] ))); - console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`); + //const tokenHeader = decodeURIComponent(window.atob( elems[0] )); + const tokenData = decodeURIComponent(window.atob( elems[1] )); + //console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`); const parsedData = JSON.parse(tokenData); - console.error(`Retreive exp data=${new Date(parsedData.exp*1000).toISOString()} < ${new Date().toISOString()}`); + console.debug(`Retreive token exp data=${new Date(parsedData.exp*1000).toISOString()} < ${new Date().toISOString()}`); const expireIn = new Date(parsedData.exp*1000); const nowTime = new Date(); // TODO: set a marging of 2 hours... @@ -81,6 +84,7 @@ export class UserService { * Check if the system can be connected */ checkAutoConnect(): Promise { + let locationOrigin = getApplicationLocation(); let self = this; return new Promise((resolve, reject) => { // Need to use the windows global route to prevent the log in cycle ... @@ -96,20 +100,29 @@ export class UserService { console.log(" ==> Check if need reconnect?"); let rememberMe = self.storageService.get(self.cookiesRememberMe)==="true"; // TODO: in case of jest reload ==> no need to manage the SSO ==> just keep the token ... it in enought... - let token = self.storageService.getSession(self.cookiesToken); + let token = null; + if (isNullOrUndefined(environment.tokenStoredInPermanentStorage) || environment.tokenStoredInPermanentStorage !== true) { + token = self.storageService.getSession(self.cookiesToken); + } else { + token = self.storageService.get(self.cookiesToken); + } // TODO: check validity of th eToken: if (self.isTokenUpToDate(token)) { // remove in case of fail !!! this.storageService.removeSession(this.cookiesToken); + this.storageService.remove(this.cookiesToken); self.startSession(token, rememberMe).then(() => { + self.router.navigateByUrl(locationOrigin); + console.log(`update global URL = ${locationOrigin}`); resolve(); }).catch(() => { // jump in the sign-in page (automatically of request remember-me) if(rememberMe) { // jump to the sso !!! (remove local data to prevent login loop) this.storageService.remove(this.cookiesRememberMe); + this.storageService.remove(this.cookiesToken); this.storageService.removeSession(this.cookiesToken); - self.ssoService.requestSignIn(); + self.ssoService.requestSignIn(locationOrigin); reject(); } resolve(); @@ -119,8 +132,9 @@ export class UserService { if(rememberMe) { // jump to the sso !!! (remove local data to prevent login loop) this.storageService.remove(this.cookiesRememberMe); + this.storageService.remove(this.cookiesToken); this.storageService.removeSession(this.cookiesToken); - self.ssoService.requestSignIn(); + self.ssoService.requestSignIn(locationOrigin); reject(); } resolve(); @@ -136,9 +150,11 @@ export class UserService { if(rememberMe === true) { self.storageService.set(self.cookiesRememberMe, rememberMe?"true":"false"); } - // transfer the session token property - self.sessionService.setToken(token); - self.storageService.setSession(self.cookiesToken, token); + if (isNullOrUndefined(environment.tokenStoredInPermanentStorage) || environment.tokenStoredInPermanentStorage !== true) { + self.storageService.setSession(self.cookiesToken, token); + } else { + self.storageService.set(self.cookiesToken, token); + } resolve(self.sessionService.getLogin()); }).catch(() => { reject('sdfsdfsdf'); @@ -160,12 +176,17 @@ export class UserService { // TODO: check type ... console.log(`loginWithToken : get some data to check: ${JSON.stringify(response.data)}`) self.sessionService.create( - response.data.sessionId, - response.data.id, - response.data.login, - response.data.email, - response.data.role, - response.data.avatar); + { + sessionId: response.data.sessionId, + userId: response.data.id, + userLogin: response.data.login, + userEMail: response.data.email, + userAdmin: response.data.admin, + userBlocked: response.data.blocked, + userRemoved: response.data.removed, + userAvatar: response.data.avatar, + tokenJwt: token, + }); resolve(true); }).catch((error:any) => { reject(`return ERROR ${ JSON.stringify(error, null, 2)}`); @@ -174,7 +195,7 @@ export class UserService { } create(login : string, email : string, password : string) { - return this.createSha(login, email, SHA512(password)); + return this.createSha(login, email, sha512(password)); } createSha(login : string, email : string, password : string) { let data = { diff --git a/front/src/common/utils/applPath.ts b/front/src/common/utils/applPath.ts new file mode 100644 index 0000000..5109ec1 --- /dev/null +++ b/front/src/common/utils/applPath.ts @@ -0,0 +1,17 @@ +import { environment } from "environments/environment"; + +export function getApplicationLocation(): string { + let pathName = location.pathname; + //console.log("start Path-name: '" + pathName + "'"); + //console.log("check with: '" + environment.applName + "/sso/" + "'"); + if (pathName.startsWith('/' + environment.applName + '/')) { + pathName = pathName.substring(environment.applName.length+2); + } else if (pathName.startsWith('/' + environment.applName)) { + pathName = pathName.substring(environment.applName.length + 1); + } else if (pathName.startsWith(environment.applName + '/')) { + pathName = pathName.substring(environment.applName.length+1); + } else if (pathName.startsWith(environment.applName)) { + pathName = pathName.substring(environment.applName.length); + } + return pathName; +} \ No newline at end of file diff --git a/front/src/common/utils/dataInterface.ts b/front/src/common/utils/dataInterface.ts index 72aaa0d..636d402 100644 --- a/front/src/common/utils/dataInterface.ts +++ b/front/src/common/utils/dataInterface.ts @@ -30,7 +30,6 @@ export interface SelectModel { * @breif Generic interface to access to the BDD (no BDD, direct file IO) */ export class DataInterface { - static extractLimitOne(data: NodeData[], key: string): any[] { const out = []; for (let iii=0; iii> 5] |= (str.charCodeAt(i / charsize) & mask) << (32 - charsize - (i % 32)); } @@ -76,12 +76,12 @@ function SHA512(str) { } function binb2hex(binarray) { - var hex_tab = "0123456789abcdef"; - var str = ""; - var length = binarray.length * 4; - var srcByte; + let hex_tab = "0123456789abcdef"; + let str = ""; + let length = binarray.length * 4; + let srcByte; - for (var i = 0; i < length; i += 1) { + for (let i = 0; i < length; i += 1) { srcByte = binarray[i >> 2] >> ((3 - (i % 4)) * 8); str += hex_tab.charAt((srcByte >> 4) & 0xF) + hex_tab.charAt(srcByte & 0xF); } @@ -90,7 +90,7 @@ function SHA512(str) { } function safe_add_2(x, y) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (x.lowOrder & 0xFFFF) + (y.lowOrder & 0xFFFF); msw = (x.lowOrder >>> 16) + (y.lowOrder >>> 16) + (lsw >>> 16); @@ -104,7 +104,7 @@ function SHA512(str) { } function safe_add_4(a, b, c, d) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) + (c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF); msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) + (c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (lsw >>> 16); @@ -118,7 +118,7 @@ function SHA512(str) { } function safe_add_5(a, b, c, d, e) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) + (c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF) + (e.lowOrder & 0xFFFF); msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) + (c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (e.lowOrder >>> 16) + (lsw >>> 16); @@ -160,9 +160,9 @@ function SHA512(str) { } function sigma0(x) { - var rotr28 = rotr(x, 28); - var rotr34 = rotr(x, 34); - var rotr39 = rotr(x, 39); + let rotr28 = rotr(x, 28); + let rotr34 = rotr(x, 34); + let rotr39 = rotr(x, 39); return new int64( rotr28.highOrder ^ rotr34.highOrder ^ rotr39.highOrder, @@ -171,9 +171,9 @@ function SHA512(str) { } function sigma1(x) { - var rotr14 = rotr(x, 14); - var rotr18 = rotr(x, 18); - var rotr41 = rotr(x, 41); + let rotr14 = rotr(x, 14); + let rotr18 = rotr(x, 18); + let rotr41 = rotr(x, 41); return new int64( rotr14.highOrder ^ rotr18.highOrder ^ rotr41.highOrder, @@ -182,7 +182,7 @@ function SHA512(str) { } function gamma0(x) { - var rotr1 = rotr(x, 1), rotr8 = rotr(x, 8), shr7 = shr(x, 7); + let rotr1 = rotr(x, 1), rotr8 = rotr(x, 8), shr7 = shr(x, 7); return new int64( rotr1.highOrder ^ rotr8.highOrder ^ shr7.highOrder, @@ -191,9 +191,9 @@ function SHA512(str) { } function gamma1(x) { - var rotr19 = rotr(x, 19); - var rotr61 = rotr(x, 61); - var shr6 = shr(x, 6); + let rotr19 = rotr(x, 19); + let rotr61 = rotr(x, 61); + let shr6 = shr(x, 6); return new int64( rotr19.highOrder ^ rotr61.highOrder ^ shr6.highOrder, @@ -216,13 +216,13 @@ function SHA512(str) { } str = utf8_encode(str); - strlen = str.length*charsize; + let strlen = str.length*charsize; str = str2binb(str); str[strlen >> 5] |= 0x80 << (24 - strlen % 32); str[(((strlen + 128) >> 10) << 5) + 31] = strlen; - for (var i = 0; i < str.length; i += 32) { + for (let i = 0; i < str.length; i += 32) { a = H[0]; b = H[1]; c = H[2]; @@ -232,7 +232,7 @@ function SHA512(str) { g = H[6]; h = H[7]; - for (var j = 0; j < 80; j++) { + for (let j = 0; j < 80; j++) { if (j < 16) { W[j] = new int64(str[j*2 + i], str[j*2 + i + 1]); } else { @@ -261,8 +261,8 @@ function SHA512(str) { H[7] = safe_add_2(h, H[7]); } - var binarray = []; - for (var i = 0; i < H.length; i++) { + let binarray = []; + for (let i = 0; i < H.length; i++) { binarray.push(H[i].highOrder); binarray.push(H[i].lowOrder); } diff --git a/front/src/common/utils/validator.ts b/front/src/common/utils/validator.ts index 24f44cf..a5cf2bd 100644 --- a/front/src/common/utils/validator.ts +++ b/front/src/common/utils/validator.ts @@ -23,11 +23,22 @@ export function isUndefined(data: any): data is undefined { export function isNullOrUndefined(data: any): data is undefined | null { return data === undefined || data === null; } +export function isStringNullOrUndefined(data: any): data is undefined | null { + return data === "undefined" || data === "null" || data === ""; +} export function isObject(data: any): data is any { return !isNullOrUndefined(data) && typeof data === 'object' && !isArray(data); } +export function isInArray(data: any, listElment: any[]): boolean { + for (let iii=0; iii(data: any, typeChecker: (subData: any) => subData is TYPE, length?: number): data is TYPE[] { if (!isArray(data)) { diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts index bcb557a..6bcd629 100644 --- a/front/src/environments/environment.prod.ts +++ b/front/src/environments/environment.prod.ts @@ -4,7 +4,7 @@ // The list of which env maps to which file can be found in `.angular-cli.json`. export const environment = { - production: false, + production: true, // URL of development API applName: "karusic", defaultServer: "karusic", @@ -16,5 +16,5 @@ export const environment = { ssoSignUp: `${location.origin}/karso/signup/karusic/`, ssoSignOut: `${location.origin}/karso/signout/karusic/`, frontBaseUrl: '', - apiMode: 'REWRITE' -}; \ No newline at end of file + tokenStoredInPermanentStorage: false, +}; diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts index 356de3d..0c58a7e 100644 --- a/front/src/environments/environment.ts +++ b/front/src/environments/environment.ts @@ -3,7 +3,7 @@ // `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_back_prod = { +const environment_back_prod = { production: false, // URL of development API applName: "karusic", @@ -16,10 +16,10 @@ export const environment_back_prod = { ssoSignUp: 'http://192.168.1.156/karso/signup/karusic-dev/', ssoSignOut: 'http://192.168.1.156/karso/signout/karusic-dev/', frontBaseUrl: '', - apiMode: 'REWRITE' + tokenStoredInPermanentStorage: false, }; -export const environment_local = { +const environment_local = { production: false, // URL of development API applName: "karusic", @@ -32,10 +32,10 @@ export const environment_local = { ssoSignUp: 'http://192.168.1.156/karso/signup/karusic-dev/', ssoSignOut: 'http://192.168.1.156/karso/signout/karusic-dev/', frontBaseUrl: '', - apiMode: 'REWRITE' + tokenStoredInPermanentStorage: false, }; -export const environment_full_local = { +const environment_full_local = { production: false, // URL of development API applName: "karusic", @@ -48,10 +48,10 @@ export const environment_full_local = { ssoSignUp: 'http://localhost:4200/signup/karusic-dev/', ssoSignOut: 'http://localhost:4200/signout/karusic-dev/', frontBaseUrl: '', - apiMode: 'REWRITE' + tokenStoredInPermanentStorage: false, }; -export const environment_hybrid = { +const environment_hybrid = { production: false, // URL of development API applName: "karusic", @@ -64,7 +64,7 @@ export const environment_hybrid = { ssoSignUp: 'http://localhost:4200/signup/karusic-dev/', ssoSignOut: 'http://localhost:4200/signout/karusic-dev/', frontBaseUrl: '', - apiMode: 'REWRITE' + tokenStoredInPermanentStorage: false, }; -export const environment = environment_full_local; +export const environment = environment_back_prod; diff --git a/front/src/index.html b/front/src/index.html index b4ed11e..421ed05 100644 --- a/front/src/index.html +++ b/front/src/index.html @@ -18,10 +18,6 @@ - - - -
diff --git a/readme.md b/readme.md index f72ef32..5c311cb 100644 --- a/readme.md +++ b/readme.md @@ -22,6 +22,9 @@ docker-compose up -d build the local image: +docker pull archlinux:base-devel +docker pull bellsoft/liberica-openjdk-alpine:latest + docker build -t gitea.atria-soft.org/kangaroo-and-rabbit/karusic:latest . docker login gitea.atria-soft.org