[DEV] Update to manage new interface of karauth

This commit is contained in:
Edouard DUPIN 2022-11-22 22:40:24 +01:00
parent 62da0f878c
commit e4883e6176
25 changed files with 494 additions and 43 deletions

View File

@ -36,6 +36,7 @@ public class WebLauncher {
}
public static void main(String[] args) {
ConfigBaseVariable.bdDatabase = "karusic";
//
// if (false) {

View File

@ -0,0 +1,17 @@
package org.kar.karusic;
import org.kar.archidata.util.ConfigBaseVariable;
public class WebLauncherLocal {
private WebLauncherLocal() {}
public static void main(String[] args) throws InterruptedException {
if (true) {
// for local test:
ConfigBaseVariable.apiAdress = "http://0.0.0.0:19080/karusic/api/";
ConfigBaseVariable.dbPort = "3306";
ConfigBaseVariable.ssoAdress = "http://localhost:15080/karauth/api/";
}
WebLauncher.main(args);
}
}

View File

@ -7,7 +7,7 @@ import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Album;
import org.kar.karusic.model.Track;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -6,7 +6,7 @@ import org.kar.karusic.model.Artist;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -3,15 +3,15 @@ package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.annotation.PermitTokenInURI;
import org.kar.archidata.annotation.security.PermitTokenInURI;
import org.kar.archidata.filter.GenericContext;
import org.kar.archidata.util.ConfigBaseVariable;
import org.kar.archidata.util.DataTools;
import org.kar.archidata.db.DBEntry;
import org.kar.karusic.model.DataSmall;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.PermitAll;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.imageio.ImageIO;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
@ -23,6 +23,7 @@ import javax.ws.rs.core.StreamingOutput;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.file.Files;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -90,8 +91,8 @@ public class DataResource {
DataSmall value = getSmall(id);
if (value == null) {
Response.status(404).
entity("media NOT FOUND: " + id).
type("text/plain").
entity("{\"error\":\"media NOT FOUND: " + id + "\"}").
type("application/json").
build();
}
return buildStream(ConfigBaseVariable.getMediaDataFolder() + File.separator + id + File.separator + "data", range, value.mimeType);
@ -108,20 +109,27 @@ public class DataResource {
System.out.println("===================================================");
System.out.println("== DATA retriveDataThumbnailId ? " + (gc==null?"null":gc.user));
System.out.println("===================================================");
System.out.println("==id = " + id);
DataSmall value = getSmall(id);
if (value == null) {
return Response.status(404).
entity("media NOT FOUND: " + id).
type("text/plain").
entity("{\"error\":\"media NOT FOUND: " + id + "\"}").
type("application/json").
build();
}
String filePathName = ConfigBaseVariable.getMediaDataFolder() + File.separator + id + File.separator + "data";
File inputFile = new File(filePathName);
if (!inputFile.exists()) {
return Response.status(404).
entity("{\"error\":\"media Does not exist: " + id + "\"}").
type("application/json").
build();
}
if ( value.mimeType.contentEquals("image/jpeg")
|| value.mimeType.contentEquals("image/png")
// || value.mimeType.contentEquals("image/webp")
) {
// reads input image
File inputFile = new File(filePathName);
BufferedImage inputImage = ImageIO.read(inputFile);
int scaledWidth = 250;
int scaledHeight = (int)((float)inputImage.getHeight() / (float)inputImage.getWidth() * (float) scaledWidth);

View File

@ -3,7 +3,7 @@ package org.kar.karusic.api;
import java.io.File;
import java.util.List;
import javax.annotation.security.PermitAll;
import org.kar.archidata.annotation.security.PermitAll;
import javax.ws.rs.*;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.PathSegment;

View File

@ -7,7 +7,7 @@ import org.kar.karusic.model.Gender;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -1,6 +1,6 @@
package org.kar.karusic.api;
import javax.annotation.security.PermitAll;
import org.kar.archidata.annotation.security.PermitAll;
import javax.ws.rs.core.Response;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

View File

@ -6,7 +6,7 @@ import org.kar.karusic.model.Playlist;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -10,7 +10,7 @@ import org.kar.karusic.model.Track;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -2,14 +2,13 @@ package org.kar.karusic.api;
import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.SqlWrapper;
import org.kar.karusic.WebLauncher;
import org.kar.archidata.db.DBEntry;
import org.kar.archidata.filter.GenericContext;
import org.kar.archidata.model.User;
import org.kar.karusic.model.UserKarusic;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import org.kar.archidata.annotation.security.PermitAll;
import org.kar.archidata.annotation.security.RolesAllowed;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

View File

@ -39,4 +39,5 @@ docker build -t gitea.atria-soft.org/kangaroo-and-rabbit/karideo:latest .
docker login gitea.atria-soft.org
docker push gitea.atria-soft.org/kangaroo-and-rabbit/karideo:latest
docker push gitea.atria-soft.org/kangaroo-and-rabbit/karideo:latest

View File

@ -1,10 +1,5 @@
<!-- exercice section -->
<app-top-menu></app-top-menu>
<!--
<div class="main-content" ng-include="currentDisplay" ng-if="currentDisplay != ''"></div>
<div class="main-modal" ng-include="currentModal" ng-if="currentModal != ''" ></div> <!-- (click)="onOutModal()" -->
-->
<div class="main-content">
<router-outlet *ngIf="autoConnectedDone"></router-outlet>
<div class="generic-page" *ngIf="!isConnected">

View File

@ -109,7 +109,7 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent,
PopInComponent,
PopInUploadProgress,
PopInDeleteConfirm,
],
],
bootstrap: [
AppComponent
],

View File

@ -0,0 +1,47 @@
<div class="top">
<div id="main-menu" class="main-menu color-menu-background">
<div *ngFor="let data of menu">
<button class="item"
(click)="onGeneric(data, $event)"
(auxclick)="onGeneric(data, $event)"
[ngStyle]="{'float': data.position}"
[disable]="false">
<div class="xdesktop" *ngIf="data.icon">
<i class="material-icons">{{data.icon}}</i> {{data.title}}
</div>
<div class="xmobile" *ngIf="data.icon">
<i class="material-icons">{{data.icon}}</i>
</div>
<div class="xdesktop" *ngIf="!data.icon">
{{data.title}}
</div>
</button>
</div>
</div>
<div class="fill-all" *ngIf="subMenu" (click)="onOutUserProperty()">
<div class="sub-menu menu-left color-menu-background">
<div *ngFor="let data of subMenu">
<button class="item"
(click)="onGeneric(data, $event)"
(auxclick)="onGeneric(data, $event)"
[ngStyle]="{'float': data.position}"
[disable]="false">
<div class="xdesktop"
*ngIf="data.icon"
[ngStyle]="{'float': data.position}">
<i class="material-icons">{{data.icon}}</i> {{data.title}}
</div>
<div class="xmobile"
*ngIf="data.icon"
[ngStyle]="{'float': data.position}">
<i class="material-icons">{{data.icon}}</i>
</div>
<div *ngIf="!data.icon"
[ngStyle]="{'float': data.position}">
{{data.title}}
</div>
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,176 @@
.element-pos-left {
z-index: 5;
float: left;
}
.element-pos-right {
z-index: 5;
float: right;
}
.element-pos-center {
z-index: 5;
float: none;
}
.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;
}
}
.menu-left {
top:75px;
left:15px;
}
.menu-right {
top:75px;
right:15px;
}
.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;
}
}
}

