[DEV] super update de generisation back et front ==> nearly stable

This commit is contained in:
Edouard DUPIN 2022-12-16 00:57:53 +01:00
parent e4883e6176
commit f148a38c5d
81 changed files with 6324 additions and 12323 deletions

View File

@ -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/

View File

@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kar</groupId>
<groupId>org.kar</groupId>
<artifactId>karusic</artifactId>
<version>0.1.0</version>
<properties>
@ -11,12 +11,18 @@
<maven.dependency.version>3.1.1</maven.dependency.version>
</properties>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>kar</groupId>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.1.0</version>
<version>0.1.3</version>
</dependency>
</dependencies>
@ -62,19 +68,19 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Create coverage -->
<!--
<plugin>

View File

@ -11,7 +11,6 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.kar.karusic.api.AlbumResource;
import org.kar.karusic.api.ArtistResource;
import org.kar.karusic.api.DataResource;
import org.kar.karusic.api.Front;
import org.kar.karusic.api.GenderResource;
import org.kar.karusic.api.HealthCheck;
@ -21,6 +20,7 @@ import org.kar.karusic.api.UserResource;
import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.UpdateJwtPublicKey;
import org.kar.archidata.api.DataResource;
import org.kar.archidata.filter.AuthenticationFilter;
import org.kar.archidata.filter.CORSFilter;
import org.kar.archidata.filter.OptionFilter;
@ -38,58 +38,21 @@ public class WebLauncher {
public static void main(String[] args) {
ConfigBaseVariable.bdDatabase = "karusic";
//
// if (false) {
// Track tmpTrack = new Track();
// tmpTrack.dataId = (long) 542;
// tmpTrack.genderId = (long) 15;
// tmpTrack.description = "my beautifull description";
// tmpTrack.name = "I am singging in the rain.";
// try {
// //Track tmpTrack2 = new SqlWrapper().insert(tmpTrack);
// //System.out.println("receive data = " + tmpTrack2);
//
// SqlWrapper.update(Track.class, 2, "{\"deleted\": true }");
// Object gettedValue = SqlWrapper.get(Track.class, 2);
// System.out.println("retreive data = " + gettedValue);
// List<Track> allValues = SqlWrapper.gets(Track.class, true);
// System.out.println("retreive data:");
// for (Object elem: allValues) {
// System.out.println(" - " + elem);
// }
// } catch (Exception e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// }
// }
//
// if (false) {
// generate the BDD:
try {
String out = "";
//out += SqlWrapper.createTable(User.class);
out += SqlWrapper.createTable(Track.class);
// generate the BDD:
try {
String out = "";
//out += SqlWrapper.createTable(User.class);
out += SqlWrapper.createTable(Track.class);
// out += SqlWrapper.createTable(Artist.class);
// out += SqlWrapper.createTable(Gender.class);
// out += SqlWrapper.createTable(Playlist.class);
// out += SqlWrapper.createTable(Album.class);
System.out.println(out);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// return;
// }
// if (false) {
// // generate the BDD:
// /*
// String out = new Artist().getQueryString();
// System.out.println("The query:");
// System.out.println(out);
// return;
// */
// }
//
System.out.println(out);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// ===================================================================
// Configure resources
// ===================================================================
@ -155,5 +118,12 @@ public class WebLauncher {
System.out.println("There was an error while starting Grizzly HTTP server.");
e.printStackTrace();
}
keyUpdater.kill();
try {
keyUpdater.join(4000, 0);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -9,8 +9,8 @@ public class WebLauncherLocal {
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/";
//ConfigBaseVariable.ssoAdress = "http://localhost:15080/karauth/api/";
ConfigBaseVariable.ssoAdress = "https://atria-soft.org/karauth/api/";
}
WebLauncher.main(args);
}

View File

@ -1,252 +0,0 @@
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.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 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;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
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;
import java.util.Date;
// https://stackoverflow.com/questions/35367113/jersey-webservice-scalable-approach-to-download-file-and-reply-to-client
// https://gist.github.com/aitoroses/4f7a2b197b732a6a691d
@Path("/data")
@Produces({MediaType.APPLICATION_JSON})
public class DataResource {
public DataSmall getSmall(Long id) {
DBEntry entry = new DBEntry(GlobalConfiguration.dbConfig);
String query = "SELECT `id`, `sha512`, `mime_type`, `size` FROM `data` WHERE `deleted` = false AND `id` = ?";
try {
PreparedStatement ps = entry.connection.prepareStatement(query);
ps.setLong(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
DataSmall out = new DataSmall(rs);
entry.disconnect();
return out;
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
entry.disconnect();
return null;
}
@POST
@Path("/upload/")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@RolesAllowed("ADMIN")
public Response uploadFile(@Context SecurityContext sc, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileMetaData) {
GenericContext gc = (GenericContext) sc.getUserPrincipal();
System.out.println("===================================================");
System.out.println("== DATA uploadFile " + (gc==null?"null":gc.user));
System.out.println("===================================================");
//public NodeSmall uploadFile(final FormDataMultiPart form) {
System.out.println("Upload file: ");
String filePath = DataTools.getTmpFolder();
try {
DataTools.createFolder(ConfigBaseVariable.getTmpDataFolder() + File.separator);
} catch (IOException e) {
e.printStackTrace();
}
DataTools.saveFile(fileInputStream, filePath);
return Response.ok("Data uploaded successfully !!").build();
//return null;
}
@GET
@Path("{id}")
@PermitTokenInURI
@RolesAllowed("USER")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response retriveDataId(@Context SecurityContext sc, @QueryParam(HttpHeaders.AUTHORIZATION) String token, @HeaderParam("Range") String range, @PathParam("id") Long id) throws Exception {
GenericContext gc = (GenericContext) sc.getUserPrincipal();
System.out.println("===================================================");
System.out.println("== DATA retriveDataId ? " + (gc==null?"null":gc.user));
System.out.println("===================================================");
DataSmall value = getSmall(id);
if (value == null) {
Response.status(404).
entity("{\"error\":\"media NOT FOUND: " + id + "\"}").
type("application/json").
build();
}
return buildStream(ConfigBaseVariable.getMediaDataFolder() + File.separator + id + File.separator + "data", range, value.mimeType);
}
@GET
@Path("thumbnail/{id}")
@RolesAllowed("USER")
@PermitTokenInURI
@Produces(MediaType.APPLICATION_OCTET_STREAM)
//@CacheMaxAge(time = 10, unit = TimeUnit.DAYS)
public Response retriveDataThumbnailId(@Context SecurityContext sc, @QueryParam(HttpHeaders.AUTHORIZATION) String token, @HeaderParam("Range") String range, @PathParam("id") Long id) throws Exception {
GenericContext gc = (GenericContext) sc.getUserPrincipal();
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("{\"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
BufferedImage inputImage = ImageIO.read(inputFile);
int scaledWidth = 250;
int scaledHeight = (int)((float)inputImage.getHeight() / (float)inputImage.getWidth() * (float) scaledWidth);
// creates output image
BufferedImage outputImage = new BufferedImage(scaledWidth,
scaledHeight, inputImage.getType());
// scales the input image to the output image
Graphics2D g2d = outputImage.createGraphics();
g2d.drawImage(inputImage, 0, 0, scaledWidth, scaledHeight, null);
g2d.dispose();
// create the oputput stream:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(outputImage, "JPG", baos);
byte[] imageData = baos.toByteArray();
Response.ok(new ByteArrayInputStream(imageData)).build();
Response.ResponseBuilder out = Response.ok(imageData)
.header(HttpHeaders.CONTENT_LENGTH, imageData.length);
out.type("image/jpeg");
return out.build();
}
return buildStream(filePathName, range, value.mimeType);
}
//@Secured
@GET
@Path("{id}/{name}")
@PermitTokenInURI
//@RolesAllowed("USER")
@PermitAll
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response retriveDataFull(@Context SecurityContext sc, @QueryParam(HttpHeaders.AUTHORIZATION) String token, @HeaderParam("Range") String range, @PathParam("id") Long id, @PathParam("name") String name) throws Exception {
GenericContext gc = (GenericContext) sc.getUserPrincipal();
System.out.println("===================================================");
System.out.println("== DATA retriveDataFull ? " + (gc==null?"null":gc.user));
System.out.println("===================================================");
DataSmall value = getSmall(id);
if (value == null) {
Response.status(404).
entity("media NOT FOUND: " + id).
type("text/plain").
build();
}
return buildStream(ConfigBaseVariable.getMediaDataFolder() + File.separator + id + File.separator + "data", range, value.mimeType);
}
/**
* Adapted from http://stackoverflow.com/questions/12768812/video-streaming-to-ipad-does-not-work-with-tapestry5/12829541#12829541
*
* @param range range header
* @return Streaming output
* @throws Exception IOException if an error occurs in streaming.
*/
private Response buildStream(final String filename, final String range, String mimeType) throws Exception {
File file = new File(filename);
//System.out.println("request range : " + range);
// range not requested : Firefox does not send range headers
if (range == null) {
final StreamingOutput output = new StreamingOutput() {
@Override
public void write(OutputStream out) {
try (FileInputStream in = new FileInputStream(file)) {
byte[] buf = new byte[1024 * 1024];
int len;
while ((len = in.read(buf)) != -1) {
try {
out.write(buf, 0, len);
out.flush();
//System.out.println("---- wrote " + len + " bytes file ----");
} catch (IOException ex) {
System.out.println("remote close connection");
break;
}
}
} catch (IOException ex) {
throw new InternalServerErrorException(ex);
}
}
};
Response.ResponseBuilder out = Response.ok(output)
.header(HttpHeaders.CONTENT_LENGTH, file.length());
if (mimeType != null) {
out.type(mimeType);
}
return out.build();
}
String[] ranges = range.split("=")[1].split("-");
final long from = Long.parseLong(ranges[0]);
//System.out.println("request range : " + ranges.length);
//Chunk media if the range upper bound is unspecified. Chrome, Opera sends "bytes=0-"
long to = DataTools.CHUNK_SIZE + from;
if (ranges.length == 1) {
to = file.length() - 1;
} else {
if (to >= file.length()) {
to = (long) (file.length() - 1);
}
}
final String responseRange = String.format("bytes %d-%d/%d", from, to, file.length());
//System.out.println("responseRange : " + responseRange);
final RandomAccessFile raf = new RandomAccessFile(file, "r");
raf.seek(from);
final long len = to - from + 1;
final MediaStreamer streamer = new MediaStreamer(len, raf);
Response.ResponseBuilder out = Response.ok(streamer)
.status(Response.Status.PARTIAL_CONTENT)
.header("Accept-Ranges", "bytes")
.header("Content-Range", responseRange)
.header(HttpHeaders.CONTENT_LENGTH, streamer.getLenth())
.header(HttpHeaders.LAST_MODIFIED, new Date(file.lastModified()));
if (mimeType != null) {
out.type(mimeType);
}
return out.build();
}
}

View File

@ -1,71 +0,0 @@
package org.kar.karusic.api;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.StreamingOutput;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
public class MediaStreamer implements StreamingOutput {
private final int CHUNK_SIZE = 1024 * 1024; // 1MB chunks
final byte[] buf = new byte[CHUNK_SIZE];
private long length;
private RandomAccessFile raf;
public MediaStreamer(long length, RandomAccessFile raf) throws IOException {
//System.out.println("request stream of " + length / 1024 + " data");
if (length<0) {
throw new IOException("Wrong size of the file to stream: " + length);
}
this.length = length;
this.raf = raf;
}
/*
public void write(OutputStream out) {
try (FileInputStream in = new FileInputStream(file)) {
byte[] buf = new byte[1024*1024];
int len;
while ((len = in.read(buf)) != -1) {
out.write(buf, 0, len);
out.flush();
//System.out.println("---- wrote " + len + " bytes file ----");
}
} catch (IOException ex) {
throw new InternalServerErrorException(ex);
}
}
*/
@Override
public void write(OutputStream outputStream) {
try {
while (length != 0) {
int read = raf.read(buf, 0, buf.length > length ? (int) length : buf.length);
try {
outputStream.write(buf, 0, read);
} catch (IOException ex) {
System.out.println("remote close connection");
break;
}
length -= read;
}
} catch (IOException ex) {
throw new InternalServerErrorException(ex);
} catch (WebApplicationException ex) {
throw new InternalServerErrorException(ex);
} finally {
try {
raf.close();
} catch (IOException ex) {
ex.printStackTrace();
throw new InternalServerErrorException(ex);
}
}
}
public long getLenth() {
return length;
}
}

View File

@ -1,25 +1,15 @@
package org.kar.karusic.api;
import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.SqlWrapper;
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 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;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
@ -30,30 +20,6 @@ public class UserResource {
public UserResource() {
}
// private static String randomString(int count) {
// Random rand = new Random(System.nanoTime());
// String s = new String();
// int nbChar = count;
// for (int i = 0; i < nbChar; i++) {
// char c = (char) rand.nextInt();
// while ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9'))
// c = (char) rand.nextInt();
// s = s + c;
// }
// return s;
// }
// I do not understand why angular request option before, but this is needed..
/*
@OPTIONS
public Response getOption(){
return Response.ok()
.header("Allow", "POST")
.header("Allow", "GET")
.header("Allow", "OPTIONS")
.build();
}
*/
// curl http://localhost:9993/api/users
@GET
@RolesAllowed("ADMIN")
@ -68,18 +34,6 @@ public class UserResource {
return null;
}
// I do not understand why angular request option before, but this is needed..
/*
@OPTIONS
@Path("{id}")
public Response getTokenOption(@PathParam("id") long userId){
return Response.ok()
.header("Allow", "POST")
.header("Allow", "GET")
.header("Allow", "OPTIONS")
.build();
}
*/
// curl http://localhost:9993/api/users/3
@GET
@Path("{id}")
@ -99,16 +53,6 @@ public class UserResource {
return null;
}
/*
@OPTIONS
@Path("me")
public Response getOptionMe(){
return Response.ok()
.header("Allow", "GET")
.header("Allow", "OPTIONS")
.build();
}
*/
// curl http://localhost:9993/api/users/3
@GET
@Path("me")
@ -122,103 +66,6 @@ public class UserResource {
return gc.user;
}
// curl -d '{"id":3,"login":"HeeroYui","password":"bouloued","email":"yui.heero@gmail.com","emailValidate":0,"newEmail":null,"authorisationLevel":"ADMIN"}' -H "Content-Type: application/json" -X POST http://localhost:9993/api/users
@POST
@RolesAllowed("ADMIN")
public Response createUser(UserKarusic user) {
System.out.println("getUser " + user);
/*
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
String query = "SELECT * FROM user WHERE id = ?";
try {
PreparedStatement ps = entry.connection.prepareStatement(query);
ps.setLong(1, userId);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
User out = new User(rs);
entry.disconnect();
return out;
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
entry.disconnect();
entry = null;
return null;
*/
String result = "User saved ... : " + user;
return Response.status(201).entity(result).build();
}
@GET
@Path("/check_login")
@PermitAll
public Response checkLogin(@QueryParam("login") String login) {
System.out.println("checkLogin: " + login);
DBEntry entry = new DBEntry(GlobalConfiguration.dbConfig);
String query = "SELECT COUNT(*) FROM user WHERE login = ?";
try {
PreparedStatement ps = entry.connection.prepareStatement(query);
ps.setString(1, login);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
int count = rs.getInt(1);
entry.disconnect();
if (count >= 1) {
return Response.ok().build();
}
return Response.status(404).build();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
entry.disconnect();
return Response.status(520).build();
}
// TODO: for more security we need to hash the email when sended... or remove thios API !!!
@GET
@Path("/check_email")
@PermitAll
public Response checkEmail(@QueryParam("email") String email) {
System.out.println("checkEmail: " + email);
DBEntry entry = new DBEntry(GlobalConfiguration.dbConfig);
String query = "SELECT COUNT(*) FROM user WHERE email = ?";
try {
PreparedStatement ps = entry.connection.prepareStatement(query);
ps.setString(1, email);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
int count = rs.getInt(1);
entry.disconnect();
if (count >= 1) {
return Response.ok().build();
}
return Response.status(404).build();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
entry.disconnect();
return Response.status(520).build();
}
public String getSHA512(String passwordToHash) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -1,8 +0,0 @@
package org.kar.karusic.model;
public class DataGetToken {
public String login;
public String method;
public String time;
public String password;
}

View File

@ -1,57 +0,0 @@
package org.kar.karusic.model;
import java.sql.ResultSet;
import java.sql.SQLException;
/*
CREATE TABLE `token` (
`id` bigint NOT NULL COMMENT 'Unique ID of the TOKEN' AUTO_INCREMENT PRIMARY KEY,
`userId` bigint NOT NULL COMMENT 'Unique ID of the user',
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)',
`createTime` datetime NOT NULL COMMENT 'Time the token has been created',
`endValidityTime` datetime NOT NULL COMMENT 'Time of the token end validity'
) AUTO_INCREMENT=10;
*/
public class Token {
public Long id;
public Long userId;
public String token;
public String createTime;
public String endValidityTime;
public Token() {
}
public Token(long id, long userId, String token, String createTime, String endValidityTime) {
this.id = id;
this.userId = userId;
this.token = token;
this.createTime = createTime;
this.endValidityTime = endValidityTime;
}
public Token(ResultSet rs) {
int iii = 1;
try {
this.id = rs.getLong(iii++);
this.userId = rs.getLong(iii++);
this.token = rs.getString(iii++);
this.createTime = rs.getString(iii++);
this.endValidityTime = rs.getString(iii++);
} catch (SQLException ex) {
ex.printStackTrace();
}
}
@Override
public String toString() {
return "Token{" +
"id=" + id +
", userId=" + userId +
", token='" + token + '\'' +
", createTime=" + createTime +
", endValidityTime=" + endValidityTime +
'}';
}
}

View File

@ -1,36 +0,0 @@
package org.kar.karusic.model;
/*
CREATE TABLE `user` (
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
`login` varchar(128) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'login of the user',
`email` varchar(512) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'email of the user',
`lastConnection` datetime NOT NULL COMMENT 'last connection time',
`admin` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE',
`blocked` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE',
`removed` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE'
) AUTO_INCREMENT=10;
*/
public class UserExtern {
public Long id;
public String login;
public boolean admin;
public UserExtern(UserKarusic other) {
this.id = other.id;
this.login = other.login;
this.admin = other.admin;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", login='" + login + '\'' +
", admin=" + admin +
'}';
}
}

View File

@ -1,42 +0,0 @@
package org.kar.karusic.model;
/*
CREATE TABLE `user` (
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
`login` varchar(128) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'login of the user',
`email` varchar(512) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'email of the user',
`lastConnection` datetime NOT NULL COMMENT 'last connection time',
`admin` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE',
`blocked` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE',
`removed` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE'
) AUTO_INCREMENT=10;
*/
public class UserPerso {
public Long id;
public String login;
public boolean admin;
public boolean blocked;
public boolean removed;
public UserPerso(UserKarusic other) {
this.id = other.id;
this.login = other.login;
this.admin = other.admin;
this.blocked = other.blocked;
this.removed = other.removed;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", login='" + login + '\'' +
", admin=" + admin +
", blocked=" + blocked +
", removed=" + removed +
'}';
}
}

View File

@ -1,73 +0,0 @@
package org.kar.karusic.model;
/*
CREATE TABLE `user` (
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
`login` varchar(128) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'login of the user',
`password` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'password of the user hashed (sha512)',
`email` varchar(512) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'email of the user',
`emailValidate` bigint COMMENT 'date of the email validation',
`newEmail` varchar(512) COLLATE 'utf8_general_ci' COMMENT 'email of the user if he want to change',
`authorisationLevel` enum("REMOVED", "USER", "ADMIN") NOT NULL COMMENT 'user level of authorization'
) AUTO_INCREMENT=10;
*/
import java.sql.ResultSet;
import java.sql.SQLException;
public class UserSmall {
public long id;
public String login;
public String email;
public State authorisationLevel;
public UserSmall() {
}
public UserSmall(long id, String login, String email, State authorisationLevel) {
this.id = id;
this.login = login;
this.email = email;
this.authorisationLevel = authorisationLevel;
}
public UserSmall(ResultSet rs) {
int iii = 1;
try {
this.id = rs.getLong(iii++);
this.login = rs.getString(iii++);
this.email = rs.getString(iii++);
this.authorisationLevel = State.valueOf(rs.getString(iii++));
} catch (SQLException ex) {
ex.printStackTrace();
}
}
/*
public void serialize(ResultSet rs) {
int iii = 1;
try {
this.id = rs.getLong(iii++);
this.login = rs.getString(iii++);
this.password = rs.getString(iii++);
this.email = rs.getString(iii++);
this.emailValidate = rs.getLong(iii++);
this.newEmail = rs.getString(iii++);
this.authorisationLevel = State.valueOf(rs.getString(iii++));
} catch (SQLException ex) {
ex.printStackTrace();
}
}
*/
@Override
public String toString() {
return "UserSmall{" +
"id='" + id + '\'' +
", login='" + login + '\'' +
", email='" + email + '\'' +
", authorisationLevel=" + authorisationLevel +
'}';
}
}

View File

@ -7,7 +7,7 @@ public class ConfigVariable {
public static String getFrontFolder() {
String out = System.getenv(BASE_NAME + "FRONT_FOLDER");
if (out == null) {
return "/application/karusic";
return "/application/front";
}
return out;
}

View File

@ -35,6 +35,16 @@
"replace" : "src/environments/environment.ts",
"with" : "src/environments/environment.prod.ts"
} ]
},
"develop" : {
"optimization" : false,
"outputHashing" : "none",
"sourceMap" : true,
"namedChunks" : true,
"aot" : true,
"extractLicenses" : true,
"vendorChunk" : true,
"buildOptimizer" : false
}
}
},
@ -46,6 +56,9 @@
"configurations" : {
"production" : {
"browserTarget" : "karusic:build:production"
},
"develop" : {
"browserTarget" : "karusic:build:develop"
}
}
},

15508
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"scripts": {
"all": "npm run build && npm run test",
"ng": "ng",
"start": "ng serve --watch --port 4203",
"start": "ng serve --configuration=develop --watch --port 4203",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
@ -13,51 +13,28 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^13.2.5",
"@angular/cdk": "^13.2.5",
"@angular/common": "^13.2.5",
"@angular/compiler": "^13.2.5",
"@angular/core": "^13.2.5",
"@angular/forms": "^13.2.5",
"@angular/material": "^13.2.5",
"@angular/platform-browser": "^13.2.5",
"@angular/platform-browser-dynamic": "^13.2.5",
"@angular/router": "^13.2.5",
"core-js": "^3.21.1",
"jquery": "^3.6.0",
"rxjs": "^7.5.4",
"tslib": "^2.3.1",
"videogular": "^2.2.1",
"zone.js": "^0.11.5"
"@angular/animations": "^14.2.10",
"@angular/cdk": "^14.2.7",
"@angular/common": "^14.2.10",
"@angular/compiler": "^14.2.10",
"@angular/core": "^14.2.10",
"@angular/forms": "^14.2.10",
"@angular/material": "^14.2.7",
"@angular/platform-browser": "^14.2.10",
"@angular/platform-browser-dynamic": "^14.2.10",
"@angular/router": "^14.2.10",
"rxjs": "^7.5.7",
"zone.js": "^0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.2.5",
"@angular-eslint/builder": "13.1.0",
"@angular-eslint/eslint-plugin": "13.1.0",
"@angular-eslint/eslint-plugin-template": "13.1.0",
"@angular-eslint/schematics": "13.1.0",
"@angular-eslint/template-parser": "13.1.0",
"@angular/cli": "^13.2.5",
"@angular/compiler-cli": "^13.2.5",
"@angular/language-service": "^13.2.5",
"@types/jasmine": "^3.10.3",
"@types/jasminewd2": "^2.0.10",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"codelyzer": "^6.0.2",
"eslint": "^8.12.0",
"eslint-config-google": "^0.14.0",
"jasmine-core": "^4.0.1",
"jasmine-spec-reporter": "^7.0.0",
"karma": "^6.3.17",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-jasmine": "^4.0.1",
"karma-jasmine-html-reporter": "^1.7.0",
"protractor": "^7.0.0",
"ts-node": "^10.7.0",
"tslint": "^5.20.1",
"typescript": "~4.5.5"
"@angular-devkit/build-angular": "^14.2.9",
"@angular-eslint/builder": "14.2.0",
"@angular-eslint/eslint-plugin": "14.2.0",
"@angular-eslint/eslint-plugin-template": "14.2.0",
"@angular-eslint/schematics": "14.2.0",
"@angular-eslint/template-parser": "14.2.0",
"@angular/cli": "^14.2.9",
"@angular/compiler-cli": "^14.2.10",
"@angular/language-service": "^14.2.10"
}
}

View File

@ -35,9 +35,9 @@ npx ng lint
build the local image:
docker build -t gitea.atria-soft.org/kangaroo-and-rabbit/karideo:latest .
docker build -t gitea.atria-soft.org/kangaroo-and-rabbit/karusic: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/karusic:latest

View File

@ -6,7 +6,8 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
import { SsoScene } from 'common/scene';
import { ForbiddenScene, HomeOutScene, NotFound404Scene, SsoScene } from 'common/scene';
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service';
import { HelpScene, HomeScene, AlbumEditScene, AlbumsScene, ArtistEditScene, ArtistScene, SettingsScene,
GenderScene, PlaylistScene, TrackEditScene, TrackScene, UploadScene, ArtistsScene, ArtistAlbumScene, AlbumScene } from './scene';
@ -19,23 +20,57 @@ import { HelpScene, HomeScene, AlbumEditScene, AlbumsScene, ArtistEditScene, Art
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'forbidden', component: ForbiddenScene },
// ------------------------------------
// -- home global interface
// ------------------------------------
{ path: 'home', component: HomeScene },
{
path: 'home',
component: HomeScene,
canActivate: [OnlyUsersGuardHome], // this route to unregistered path when not logged ==> permit to simplify display
},
{
path: 'unregistered',
component: HomeOutScene,
canActivate: [OnlyUnregisteredGuardHome], // jump to the home when registered
},
// ------------------------------------
// -- SSO Generic interface
// ------------------------------------
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
{ path: 'sso/:keepConnected/:token', component: SsoScene },
{ path: 'sso', component: SsoScene },
// ------------------------------------
// -- Generic pages
// ------------------------------------
{ path: 'help/:page', component: HelpScene },
{ path: 'help', component: HelpScene },
// ------------------------------------
// -- upload new data:
// ------------------------------------
{ path: 'upload', component: UploadScene },
{
path: 'upload',
component: UploadScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------
// -- gender:
// ------------------------------------
// display all gender
{ path: 'gender', component: GenderScene },
{
path: 'gender',
component: GenderScene,
canActivate: [OnlyUsersGuard],
},
// display all (artist | album | traks)
{ path: 'gender/:genderId', component: GenderScene },
{
path: 'gender/:genderId',
component: GenderScene,
canActivate: [OnlyUsersGuard],
},
//{ path: 'gender-edit/:genderId', component: GenderEditScene },
//{ path: 'gender/:genderId', component: GenderScene },
@ -44,8 +79,16 @@ const routes: Routes = [
// ------------------------------------
// -- playlist:
// ------------------------------------
{ path: 'playlist', component: PlaylistScene },
{ path: 'playlist/:playlistId', component: PlaylistScene },
{
path: 'playlist',
component: PlaylistScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'playlist/:playlistId',
component: PlaylistScene,
canActivate: [OnlyUsersGuard],
},
//{ path: 'playlist-edit/:playlistId', component: PlaylistEditScene },
@ -53,47 +96,89 @@ const routes: Routes = [
// -- Artist:
// ------------------------------------
// display list of all artist
{ path: 'artist', component: ArtistsScene },
{
path: 'artist',
component: ArtistsScene,
canActivate: [OnlyUsersGuard],
},
// display list af all artist with a specific gender
{ path: 'artist/:artistId', component: ArtistScene },
{ path: 'artist/:artistId/:albumId', component: ArtistAlbumScene },
{ path: 'artist-edit/:artistId', component: ArtistEditScene },
{
path: 'artist/:artistId',
component: ArtistScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'artist/:artistId/:albumId',
component: ArtistAlbumScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'artist-edit/:artistId',
component: ArtistEditScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------
// -- Album:
// ------------------------------------
// display all Album
{ path: 'album', component: AlbumsScene },
{ path: 'album/:albumId', component: AlbumScene },
{ path: 'album-edit/:albumId', component: AlbumEditScene },
{
path: 'album',
component: AlbumsScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'album/:albumId',
component: AlbumScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'album-edit/:albumId',
component: AlbumEditScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------
// -- Tracks:
// ------------------------------------
{ path: 'track/:genderId/:artistId/:albumId/:trackId', component: TrackScene },
{ path: 'track-edit/:trackId', component: TrackEditScene },
{
path: 'track/:genderId/:artistId/:albumId/:trackId',
component: TrackScene,
canActivate: [OnlyUsersGuard],
},
{
path: 'track-edit/:trackId',
component: TrackEditScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------
// -- SSO Generic interface
// -- setting:
// ------------------------------------
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
{ path: 'sso', component: SsoScene },
// ------------------------------------
// -- Generic pages
// ------------------------------------
{ path: 'help/:page', component: HelpScene },
{ path: 'help', component: HelpScene },
{ path: 'settings', component: SettingsScene },
{
path: 'settings',
component: SettingsScene,
canActivate: [OnlyUsersGuard],
},
{
path: '**',
component: NotFound404Scene,
},
];
@NgModule({
imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
exports: [ RouterModule ]
imports: [
RouterModule.forRoot(
routes,
{
//enableTracing: true, // <-- debugging purposes only
},
),
],
exports: [
RouterModule,
]
})
export class AppRoutingModule { }
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);

View File

@ -1,10 +1,13 @@
<app-top-menu></app-top-menu>
<div class="main-content">
<router-outlet *ngIf="autoConnectedDone"></router-outlet>
<div class="generic-page" *ngIf="!isConnected">
<!-- Generig global menu -->
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
<!-- all interfaced pages -->
<div class="main-content" *ngIf="autoConnectedDone">
<router-outlet ></router-outlet>
</div>
<div class="main-content" *ngIf="!autoConnectedDone">
<div class="generic-page">
<div class="fill-all colomn_mutiple">
<b style="color:red;">You Must be connected to access @Karusic...</b>
<b style="color:red;">Auto-connection in progress</b>
<div class="clear"></div>
</div>
</div>

View File

@ -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: <b>${this.sessionService.getLogin()}</b>`,
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 "";
}
}

View File

@ -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,

View File

@ -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(() => {});
}

View File

@ -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;
});

View File

@ -1,211 +0,0 @@
<div class="top">
<div id="main-menu" class="main-menu color-menu-background">
<button class="item"
(click)="onHome($event)"
(auxclick)="($event)">
<div class="xdesktop">
<i class="material-icons">home</i> Home
</div>
<div class="xmobile">
<i class="material-icons">home</i>
</div>
</button>
<div class="ariane">
<button class="item"
*ngIf="arianeTypeId !== null"
title="Uype"
(click)="onArianeType($event)"
(auxclick)="onArianeType($event)">
<div class="xdesktop">
{{arianeTypeName}}
</div>
<div class="xmobile">
T
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianePlaylistId !== null && arianeTypeId !== null" >/</div>
<button class="item"
*ngIf="arianePlaylistId !== null"
title="Playlist"
(click)="onArianePlaylist($event)"
(auxclick)="onArianePlaylist($event)">
<div class="xdesktop">
{{arianePlaylistName}}
</div>
<div class="xmobile">
U
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianeArtistId !== null && (arianePlaylistId !== null || arianeTypeId !== null)" >/</div>
<button class="item"
*ngIf="arianeArtistId !== null"
title="Artist"
(click)="onArianeArtist($event)"
(auxclick)="onArianeArtist($event)">
<div class="xdesktop">
{{arianeArtistName}}
</div>
<div class="xmobile">
G
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianeAlbumId !== null && (arianeArtistId !== null || arianePlaylistId !== null || arianeTypeId !== null)" >/</div>
<button class="item"
*ngIf="arianeAlbumId !== null"
title="Album"
(click)="onArianeAlbum($event)"
(auxclick)="onArianeAlbum($event)">
<div class="xdesktop">
{{arianeAlbumName}}
</div>
<div class="xmobile">
S
</div>
</button>
</div>
<button class="item"
*ngIf="!login"
style="float:right;"
(click)="onSignUp($event)"
(auxclick)="onSignUp($event)">
<div class="xdesktop">
<i class="material-icons">add_circle_outline</i> Sign-up
</div>
<div class="xmobile">
<i class="material-icons">add_circle_outline</i>
</div>
</button>
<button class="item"
*ngIf="!login"
style="float:right;"
(click)="onSignIn($event)"
(auxclick)="onSignIn($event)">
<div class="xdesktop">
<i class="material-icons">account_circle</i> Sign-in
</div>
<div class="xmobile">
<i class="material-icons">account_circle</i>
</div>
</button>
<button class="item"
*ngIf="login"
style="float:right; height:56px;"
(click)="onAvatar()">
<img class="avatar" src="{{avatar}}"/>
</button>
<button class="item"
*ngIf="editShow === true"
style="float:right; height:56px;"
(click)="onEdit()">
<div class="xdesktop">
<i class="material-icons">edit</i> Edit
</div>
<div class="xmobile">
<i class="material-icons">edit</i>
</div>
</button>
</div>
<div class="fill-all" *ngIf="login && displayUserMenu === true" (click)="onOutUserProperty()">
<!-- (click)="onOutUserProperty()" -->
<div class="sub-menu user-menu color-menu-background">
<button class="item" disabled="disabled">
Sign in as <b>{{login}}</b>
</button>
<button class="item"
(click)="onHelp($event)"
(auxclick)="onHelp($event)">
<i class="material-icons">help_outline</i> Help
</button>
<button class="item"
(click)="onSetting($event)"
(auxclick)="onSetting($event)">
<i class="material-icons">settings</i> Settings
</button>
<button class="item"
(click)="onLogout($event)"
(auxclick)="onLogout($event)">
<i class="material-icons">exit_to_app</i> Sign out
</button>
<button class="item"
(click)="onAddMedia($event)"
(auxclick)="onAddMedia($event)">
<i class="material-icons">add_circle</i> Add media
</button>
</div>
</div>
<div class="fill-all" *ngIf="displayEditMenu == true" (click)="onOutUserProperty()">
<!-- (click)="onOutUserProperty()" -->
<div class="xdesktop">
<div class="sub-menu edit-menu color-menu-background">
<!--
<button class="item"
*ngIf="arianeTypeId !== null"
(click)="onSubEditType($event)"
(auxclick)="onSubEditType($event)">
<b>Edit Type</b>
</button>
<button class="item"
*ngIf="arianePlaylistId !== null"
(click)="onSubEditPlaylist($event)"
(auxclick)="onSubEditPlaylist($event)">
<b>Edit Playlist</b>
</button>
-->
<button class="item"
*ngIf="arianeArtistId !== null"
(click)="onSubEditArtist($event)"
(auxclick)="onSubEditArtist($event)">
<b>Edit Artist</b>
</button>
<button class="item"
*ngIf="arianeAlbumId !== null"
(click)="onSubEditAlbum($event)"
(auxclick)="onSubEditAlbum($event)">
<b>Edit Album</b>
</button>
<button class="item"
*ngIf="arianeTrackId !== null"
(click)="onSubEditTrack($event)"
(auxclick)="onSubEditTrack($event)">
<b>Edit Track</b>
</button>
</div>
</div>
<div class="xmobile">
<div class="sub-menu edit-menu-mob color-menu-background">
<!--
<button class="item"
*ngIf="arianeTypeId !== null"
(click)="onSubEditType($event)"
(auxclick)="onSubEditType($event)">
<b>Edit Type</b>
</button>
<button class="item"
*ngIf="arianePlaylistId !== null"
(click)="onSubEditPlaylist($event)"
(auxclick)="onSubEditPlaylist($event)">
<b>Edit Playlist</b>
</button>
-->
<button class="item"
*ngIf="arianeArtistId !== null"
(click)="onSubEditArtist($event)"
(auxclick)="onSubEditArtist($event)">
<b>Edit Artist</b>
</button>
<button class="item"
*ngIf="arianeAlbumId !== null"
(click)="onSubEditAlbum($event)"
(auxclick)="onSubEditAlbum($event)">
<b>Edit Album</b>
</button>
<button class="item"
*ngIf="arianeTrackId !== null"
(click)="onSubEditTrack($event)"
(auxclick)="onSubEditTrack($event)">
<b>Edit Track</b>
</button>
</div>
</div>
</div>
</div>

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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<String[]>;
constructor(
private route: ActivatedRoute,
private albumService: AlbumService,
private artistService: ArtistService,
private arianeService: ArianeService,
@ -42,13 +39,12 @@
}
getArtistsStringCallback(albumId: number) : Promise<String[]> {
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)";

View File

@ -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: '---' } ];

View File

@ -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;
}
}

View File

@ -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<Number>;
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();

View File

@ -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<Number>;
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()

View File

@ -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);
}
}

View File

@ -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}`);

View File

@ -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;

View File

@ -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()

View File

@ -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}`);

View File

@ -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`);

View File

@ -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: '---' } ];

View File

@ -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}`);

View File

@ -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: '---' } ];

View File

@ -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';

View File

@ -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<number> = new EventEmitter();
public playlistId: number = null;
public playlistName: string = null;
public playlistId: number = undefined;
public playlistName: string = undefined;
@Output() playlistChange: EventEmitter<number> = new EventEmitter();
public artistId: number = null;
public artistName: string = null;
public artistId: number = undefined;
public artistName: string = undefined;
@Output() artistChange: EventEmitter<number> = new EventEmitter();
public albumId: number = null;
public albumName: string = null;
public albumId: number = undefined;
public albumName: string = undefined;
@Output() albumChange: EventEmitter<number> = new EventEmitter();
public trackId: number = null;
public trackName: string = null;
public trackId: number = undefined;
public trackName: string = undefined;
@Output() trackChange: EventEmitter<number> = new EventEmitter();
@Output() update: EventEmitter<InputOrders> = new EventEmitter();
public segment: string = "";
@Output() segmentChange: EventEmitter<string> = 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 });
}
}

View File

@ -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 {

View File

@ -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
};

View File

@ -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,
};

View File

@ -1,11 +1,10 @@
<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="inert_element"
*ngIf="isNotButton(data)"
[ngStyle]="{'float': data.position}"
[ngClass]="getClassModel(data.model)">
<div class="xdesktop" *ngIf="data.icon">
<i class="material-icons">{{data.icon}}</i> {{data.title}}
</div>
@ -15,17 +14,37 @@
<div class="xdesktop" *ngIf="!data.icon">
{{data.title}}
</div>
</div>
<button class="item"
*ngIf="!isNotButton(data)"
(click)="onGeneric(data, $event)"
(auxclick)="onGeneric(data, $event)"
[ngStyle]="{'float': data.position}"
[ngClass]="getClassModel(data.model)"
[disable]="false">
<div class="avatar" *ngIf="data.image">
<img class="avatar" src="{{data.image}}"/> {{data.title}}
</div>
<div class="xdesktop" *ngIf="data.icon && !data.image">
<i class="material-icons">{{data.icon}}</i> {{data.title}}
</div>
<div class="xmobile" *ngIf="data.icon && !data.image">
<i class="material-icons">{{data.icon}}</i>
</div>
<div class="xdesktop" *ngIf="!data.icon && !data.image">
{{data.title}}
</div>
</button>
</div>
</div>
<div class="fill-all" *ngIf="subMenu" (click)="onOutUserProperty()">
<div class="sub-menu menu-left color-menu-background">
<div class="sub-menu color-menu-background"
[ngClass]="getClassMenuPosition()">
<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="inert_element unselectable"
*ngIf="isNotButton(data)"
[ngStyle]="{'float': data.position}"
[ngClass]="getClassModel(data.model)" >
<div class="xdesktop"
*ngIf="data.icon"
[ngStyle]="{'float': data.position}">
@ -40,8 +59,24 @@
[ngStyle]="{'float': data.position}">
{{data.title}}
</div>
</div>
<button class="item"
*ngIf="isEnable(data) && !isNotButton(data)"
(click)="onGeneric(data, $event)"
(auxclick)="onGeneric(data, $event)"
[ngStyle]="{'float': data.position}"
[ngClass]="getClassModel(data.model)"
[disable]="false">
<div *ngIf="data.icon"
[ngStyle]="{'float': data.position}">
<i class="material-icons">{{data.icon}}</i> {{data.title}}
</div>
<div *ngIf="!data.icon"
[ngStyle]="{'float': data.position}">
{{data.title}}
</div>
</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -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 {

View File

@ -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<EventOnMenu> = 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;
}
}

View File

@ -1,6 +1,8 @@
import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from "./menu-item";
import { NodeData, isNodeData } from "./node";
export {
NodeData, isNodeData,
}
MenuPosition, isMenuPosition, MenuItem, isMenuItem,
}

View File

@ -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;
}
}

View File

@ -0,0 +1,8 @@
import { PopInDeleteConfirm } from "./delete-confirm/delete-confirm";
import { PopInUploadProgress } from "./upload-progress/upload-progress";
export {
PopInDeleteConfirm,
PopInUploadProgress,
}

View File

@ -0,0 +1,6 @@
<div class="full-mode">
<div class="centered">
<div class="error"><label class="unselectable"><i class="material-icons">report</i> 404 Not Found !</label></div>
<div class="comment"><label class="unselectable">Unknwn this page.</label></div>
</div>
</div>

View File

@ -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;
}

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-404-not-found',
templateUrl: './404.html',
styleUrls: [ './404.less' ]
})
export class NotFound404Scene {
constructor() { }
}

View File

@ -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);
}
}

View File

@ -1,6 +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="error"><label class="unselectable"><i class="material-icons">gpp_bad</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,6 @@
<div class="full-mode">
<div class="centered">
<div class="error"><label class="unselectable"><i class="material-icons">login</i> Not registered!</label></div>
<div class="comment"><label class="unselectable">you must login to access to this website.</label></div>
</div>
</div>

View File

@ -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;
}

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

View File

@ -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,
};

View File

@ -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();
}

View File

@ -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<Response> {
//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<api.length; iii++) {
let elem = api[iii];
out += `/${elem}`;
if (out.endsWith("/")) {
out += elem;
} else {
out += `/${elem}`;
}
}
} else {
out += api;
@ -195,7 +203,7 @@ export class HttpWrapperService {
out = out + "=" + options[keys[iii]];
}
}
console.log(`try to get session : ${this.session.getToken()}`);
//console.log(`try to get session : ${this.session.getToken()}`);
if (!isNullOrUndefined(this.session.getToken())) {
if (addURLToken !== undefined && addURLToken === true) {
if(first === false) {
@ -232,7 +240,7 @@ export class HttpWrapperService {
}
// Deprecated ... old model stream
post(uriRest:string, headerOption:any, data:any, progress:ProgressCallback = null) {
console.log(`-------------------------------------------------------\nHTTP-wrapper POST '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
//console.log(`-------------------------------------------------------\nHTTP-wrapper POST '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
@ -251,33 +259,33 @@ export class HttpWrapperService {
if(self.displayReturn === true) {
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res.type === HttpEventType.Sent) {
/* res.type === 0 */
console.log('post : Sent');
} else if(res.type === HttpEventType.UploadProgress) {
/* res.type === 1 */
// console.log("post : " + res.loaded + " / " + res.total);
progress(res.loaded, res.total);
} else if(res.type === HttpEventType.ResponseHeader) {
/* res.type === 2 */
console.log('post : get header');
} else if(res.type === HttpEventType.DownloadProgress) {
/* res.type === 3 */
console.log(`post : get DownloadProgress ${ res.loaded}`);
} else if(res.type === HttpEventType.Response) {
/* res.type === 4 */
console.log('post : get response');
if(res.httpCode) {
if(res.type === HttpEventType.Sent) {
/* res.type === 0 */
//console.log('post : Sent');
} else if(res.type === HttpEventType.UploadProgress) {
/* res.type === 1 */
// console.log("post : " + res.loaded + " / " + res.total);
progress(res.loaded, res.total);
} else if(res.type === HttpEventType.ResponseHeader) {
/* res.type === 2 */
//console.log('post : get header');
} else if(res.type === HttpEventType.DownloadProgress) {
/* res.type === 3 */
//console.log(`post : get DownloadProgress ${ res.loaded}`);
} else if(res.type === HttpEventType.Response) {
/* res.type === 4 */
//console.log('post : get response');
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
}
} else if(res.type === HttpEventType.User) {
/* res.type === 5 */
console.log('post : get User');
} else {
console.log(`post : get unknown ... ${ res.type}`);
}
} else if(res.type === HttpEventType.User) {
/* res.type === 5 */
//console.log('post : get User');
} else {
console.log(`post : get unknown ... ${ res.type}`);
}
},
(error) => {
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;

View File

@ -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,
};

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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<boolean> {
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);
});
}
}