View File

@ -0,0 +1,67 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { isNullOrUndefined } from '../../utils';
import { MenuItem } from '../../model/menu-item';
@Component({
selector: 'app-top-menu',
templateUrl: './top-menu.html',
styleUrls: [ './top-menu.less' ]
})
export class TopMenuComponent implements OnInit {
@Input() menu: MenuItem[];
subMenu: MenuItem[] = null;
constructor(private router: Router) {
}
getPosition(data: string) : string {
return `float: ${data}`;
}
ngOnInit() {
}
onOutUserProperty(): void {
console.log('onOutUserProperty ==> event...');
this.subMenu = undefined;
}
onGeneric(data: MenuItem, event: any): void {
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.router.navigate([ data.navigateTo ]);
return;
}
// check if we need to display a submenu
if (isNullOrUndefined(data.subMenu)) {
console.log("No menu !!!");
//just a toggle mode:
data.subMenu = undefined;
return;
}
if (this.subMenu === data.subMenu) {
console.log("Toggle menu");
//just a toggle mode:
this.subMenu = undefined;
return;
}
console.log(`Set Menu: ${JSON.stringify(data.subMenu)}`);
// set the requested menu
this.subMenu = data.subMenu;
}
}

View File

@ -0,0 +1,58 @@
import { isNumberFinite, isObject, isOptionalOf, isString, isNullOrUndefined, isOptionalArrayOf } from "../utils";
export enum MenuPosition {
LEFT = "left",
RIGHT = "right",
CENTER = "none",
}
export function isMenuPosition(data: any): data is MenuPosition {
return data === "left"
|| data === "right"
|| data === "none";
}
export interface MenuItem {
// Position of the menue element
position: MenuPosition;
// Hover help
hover?: string;
// Icon of the menue (need to be a meterial-icon name
icon?: string;
// Displayed Title
title: string;
// Jump Link (If undefined: it is considered as text and not a button)
navigateTo?: string;
// Menu model For a subList of elements
subMenu?: MenuItem[];
};
export function isMenuItem(data: any): data is MenuItem {
if (isNullOrUndefined(data)) {
return false;
}
if (!isObject(data)) {
return false;
}
if (!isMenuPosition(data.position)) {
return false;
}
if (!isOptionalOf(data.hover, isString)) {
return false;
}
if (!isOptionalOf(data.icon, isString)) {
return false;
}
if (!isString(data.title)) {
return false;
}
if (!isOptionalOf(data.navigateTo, isString)) {
return false;
}
if (!isOptionalArrayOf(data.subMenu, isMenuItem)) {
return false;
}
return true;
}