View File

@ -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<void> {
let locationOrigin = getApplicationLocation();
let self = this;
return new Promise<void>((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 = {

View File

@ -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;
}

View File

@ -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<data.length; iii++) {
@ -193,7 +192,7 @@ export class DataInterface {
if(select.length === 0) {
find = false;
}
//console.log("Check : " + JSON.stringify(values[iiiElem], null, 2));
// console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
let control = select[iiiSelect];
let valueElement = values[iiiElem][control.key]

View File

@ -1,7 +1,9 @@
import { getApplicationLocation } from "./applPath";
import { DataInterface, TypeCheck } from "./dataInterface";
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs } from "./validator";
import { sha512 } from "./sha512";
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs, isInArray, isStringNullOrUndefined } from "./validator";
export {
isNumber,
@ -17,7 +19,11 @@ export {
isArrayOfs,
isOptionalOf,
isOptionalArrayOf,
isInArray,
isStringNullOrUndefined,
DataInterface,
TypeCheck,
getApplicationLocation,
sha512,
}

View File

@ -2,18 +2,18 @@
* Secure Hash Algorithm (SHA512)
*/
function SHA512(str) {
export function sha512(str) {
function int64(msint_32, lsint_32) {
this.highOrder = msint_32;
this.lowOrder = lsint_32;
}
var H = [new int64(0x6a09e667, 0xf3bcc908), new int64(0xbb67ae85, 0x84caa73b),
let H = [new int64(0x6a09e667, 0xf3bcc908), new int64(0xbb67ae85, 0x84caa73b),
new int64(0x3c6ef372, 0xfe94f82b), new int64(0xa54ff53a, 0x5f1d36f1),
new int64(0x510e527f, 0xade682d1), new int64(0x9b05688c, 0x2b3e6c1f),
new int64(0x1f83d9ab, 0xfb41bd6b), new int64(0x5be0cd19, 0x137e2179)];
var K = [new int64(0x428a2f98, 0xd728ae22), new int64(0x71374491, 0x23ef65cd),
let K = [new int64(0x428a2f98, 0xd728ae22), new int64(0x71374491, 0x23ef65cd),
new int64(0xb5c0fbcf, 0xec4d3b2f), new int64(0xe9b5dba5, 0x8189dbbc),
new int64(0x3956c25b, 0xf348b538), new int64(0x59f111f1, 0xb605d019),
new int64(0x923f82a4, 0xaf194f9b), new int64(0xab1c5ed5, 0xda6d8118),
@ -54,21 +54,21 @@ function SHA512(str) {
new int64(0x4cc5d4be, 0xcb3e42b6), new int64(0x597f299c, 0xfc657e2a),
new int64(0x5fcb6fab, 0x3ad6faec), new int64(0x6c44198c, 0x4a475817)];
var W = new Array(64);
var a, b, c, d, e, f, g, h, i, j;
var T1, T2;
var charsize = 8;
let W = new Array(64);
let a, b, c, d, e, f, g, h, i, j;
let T1, T2;
let charsize = 8;
function utf8_encode(str) {
return unescape(encodeURIComponent(str));
}
function str2binb(str) {
var bin = [];
var mask = (1 << charsize) - 1;
var len = str.length * charsize;
let bin = [];
let mask = (1 << charsize) - 1;
let len = str.length * charsize;
for (var i = 0; i < len; i += charsize) {
for (let i = 0; i < len; i += charsize) {
bin[i >> 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);
}

View File

@ -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<listElment.length; iii++) {
if (listElment[iii] === data) {
return true;
}
}
return false;
}
export function isArrayOf<TYPE>(data: any, typeChecker: (subData: any) => subData is TYPE, length?: number): data is TYPE[] {
if (!isArray(data)) {

View File

@ -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'
};
tokenStoredInPermanentStorage: false,
};

View File

@ -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;

View File

@ -18,10 +18,6 @@
<!-- some generic sheets -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
<!-- Some tools -->
<script src="assets/js_3rd_party/dateFormat.min.js"></script>
<script src="assets/js_3rd_party/sha512.js"></script>
</head>
<body>
<div class="full-back"> </div>

View File

@ -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