View File

@ -0,0 +1,6 @@
<div class="full-mode">
<div class="centered">
<div class="error"><label class="unselectable"><i class="material-icons">block</i> 403 Forbidden</label></div>
<div class="comment"><label class="unselectable">You don't have permission to access this resource.</label></div>
</div>
</div>

View File

@ -0,0 +1,51 @@
.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:500px;
padding: 16px 32px 16px 32px;
top: 50%;
left: 50%;
transform: ~"translate(-50%, -50%)";
font-size: 30px;
font-weight: 600;
text-align: left;
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;
}

View File

@ -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-forbidden',
templateUrl: './forbidden.html',
styleUrls: [ './forbidden.less' ]
})
export class ForbiddenScene {
constructor() { }
}

View File

@ -16,7 +16,7 @@ import { environment } from 'environments/environment';
}
set(cname: string, cvalue: string): void {
console.error(`storage set: ${cname} : ${cvalue}`);
//console.debug(`storage set: ${cname} : ${cvalue}`);
localStorage.setItem(this.baseLocalStorageName + cname, cvalue);
}
// limit at the current session ...
@ -25,7 +25,7 @@ import { environment } from 'environments/environment';
}
remove(cname: string) : void {
console.error(`storage remove: ${cname}`);
//console.debug(`storage remove: ${cname}`);
localStorage.removeItem(this.baseLocalStorageName + cname);
}
removeSession(cname: string) : void {
@ -33,10 +33,10 @@ import { environment } from 'environments/environment';
}
get(cname: string) : string | undefined {
console.error(`storage get: ${cname}`);
//console.debug(`storage get: ${cname}`);
// TODO check expire day...
const data = localStorage.getItem(this.baseLocalStorageName + cname);
console.log(`get value form the storage (1): ${data}`)
//console.debug(`get value form the storage (1): ${data}`)
if (data === null || data === undefined) {
return undefined;
}
@ -51,4 +51,4 @@ import { environment } from 'environments/environment';
}
}

View File

@ -9,12 +9,12 @@ export const environment = {
applName: "karusic",
defaultServer: "karusic",
server: {
karusic: 'http://192.168.1.156/karusic/api',
karauth: 'http://192.168.1.156/karauth/api',
karusic: `${location.origin}/karusic/api`,
karauth: `${location.origin}/karauth/api`,
},
ssoSignIn: 'http://192.168.1.156/karso/signin/karusic/',
ssoSignUp: 'http://192.168.1.156/karso/signup/karusic/',
ssoSignOut: 'http://192.168.1.156/karso/signout/karusic/',
ssoSignIn: `${location.origin}/karso/signin/karusic/`,
ssoSignUp: `${location.origin}/karso/signup/karusic/`,
ssoSignOut: `${location.origin}/karso/signout/karusic/`,
frontBaseUrl: '',
apiMode: 'REWRITE'
};

View File

@ -35,6 +35,22 @@ export const environment_local = {
apiMode: 'REWRITE'
};
export const environment_full_local = {
production: false,
// URL of development API
applName: "karusic",
defaultServer: "karusic",
server: {
karusic: 'http://localhost:19080/karusic/api',
karauth: 'http://localhost:15080/karauth/api',
},
ssoSignIn: 'http://localhost:4200/signin/karusic-dev/',
ssoSignUp: 'http://localhost:4200/signup/karusic-dev/',
ssoSignOut: 'http://localhost:4200/signout/karusic-dev/',
frontBaseUrl: '',
apiMode: 'REWRITE'
};
export const environment_hybrid = {
production: false,
// URL of development API
@ -50,5 +66,5 @@ export const environment_hybrid = {
frontBaseUrl: '',
apiMode: 'REWRITE'
};
export const environment = environment_back_prod;
export const environment = environment_full_local;

View File

@ -1,7 +0,0 @@
/* SystemJS module definition */
interface NodeModule {
id: string;
}
declare let module: NodeModule;