[DEV] refactor all (SSO + better bdd, no null ...)
This commit is contained in:
parent
593abab525
commit
e421ead4ab
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
out
|
||||||
|
.idea
|
||||||
|
|
||||||
# compiled output
|
# compiled output
|
||||||
/dist
|
/dist
|
||||||
|
79
Dockerfile
Normal file
79
Dockerfile
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
######################################################################################
|
||||||
|
##
|
||||||
|
## buyilding-end install applications:
|
||||||
|
##
|
||||||
|
######################################################################################
|
||||||
|
FROM archlinux:base-devel AS builder
|
||||||
|
# update system
|
||||||
|
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||||
|
&& pacman -S --noconfirm jdk-openjdk maven npm \
|
||||||
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
|
ENV PATH /tmp/node_modules/.bin:$PATH
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
##
|
||||||
|
## Build back:
|
||||||
|
##
|
||||||
|
######################################################################################
|
||||||
|
FROM builder AS buildBack
|
||||||
|
COPY back/pom.xml /tmp
|
||||||
|
COPY back/src /tmp/src/
|
||||||
|
RUN mvn clean compile assembly:single
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
##
|
||||||
|
## Build front:
|
||||||
|
##
|
||||||
|
######################################################################################
|
||||||
|
FROM builder AS buildFront
|
||||||
|
|
||||||
|
ADD front/package-lock.json \
|
||||||
|
front/package.json \
|
||||||
|
front/karma.conf.js \
|
||||||
|
front/protractor.conf.js \
|
||||||
|
/tmp/
|
||||||
|
|
||||||
|
# install and cache app dependencies
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
ADD front/e2e \
|
||||||
|
front/tsconfig.json \
|
||||||
|
front/tslint.json \
|
||||||
|
front/angular.json \
|
||||||
|
/tmp/
|
||||||
|
ADD front/src /tmp/src
|
||||||
|
|
||||||
|
# generate build
|
||||||
|
RUN ng build --output-path=dist --configuration=production --base-href=/karideo/ --deploy-url=/karideo/
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
##
|
||||||
|
## Production area:
|
||||||
|
##
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
FROM bellsoft/liberica-openjdk-alpine:latest
|
||||||
|
# add wget to manage the health check...
|
||||||
|
RUN apk add --no-cache wget
|
||||||
|
|
||||||
|
#FROM archlinux:base
|
||||||
|
#RUN pacman -Syu --noconfirm && pacman-db-upgrade
|
||||||
|
## install package
|
||||||
|
#RUN pacman -S --noconfirm jdk-openjdk wget
|
||||||
|
## intall npm
|
||||||
|
#RUN pacman -S --noconfirm npm
|
||||||
|
## clean all the caches Need only on the release environment
|
||||||
|
#RUN pacman -Scc --noconfirm
|
||||||
|
|
||||||
|
ENV LANG=C.UTF-8
|
||||||
|
|
||||||
|
COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar
|
||||||
|
COPY --from=buildFront /tmp/dist /application/karideo/
|
||||||
|
|
||||||
|
WORKDIR /application/
|
||||||
|
|
||||||
|
EXPOSE 17080
|
||||||
|
|
||||||
|
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karideo.WebLauncher"]
|
13
back/pom.xml
13
back/pom.xml
@ -10,8 +10,8 @@
|
|||||||
<istack.version>3.0.7</istack.version>
|
<istack.version>3.0.7</istack.version>
|
||||||
|
|
||||||
<maven.compiler.version>3.1</maven.compiler.version>
|
<maven.compiler.version>3.1</maven.compiler.version>
|
||||||
<maven.compiler.source>14</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>14</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
||||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||||
</properties>
|
</properties>
|
||||||
@ -33,17 +33,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-multipart</artifactId>
|
<artifactId>jersey-media-multipart</artifactId>
|
||||||
<version>${jersey.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.inject</groupId>
|
<groupId>org.glassfish.jersey.inject</groupId>
|
||||||
<artifactId>jersey-hk2</artifactId>
|
<artifactId>jersey-hk2</artifactId>
|
||||||
<version>${jersey.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.containers</groupId>
|
<groupId>org.glassfish.jersey.containers</groupId>
|
||||||
<artifactId>jersey-container-grizzly2-http</artifactId>
|
<artifactId>jersey-container-grizzly2-http</artifactId>
|
||||||
<version>${jersey.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
@ -78,7 +75,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
<artifactId>jersey-media-json-jackson</artifactId>
|
||||||
<version>${jersey.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
@ -97,6 +93,11 @@
|
|||||||
<version>RELEASE</version>
|
<version>RELEASE</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.nimbusds</groupId>
|
||||||
|
<artifactId>nimbus-jose-jwt</artifactId>
|
||||||
|
<version>9.22</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -2,7 +2,6 @@ package org.kar.karideo;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.kar.karideo.db.DBEntry;
|
import org.kar.karideo.db.DBEntry;
|
||||||
import org.kar.karideo.model.State;
|
|
||||||
import org.kar.karideo.model.User;
|
import org.kar.karideo.model.User;
|
||||||
import org.kar.karideo.model.UserSmall;
|
import org.kar.karideo.model.UserSmall;
|
||||||
|
|
||||||
@ -39,103 +38,26 @@ public class UserDB {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static User getAndCreate(long userId, String token) throws IOException {
|
public static User getUserOrCreate(long userId, String userLogin) {
|
||||||
// check Token:
|
User user = getUsers(userId);
|
||||||
URL obj = new URL(WebLauncher.getOAuthURI() + "users/check_token?id=" + userId + "&token=" + token);
|
|
||||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
|
||||||
con.setRequestMethod("GET");
|
|
||||||
con.setRequestProperty("User-Agent", "karideo");
|
|
||||||
con.setRequestProperty("Cache-Control", "no-cache");
|
|
||||||
con.setRequestProperty("Content-Type", "application/json");
|
|
||||||
con.setRequestProperty("Accept", "application/json");
|
|
||||||
int responseCode = con.getResponseCode();
|
|
||||||
|
|
||||||
System.out.println("GET Response Code :: " + responseCode);
|
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) { // success
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
|
||||||
con.getInputStream()));
|
|
||||||
|
|
||||||
String inputLine;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
|
||||||
response.append(inputLine);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
// print result
|
|
||||||
System.out.println(response.toString());
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
;
|
|
||||||
UserSmall value = mapper.readValue(response.toString(), UserSmall.class);
|
|
||||||
System.out.println("user SMALL " + value);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
System.out.println("GET request not worked");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UserSmall getUserOAuth(long userId, String token) throws IOException {
|
|
||||||
// check Token:
|
|
||||||
URL obj = new URL(WebLauncher.getOAuthURI() + "users/check_token?id=" + userId + "&token=" + token);
|
|
||||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
|
||||||
con.setRequestMethod("GET");
|
|
||||||
con.setRequestProperty("User-Agent", "karideo");
|
|
||||||
con.setRequestProperty("Cache-Control", "no-cache");
|
|
||||||
con.setRequestProperty("Content-Type", "application/json");
|
|
||||||
con.setRequestProperty("Accept", "application/json");
|
|
||||||
int responseCode = con.getResponseCode();
|
|
||||||
|
|
||||||
System.out.println("GET Response Code :: " + responseCode);
|
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) { // success
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
|
||||||
con.getInputStream()));
|
|
||||||
|
|
||||||
String inputLine;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
|
||||||
response.append(inputLine);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
// print result
|
|
||||||
System.out.println(response.toString());
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
;
|
|
||||||
return mapper.readValue(response.toString(), UserSmall.class);
|
|
||||||
}
|
|
||||||
System.out.println("GET request not worked");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static User getUserOrCreate(UserSmall userOAuth) {
|
|
||||||
User user = getUsers(userOAuth.id);
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
/*
|
||||||
boolean blocked = false;
|
boolean blocked = false;
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
if (userOAuth.authorisationLevel == State.BLOCKED) {
|
|
||||||
blocked = true;
|
|
||||||
} else if (userOAuth.authorisationLevel == State.REMOVED) {
|
|
||||||
removed = true;
|
|
||||||
}
|
|
||||||
if (user.email != userOAuth.email || user.login != userOAuth.login || user.blocked != blocked || user.removed != removed) {
|
if (user.email != userOAuth.email || user.login != userOAuth.login || user.blocked != blocked || user.removed != removed) {
|
||||||
updateUsersInfoFromOAuth(userOAuth.id, userOAuth.email, userOAuth.login, blocked, removed);
|
updateUsersInfoFromOAuth(userOAuth.id, userOAuth.email, userOAuth.login, blocked, removed);
|
||||||
} else {
|
} else {
|
||||||
updateUsersConnectionTime(userOAuth.id);
|
updateUsersConnectionTime(userOAuth.id);
|
||||||
}
|
}
|
||||||
return getUsers(userOAuth.id);
|
return getUsers(userOAuth.id);
|
||||||
} else {
|
*/
|
||||||
if (userOAuth.authorisationLevel == State.BLOCKED) {
|
return user;
|
||||||
return null;
|
|
||||||
} else if (userOAuth.authorisationLevel == State.REMOVED) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
createUsersInfoFromOAuth(userOAuth.id, userOAuth.email, userOAuth.login);
|
|
||||||
}
|
}
|
||||||
return getUsers(userOAuth.id);
|
createUsersInfoFromOAuth(userId, userLogin);
|
||||||
|
return getUsers(userId);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
private static void updateUsersConnectionTime(long userId) {
|
private static void updateUsersConnectionTime(long userId) {
|
||||||
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
|
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
|
||||||
String query = "UPDATE `user` SET `lastConnection`=now(3) WHERE `id` = ?";
|
String query = "UPDATE `user` SET `lastConnection`=now(3) WHERE `id` = ?";
|
||||||
@ -165,15 +87,15 @@ public class UserDB {
|
|||||||
}
|
}
|
||||||
entry.disconnect();
|
entry.disconnect();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private static void createUsersInfoFromOAuth(long userId, String email, String login) {
|
private static void createUsersInfoFromOAuth(long userId, String login) {
|
||||||
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
|
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
|
||||||
String query = "INSERT INTO `user` (`id`, `login`, `email`, `lastConnection`, `admin`, `blocked`, `removed`) VALUE (?,?,?,now(3),'FALSE','FALSE','FALSE')";
|
String query = "INSERT INTO `user` (`id`, `login`, `lastConnection`, `admin`, `blocked`, `removed`) VALUE (?,?,now(3),'FALSE','FALSE','FALSE')";
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = entry.connection.prepareStatement(query);
|
PreparedStatement ps = entry.connection.prepareStatement(query);
|
||||||
ps.setLong(1, userId);
|
ps.setLong(1, userId);
|
||||||
ps.setString(2, login);
|
ps.setString(2, login);
|
||||||
ps.setString(3, email);
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
|
@ -6,6 +6,11 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
|||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.kar.karideo.api.*;
|
import org.kar.karideo.api.*;
|
||||||
import org.kar.karideo.db.DBConfig;
|
import org.kar.karideo.db.DBConfig;
|
||||||
|
import org.kar.karideo.filter.AuthenticationFilter;
|
||||||
|
import org.kar.karideo.filter.CORSFilter;
|
||||||
|
import org.kar.karideo.filter.OptionFilter;
|
||||||
|
import org.kar.karideo.util.ConfigVariable;
|
||||||
|
import org.kar.karideo.util.JWTWrapper;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
@ -25,12 +30,23 @@ public class WebLauncher {
|
|||||||
return UriBuilder.fromUri(ConfigVariable.getlocalAddress()).build();
|
return UriBuilder.fromUri(ConfigVariable.getlocalAddress()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOAuthURI() {
|
|
||||||
return ConfigVariable.getRestOAuthServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ResourceConfig rc = new ResourceConfig();
|
ResourceConfig rc = new ResourceConfig();
|
||||||
|
// need to uppgrade when server call us...
|
||||||
|
try {
|
||||||
|
JWTWrapper.initLocalTokenRemote(ConfigVariable.getSSOAddress(), "karideo");
|
||||||
|
} catch (Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
System.out.println("Wait 10 seconds ....");
|
||||||
|
try {
|
||||||
|
Thread.sleep(10000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// add multipart models ..
|
// add multipart models ..
|
||||||
//rc.register(new MultiPartFeature());
|
//rc.register(new MultiPartFeature());
|
||||||
//rc.register(new InjectionBinder());
|
//rc.register(new InjectionBinder());
|
||||||
@ -51,24 +67,26 @@ public class WebLauncher {
|
|||||||
rc.registerClasses(TypeResource.class);
|
rc.registerClasses(TypeResource.class);
|
||||||
rc.registerClasses(UniverseResource.class);
|
rc.registerClasses(UniverseResource.class);
|
||||||
rc.registerClasses(VideoResource.class);
|
rc.registerClasses(VideoResource.class);
|
||||||
|
rc.registerClasses(HealthCheck.class);
|
||||||
|
rc.registerClasses(Front.class);
|
||||||
// add jackson to be discovenr when we are ins standalone server
|
// add jackson to be discovenr when we are ins standalone server
|
||||||
rc.register(JacksonFeature.class);
|
rc.register(JacksonFeature.class);
|
||||||
// enable this to show low level request
|
// enable this to show low level request
|
||||||
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||||
|
|
||||||
System.out.println("Connect on the BDD:");
|
//System.out.println("Connect on the BDD:");
|
||||||
System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
|
//System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
|
||||||
System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
|
//System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
|
||||||
System.out.println(" getDBLogin: '" + ConfigVariable.getDBLogin() + "'");
|
//System.out.println(" getDBLogin: '" + ConfigVariable.getDBLogin() + "'");
|
||||||
System.out.println(" getDBPassword: '" + ConfigVariable.getDBPassword() + "'");
|
//System.out.println(" getDBPassword: '" + ConfigVariable.getDBPassword() + "'");
|
||||||
System.out.println(" getDBName: '" + ConfigVariable.getDBName() + "'");
|
//System.out.println(" getDBName: '" + ConfigVariable.getDBName() + "'");
|
||||||
dbConfig = new DBConfig(ConfigVariable.getDBHost(),
|
dbConfig = new DBConfig(ConfigVariable.getDBHost(),
|
||||||
Integer.parseInt(ConfigVariable.getDBPort()),
|
Integer.parseInt(ConfigVariable.getDBPort()),
|
||||||
ConfigVariable.getDBLogin(),
|
ConfigVariable.getDBLogin(),
|
||||||
ConfigVariable.getDBPassword(),
|
ConfigVariable.getDBPassword(),
|
||||||
ConfigVariable.getDBName());
|
ConfigVariable.getDBName());
|
||||||
System.out.println(" ==> " + dbConfig);
|
System.out.println(" ==> " + dbConfig);
|
||||||
System.out.println("OAuth service " + ConfigVariable.getRestOAuthServer());
|
System.out.println("OAuth service " + getBaseURI());
|
||||||
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,14 +2,15 @@ package org.kar.karideo.api;
|
|||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.karideo.ConfigVariable;
|
|
||||||
import org.kar.karideo.GenericContext;
|
|
||||||
import org.kar.karideo.WebLauncher;
|
import org.kar.karideo.WebLauncher;
|
||||||
import org.kar.karideo.annotation.PermitTokenInURI;
|
import org.kar.karideo.annotation.PermitTokenInURI;
|
||||||
import org.kar.karideo.db.DBEntry;
|
import org.kar.karideo.db.DBEntry;
|
||||||
|
import org.kar.karideo.filter.GenericContext;
|
||||||
import org.kar.karideo.model.Data;
|
import org.kar.karideo.model.Data;
|
||||||
import org.kar.karideo.model.DataSmall;
|
import org.kar.karideo.model.DataSmall;
|
||||||
|
import org.kar.karideo.util.ConfigVariable;
|
||||||
|
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -380,7 +381,7 @@ public class DataResource {
|
|||||||
System.out.println("===================================================");
|
System.out.println("===================================================");
|
||||||
DataSmall value = getSmall(id);
|
DataSmall value = getSmall(id);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
Response.status(404).
|
return Response.status(404).
|
||||||
entity("media NOT FOUND: " + id).
|
entity("media NOT FOUND: " + id).
|
||||||
type("text/plain").
|
type("text/plain").
|
||||||
build();
|
build();
|
||||||
@ -419,7 +420,8 @@ public class DataResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("{id}/{name}")
|
@Path("{id}/{name}")
|
||||||
@PermitTokenInURI
|
@PermitTokenInURI
|
||||||
@RolesAllowed("USER")
|
//@RolesAllowed("USER")
|
||||||
|
@PermitAll
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
@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 {
|
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();
|
GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
|
103
back/src/org/kar/karideo/api/Front.java
Normal file
103
back/src/org/kar/karideo/api/Front.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.CacheControl;
|
||||||
|
import javax.ws.rs.core.PathSegment;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||||
|
|
||||||
|
import org.kar.karideo.util.ConfigVariable;
|
||||||
|
|
||||||
|
@Path("/karideo")
|
||||||
|
public class Front {
|
||||||
|
private String getExtension(String filename) {
|
||||||
|
if (filename.contains(".")) {
|
||||||
|
return filename.substring(filename.lastIndexOf(".") + 1);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
private Response retrive(String fileName) throws Exception {
|
||||||
|
String filePathName = ConfigVariable.getFrontFolder() + File.separator + fileName;
|
||||||
|
String extention = getExtension(filePathName);
|
||||||
|
String mineType = null;
|
||||||
|
System.out.println("try retrive : '" + filePathName + "' '" + extention + "'");
|
||||||
|
if (extention.length() !=0 && extention.length() <= 5) {
|
||||||
|
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||||
|
mineType = "image/jpeg";
|
||||||
|
} else if (extention.equalsIgnoreCase("gif")) {
|
||||||
|
mineType = "image/gif";
|
||||||
|
} else if (extention.equalsIgnoreCase("png")) {
|
||||||
|
mineType = "image/png";
|
||||||
|
} else if (extention.equalsIgnoreCase("svg")) {
|
||||||
|
mineType = "image/svg+xml";
|
||||||
|
} else if (extention.equalsIgnoreCase("webp")) {
|
||||||
|
mineType = "image/webp";
|
||||||
|
} else if (extention.equalsIgnoreCase("js")) {
|
||||||
|
mineType = "application/javascript";
|
||||||
|
} else if (extention.equalsIgnoreCase("json")) {
|
||||||
|
mineType = "application/json";
|
||||||
|
} else if (extention.equalsIgnoreCase("ico")) {
|
||||||
|
mineType = "image/x-icon";
|
||||||
|
} else if (extention.equalsIgnoreCase("html")) {
|
||||||
|
mineType = "text/html";
|
||||||
|
} else if (extention.equalsIgnoreCase("css")) {
|
||||||
|
mineType = "text/css";
|
||||||
|
} else {
|
||||||
|
return Response.status(403).
|
||||||
|
entity("Not supported model: '" + fileName + "'").
|
||||||
|
type("text/plain").
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mineType = "text/html";
|
||||||
|
filePathName = ConfigVariable.getFrontFolder() + File.separator + "index.html";
|
||||||
|
}
|
||||||
|
System.out.println(" ==> '" + filePathName + "'");
|
||||||
|
// reads input image
|
||||||
|
File download = new File(filePathName);
|
||||||
|
if (!download.exists()) {
|
||||||
|
return Response.status(404).
|
||||||
|
entity("Not Found: '" + fileName + "' extension='" + extention + "'").
|
||||||
|
type("text/plain").
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
ResponseBuilder response = Response.ok((Object)download);
|
||||||
|
// use this if I want to download the file:
|
||||||
|
//response.header("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
|
CacheControl cc = new CacheControl();
|
||||||
|
cc.setMaxAge(60);
|
||||||
|
cc.setNoCache(false);
|
||||||
|
response.cacheControl(cc);
|
||||||
|
response.type(mineType);
|
||||||
|
|
||||||
|
return response.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@PermitAll()
|
||||||
|
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
//@CacheMaxAge(time = 1, unit = TimeUnit.DAYS)
|
||||||
|
public Response retrive0() throws Exception {
|
||||||
|
return retrive("index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{any: .*}")
|
||||||
|
@PermitAll()
|
||||||
|
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
//@CacheMaxAge(time = 10, unit = TimeUnit.DAYS)
|
||||||
|
public Response retrive1(@PathParam("any") List<PathSegment> segments) throws Exception {
|
||||||
|
String filename = "";
|
||||||
|
for (PathSegment elem: segments) {
|
||||||
|
if (!filename.isEmpty()) {
|
||||||
|
filename += File.separator;
|
||||||
|
}
|
||||||
|
filename += elem.getPath();
|
||||||
|
}
|
||||||
|
return retrive(filename);
|
||||||
|
}
|
||||||
|
}
|
22
back/src/org/kar/karideo/api/HealthCheck.java
Normal file
22
back/src/org/kar/karideo/api/HealthCheck.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
@Path("/health_check")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public class HealthCheck {
|
||||||
|
public class HealthResult {
|
||||||
|
public String value;
|
||||||
|
public HealthResult(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// todo : do it better...
|
||||||
|
@GET
|
||||||
|
@PermitAll
|
||||||
|
public HealthResult getHealth() {
|
||||||
|
return new HealthResult("alive and kicking");
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.kar.karideo.GenericContext;
|
|
||||||
import org.kar.karideo.UserDB;
|
import org.kar.karideo.UserDB;
|
||||||
import org.kar.karideo.WebLauncher;
|
import org.kar.karideo.WebLauncher;
|
||||||
import org.kar.karideo.db.DBEntry;
|
import org.kar.karideo.db.DBEntry;
|
||||||
|
import org.kar.karideo.filter.GenericContext;
|
||||||
import org.kar.karideo.model.User;
|
import org.kar.karideo.model.User;
|
||||||
import org.kar.karideo.model.UserExtern;
|
import org.kar.karideo.model.UserExtern;
|
||||||
import org.kar.karideo.model.UserPerso;
|
import org.kar.karideo.model.UserPerso;
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.filter;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import javax.annotation.security.DenyAll;
|
import javax.annotation.security.DenyAll;
|
||||||
import javax.annotation.security.PermitAll;
|
import javax.annotation.security.PermitAll;
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
|
|
||||||
import org.kar.karideo.annotation.PermitTokenInURI;
|
|
||||||
import org.kar.karideo.model.User;
|
|
||||||
import org.kar.karideo.model.UserSmall;
|
|
||||||
|
|
||||||
import javax.annotation.Priority;
|
import javax.annotation.Priority;
|
||||||
import javax.ws.rs.Priorities;
|
import javax.ws.rs.Priorities;
|
||||||
@ -21,6 +18,16 @@ import javax.ws.rs.core.MultivaluedMap;
|
|||||||
import javax.ws.rs.core.PathSegment;
|
import javax.ws.rs.core.PathSegment;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
|
import org.kar.karideo.UserDB;
|
||||||
|
|
||||||
|
import org.kar.karideo.annotation.PermitTokenInURI;
|
||||||
|
import org.kar.karideo.model.User;
|
||||||
|
import org.kar.karideo.model.UserSmall;
|
||||||
|
import org.kar.karideo.util.JWTWrapper;
|
||||||
|
|
||||||
|
import com.nimbusds.jwt.JWTClaimsSet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,7 +43,6 @@ public class AuthenticationFilter implements ContainerRequestFilter {
|
|||||||
@Context
|
@Context
|
||||||
private ResourceInfo resourceInfo;
|
private ResourceInfo resourceInfo;
|
||||||
|
|
||||||
private static final String REALM = "example";
|
|
||||||
private static final String AUTHENTICATION_SCHEME = "Yota";
|
private static final String AUTHENTICATION_SCHEME = "Yota";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,10 +123,11 @@ public class AuthenticationFilter implements ContainerRequestFilter {
|
|||||||
abortWithUnauthorized(requestContext);
|
abortWithUnauthorized(requestContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// check JWT token (basic:)
|
||||||
|
|
||||||
// Extract the token from the Authorization header (Remove "Yota ")
|
// Extract the token from the Authorization header (Remove "Yota ")
|
||||||
String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim();
|
String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim();
|
||||||
//System.out.println("token: " + token);
|
System.out.println("token: " + token);
|
||||||
|
|
||||||
|
|
||||||
User user = null;
|
User user = null;
|
||||||
@ -171,22 +178,22 @@ public class AuthenticationFilter implements ContainerRequestFilter {
|
|||||||
requestContext.abortWith(
|
requestContext.abortWith(
|
||||||
Response.status(Response.Status.UNAUTHORIZED)
|
Response.status(Response.Status.UNAUTHORIZED)
|
||||||
.header(HttpHeaders.WWW_AUTHENTICATE,
|
.header(HttpHeaders.WWW_AUTHENTICATE,
|
||||||
AUTHENTICATION_SCHEME + " 215:asdfglkjsqdfgsd4fg56sd4fg23d45fg6sd81fg35sdf4g6d53s4fg3s2d41fg")
|
AUTHENTICATION_SCHEME + " base64(HEADER).base64(CONTENT).base64(KEY)")
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private User validateToken(String authorization) throws Exception {
|
private User validateToken(String authorization) throws Exception {
|
||||||
//System.out.println("-----------------------------------------------------");
|
System.out.println(" validate token : " + authorization);
|
||||||
System.out.println("---- TODO validate token ----");
|
JWTClaimsSet ret = JWTWrapper.validateToken(authorization, "KarAuth");
|
||||||
//System.out.println("-----------------------------------------------------");
|
// check the token is valid !!! (signed and coherent issuer...
|
||||||
// Check if the token was issued by the server and if it's not expired
|
if (ret == null) {
|
||||||
// Throw an Exception if the token is invalid
|
System.out.println("The token is not valid: '" + authorization + "'");
|
||||||
String[] value = authorization.split(":");
|
return null;
|
||||||
long user = Long.valueOf(value[0]);
|
}
|
||||||
String token = value[1];
|
// check userID
|
||||||
UserSmall userOAuth = UserDB.getUserOAuth(user, token);
|
String userUID = ret.getSubject();
|
||||||
//System.out.println("Get local userOAuth : " + userOAuth);
|
long id = Long.parseLong(userUID);
|
||||||
// TODO: Set here the way of the default create user or need to have right to access on this website...
|
System.out.println("request user: '" + userUID + "'");
|
||||||
return UserDB.getUserOrCreate(userOAuth);
|
return UserDB.getUserOrCreate(id, (String)ret.getClaim("login") );
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.filter;
|
||||||
|
|
||||||
import javax.ws.rs.container.ContainerRequestContext;
|
import javax.ws.rs.container.ContainerRequestContext;
|
||||||
import javax.ws.rs.container.ContainerResponseContext;
|
import javax.ws.rs.container.ContainerResponseContext;
|
@ -1,4 +1,4 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.filter;
|
||||||
|
|
||||||
import org.kar.karideo.model.User;
|
import org.kar.karideo.model.User;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.filter;
|
||||||
|
|
||||||
|
|
||||||
import org.kar.karideo.model.User;
|
import org.kar.karideo.model.User;
|
@ -1,4 +1,4 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.filter;
|
||||||
|
|
||||||
import javax.ws.rs.container.ContainerRequestContext;
|
import javax.ws.rs.container.ContainerRequestContext;
|
||||||
import javax.ws.rs.container.ContainerRequestFilter;
|
import javax.ws.rs.container.ContainerRequestFilter;
|
@ -19,6 +19,10 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
|
||||||
public class MediaSmall {
|
public class MediaSmall {
|
||||||
public class MediaStreamProperty {
|
public class MediaStreamProperty {
|
||||||
public Long id;
|
public Long id;
|
||||||
@ -42,7 +46,7 @@ public class MediaSmall {
|
|||||||
public Integer date;
|
public Integer date;
|
||||||
public Integer time;
|
public Integer time;
|
||||||
public String ageLimit;
|
public String ageLimit;
|
||||||
public List<Long> covers = new ArrayList<>();
|
public List<Long> covers = null;
|
||||||
public MediaStreamProperty media;
|
public MediaStreamProperty media;
|
||||||
|
|
||||||
public MediaSmall(ResultSet rs) {
|
public MediaSmall(ResultSet rs) {
|
||||||
@ -86,6 +90,7 @@ public class MediaSmall {
|
|||||||
this.ageLimit = rs.getString(iii++);
|
this.ageLimit = rs.getString(iii++);
|
||||||
String coversString = rs.getString(iii++);
|
String coversString = rs.getString(iii++);
|
||||||
if (!rs.wasNull()) {
|
if (!rs.wasNull()) {
|
||||||
|
covers = new ArrayList<>();
|
||||||
String[] elements = coversString.split("-");
|
String[] elements = coversString.split("-");
|
||||||
for (String elem : elements) {
|
for (String elem : elements) {
|
||||||
Long tmp = Long.parseLong(elem);
|
Long tmp = Long.parseLong(elem);
|
||||||
|
@ -17,12 +17,15 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
|
||||||
|
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
|
||||||
public class NodeSmall {
|
public class NodeSmall {
|
||||||
public Long id;
|
public Long id;
|
||||||
public String name;
|
public String name;
|
||||||
public String description;
|
public String description;
|
||||||
public Long parentId;
|
public Long parentId;
|
||||||
public List<Long> covers = new ArrayList<>();
|
public List<Long> covers = null;
|
||||||
|
|
||||||
public NodeSmall(ResultSet rs) {
|
public NodeSmall(ResultSet rs) {
|
||||||
int iii = 1;
|
int iii = 1;
|
||||||
@ -36,10 +39,11 @@ public class NodeSmall {
|
|||||||
}
|
}
|
||||||
String coversString = rs.getString(iii++);
|
String coversString = rs.getString(iii++);
|
||||||
if (!rs.wasNull()) {
|
if (!rs.wasNull()) {
|
||||||
|
this.covers = new ArrayList<>();
|
||||||
String[] elements = coversString.split("-");
|
String[] elements = coversString.split("-");
|
||||||
for (String elem : elements) {
|
for (String elem : elements) {
|
||||||
Long tmp = Long.parseLong(elem);
|
Long tmp = Long.parseLong(elem);
|
||||||
covers.add(tmp);
|
this.covers.add(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
@ -21,12 +21,10 @@ import java.sql.Timestamp;
|
|||||||
public class User {
|
public class User {
|
||||||
public Long id;
|
public Long id;
|
||||||
public String login;
|
public String login;
|
||||||
public String email;
|
|
||||||
public Timestamp lastConnection;
|
public Timestamp lastConnection;
|
||||||
public boolean admin;
|
public boolean admin;
|
||||||
public boolean blocked;
|
public boolean blocked;
|
||||||
public boolean removed;
|
public boolean removed;
|
||||||
public Long avatar;
|
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
}
|
}
|
||||||
@ -35,11 +33,9 @@ public class User {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.lastConnection = lastConnection;
|
this.lastConnection = lastConnection;
|
||||||
this.email = email;
|
|
||||||
this.admin = admin;
|
this.admin = admin;
|
||||||
this.blocked = blocked;
|
this.blocked = blocked;
|
||||||
this.removed = removed;
|
this.removed = removed;
|
||||||
this.avatar = avatar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(ResultSet rs) {
|
public User(ResultSet rs) {
|
||||||
@ -48,14 +44,9 @@ public class User {
|
|||||||
this.id = rs.getLong(iii++);
|
this.id = rs.getLong(iii++);
|
||||||
this.lastConnection = rs.getTimestamp(iii++);
|
this.lastConnection = rs.getTimestamp(iii++);
|
||||||
this.login = rs.getString(iii++);
|
this.login = rs.getString(iii++);
|
||||||
this.email = rs.getString(iii++);
|
|
||||||
this.admin = "TRUE".equals(rs.getString(iii++));
|
this.admin = "TRUE".equals(rs.getString(iii++));
|
||||||
this.blocked = "TRUE".equals(rs.getString(iii++));
|
this.blocked = "TRUE".equals(rs.getString(iii++));
|
||||||
this.removed = "TRUE".equals(rs.getString(iii++));
|
this.removed = "TRUE".equals(rs.getString(iii++));
|
||||||
this.avatar = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.avatar = null;
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -66,12 +57,10 @@ public class User {
|
|||||||
return "User{" +
|
return "User{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", login='" + login + '\'' +
|
", login='" + login + '\'' +
|
||||||
", email='" + email + '\'' +
|
|
||||||
", lastConnection='" + lastConnection + '\'' +
|
", lastConnection='" + lastConnection + '\'' +
|
||||||
", admin=" + admin +
|
", admin=" + admin +
|
||||||
", blocked=" + blocked +
|
", blocked=" + blocked +
|
||||||
", removed=" + removed +
|
", removed=" + removed +
|
||||||
", avatar=" + avatar +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,11 @@ public class UserExtern {
|
|||||||
public Long id;
|
public Long id;
|
||||||
public String login;
|
public String login;
|
||||||
public boolean admin;
|
public boolean admin;
|
||||||
public Long avatar;
|
|
||||||
|
|
||||||
public UserExtern(User other) {
|
public UserExtern(User other) {
|
||||||
this.id = other.id;
|
this.id = other.id;
|
||||||
this.login = other.login;
|
this.login = other.login;
|
||||||
this.admin = other.admin;
|
this.admin = other.admin;
|
||||||
this.avatar = other.avatar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,7 +31,6 @@ public class UserExtern {
|
|||||||
"id=" + id +
|
"id=" + id +
|
||||||
", login='" + login + '\'' +
|
", login='" + login + '\'' +
|
||||||
", admin=" + admin +
|
", admin=" + admin +
|
||||||
", avatar=" + avatar +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,16 @@ CREATE TABLE `user` (
|
|||||||
public class UserPerso {
|
public class UserPerso {
|
||||||
public Long id;
|
public Long id;
|
||||||
public String login;
|
public String login;
|
||||||
public String email;
|
|
||||||
public boolean admin;
|
public boolean admin;
|
||||||
public boolean blocked;
|
public boolean blocked;
|
||||||
public boolean removed;
|
public boolean removed;
|
||||||
public Long avatar;
|
|
||||||
|
|
||||||
public UserPerso(User other) {
|
public UserPerso(User other) {
|
||||||
this.id = other.id;
|
this.id = other.id;
|
||||||
this.login = other.login;
|
this.login = other.login;
|
||||||
this.email = other.email;
|
|
||||||
this.admin = other.admin;
|
this.admin = other.admin;
|
||||||
this.blocked = other.blocked;
|
this.blocked = other.blocked;
|
||||||
this.removed = other.removed;
|
this.removed = other.removed;
|
||||||
this.avatar = other.avatar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,11 +34,9 @@ public class UserPerso {
|
|||||||
return "User{" +
|
return "User{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", login='" + login + '\'' +
|
", login='" + login + '\'' +
|
||||||
", email='" + email + '\'' +
|
|
||||||
", admin=" + admin +
|
", admin=" + admin +
|
||||||
", blocked=" + blocked +
|
", blocked=" + blocked +
|
||||||
", removed=" + removed +
|
", removed=" + removed +
|
||||||
", avatar=" + avatar +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo.util;
|
||||||
|
|
||||||
public class ConfigVariable {
|
public class ConfigVariable {
|
||||||
|
|
||||||
@ -17,17 +17,18 @@ public class ConfigVariable {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRestOAuthServer() {
|
public static String getFrontFolder() {
|
||||||
String out = System.getenv("org.kar.karideo.rest.oauth");
|
String out = System.getenv("ORG_KARIDEO_FRONT_FOLDER");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "http://localhost:17080/karauth/api/";
|
return "/application/karideo";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getDBHost() {
|
public static String getDBHost() {
|
||||||
String out = System.getenv("org.kar.karideo.db.host");
|
String out = System.getenv("ORG_KARIDEO_DB_HOST");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "localhost";
|
return "localhost";
|
||||||
}
|
}
|
||||||
@ -35,15 +36,15 @@ public class ConfigVariable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getDBPort() {
|
public static String getDBPort() {
|
||||||
String out = System.getenv("org.kar.karideo.db.port");
|
String out = System.getenv("ORG_KARIDEO_DB_PORT");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "15306";
|
return "17036";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDBLogin() {
|
public static String getDBLogin() {
|
||||||
String out = System.getenv("org.kar.karideo.db.login");
|
String out = System.getenv("ORG_KARIDEO_DB_LOGIN");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "root";
|
return "root";
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ public class ConfigVariable {
|
|||||||
public static String getDBPassword() {
|
public static String getDBPassword() {
|
||||||
String out = System.getenv("MYSQL_ROOT_PASSWORD");
|
String out = System.getenv("MYSQL_ROOT_PASSWORD");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "klkhj456gkgtkhjgvkujfhjgkjhgsdfhb3467465fgdhdesfgh";
|
return "ZERTYSDGFVHSDFGHJYZSDFGSQxfgsqdfgsqdrf4564654";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -67,10 +68,18 @@ public class ConfigVariable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getlocalAddress() {
|
public static String getlocalAddress() {
|
||||||
String out = System.getenv("org.kar.karideo.address");
|
String out = System.getenv("ORG_KARIDEO_ADDRESS");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "http://0.0.0.0:18080/karideo/api/";
|
return "http://0.0.0.0:18080/karideo/api/";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getSSOAddress() {
|
||||||
|
String out = System.getenv("SSO_ADDRESS");
|
||||||
|
if (out == null) {
|
||||||
|
return "http://192.168.1.156/karauth/api/";
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
}
|
}
|
175
back/src/org/kar/karideo/util/JWTWrapper.java
Normal file
175
back/src/org/kar/karideo/util/JWTWrapper.java
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
package org.kar.karideo.util;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.nimbusds.jose.JOSEException;
|
||||||
|
import com.nimbusds.jose.JOSEObjectType;
|
||||||
|
import com.nimbusds.jose.JWSAlgorithm;
|
||||||
|
import com.nimbusds.jose.JWSHeader;
|
||||||
|
import com.nimbusds.jose.JWSSigner;
|
||||||
|
import com.nimbusds.jose.JWSVerifier;
|
||||||
|
import com.nimbusds.jose.crypto.RSASSASigner;
|
||||||
|
import com.nimbusds.jose.crypto.RSASSAVerifier;
|
||||||
|
import com.nimbusds.jose.jwk.RSAKey;
|
||||||
|
import com.nimbusds.jose.jwk.gen.RSAKeyGenerator;
|
||||||
|
import com.nimbusds.jwt.JWTClaimsSet;
|
||||||
|
import com.nimbusds.jwt.SignedJWT;
|
||||||
|
|
||||||
|
public class JWTWrapper {
|
||||||
|
private static RSAKey rsaJWK = null;;
|
||||||
|
private static RSAKey rsaPublicJWK = null;
|
||||||
|
|
||||||
|
public static class PublicKey {
|
||||||
|
public String key;
|
||||||
|
|
||||||
|
public PublicKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
public PublicKey() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void initLocalTokenRemote(String ssoUri, String application) throws IOException, ParseException {
|
||||||
|
// check Token:
|
||||||
|
URL obj = new URL(ssoUri + "public_key");
|
||||||
|
System.out.println("Request token from:" + obj);
|
||||||
|
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setRequestProperty("User-Agent", application);
|
||||||
|
con.setRequestProperty("Cache-Control", "no-cache");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestProperty("Accept", "application/json");
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
|
System.out.println("GET Response Code :: " + responseCode);
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) { // success
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
|
||||||
|
String inputLine;
|
||||||
|
StringBuffer response = new StringBuffer();
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
response.append(inputLine);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
// print result
|
||||||
|
System.out.println(response.toString());
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
;
|
||||||
|
PublicKey values = mapper.readValue(response.toString(), PublicKey.class);
|
||||||
|
rsaPublicJWK = RSAKey.parse(values.key);
|
||||||
|
}
|
||||||
|
System.out.println("GET JWT validator token not worked");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initLocalToken() throws Exception{
|
||||||
|
// RSA signatures require a public and private RSA key pair, the public key
|
||||||
|
// must be made known to the JWS recipient in order to verify the signatures
|
||||||
|
try {
|
||||||
|
String generatedStringForKey = UUID.randomUUID().toString();
|
||||||
|
rsaJWK = new RSAKeyGenerator(2048).keyID(generatedStringForKey).generate();
|
||||||
|
rsaPublicJWK = rsaJWK.toPublicJWK();
|
||||||
|
//System.out.println("RSA key (all): " + rsaJWK.toJSONString());
|
||||||
|
//System.out.println("RSA key (pub): " + rsaPublicJWK.toJSONString());
|
||||||
|
} catch (JOSEException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("Can not generate teh public abnd private keys ...");
|
||||||
|
rsaJWK = null;
|
||||||
|
rsaPublicJWK = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initValidateToken(String publicKey) {
|
||||||
|
try {
|
||||||
|
rsaPublicJWK = RSAKey.parse(publicKey);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("Can not retrieve public Key !!!!!!!! RSAKey='" + publicKey + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static String getPublicKey() {
|
||||||
|
if (rsaPublicJWK == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rsaPublicJWK.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a token with the provided elements
|
||||||
|
* @param userID UniqueId of the USER (global unique ID)
|
||||||
|
* @param userLogin Login of the user (never change)
|
||||||
|
* @param isuer The one who provide the Token
|
||||||
|
* @param timeOutInMunites Expiration of the token.
|
||||||
|
* @return the encoded token
|
||||||
|
*/
|
||||||
|
public static String generateJWToken(long userID, String userLogin, String isuer, int timeOutInMunites) {
|
||||||
|
if (rsaJWK == null) {
|
||||||
|
System.out.println("JWT private key is not present !!!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Create RSA-signer with the private key
|
||||||
|
JWSSigner signer = new RSASSASigner(rsaJWK);
|
||||||
|
// Prepare JWT with claims set
|
||||||
|
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
|
||||||
|
.subject(Long.toString(userID))
|
||||||
|
.claim("login", userLogin)
|
||||||
|
.issuer(isuer)
|
||||||
|
.issueTime(new Date())
|
||||||
|
.expirationTime(new Date(new Date().getTime() + 60 * timeOutInMunites * 1000 /* millisecond */))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SignedJWT signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).type(JOSEObjectType.JWT)/*.keyID(rsaJWK.getKeyID())*/.build(), claimsSet);
|
||||||
|
|
||||||
|
// Compute the RSA signature
|
||||||
|
signedJWT.sign(signer);
|
||||||
|
// serialize the output...
|
||||||
|
return signedJWT.serialize();
|
||||||
|
} catch (JOSEException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JWTClaimsSet validateToken(String signedToken, String isuer) {
|
||||||
|
if (rsaPublicJWK == null) {
|
||||||
|
System.out.println("JWT public key is not present !!!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// On the consumer side, parse the JWS and verify its RSA signature
|
||||||
|
SignedJWT signedJWT = SignedJWT.parse(signedToken);
|
||||||
|
|
||||||
|
JWSVerifier verifier = new RSASSAVerifier(rsaPublicJWK);
|
||||||
|
if (!signedJWT.verify(verifier)) {
|
||||||
|
System.out.println("JWT token is NOT verified ");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!new Date().before(signedJWT.getJWTClaimsSet().getExpirationTime())) {
|
||||||
|
System.out.println("JWT token is expired now = " + new Date() + " with=" + signedJWT.getJWTClaimsSet().getExpirationTime() );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!isuer.equals(signedJWT.getJWTClaimsSet().getIssuer())) {
|
||||||
|
System.out.println("JWT issuer is wong: '" + isuer + "' != '" + signedJWT.getJWTClaimsSet().getIssuer() + "'" );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// the element must be validated outside ...
|
||||||
|
//System.out.println("JWT token is verified 'alice' =?= '" + signedJWT.getJWTClaimsSet().getSubject() + "'");
|
||||||
|
//System.out.println("JWT token isuer 'https://c2id.com' =?= '" + signedJWT.getJWTClaimsSet().getIssuer() + "'");
|
||||||
|
return signedJWT.getJWTClaimsSet();
|
||||||
|
} catch (JOSEException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
10
back/src/org/kar/karideo/util/PublicKey.java
Normal file
10
back/src/org/kar/karideo/util/PublicKey.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package org.kar.karideo.util;
|
||||||
|
|
||||||
|
|
||||||
|
public class PublicKey {
|
||||||
|
public String key;
|
||||||
|
|
||||||
|
public PublicKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
@ -10,35 +10,38 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /workspace/data/karideo/db:/var/lib/mysql
|
- /workspace/data/karideo/db:/var/lib/mysql
|
||||||
mem_limit: 600m
|
mem_limit: 600m
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||||
|
timeout: 20s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
karideo_adminer_service:
|
karauth_adminer_service:
|
||||||
image: adminer:latest
|
image: adminer:latest
|
||||||
restart: always
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- karideo_db_service
|
||||||
ports:
|
ports:
|
||||||
- 18079:8080
|
- 18079:8080
|
||||||
links:
|
links:
|
||||||
- karideo_db_service:db
|
- karideo_db_service:db
|
||||||
|
read_only: true
|
||||||
mem_limit: 100m
|
mem_limit: 100m
|
||||||
|
|
||||||
karideo_back_service:
|
karideo_back_service:
|
||||||
build: back/
|
build: .
|
||||||
restart: always
|
restart: always
|
||||||
image: org.kar.video.back
|
image: org.kar.karideo
|
||||||
|
depends_on:
|
||||||
|
- karideo_db_service
|
||||||
ports:
|
ports:
|
||||||
- 18080:18080
|
- 18080:18080
|
||||||
env_file:
|
env_file:
|
||||||
- ./config.env
|
- ./config.env
|
||||||
links:
|
links:
|
||||||
- karideo_db_service:db
|
- karideo_db_service:db
|
||||||
volumes:
|
read_only: true
|
||||||
- /workspace/data/karideo/media:/application/data
|
|
||||||
mem_limit: 1200m
|
mem_limit: 1200m
|
||||||
|
healthcheck:
|
||||||
karideo_front_service:
|
test: ["CMD", "wget" ,"http://localhost:18080/karideo/api/health_check", "-O", "/dev/null"]
|
||||||
build: front/
|
timeout: 20s
|
||||||
restart: always
|
retries: 3
|
||||||
image: org.kar.video.front
|
|
||||||
ports:
|
|
||||||
#- 15081:4200
|
|
||||||
- 18081:80
|
|
||||||
mem_limit: 100m
|
|
||||||
|
@ -7,19 +7,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
||||||
|
|
||||||
import { HomeScene } from './scene/home/home';
|
import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, SsoScene, TypeScene, UniverseScene, UploadScene, VideoEditScene, VideoScene } from './scene';
|
||||||
import { TypeScene } from './scene/type/type';
|
|
||||||
import { UniverseScene } from './scene/universe/universe';
|
|
||||||
import { SeriesScene } from './scene/series/series';
|
|
||||||
import { SeasonScene } from './scene/season/season';
|
|
||||||
import { VideoScene } from './scene/video/video';
|
|
||||||
import { LoginScene } from './scene/login/login';
|
|
||||||
import { SignUpScene } from './scene/sign-up/sign-up';
|
|
||||||
import { SettingsScene } from './scene/settings/settings';
|
|
||||||
import { UploadScene } from './scene/upload/upload';
|
|
||||||
import { VideoEditScene } from './scene/video-edit/video-edit';
|
|
||||||
import { SeriesEditScene } from './scene/series-edit/series-edit';
|
|
||||||
import { SeasonEditScene } from './scene/season-edit/season-edit';
|
|
||||||
// import { HelpComponent } from './help/help.component';
|
// import { HelpComponent } from './help/help.component';
|
||||||
|
|
||||||
// see https://angular.io/guide/router
|
// see https://angular.io/guide/router
|
||||||
@ -42,26 +30,14 @@ const routes: Routes = [
|
|||||||
{ path: 'video/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoScene },
|
{ path: 'video/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoScene },
|
||||||
{ path: 'video-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoEditScene },
|
{ path: 'video-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoEditScene },
|
||||||
|
|
||||||
{ path: 'login', component: LoginScene },
|
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
|
||||||
{ path: 'signup', component: SignUpScene },
|
{ path: 'sso', component: SsoScene },
|
||||||
|
{ path: 'help/:page', component: HelpScene },
|
||||||
|
{ path: 'help', component: HelpScene },
|
||||||
{ path: 'settings', component: SettingsScene },
|
{ path: 'settings', component: SettingsScene },
|
||||||
|
|
||||||
/* { path: 'help', component: HelpComponent }*/
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
|
||||||
@NgModule({
|
|
||||||
imports: [
|
|
||||||
RouterModule.forRoot(routes)
|
|
||||||
],
|
|
||||||
exports: [
|
|
||||||
RouterModule
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
export class AppRoutingModule {}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
|
imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
|
||||||
exports: [ RouterModule ]
|
exports: [ RouterModule ]
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
<div class="main-modal" ng-include="currentModal" ng-if="currentModal != ''" ></div> <!-- (click)="onOutModal()" -->
|
<div class="main-modal" ng-include="currentModal" ng-if="currentModal != ''" ></div> <!-- (click)="onOutModal()" -->
|
||||||
-->
|
-->
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<router-outlet *ngIf="isConnected"></router-outlet>
|
<router-outlet *ngIf="autoConnectedDone"></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { UserService } from './service/user';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { SessionService } from './service/session';
|
import { UserService, SessionService } from './service';
|
||||||
import { CookiesService } from './service/cookies';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -18,41 +17,29 @@ import { CookiesService } from './service/cookies';
|
|||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title: string = 'Karideo';
|
title: string = 'Karideo';
|
||||||
|
autoConnectedDone: boolean = false;
|
||||||
isConnected: boolean = false;
|
isConnected: boolean = false;
|
||||||
|
|
||||||
constructor(private cookiesService: CookiesService,
|
constructor(
|
||||||
private userService: UserService,
|
private router: Router,
|
||||||
private sessionService: SessionService) {
|
private userService: UserService,
|
||||||
|
private sessionService: SessionService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let login = this.cookiesService.get('yota-login');
|
this.autoConnectedDone = false;
|
||||||
let password = this.cookiesService.get('yota-password');
|
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
if(login !== '' &&
|
let self = this;
|
||||||
password !== '' &&
|
this.sessionService.change.subscribe((isConnected) => {
|
||||||
password.length > 40) {
|
console.log(`receive event from session ...${ isConnected}`);
|
||||||
console.log(`Get previous connection ... ${ login }:xxxxxx`);
|
self.isConnected = isConnected;
|
||||||
let self = this;
|
self.autoConnectedDone = true;
|
||||||
this.userService.loginSha(login, password)
|
});
|
||||||
.then((response: any) => {
|
|
||||||
console.log('auto log ==> OK');
|
this.userService.checkAutoConnect().finally(() => {
|
||||||
self.sessionService.create(response.session,
|
self.autoConnectedDone = true;
|
||||||
response.login,
|
});
|
||||||
response.email,
|
|
||||||
response.admin,
|
|
||||||
response.avatar);
|
|
||||||
this.isConnected = true;
|
|
||||||
// self.router.navigate(['home']);
|
|
||||||
}).catch((response: any) => {
|
|
||||||
console.log('auto log ==> Error');
|
|
||||||
self.cookiesService.remove('yota-login');
|
|
||||||
self.cookiesService.remove('yota-password');
|
|
||||||
this.isConnected = true;
|
|
||||||
// this force the need to refresh after connection ...
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,41 +24,12 @@ import { PopInCreateType } from './popin/create-type/create-type';
|
|||||||
import { PopInUploadProgress } from './popin/upload-progress/upload-progress';
|
import { PopInUploadProgress } from './popin/upload-progress/upload-progress';
|
||||||
import { PopInDeleteConfirm } from './popin/delete-confirm/delete-confirm';
|
import { PopInDeleteConfirm } from './popin/delete-confirm/delete-confirm';
|
||||||
|
|
||||||
import { HelpScene } from './scene/help/help';
|
|
||||||
import { LoginScene } from './scene/login/login';
|
|
||||||
import { SignUpScene } from './scene/sign-up/sign-up';
|
|
||||||
import { ValidateEmailScene } from './scene/validate-email/validate-email';
|
|
||||||
import { HomeScene } from './scene/home/home';
|
|
||||||
import { TypeScene } from './scene/type/type';
|
|
||||||
import { UniverseScene } from './scene/universe/universe';
|
|
||||||
import { SeriesScene } from './scene/series/series';
|
|
||||||
import { SeasonScene } from './scene/season/season';
|
|
||||||
import { VideoScene } from './scene/video/video';
|
|
||||||
import { SettingsScene } from './scene/settings/settings';
|
|
||||||
import { ErrorViewerScene } from './scene/error-viewer/error-viewer';
|
|
||||||
import { ErrorComponent } from './error/error';
|
|
||||||
import { VideoEditScene } from './scene/video-edit/video-edit';
|
|
||||||
import { UploadScene } from './scene/upload/upload';
|
|
||||||
import { SeasonEditScene } from './scene/season-edit/season-edit';
|
|
||||||
import { SeriesEditScene } from './scene/series-edit/series-edit';
|
|
||||||
|
|
||||||
import { AuthService } from './service/auth';
|
|
||||||
import { ArianeService } from './service/ariane';
|
|
||||||
import { CookiesService } from './service/cookies';
|
|
||||||
import { HttpWrapperService } from './service/http-wrapper';
|
|
||||||
//import { HttpOAuthWrapperService } from './service/http-oauth-wrapper';
|
|
||||||
import { UserService } from './service/user';
|
|
||||||
import { UniverseService } from './service/universe';
|
|
||||||
import { SeriesService } from './service/series';
|
|
||||||
import { DataService } from './service/data';
|
|
||||||
import { TypeService } from './service/type';
|
|
||||||
import { SeasonService } from './service/season';
|
|
||||||
import { VideoService } from './service/video';
|
|
||||||
import { SessionService } from './service/session';
|
|
||||||
import { BddService } from './service/bdd';
|
|
||||||
import { PopInService } from './service/popin';
|
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
import { ErrorComponent } from './error/error';
|
||||||
|
import { HomeScene, ErrorViewerScene, HelpScene, SsoScene, TypeScene, UniverseScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
|
||||||
|
VideoEditScene, SeasonEditScene, SeriesEditScene, UploadScene } from './scene';
|
||||||
|
import { PopInService, HttpWrapperService, SessionService, CookiesService, StorageService, UserService, SSOService, BddService, TypeService,
|
||||||
|
DataService, UniverseService, SeriesService, SeasonService, VideoService, ArianeService } from './service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -77,22 +48,20 @@ import { AppComponent } from './app.component';
|
|||||||
PopInUploadProgress,
|
PopInUploadProgress,
|
||||||
PopInDeleteConfirm,
|
PopInDeleteConfirm,
|
||||||
|
|
||||||
HelpScene,
|
|
||||||
LoginScene,
|
|
||||||
SignUpScene,
|
|
||||||
ValidateEmailScene,
|
|
||||||
HomeScene,
|
HomeScene,
|
||||||
|
ErrorViewerScene,
|
||||||
|
HelpScene,
|
||||||
|
SsoScene,
|
||||||
TypeScene,
|
TypeScene,
|
||||||
UniverseScene,
|
UniverseScene,
|
||||||
SeriesScene,
|
SeriesScene,
|
||||||
SeasonScene,
|
SeasonScene,
|
||||||
VideoScene,
|
VideoScene,
|
||||||
SettingsScene,
|
SettingsScene,
|
||||||
ErrorViewerScene,
|
|
||||||
VideoEditScene,
|
VideoEditScene,
|
||||||
SeasonEditScene,
|
SeasonEditScene,
|
||||||
SeriesEditScene,
|
SeriesEditScene,
|
||||||
UploadScene
|
UploadScene,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@ -105,11 +74,12 @@ import { AppComponent } from './app.component';
|
|||||||
providers: [
|
providers: [
|
||||||
PopInService,
|
PopInService,
|
||||||
HttpWrapperService,
|
HttpWrapperService,
|
||||||
BddService,
|
|
||||||
AuthService,
|
|
||||||
SessionService,
|
SessionService,
|
||||||
CookiesService,
|
CookiesService,
|
||||||
|
StorageService,
|
||||||
UserService,
|
UserService,
|
||||||
|
SSOService,
|
||||||
|
BddService,
|
||||||
TypeService,
|
TypeService,
|
||||||
DataService,
|
DataService,
|
||||||
UniverseService,
|
UniverseService,
|
||||||
@ -122,16 +92,16 @@ import { AppComponent } from './app.component';
|
|||||||
AppComponent,
|
AppComponent,
|
||||||
TopMenuComponent,
|
TopMenuComponent,
|
||||||
UploadFileComponent,
|
UploadFileComponent,
|
||||||
|
ErrorComponent,
|
||||||
ElementTypeComponent,
|
ElementTypeComponent,
|
||||||
ElementSeriesComponent,
|
ElementSeriesComponent,
|
||||||
ElementSeasonComponent,
|
ElementSeasonComponent,
|
||||||
ElementVideoComponent,
|
ElementVideoComponent,
|
||||||
ErrorComponent,
|
|
||||||
PopInCreateType,
|
PopInCreateType,
|
||||||
|
|
||||||
PopInComponent,
|
PopInComponent,
|
||||||
PopInUploadProgress,
|
PopInUploadProgress,
|
||||||
PopInDeleteConfirm
|
PopInDeleteConfirm,
|
||||||
],
|
],
|
||||||
bootstrap: [
|
bootstrap: [
|
||||||
AppComponent
|
AppComponent
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
<div>
|
<!--<canvas width="200" height="250" style="border:1px solid #d3d3d3;" id="imageCanvas" #imageCanvas></canvas>-->
|
||||||
<!--<canvas width="200" height="250" style="border:1px solid #d3d3d3;" id="imageCanvas" #imageCanvas></canvas>-->
|
<img src="{{cover}}"/>
|
||||||
<img src="{{cover}}"/>
|
|
||||||
</div>
|
|
@ -5,8 +5,8 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="imgContainer-small">
|
<div class="imgContainer-small">
|
||||||
<div *ngIf="cover">
|
<div *ngIf="covers">
|
||||||
<img src="{{cover}}" alt="type image" class="miniature-small"/>
|
<img src="{{covers[0]}}" alt="type image" class="miniature-small"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="title-small">
|
<div class="title-small">
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { isArrayOf, isNumberFinite } from '../../utils';
|
||||||
|
|
||||||
import { TypeService } from '../../service/type';
|
import { TypeService } from '../../service/type';
|
||||||
|
import { NodeData } from '../..//model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-type',
|
selector: 'app-element-type',
|
||||||
@ -13,86 +15,50 @@ import { TypeService } from '../../service/type';
|
|||||||
styleUrls: [ './element-type.less' ]
|
styleUrls: [ './element-type.less' ]
|
||||||
})
|
})
|
||||||
|
|
||||||
@Injectable()
|
//@Injectable()
|
||||||
export class ElementTypeComponent implements OnInit {
|
export class ElementTypeComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() idType:number = -1;
|
@Input() idType:number = -1;
|
||||||
|
|
||||||
imageSource:string = '';
|
public name: string = 'rr';
|
||||||
name:string = '';
|
public description: string = 'sdqdfqsd';
|
||||||
error:string = '';
|
|
||||||
description:string = '';
|
|
||||||
countvideo:number = null;
|
|
||||||
countserie:number = null;
|
|
||||||
|
|
||||||
cover:string = '';
|
public imageSource:string; // TODO: remove this ...
|
||||||
covers:Array<string> = [];
|
public error:string;
|
||||||
|
public countvideo:number;
|
||||||
|
public countserie:number;
|
||||||
|
|
||||||
|
public covers: string[];
|
||||||
|
|
||||||
constructor(private typeService: TypeService) {
|
constructor(private typeService: TypeService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.name = `ll ${ this.idType}`;
|
|
||||||
let self = this;
|
let self = this;
|
||||||
console.log(`get parameter id: ${ this.idType}`);
|
//console.log(`get parameter id: ${ this.idType}`);
|
||||||
this.typeService.get(this.idType)
|
this.typeService.get(this.idType)
|
||||||
.then((response) => {
|
.then((response: NodeData) => {
|
||||||
|
//console.log("Get element ! " + JSON.stringify(response));
|
||||||
self.error = '';
|
self.error = '';
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
if(!isArrayOf(response.covers, isNumberFinite) || response.covers.length === 0) {
|
||||||
self.cover = null;
|
self.covers = undefined;
|
||||||
// self.covers = [];
|
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.typeService.getCoverThumbnailUrl(response.covers[0]);
|
self.covers = [];
|
||||||
for(let iii = 0; iii < response.covers.length; iii++) {
|
for(let iii = 0; iii < response.covers.length; iii++) {
|
||||||
self.covers.push(self.typeService.getCoverThumbnailUrl(response.covers[iii]));
|
self.covers.push(self.typeService.getCoverThumbnailUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (self.name) {
|
|
||||||
case 'Documentary':
|
|
||||||
self.imageSource = 'assets/images/type_documentary.svg';
|
|
||||||
break;
|
|
||||||
case 'Movie':
|
|
||||||
self.imageSource = 'assets/images/type_film.svg';
|
|
||||||
break;
|
|
||||||
case 'Annimation':
|
|
||||||
self.imageSource = 'assets/images/type_annimation.svg';
|
|
||||||
break;
|
|
||||||
case 'Short Films':
|
|
||||||
self.imageSource = 'assets/images/type_film-short.svg';
|
|
||||||
break;
|
|
||||||
case 'tv show':
|
|
||||||
self.imageSource = 'assets/images/type_tv-show.svg';
|
|
||||||
break;
|
|
||||||
case 'Anniation tv show':
|
|
||||||
self.imageSource = 'assets/images/type_tv-show-annimation.svg';
|
|
||||||
break;
|
|
||||||
case 'Theater':
|
|
||||||
self.imageSource = 'assets/images/type_theater.svg';
|
|
||||||
break;
|
|
||||||
case 'One man show':
|
|
||||||
self.imageSource = 'assets/images/type_one-man-show.svg';
|
|
||||||
break;
|
|
||||||
case 'Concert':
|
|
||||||
self.imageSource = 'assets/images/type_concert.svg';
|
|
||||||
break;
|
|
||||||
case 'Opera':
|
|
||||||
self.imageSource = 'assets/images/type_opera.svg';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.error = 'Can not get the data';
|
self.error = 'Can not get the data';
|
||||||
self.name = '';
|
self.name = undefined;
|
||||||
self.description = '';
|
self.description = undefined;
|
||||||
self.imageSource = '';
|
self.imageSource = undefined;
|
||||||
self.cover = null;
|
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
});
|
});
|
||||||
this.typeService.countVideo(this.idType)
|
this.typeService.countVideo(this.idType)
|
||||||
.then((response) => {
|
.then((response: number) => {
|
||||||
self.countvideo = response;
|
self.countvideo = response;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.countvideo = 0;
|
self.countvideo = 0;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="videoImgContainer">
|
<div class="videoImgContainer">
|
||||||
<div *ngIf="cover">
|
<div *ngIf="cover">
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
<!--<data-image id="{{cover}}"></data-image>-->
|
||||||
<img src="{{cover}}"/>-->
|
<img src="{{cover}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!cover" class="noImage">
|
<div *ngIf="!cover" class="noImage">
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { PopInService } from '../../service/popin';
|
import { PopInService } from '../../service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
// moduleId: module.id.toString(),
|
// moduleId: module.id.toString(),
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="ariane">
|
<div class="ariane">
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeTypeId != null"
|
*ngIf="arianeTypeId !== null"
|
||||||
title="Uype"
|
title="Uype"
|
||||||
(click)="onArianeType($event)"
|
(click)="onArianeType($event)"
|
||||||
(auxclick)="onArianeType($event)">
|
(auxclick)="onArianeType($event)">
|
||||||
@ -23,9 +23,9 @@
|
|||||||
T
|
T
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div class="item_ariane_separator" *ngIf="arianeUniverseId != null && arianeTypeId != null" >/</div>
|
<div class="item_ariane_separator" *ngIf="arianeUniverseId !== null && arianeTypeId !== null" >/</div>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeUniverseId != null"
|
*ngIf="arianeUniverseId !== null"
|
||||||
title="Universe"
|
title="Universe"
|
||||||
(click)="onArianeUniverse($event)"
|
(click)="onArianeUniverse($event)"
|
||||||
(auxclick)="onArianeUniverse($event)">
|
(auxclick)="onArianeUniverse($event)">
|
||||||
@ -36,9 +36,9 @@
|
|||||||
U
|
U
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div class="item_ariane_separator" *ngIf="arianeSeriesId != null && (arianeUniverseId != null || arianeTypeId != null)" >/</div>
|
<div class="item_ariane_separator" *ngIf="arianeSeriesId !== null && (arianeUniverseId !== null || arianeTypeId !== null)" >/</div>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeriesId != null"
|
*ngIf="arianeSeriesId !== null"
|
||||||
title="Series"
|
title="Series"
|
||||||
(click)="onArianeSeries($event)"
|
(click)="onArianeSeries($event)"
|
||||||
(auxclick)="onArianeSeries($event)">
|
(auxclick)="onArianeSeries($event)">
|
||||||
@ -49,9 +49,9 @@
|
|||||||
G
|
G
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div class="item_ariane_separator" *ngIf="arianeSeasonId != null && (arianeSeriesId != null || arianeUniverseId != null || arianeTypeId != null)" >/</div>
|
<div class="item_ariane_separator" *ngIf="arianeSeasonId !== null && (arianeSeriesId !== null || arianeUniverseId !== null || arianeTypeId !== null)" >/</div>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeasonId != null"
|
*ngIf="arianeSeasonId !== null"
|
||||||
title="Season"
|
title="Season"
|
||||||
(click)="onArianeSeason($event)"
|
(click)="onArianeSeason($event)"
|
||||||
(auxclick)="onArianeSeason($event)">
|
(auxclick)="onArianeSeason($event)">
|
||||||
@ -66,8 +66,8 @@
|
|||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="login === null"
|
*ngIf="login === null"
|
||||||
style="float:right;"
|
style="float:right;"
|
||||||
(click)="onSignIn($event)"
|
(click)="onSignUp($event)"
|
||||||
(auxclick)="onSignIn($event)">
|
(auxclick)="onSignUp($event)">
|
||||||
<div class="xdesktop">
|
<div class="xdesktop">
|
||||||
<i class="material-icons">add_circle_outline</i> Sign-up
|
<i class="material-icons">add_circle_outline</i> Sign-up
|
||||||
</div>
|
</div>
|
||||||
@ -76,10 +76,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="login == null"
|
*ngIf="login === null"
|
||||||
style="float:right;"
|
style="float:right;"
|
||||||
(click)="onLogin($event)"
|
(click)="onSignIn($event)"
|
||||||
(auxclick)="onLogin($event)">
|
(auxclick)="onSignIn($event)">
|
||||||
<div class="xdesktop">
|
<div class="xdesktop">
|
||||||
<i class="material-icons">account_circle</i> Sign-in
|
<i class="material-icons">account_circle</i> Sign-in
|
||||||
</div>
|
</div>
|
||||||
@ -88,13 +88,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="login != null"
|
*ngIf="login !== null"
|
||||||
style="float:right; height:56px;"
|
style="float:right; height:56px;"
|
||||||
(click)="onAvatar()">
|
(click)="onAvatar()">
|
||||||
<img class="avatar" src="{{avatar}}"/>
|
<img class="avatar" src="{{avatar}}"/>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="editShow == true"
|
*ngIf="editShow === true"
|
||||||
style="float:right; height:56px;"
|
style="float:right; height:56px;"
|
||||||
(click)="onEdit()">
|
(click)="onEdit()">
|
||||||
<div class="xdesktop">
|
<div class="xdesktop">
|
||||||
@ -105,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="login != null && displayUserMenu == true" (click)="onOutUserProperty()">
|
<div class="fill-all" *ngIf="login !== null && displayUserMenu === true" (click)="onOutUserProperty()">
|
||||||
<!-- (click)="onOutUserProperty()" -->
|
<!-- (click)="onOutUserProperty()" -->
|
||||||
<div class="sub-menu user-menu color-menu-background">
|
<div class="sub-menu user-menu color-menu-background">
|
||||||
<button class="item" disabled="disabled">
|
<button class="item" disabled="disabled">
|
||||||
@ -139,32 +139,32 @@
|
|||||||
<div class="sub-menu edit-menu color-menu-background">
|
<div class="sub-menu edit-menu color-menu-background">
|
||||||
<!--
|
<!--
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeTypeId != null"
|
*ngIf="arianeTypeId !== null"
|
||||||
(click)="onSubEditType($event)"
|
(click)="onSubEditType($event)"
|
||||||
(auxclick)="onSubEditType($event)">
|
(auxclick)="onSubEditType($event)">
|
||||||
<b>Edit Type</b>
|
<b>Edit Type</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeUniverseId != null"
|
*ngIf="arianeUniverseId !== null"
|
||||||
(click)="onSubEditUniverse($event)"
|
(click)="onSubEditUniverse($event)"
|
||||||
(auxclick)="onSubEditUniverse($event)">
|
(auxclick)="onSubEditUniverse($event)">
|
||||||
<b>Edit Universe</b>
|
<b>Edit Universe</b>
|
||||||
</button>
|
</button>
|
||||||
-->
|
-->
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeriesId != null"
|
*ngIf="arianeSeriesId !== null"
|
||||||
(click)="onSubEditSeries($event)"
|
(click)="onSubEditSeries($event)"
|
||||||
(auxclick)="onSubEditSeries($event)">
|
(auxclick)="onSubEditSeries($event)">
|
||||||
<b>Edit Series</b>
|
<b>Edit Series</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeasonId != null"
|
*ngIf="arianeSeasonId !== null"
|
||||||
(click)="onSubEditSeason($event)"
|
(click)="onSubEditSeason($event)"
|
||||||
(auxclick)="onSubEditSeason($event)">
|
(auxclick)="onSubEditSeason($event)">
|
||||||
<b>Edit Season</b>
|
<b>Edit Season</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeVideoId != null"
|
*ngIf="arianeVideoId !== null"
|
||||||
(click)="onSubEditVideo($event)"
|
(click)="onSubEditVideo($event)"
|
||||||
(auxclick)="onSubEditVideo($event)">
|
(auxclick)="onSubEditVideo($event)">
|
||||||
<b>Edit Video</b>
|
<b>Edit Video</b>
|
||||||
@ -175,32 +175,32 @@
|
|||||||
<div class="sub-menu edit-menu-mob color-menu-background">
|
<div class="sub-menu edit-menu-mob color-menu-background">
|
||||||
<!--
|
<!--
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeTypeId != null"
|
*ngIf="arianeTypeId !== null"
|
||||||
(click)="onSubEditType($event)"
|
(click)="onSubEditType($event)"
|
||||||
(auxclick)="onSubEditType($event)">
|
(auxclick)="onSubEditType($event)">
|
||||||
<b>Edit Type</b>
|
<b>Edit Type</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeUniverseId != null"
|
*ngIf="arianeUniverseId !== null"
|
||||||
(click)="onSubEditUniverse($event)"
|
(click)="onSubEditUniverse($event)"
|
||||||
(auxclick)="onSubEditUniverse($event)">
|
(auxclick)="onSubEditUniverse($event)">
|
||||||
<b>Edit Universe</b>
|
<b>Edit Universe</b>
|
||||||
</button>
|
</button>
|
||||||
-->
|
-->
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeriesId != null"
|
*ngIf="arianeSeriesId !== null"
|
||||||
(click)="onSubEditSeries($event)"
|
(click)="onSubEditSeries($event)"
|
||||||
(auxclick)="onSubEditSeries($event)">
|
(auxclick)="onSubEditSeries($event)">
|
||||||
<b>Edit Series</b>
|
<b>Edit Series</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeSeasonId != null"
|
*ngIf="arianeSeasonId !== null"
|
||||||
(click)="onSubEditSeason($event)"
|
(click)="onSubEditSeason($event)"
|
||||||
(auxclick)="onSubEditSeason($event)">
|
(auxclick)="onSubEditSeason($event)">
|
||||||
<b>Edit Season</b>
|
<b>Edit Season</b>
|
||||||
</button>
|
</button>
|
||||||
<button class="item"
|
<button class="item"
|
||||||
*ngIf="arianeVideoId != null"
|
*ngIf="arianeVideoId !== null"
|
||||||
(click)="onSubEditVideo($event)"
|
(click)="onSubEditVideo($event)"
|
||||||
(auxclick)="onSubEditVideo($event)">
|
(auxclick)="onSubEditVideo($event)">
|
||||||
<b>Edit Video</b>
|
<b>Edit Video</b>
|
||||||
@ -208,4 +208,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,8 +8,7 @@ import { Injectable, Component, OnInit } from '@angular/core';
|
|||||||
// import { AppRoutingModule } from "../app-routing.module";
|
// import { AppRoutingModule } from "../app-routing.module";
|
||||||
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { SessionService } from '../../service/session';
|
import { UserService, SessionService, SSOService, ArianeService } from '../../service';
|
||||||
import { ArianeService } from '../../service/ariane';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-top-menu',
|
selector: 'app-top-menu',
|
||||||
@ -42,25 +41,27 @@ export class TopMenuComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private sessionService: SessionService,
|
private sessionService: SessionService,
|
||||||
private arianeService: ArianeService) {
|
private arianeService: ArianeService,
|
||||||
|
private userService: UserService,
|
||||||
|
private ssoService: SSOService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
let self = this;
|
||||||
this.sessionService.change.subscribe((isConnected) => {
|
this.sessionService.change.subscribe((isConnected) => {
|
||||||
console.log(`receive event from session ...${ isConnected}`);
|
console.log(`TOP-MENU: receive event from session ...${isConnected}`);
|
||||||
if(isConnected === false) {
|
if(isConnected === false) {
|
||||||
this.login = null;
|
self.login = null;
|
||||||
this.avatar = null;
|
self.avatar = null;
|
||||||
this.displayUserMenu = false;
|
self.displayUserMenu = false;
|
||||||
} else {
|
} else {
|
||||||
this.login = this.sessionService.getLogin();
|
self.updateIsJusteLogged();
|
||||||
this.avatar = this.sessionService.getAvatar();
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
console.log(` login:${ this.sessionService.getLogin()}`);
|
|
||||||
console.log(` avatar:${ this.avatar}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (this.sessionService.islogged()) {
|
||||||
|
this.updateIsJusteLogged();
|
||||||
|
}
|
||||||
this.arianeService.typeChange.subscribe((typeId: number) => {
|
this.arianeService.typeChange.subscribe((typeId: number) => {
|
||||||
this.arianeTypeId = typeId;
|
this.arianeTypeId = typeId;
|
||||||
this.arianeTypeName = this.arianeService.getTypeName();
|
this.arianeTypeName = this.arianeService.getTypeName();
|
||||||
@ -87,54 +88,22 @@ export class TopMenuComponent implements OnInit {
|
|||||||
this.updateEditShow();
|
this.updateEditShow();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateEditShow():void {
|
|
||||||
this.editShow = /* this.arianeTypeId !== null
|
private updateIsJusteLogged(): void {
|
||||||
|| this.arianeUniverseId !== null
|
this.login = this.sessionService.getLogin();
|
||||||
||*/ this.arianeSeriesId !== null ||
|
this.avatar = this.sessionService.getAvatar();
|
||||||
this.arianeSeasonId !== null ||
|
this.displayUserMenu = false;
|
||||||
this.arianeVideoId !== null;
|
console.log(` login:${this.sessionService.getLogin()}`);
|
||||||
|
console.log(` avatar:${this.avatar}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onAvatar(): void {
|
onAvatar(): void {
|
||||||
console.log(`onAvatar() ${ this.displayUserMenu}`);
|
console.log(`onAvatar() ${ this.displayUserMenu}`);
|
||||||
this.displayUserMenu = !this.displayUserMenu;
|
this.displayUserMenu = !this.displayUserMenu;
|
||||||
this.displayEditMenu = false;
|
this.displayEditMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onEdit(): void {
|
|
||||||
console.log('onEdit()');
|
|
||||||
this.displayEditMenu = !this.displayEditMenu;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
}
|
|
||||||
onSubEditVideo(event: any): void {
|
|
||||||
console.log('onSubEdit()');
|
|
||||||
this.displayEditMenu = false;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
this.arianeService.navigateVideoEdit(this.arianeVideoId, event.which === 2);
|
|
||||||
}
|
|
||||||
onSubEditSeason(event: any): void {
|
|
||||||
console.log('onSubEdit()');
|
|
||||||
this.displayEditMenu = false;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
this.arianeService.navigateSeasonEdit(this.arianeSeasonId, event.which === 2);
|
|
||||||
}
|
|
||||||
onSubEditSeries(event: any): void {
|
|
||||||
console.log('onSubEdit()');
|
|
||||||
this.displayEditMenu = false;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
this.arianeService.navigateSeriesEdit(this.arianeSeriesId, event.which === 2);
|
|
||||||
}
|
|
||||||
onSubEditUniverse(event: any): void {
|
|
||||||
console.log('onSubEdit()');
|
|
||||||
this.displayEditMenu = false;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
this.arianeService.navigateUniverseEdit(this.arianeUniverseId, event.which === 2);
|
|
||||||
}
|
|
||||||
onSubEditType(event: any): void {
|
|
||||||
console.log('onSubEditType()');
|
|
||||||
this.displayEditMenu = false;
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
this.arianeService.navigateTypeEdit(this.arianeTypeId, event.which === 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
onHome(event: any): void {
|
onHome(event: any): void {
|
||||||
console.log('onHome()');
|
console.log('onHome()');
|
||||||
@ -143,29 +112,23 @@ export class TopMenuComponent implements OnInit {
|
|||||||
|
|
||||||
onSignIn(event: any): void {
|
onSignIn(event: any): void {
|
||||||
console.log('onSignIn()');
|
console.log('onSignIn()');
|
||||||
// Session.destroy();
|
this.ssoService.requestSignIn();
|
||||||
this.router.navigate([ 'signup' ]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogin(event: any): void {
|
onSignUp(event: any): void {
|
||||||
console.log('onLogin()');
|
console.log('onSignIn()');
|
||||||
// Session.destroy();
|
this.ssoService.requestSignUp();
|
||||||
this.router.navigate([ 'login' ]);
|
|
||||||
this.displayUserMenu = false;
|
this.displayUserMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogout(event: any): void {
|
onLogout(event: any): void {
|
||||||
console.log('onLogout()');
|
console.log('onLogout()');
|
||||||
this.sessionService.destroy();
|
this.ssoService.requestSignOut();
|
||||||
this.router.navigate([ 'home' ]);
|
this.userService.logOut();
|
||||||
|
this.router.navigate(['home']);
|
||||||
this.displayUserMenu = false;
|
this.displayUserMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddMedia(event: any): void {
|
|
||||||
console.log('onAddMedia()');
|
|
||||||
this.router.navigate([ 'upload' ]);
|
|
||||||
this.displayUserMenu = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSetting(event: any): void {
|
onSetting(event: any): void {
|
||||||
console.log('onSetting()');
|
console.log('onSetting()');
|
||||||
@ -204,4 +167,52 @@ export class TopMenuComponent implements OnInit {
|
|||||||
console.log(`onArianeSeason(${ this.arianeSeasonId })`);
|
console.log(`onArianeSeason(${ this.arianeSeasonId })`);
|
||||||
this.arianeService.navigateSeason(this.arianeSeasonId, event.which === 2);
|
this.arianeService.navigateSeason(this.arianeSeasonId, event.which === 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateEditShow():void {
|
||||||
|
this.editShow = /* this.arianeTypeId !== null
|
||||||
|
|| this.arianeUniverseId !== null
|
||||||
|
||*/ this.arianeSeriesId !== null ||
|
||||||
|
this.arianeSeasonId !== null ||
|
||||||
|
this.arianeVideoId !== null;
|
||||||
|
}
|
||||||
|
onEdit(): void {
|
||||||
|
console.log('onEdit()');
|
||||||
|
this.displayEditMenu = !this.displayEditMenu;
|
||||||
|
this.displayUserMenu = false;
|
||||||
|
}
|
||||||
|
onSubEditVideo(event: any): void {
|
||||||
|
console.log('onSubEdit()');
|
||||||
|
this.displayEditMenu = false;
|
||||||
|
this.displayUserMenu = false;
|
||||||
|
this.arianeService.navigateVideoEdit(this.arianeVideoId, event.which === 2);
|
||||||
|
}
|
||||||
|
onSubEditSeason(event: any): void {
|
||||||
|
console.log('onSubEdit()');
|
||||||
|
this.displayEditMenu = false;
|
||||||
|
this.displayUserMenu = false;
|
||||||
|
this.arianeService.navigateSeasonEdit(this.arianeSeasonId, event.which === 2);
|
||||||
|
}
|
||||||
|
onSubEditSeries(event: any): void {
|
||||||
|
console.log('onSubEdit()');
|
||||||
|
this.displayEditMenu = false;
|
||||||
|
this.displayUserMenu = false;
|
||||||
|
this.arianeService.navigateSeriesEdit(this.arianeSeriesId, event.which === 2);
|
||||||
|
}
|
||||||
|
onSubEditUniverse(event: any): void {
|
||||||
|
console.log('onSubEdit()');
|
||||||
|
this.displayEditMenu = false;
|
||||||
|
this.displayUserMenu = false;
|
||||||
|
this.arianeService.navigateUniverseEdit(this.arianeUniverseId, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
8
front/src/app/model/index.ts
Normal file
8
front/src/app/model/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Media, isMedia } from "./media";
|
||||||
|
import { NodeData, isNodeData } from "./node";
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
NodeData, isNodeData,
|
||||||
|
Media, isMedia,
|
||||||
|
}
|
51
front/src/app/model/media.ts
Normal file
51
front/src/app/model/media.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { isObject, isNumberFinite, isString, isOptionalOf, isOptionalArrayOf } from "../utils";
|
||||||
|
import { isNodeData, NodeData } from "./node";
|
||||||
|
|
||||||
|
|
||||||
|
export interface Media extends NodeData {
|
||||||
|
dataId?: number;
|
||||||
|
typeId?: number;
|
||||||
|
universeId?: number;
|
||||||
|
seriesId?: number;
|
||||||
|
seasonId?: number;
|
||||||
|
episode?: number;
|
||||||
|
date?: number;
|
||||||
|
time?: number;
|
||||||
|
ageLimit?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function isMedia(data: any): data is Media {
|
||||||
|
if (!isNodeData(data) as any) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.dataId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.typeId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.universeId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.seriesId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.seasonId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.episode, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.date, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.time, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.ageLimit, isString)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
34
front/src/app/model/node.ts
Normal file
34
front/src/app/model/node.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { isArrayOf, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString } from "../utils";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface NodeData {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
parentId?: number;
|
||||||
|
covers?: number[];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export function isNodeData(data: any): data is NodeData {
|
||||||
|
if (!isObject(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isNumberFinite(data.id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isString(data.name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.description, isString)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalOf(data.parentId, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isOptionalArrayOf(data.cover, isNumberFinite)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { Injectable, Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Injectable, Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { PopInService } from '../../service/popin';
|
import { PopInService } from '../../service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'delete-confirm',
|
selector: 'delete-confirm',
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
import { Injectable, Component, OnInit, Input, SimpleChanges } from '@angular/core';
|
import { Injectable, Component, OnInit, Input, SimpleChanges } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { PopInService } from '../../service/popin';
|
import { PopInService } from '../../service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'upload-progress',
|
selector: 'upload-progress',
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
<p>
|
<div class="generic-page">
|
||||||
help works!
|
<div class="title">
|
||||||
</p>
|
Karauth (SSO identity manager) Help area.
|
||||||
|
</div>
|
||||||
|
<div class="fill-all colomn_mutiple">
|
||||||
|
Help
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
.title {
|
||||||
|
//background-color: green;
|
||||||
|
font-size: 45px;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 60px;
|
||||||
|
width:100%;
|
||||||
|
align: left;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 10px 0 10px 0;
|
||||||
|
text-shadow: 1px 1px 2px white, 0 0 1em white, 0 0 0.2em white;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-family: "Roboto","Helvetica","Arial",sans-serif;
|
||||||
|
}
|
||||||
|
.item-home {
|
||||||
|
background-color: rgba(200, 200, 200, 0.5);
|
||||||
|
font-size: 20px;
|
||||||
|
height: 190px;
|
||||||
|
width: 200px;
|
||||||
|
margin: 5px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
// box-shadow: 0 1px 1.5px 0 rgba(0,0,0,.12),0 1px 1px 0 rgba(0,0,0,.24);
|
||||||
|
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
|
||||||
|
line-height: normal;
|
||||||
|
border: none;
|
||||||
|
font-family: "Roboto","Helvetica","Arial","sans-serif";
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0;
|
||||||
|
will-change: box-shadow;
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
float:left;
|
||||||
|
display:block;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(200, 200, 200, 1);
|
||||||
|
//box-shadow: 0px 2px 4px 0 rgba(255, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: ~"translate(-12px,-12px)";
|
||||||
|
line-height: 24px;
|
||||||
|
width: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (min-width: 1310px) {
|
||||||
|
.colomn_mutiple {
|
||||||
|
width: ~"calc(210px * 5)";
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
}
|
@ -14,10 +14,25 @@ import { ArianeService } from '../../service/ariane';
|
|||||||
styleUrls: [ './help.less' ]
|
styleUrls: [ './help.less' ]
|
||||||
})
|
})
|
||||||
export class HelpScene implements OnInit {
|
export class HelpScene implements OnInit {
|
||||||
|
page = '';
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private arianeService: ArianeService) { }
|
private arianeService: ArianeService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectType(_event: any, _idSelected: number):void {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
front/src/app/scene/index.ts
Normal file
34
front/src/app/scene/index.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { ErrorViewerScene } from "./error-viewer/error-viewer";
|
||||||
|
import { HelpScene } from "./help/help";
|
||||||
|
import { HomeScene } from "./home/home";
|
||||||
|
import { SeasonEditScene } from "./season-edit/season-edit";
|
||||||
|
import { SeasonScene } from "./season/season";
|
||||||
|
import { SeriesEditScene } from "./series-edit/series-edit";
|
||||||
|
import { SeriesScene } from "./series/series";
|
||||||
|
import { SettingsScene } from "./settings/settings";
|
||||||
|
import { SsoScene } from "./sso/sso";
|
||||||
|
import { TypeScene } from "./type/type";
|
||||||
|
import { UniverseScene } from "./universe/universe";
|
||||||
|
import { UploadScene } from "./upload/upload";
|
||||||
|
import { VideoEditScene } from "./video-edit/video-edit";
|
||||||
|
import { VideoScene } from "./video/video";
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
ErrorViewerScene,
|
||||||
|
HelpScene,
|
||||||
|
HomeScene,
|
||||||
|
SsoScene,
|
||||||
|
SettingsScene,
|
||||||
|
SeasonScene,
|
||||||
|
SeasonEditScene,
|
||||||
|
SeriesScene,
|
||||||
|
SeriesEditScene,
|
||||||
|
TypeScene,
|
||||||
|
UniverseScene,
|
||||||
|
UploadScene,
|
||||||
|
VideoScene,
|
||||||
|
VideoEditScene,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
<div class="full">
|
|
||||||
<div class="color-background-vignette container-global">
|
|
||||||
<div class="imgContainer">
|
|
||||||
<img src="assets/images/avatar_generic.svg" alt="Avatar" class="avatar"/>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<label for="login_field"><b>{{loginType}}</b></label>
|
|
||||||
<input id="username"
|
|
||||||
name="username"
|
|
||||||
type="text"
|
|
||||||
required=""
|
|
||||||
placeholder="Enter Username/e-mail"
|
|
||||||
[value]="login"
|
|
||||||
(input)="checkLogin($event.target.value)"
|
|
||||||
/>
|
|
||||||
<div class="error color-shadow-black" *ngIf="loginHelp">{{loginHelp}}</div>
|
|
||||||
<label for="password"><b>Password</b></label> <a class="forgot" href="#">Forgot password?</a>
|
|
||||||
<input type="password"
|
|
||||||
id="password"
|
|
||||||
name="password"
|
|
||||||
placeholder="Enter Password"
|
|
||||||
required=""
|
|
||||||
[value]="password"
|
|
||||||
(input)="checkPassword($event.target.value)"
|
|
||||||
/>
|
|
||||||
<div class="error color-shadow-black" *ngIf="passHelp">{{passHelp}}</div>
|
|
||||||
<label class="container-checkbox">
|
|
||||||
Remember me
|
|
||||||
<input type="checkbox" ng-model="rememberMe"/>
|
|
||||||
<span class="checkmark"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<button class="button cancel color-button-cancel color-shadow-black"
|
|
||||||
(click)="onCancel()">Cancel</button>
|
|
||||||
<button class="button login color-button-validate color-shadow-black"
|
|
||||||
id="login-button"
|
|
||||||
[disabled]="loginButtonDisabled"
|
|
||||||
(click)="onLogin()"
|
|
||||||
type="submit">Login</button>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
{{error}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,169 +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 { ActivatedRoute } from '@angular/router';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { Location } from '@angular/common';
|
|
||||||
import { UserService } from '../../service/user';
|
|
||||||
import { SessionService } from '../../service/session';
|
|
||||||
import { CookiesService } from '../../service/cookies';
|
|
||||||
import { ArianeService } from '../../service/ariane';
|
|
||||||
|
|
||||||
|
|
||||||
export function checkLoginValidity(value:string):boolean {
|
|
||||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
|
||||||
if(regexCheck.test(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkEmailValidity(value:string):boolean {
|
|
||||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@-]+@[a-zA-Z0-9_\\.-]+\\.[a-zA-Z]+$');
|
|
||||||
if(regexCheck.test(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkPasswordValidity(value:string):boolean {
|
|
||||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@ %:;,=}{\\?\\!\\*\\+\\(\\)\\[\\]\\|&#%~/\\\\\\<\\>-£€]+$');
|
|
||||||
if(regexCheck.test(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
declare function SHA512(param1: any): any;
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-login',
|
|
||||||
templateUrl: './login.html',
|
|
||||||
styleUrls: [ './login.less' ]
|
|
||||||
})
|
|
||||||
export class LoginScene implements OnInit {
|
|
||||||
public loginOK:boolean = false;
|
|
||||||
public loginHelp:string = '';
|
|
||||||
public login:string = '';
|
|
||||||
public passOK:boolean = false;
|
|
||||||
public passHelp:string = '';
|
|
||||||
public password:string = '';
|
|
||||||
public loginButtonDisabled:boolean = true;
|
|
||||||
public error:string = '';
|
|
||||||
public loginType:string = 'Username/E-mail';
|
|
||||||
|
|
||||||
public rememberMe:boolean = true;
|
|
||||||
|
|
||||||
constructor(private router: Router,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
private locate: Location,
|
|
||||||
private cookiesService: CookiesService,
|
|
||||||
private userService: UserService,
|
|
||||||
private sessionService: SessionService,
|
|
||||||
private arianeService: ArianeService) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
// If already loaded ==> jusp in the home page ...
|
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateButtonVisibility():void {
|
|
||||||
if(this.loginOK === true &&
|
|
||||||
this.passOK === true) {
|
|
||||||
this.loginButtonDisabled = false;
|
|
||||||
} else {
|
|
||||||
this.loginButtonDisabled = true;
|
|
||||||
}
|
|
||||||
this.error = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the login writing rules
|
|
||||||
*/
|
|
||||||
checkLogin(newValue:string):void {
|
|
||||||
this.login = newValue;
|
|
||||||
if(this.login === null) {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginHelp = '';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.login.length < 6) {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginHelp = 'Need 6 characters';
|
|
||||||
this.loginType = 'Username/E-mail';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(checkLoginValidity(this.login) === true) {
|
|
||||||
this.loginOK = true;
|
|
||||||
this.loginHelp = '';
|
|
||||||
this.loginType = 'Username';
|
|
||||||
} else if(checkEmailValidity(this.login) === true) {
|
|
||||||
this.loginOK = true;
|
|
||||||
this.loginHelp = '';
|
|
||||||
this.loginType = 'E-mail';
|
|
||||||
} else {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
|
||||||
}
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the password writing rules
|
|
||||||
*/
|
|
||||||
checkPassword(newValue:string):void {
|
|
||||||
this.password = newValue;
|
|
||||||
if(this.password === null) {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = '';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.password.length < 6) {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = 'Need 6 characters';
|
|
||||||
} else if(checkPasswordValidity(this.password) === true) {
|
|
||||||
this.passOK = true;
|
|
||||||
this.passHelp = '';
|
|
||||||
} else {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
|
|
||||||
}
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
onLogin():void {
|
|
||||||
this.sessionService.destroy();
|
|
||||||
let self = this;
|
|
||||||
this.userService.login(this.login, this.password)
|
|
||||||
.then((response) => {
|
|
||||||
self.error = 'Login ...';
|
|
||||||
self.sessionService.create(response.sessionId,
|
|
||||||
response.login,
|
|
||||||
response.email,
|
|
||||||
response.role,
|
|
||||||
response.avatar);
|
|
||||||
if(self.rememberMe === true) {
|
|
||||||
self.cookiesService.set('yota-login', response.login, 120);
|
|
||||||
self.cookiesService.set('yota-password', SHA512(self.password), 60);
|
|
||||||
}
|
|
||||||
self.router.navigate([ 'home' ]);
|
|
||||||
}).catch((response) => {
|
|
||||||
self.error = 'Wrong e-mail/login or password';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
onCancel():void {
|
|
||||||
console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
|
|
||||||
this.locate.back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -41,6 +41,7 @@ export class SeasonScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.seasonService.get(this.idSeason)
|
this.seasonService.get(this.idSeason)
|
||||||
.then((response:any) => {
|
.then((response:any) => {
|
||||||
|
console.log("Get element ! " + JSON.stringify(response));
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.seriesId = response.parentId;
|
self.seriesId = response.parentId;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
|
@ -45,8 +45,8 @@ export class SeriesEditScene implements OnInit {
|
|||||||
uploadFileValue:string = '';
|
uploadFileValue:string = '';
|
||||||
selectedFiles:FileList;
|
selectedFiles:FileList;
|
||||||
|
|
||||||
seasonsCount:string = null;
|
seasonsCount: string = null;
|
||||||
videoCount:string = null;
|
videoCount: string = null;
|
||||||
|
|
||||||
coversDisplay:Array<any> = [];
|
coversDisplay:Array<any> = [];
|
||||||
// section tha define the upload value to display in the pop-in of upload
|
// section tha define the upload value to display in the pop-in of upload
|
||||||
@ -124,15 +124,15 @@ export class SeriesEditScene implements OnInit {
|
|||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
});
|
});
|
||||||
console.log(`get parameter id: ${ this.idSeries}`);
|
console.log(`get parameter id: ${ this.idSeries}`);
|
||||||
this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
|
this.seriesService.getSeason(this.idSeries)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.seasonsCount = response.length;
|
self.seasonsCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.seasonsCount = '---';
|
self.seasonsCount = '---';
|
||||||
});
|
});
|
||||||
this.seriesService.getVideo(this.idSeries)
|
this.seriesService.getVideo(this.idSeries)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.videoCount = response.length;
|
self.videoCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.videoCount = '---';
|
self.videoCount = '---';
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
|
|
||||||
import { SeriesService } from '../../service/series';
|
import { SeriesService } from '../../service/series';
|
||||||
import { ArianeService } from '../../service/ariane';
|
import { ArianeService } from '../../service/ariane';
|
||||||
|
import { NodeData } from '../../model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-series',
|
selector: 'app-series',
|
||||||
@ -23,7 +24,7 @@ export class SeriesScene implements OnInit {
|
|||||||
cover: string = '';
|
cover: string = '';
|
||||||
covers: Array<string> = [];
|
covers: Array<string> = [];
|
||||||
seasonsError: string = '';
|
seasonsError: string = '';
|
||||||
seasons: Array<any> = [];
|
seasons: NodeData[] = [];
|
||||||
videosError: string = '';
|
videosError: string = '';
|
||||||
videos: Array<any> = [];
|
videos: Array<any> = [];
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
@ -65,9 +66,10 @@ export class SeriesScene implements OnInit {
|
|||||||
self.covers = [];
|
self.covers = [];
|
||||||
// no check just ==> an error occured on season
|
// no check just ==> an error occured on season
|
||||||
});
|
});
|
||||||
console.log(`get parameter id: ${ this.idSeries}`);
|
//console.log(`get parameter id: ${ this.idSeries}`);
|
||||||
this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
|
this.seriesService.getSeason(this.idSeries)
|
||||||
.then((response) => {
|
.then((response: NodeData[]) => {
|
||||||
|
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
|
||||||
self.seasonsError = '';
|
self.seasonsError = '';
|
||||||
self.seasons = response;
|
self.seasons = response;
|
||||||
updateEnded.subSaison = true;
|
updateEnded.subSaison = true;
|
||||||
@ -79,7 +81,8 @@ export class SeriesScene implements OnInit {
|
|||||||
self.checkIfJumpIsNeeded(updateEnded);
|
self.checkIfJumpIsNeeded(updateEnded);
|
||||||
});
|
});
|
||||||
this.seriesService.getVideo(this.idSeries)
|
this.seriesService.getVideo(this.idSeries)
|
||||||
.then((response) => {
|
.then((response: NodeData[]) => {
|
||||||
|
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
|
||||||
self.videosError = '';
|
self.videosError = '';
|
||||||
self.videos = response;
|
self.videos = response;
|
||||||
updateEnded.subVideo = true;
|
updateEnded.subVideo = true;
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
<p>
|
<div class="generic-page">
|
||||||
settings works!
|
<div class="title">
|
||||||
</p>
|
Karauth (SSO identity manager)
|
||||||
|
</div>
|
||||||
|
<div class="fill-all colomn_mutiple">
|
||||||
|
Global settings.
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
.title {
|
||||||
|
//background-color: green;
|
||||||
|
font-size: 45px;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 60px;
|
||||||
|
width:100%;
|
||||||
|
align: left;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 10px 0 10px 0;
|
||||||
|
text-shadow: 1px 1px 2px white, 0 0 1em white, 0 0 0.2em white;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-family: "Roboto","Helvetica","Arial",sans-serif;
|
||||||
|
}
|
||||||
|
.item-home {
|
||||||
|
background-color: rgba(200, 200, 200, 0.5);
|
||||||
|
font-size: 20px;
|
||||||
|
height: 190px;
|
||||||
|
width: 200px;
|
||||||
|
margin: 5px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
// box-shadow: 0 1px 1.5px 0 rgba(0,0,0,.12),0 1px 1px 0 rgba(0,0,0,.24);
|
||||||
|
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
|
||||||
|
line-height: normal;
|
||||||
|
border: none;
|
||||||
|
font-family: "Roboto","Helvetica","Arial","sans-serif";
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0;
|
||||||
|
will-change: box-shadow;
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
float:left;
|
||||||
|
display:block;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(200, 200, 200, 1);
|
||||||
|
//box-shadow: 0px 2px 4px 0 rgba(255, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: ~"translate(-12px,-12px)";
|
||||||
|
line-height: 24px;
|
||||||
|
width: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (min-width: 1310px) {
|
||||||
|
.colomn_mutiple {
|
||||||
|
width: ~"calc(210px * 5)";
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
}
|
@ -14,10 +14,25 @@ import { ArianeService } from '../../service/ariane';
|
|||||||
styleUrls: [ './settings.less' ]
|
styleUrls: [ './settings.less' ]
|
||||||
})
|
})
|
||||||
export class SettingsScene implements OnInit {
|
export class SettingsScene implements OnInit {
|
||||||
|
page = '';
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private arianeService: ArianeService) { }
|
private arianeService: ArianeService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectType(_event: any, _idSelected: number):void {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
<div class="left">
|
|
||||||
<div class="global-help">
|
|
||||||
<div class="comment"><label class="unselectable">Rate and comment your medias</label></div>
|
|
||||||
<div class="share"><label class="unselectable">Shared personal media at home</label></div>
|
|
||||||
<div class="time"><label>Keep last view position</label></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<div class="modal-content color-background-vignette container-global">
|
|
||||||
<div class="logo">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<label for="login_field" ><b>Login</b></label>
|
|
||||||
<input id="username"
|
|
||||||
name="username"
|
|
||||||
class="{{loginIcon}}"
|
|
||||||
type="text"
|
|
||||||
required=""
|
|
||||||
placeholder="Pick a Username"
|
|
||||||
[value]="login"
|
|
||||||
(input)="checkLogin($event.target.value)"
|
|
||||||
/>
|
|
||||||
<div class="error color-shadow-black" *ngIf="loginHelp">{{loginHelp}}</div>
|
|
||||||
<label for="login_field" ><b>E-mail</b></label>
|
|
||||||
<input id="email"
|
|
||||||
name="e-mail"
|
|
||||||
class="{{emailIcon}}"
|
|
||||||
type="text"
|
|
||||||
required=""
|
|
||||||
placeholder="you@example.com"
|
|
||||||
[value]="email"
|
|
||||||
(input)="checkEmail($event.target.value)"
|
|
||||||
/>
|
|
||||||
<div class="error color-shadow-black" *ngIf="emailHelp">{{emailHelp}}</div>
|
|
||||||
<label for="password"><b>Password</b></label>
|
|
||||||
<input type="password"
|
|
||||||
id="password"
|
|
||||||
name="password"
|
|
||||||
class="{{passIcon}}"
|
|
||||||
placeholder="Enter Password"
|
|
||||||
required=""
|
|
||||||
[value]="password"
|
|
||||||
(input)="checkPassword($event.target.value)"
|
|
||||||
/>
|
|
||||||
<div class="error color-shadow-black" *ngIf="passHelp">{{passHelp}}</div>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<button class="button fill-x color-button-validate color-shadow-black" id="onSignUp-button" [disabled]="signUpButtonDisabled" (click)="onSignUp()" type="submit"><i class="material-icons">mode_edit</i> Sign up for Karideo</button>
|
|
||||||
</div>
|
|
||||||
<div class="container commmon-policy">
|
|
||||||
By clicking "Sign up for Karideo", you agree to our <a class="" href="https://help.karideo.com/terms" target="_blank">terms of service</a> and <a class="" href="https://help.karideo.com/privacy" target="_blank">privacy policy</a>.<br/>
|
|
||||||
Well occasionally send you account related emails.
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<a class="forgot" href="#">Forgot password?</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
{{error}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,162 +0,0 @@
|
|||||||
|
|
||||||
.right{
|
|
||||||
width:50%;
|
|
||||||
height:100%;
|
|
||||||
right:0;
|
|
||||||
margin:0;
|
|
||||||
padding:0;
|
|
||||||
border:0;
|
|
||||||
float:right;
|
|
||||||
display:block;
|
|
||||||
}
|
|
||||||
.left{
|
|
||||||
width:50%;
|
|
||||||
height:100%;
|
|
||||||
left:0;
|
|
||||||
margin:0;
|
|
||||||
padding:0;
|
|
||||||
border:0;
|
|
||||||
float:left;
|
|
||||||
display:block;
|
|
||||||
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
.comment {
|
|
||||||
background-image: url("../../../assets/images/comments.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
.share {
|
|
||||||
background-image: url("../../../assets/images/share.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
.time {
|
|
||||||
background-image: url("../../../assets/images/time.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
input[type=text], input[type=password] {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 35px 12px 15px;
|
|
||||||
margin: 8px 0;
|
|
||||||
display: inline-block;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
.global-help {
|
|
||||||
position:relative;
|
|
||||||
max-width:500px;
|
|
||||||
padding: 16px 32px 16px 32px;
|
|
||||||
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: ~"translate(-50%, -50%)";
|
|
||||||
font-size: 30px;
|
|
||||||
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: left;
|
|
||||||
line-height: 200%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container-global {
|
|
||||||
position:relative;
|
|
||||||
max-width:400px;
|
|
||||||
padding: 16px 32px 16px 32px;
|
|
||||||
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: ~"translate(-50%, -50%)";
|
|
||||||
box-shadow: 0px 8px 20px 0 rgba(0, 0, 0, 0.9);
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
padding: 16px 0 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.psw {
|
|
||||||
float: right;
|
|
||||||
padding-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.help {
|
|
||||||
color: #E44;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.forgot {
|
|
||||||
color: #00B;
|
|
||||||
font-size: 14px;
|
|
||||||
float: right;
|
|
||||||
buttum: 0;
|
|
||||||
line-height: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.commmon-policy {
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 300;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.icon-right-load {
|
|
||||||
background: white url("../../../assets/images/load.svg") right no-repeat;
|
|
||||||
background-size: 35px;
|
|
||||||
padding-right: 17px;
|
|
||||||
}
|
|
||||||
.icon-right-validate {
|
|
||||||
background: white url("../../../assets/images/validate.svg") right no-repeat;
|
|
||||||
background-size: 35px;
|
|
||||||
padding-right: 17px;
|
|
||||||
}
|
|
||||||
.icon-right-not-validate {
|
|
||||||
background: white url("../../../assets/images/validate-not.svg") right no-repeat;
|
|
||||||
background-size: 35px;
|
|
||||||
padding-right: 17px;
|
|
||||||
}
|
|
||||||
.error {
|
|
||||||
background-color: #f44336;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 10;
|
|
||||||
display: block;
|
|
||||||
max-width: 450px;
|
|
||||||
padding: 5px 8px;
|
|
||||||
margin: 2px 0 0;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 400;
|
|
||||||
border-style: solid;
|
|
||||||
border-width: 0px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
&:after, &:before {
|
|
||||||
bottom: 100%;
|
|
||||||
left: 25px;
|
|
||||||
border: solid transparent;
|
|
||||||
content: " ";
|
|
||||||
height: 0;
|
|
||||||
width: 0;
|
|
||||||
position: absolute;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:after {
|
|
||||||
border-bottom-color: #f44336;
|
|
||||||
border-width: 10px;
|
|
||||||
margin-left: -10px;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,231 +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, ActivatedRoute } from '@angular/router';
|
|
||||||
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../login/login';
|
|
||||||
import { UserService } from '../../service/user';
|
|
||||||
import { ArianeService } from '../../service/ariane';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-sign-up',
|
|
||||||
templateUrl: './sign-up.html',
|
|
||||||
styleUrls: [ './sign-up.less' ]
|
|
||||||
})
|
|
||||||
|
|
||||||
export class SignUpScene implements OnInit {
|
|
||||||
private signUpIconWrong:string = 'icon-right-not-validate';
|
|
||||||
private signUpIconWait:string = 'icon-right-load';
|
|
||||||
private signUpIconRight:string = 'icon-right-validate';
|
|
||||||
|
|
||||||
public login:string = '';
|
|
||||||
public loginOK:boolean = false;
|
|
||||||
public loginHelp:string = '';
|
|
||||||
public loginIcon:string = '';
|
|
||||||
|
|
||||||
public email:string = '';
|
|
||||||
public emailOK:boolean = false;
|
|
||||||
public emailHelp:string = '';
|
|
||||||
public emailIcon:string = '';
|
|
||||||
|
|
||||||
public password:string = '';
|
|
||||||
public passOK:boolean = false;
|
|
||||||
public passHelp:string = '';
|
|
||||||
public passIcon:string = '';
|
|
||||||
|
|
||||||
public signUpButtonDisabled:boolean = true;
|
|
||||||
public error:string = '';
|
|
||||||
|
|
||||||
public rememberMe:boolean = true;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private userService: UserService,
|
|
||||||
private router: Router,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
private arianeService: ArianeService) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updateButtonVisibility():void {
|
|
||||||
if(this.loginOK === true &&
|
|
||||||
this.passOK === true &&
|
|
||||||
this.emailOK === true) {
|
|
||||||
this.signUpButtonDisabled = false;
|
|
||||||
} else {
|
|
||||||
this.signUpButtonDisabled = true;
|
|
||||||
}
|
|
||||||
this.error = '';
|
|
||||||
}
|
|
||||||
checkLogin(newValue:string):void {
|
|
||||||
// this.userService.loginSha("loooogin", "ekljkj", true);
|
|
||||||
this.login = newValue;
|
|
||||||
if(this.login === null ||
|
|
||||||
this.login.length === 0) {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginIcon = '';
|
|
||||||
this.loginHelp = '';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.login.length < 6) {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginHelp = 'Need 6 characters';
|
|
||||||
this.loginIcon = '';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(checkLoginValidity(this.login) === true) {
|
|
||||||
this.loginOK = false;
|
|
||||||
// this.loginHelp = "check in progress...";
|
|
||||||
this.loginIcon = this.signUpIconWait;
|
|
||||||
let self = this;
|
|
||||||
this.userService.checkLogin(this.login).then(() => {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if(newValue !== self.login) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// the login exist ... ==> it is found...
|
|
||||||
self.loginOK = false;
|
|
||||||
self.loginHelp = 'Login already used ...';
|
|
||||||
self.loginIcon = self.signUpIconWrong;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
}, (error: number) => {
|
|
||||||
console.log(`1 ${ self}`);
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if(newValue !== self.login) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(error === 404) {
|
|
||||||
self.loginOK = true;
|
|
||||||
self.loginHelp = '';
|
|
||||||
self.loginIcon = self.signUpIconRight;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(`Status ${ error}`);
|
|
||||||
self.loginOK = false;
|
|
||||||
self.loginHelp = 'Login already used ...';
|
|
||||||
self.loginIcon = self.signUpIconWrong;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.loginOK = false;
|
|
||||||
this.loginHelp = 'Not valid: characters, numbers and "_-."';
|
|
||||||
}
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEmail(newValue:string):void {
|
|
||||||
this.email = newValue;
|
|
||||||
if(this.email === null ||
|
|
||||||
this.email.length === 0) {
|
|
||||||
this.emailOK = false;
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
this.emailIcon = '';
|
|
||||||
this.emailHelp = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.email.length < 6) {
|
|
||||||
this.emailOK = false;
|
|
||||||
this.emailHelp = 'Need 6 characters';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
this.passIcon = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(checkEmailValidity(this.email) === true) {
|
|
||||||
this.emailOK = false;
|
|
||||||
this.emailHelp = '';
|
|
||||||
// this.loginHelp = "check in progress...";
|
|
||||||
this.emailIcon = this.signUpIconWait;
|
|
||||||
let self = this;
|
|
||||||
this.userService.checkEMail(this.email).then(() => {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if(newValue !== self.email) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// the email exist ... ==> it is found...
|
|
||||||
self.emailOK = false;
|
|
||||||
self.emailHelp = 'email already used ...';
|
|
||||||
self.emailIcon = self.signUpIconWrong;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
}, (error: number) => {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if(newValue !== self.email) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(error === 404) {
|
|
||||||
self.emailOK = true;
|
|
||||||
self.emailHelp = '';
|
|
||||||
self.emailIcon = self.signUpIconRight;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(`Status ${ error}`);
|
|
||||||
self.emailOK = false;
|
|
||||||
self.emailHelp = 'email already used ...';
|
|
||||||
self.emailIcon = self.signUpIconWrong;
|
|
||||||
self.updateButtonVisibility();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.emailOK = false;
|
|
||||||
this.emailHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
|
||||||
}
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkPassword(newValue:string):void {
|
|
||||||
this.password = newValue;
|
|
||||||
console.log(`ooooooooooooooo ${ this.password}`);
|
|
||||||
if(this.password === null) {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = '';
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.password.length < 6) {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = 'Need 6 characters';
|
|
||||||
} else if(checkPasswordValidity(this.password) === true) {
|
|
||||||
this.passOK = true;
|
|
||||||
this.passHelp = '';
|
|
||||||
} else {
|
|
||||||
this.passOK = false;
|
|
||||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
|
|
||||||
}
|
|
||||||
this.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
onSignUp():void {
|
|
||||||
console.log('Validate ... ');
|
|
||||||
if(this.signUpButtonDisabled === true) {
|
|
||||||
// ... notify user ...
|
|
||||||
console.log('Not permited action ... ==> control does not validate this action ...');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let self = this;
|
|
||||||
// disable the currect button
|
|
||||||
this.signUpButtonDisabled = true;
|
|
||||||
this.userService.create(this.login, this.email, this.password).then(
|
|
||||||
(value) => {
|
|
||||||
console.log('User created');
|
|
||||||
self.router.navigate([ 'login' ]);
|
|
||||||
// send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
|
||||||
}, (value) => {
|
|
||||||
console.log('User NOT created');
|
|
||||||
// send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
onCancel():void {
|
|
||||||
console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
|
|
||||||
// $rootScope.currentModal = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
28
front/src/app/scene/sso/sso.html
Normal file
28
front/src/app/scene/sso/sso.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<div class="full">
|
||||||
|
<div class="color-background-vignette container-global">
|
||||||
|
<div class="containerCenter">
|
||||||
|
<label for="login_field"><b>LOGIN (after SSO)</b></label>
|
||||||
|
</div>
|
||||||
|
<div class="imgContainer">
|
||||||
|
<img src="assets/images/avatar_generic.svg" alt="Avatar" class="avatar"/>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token === '__CANCEL__'">
|
||||||
|
<label for="login_field"><b>ERROR: </b> Request cancel of connection !</label>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token === '__FAIL__'">
|
||||||
|
<label for="login_field"><b>ERROR: </b> Connection FAIL !</label>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token === '__LOGOUT__'">
|
||||||
|
<label for="login_field"><b>Dis-connected: </b> Redirect soon! </label>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token === 'ERROR_ME'">
|
||||||
|
<label for="login_field"><b>ERROR: </b> can not retreive user local informations!</label>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token !== 'ERROR_ME' and token !== '__FAIL__' and token !== '__CANCEL__' and token === '__LOGOUT__'">
|
||||||
|
<label for="login_field"><b>Connected: </b> Redirect soon!</label>
|
||||||
|
</div>
|
||||||
|
<div class="container" *ngIf="token !== 'ERROR_ME' and token !== '__FAIL__' and token !== '__CANCEL__' and token === '__LOGOUT__'">
|
||||||
|
<label for="login_field"><b>Welcome back: </b> {{userName}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -28,6 +28,11 @@ input[type=text], input[type=password] {
|
|||||||
margin: 2% 2%;
|
margin: 2% 2%;
|
||||||
width: 45%;
|
width: 45%;
|
||||||
}
|
}
|
||||||
|
.containerCenter {
|
||||||
|
text-align: center;
|
||||||
|
margin: 15px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.imgContainer {
|
.imgContainer {
|
||||||
text-align: center;
|
text-align: center;
|
86
front/src/app/scene/sso/sso.ts
Normal file
86
front/src/app/scene/sso/sso.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license PROPRIETARY (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { SSOService, UserService } from '../../service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-sso',
|
||||||
|
templateUrl: './sso.html',
|
||||||
|
styleUrls: [ './sso.less' ]
|
||||||
|
})
|
||||||
|
export class SsoScene implements OnInit {
|
||||||
|
ssoData: string;
|
||||||
|
token: string;
|
||||||
|
keepConnected: boolean
|
||||||
|
userName: string
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private ssoService: SSOService,
|
||||||
|
private userService: UserService) {
|
||||||
|
console.error("retreive data after SSO");
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
let self = this;
|
||||||
|
console.error("retreive data after SSO ng-init");
|
||||||
|
const ssoData = this.route.snapshot.paramMap.get('data');
|
||||||
|
if (ssoData == null) {
|
||||||
|
this.ssoData = undefined;
|
||||||
|
} else {
|
||||||
|
this.ssoData = ssoData;
|
||||||
|
}
|
||||||
|
const token = this.route.snapshot.paramMap.get('token');
|
||||||
|
if (token == null) {
|
||||||
|
this.token = undefined;
|
||||||
|
} else {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
const keepConnected = this.route.snapshot.paramMap.get('keepConnected');
|
||||||
|
if (keepConnected == null) {
|
||||||
|
this.keepConnected = undefined;
|
||||||
|
} else {
|
||||||
|
this.keepConnected = keepConnected === 'true';
|
||||||
|
}
|
||||||
|
console.error(`ssoData: '${ssoData}'`);
|
||||||
|
console.error(`token: '${token}'`);
|
||||||
|
console.error(`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
|
||||||
|
const realDst = this.ssoService.unHashLocalData(destination);
|
||||||
|
console.error(`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
|
||||||
|
}).catch(() => {
|
||||||
|
this.token = "ERROR_ME";
|
||||||
|
})
|
||||||
|
} else if (this.token === '__LOGOUT__') {
|
||||||
|
this.userService.removeSession();
|
||||||
|
const destination = (this.ssoData);
|
||||||
|
console.error(`ssoData (decoded): '${destination}'`);
|
||||||
|
// sample : ZZ**DST:home
|
||||||
|
const realDst = this.ssoService.unHashLocalData(destination);
|
||||||
|
console.error(`realDst: '${realDst}'`);
|
||||||
|
setTimeout(function(){
|
||||||
|
self.router.navigate([ realDst ], { replaceUrl:true });
|
||||||
|
}, 2000); // 2 seconds
|
||||||
|
} else {
|
||||||
|
this.userService.removeSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ export class TypeScene implements OnInit {
|
|||||||
self.covers = [];
|
self.covers = [];
|
||||||
self.cover = null;
|
self.cover = null;
|
||||||
});
|
});
|
||||||
this.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
|
this.typeService.getSubSeries(this.typeId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-series: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-series: ${JSON.stringify(response)}`);
|
||||||
self.seriessError = '';
|
self.seriessError = '';
|
||||||
@ -75,7 +75,7 @@ export class TypeScene implements OnInit {
|
|||||||
self.seriessError = 'Wrong e-mail/login or password';
|
self.seriessError = 'Wrong e-mail/login or password';
|
||||||
self.seriess = [];
|
self.seriess = [];
|
||||||
});
|
});
|
||||||
this.typeService.getSubVideo(this.typeId, [ 'id', 'name' ])
|
this.typeService.getSubVideo(this.typeId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-video: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-video: ${JSON.stringify(response)}`);
|
||||||
self.videosError = '';
|
self.videosError = '';
|
||||||
|
@ -175,7 +175,7 @@ export class UploadScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
if(this.typeId !== null) {
|
if(this.typeId !== null) {
|
||||||
self.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
|
self.typeService.getSubSeries(this.typeId)
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for(let iii = 0; iii < response2.length; iii++) {
|
for(let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
@ -573,7 +573,7 @@ export class UploadScene implements OnInit {
|
|||||||
|
|
||||||
self.saisonId = null;
|
self.saisonId = null;
|
||||||
// set 1 find the ID of the season:
|
// set 1 find the ID of the season:
|
||||||
this.seriesService.getSeason(this.seriesId, [ 'id', 'name' ])
|
this.seriesService.getSeason(this.seriesId)
|
||||||
.then((response: any[]) => {
|
.then((response: any[]) => {
|
||||||
// console.log("find season: " + response.length);
|
// console.log("find season: " + response.length);
|
||||||
for(let iii = 0; iii < response.length; iii++) {
|
for(let iii = 0; iii < response.length; iii++) {
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
<div class="sign" ng-controller="controlerValidateEmail">
|
|
||||||
<div class="full-back">
|
|
||||||
<div class="global-help">
|
|
||||||
<i class="material-icons big-one">email</i>
|
|
||||||
<div>Waiting email validation ...</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="button sender color-button-validate color-shadow-light" ng-disabled="syncButtonDisabled" (click)="onSend()">
|
|
||||||
<i class="material-icons">send</i> re-send the validation code.
|
|
||||||
</button>
|
|
||||||
<button class="button last-update color-button-normal color-shadow-light" ng-disabled="sendButtonDisabled" (click)="onCheck()">
|
|
||||||
<i class="material-icons">loop</i> 18h15
|
|
||||||
</button>
|
|
||||||
</div>
|
|
@ -1,122 +0,0 @@
|
|||||||
sign {
|
|
||||||
.full-back{
|
|
||||||
position:absolute;
|
|
||||||
width:100%;
|
|
||||||
height:100%;
|
|
||||||
right:100;
|
|
||||||
background-color:#2b3137;
|
|
||||||
|
|
||||||
background-image: url("../../../assets/images/ikon_gray.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
/*
|
|
||||||
background-size: contain;
|
|
||||||
*/
|
|
||||||
background-size: 80%;
|
|
||||||
background-attachment: fixed;
|
|
||||||
background-position: 50% 50%;
|
|
||||||
|
|
||||||
z-index:-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left{
|
|
||||||
width:50%;
|
|
||||||
height:100%;
|
|
||||||
left:0;
|
|
||||||
margin:0;
|
|
||||||
padding:0;
|
|
||||||
border:0;
|
|
||||||
float:left;
|
|
||||||
display:block;
|
|
||||||
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
.comment {
|
|
||||||
background-image: url("../../../assets/images/comments.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
.share {
|
|
||||||
background-image: url("../../../assets/images/share.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
.forget {
|
|
||||||
background-image: url("../../../assets/images/erase.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
.time {
|
|
||||||
background-image: url("../../../assets/images/time.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
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 #2b3137;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.global-help {
|
|
||||||
color: white;
|
|
||||||
text-shadow:0px 0px 4px #2b3137;
|
|
||||||
position:relative;
|
|
||||||
max-width:500px;
|
|
||||||
padding: 16px 32px 16px 32px;
|
|
||||||
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 30px;
|
|
||||||
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: center;
|
|
||||||
line-height: 200%;
|
|
||||||
.big-one {
|
|
||||||
font-size: 90px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.sender {
|
|
||||||
position: fixed;
|
|
||||||
display: block;
|
|
||||||
float: buttom;
|
|
||||||
top: 80%;
|
|
||||||
left:50%;
|
|
||||||
transform: translate(-50%, 0%);
|
|
||||||
//background-color: #4CAF50;
|
|
||||||
//padding: 14px 20px;
|
|
||||||
margin: 1%;
|
|
||||||
vertical-align: middle;
|
|
||||||
width:350px;
|
|
||||||
}
|
|
||||||
.last-update {
|
|
||||||
position: fixed;
|
|
||||||
display: block;
|
|
||||||
float: buttom;
|
|
||||||
top: 90%;
|
|
||||||
left:50%;
|
|
||||||
transform: translate(-50%, 0%);
|
|
||||||
//background-color: transparent;
|
|
||||||
//background-color: #2b3137;
|
|
||||||
//padding: 14px 20px;
|
|
||||||
margin: 1%;
|
|
||||||
vertical-align: middle;
|
|
||||||
width:350px;
|
|
||||||
color:white;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,260 +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 { ActivatedRoute } from '@angular/router';
|
|
||||||
import { ArianeService } from '../../service/ariane';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-validate-email',
|
|
||||||
templateUrl: './validate-email.html',
|
|
||||||
styleUrls: [ './validate-email.less' ]
|
|
||||||
})
|
|
||||||
export class ValidateEmailScene implements OnInit {
|
|
||||||
constructor(private route: ActivatedRoute,
|
|
||||||
private arianeService: ArianeService
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSend() {
|
|
||||||
}
|
|
||||||
onCheck() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
app.controller("controlerValidateEmail", function($scope, $http, $rootScope, AuthService) {
|
|
||||||
$scope.sendButtonDisabled = false;
|
|
||||||
$scope.syncButtonDisabled = false;
|
|
||||||
$scope.error = "";
|
|
||||||
|
|
||||||
$scope.rememberMe = true;
|
|
||||||
|
|
||||||
$rootScope.currentModalCanRemove = true;
|
|
||||||
|
|
||||||
$scope.updateButtonVisibility = function() {
|
|
||||||
if ( $scope.loginOK == true
|
|
||||||
&& $scope.passOK == true
|
|
||||||
&& $scope.emailOK == true) {
|
|
||||||
$scope.signUpButtonDisabled = false;
|
|
||||||
} else {
|
|
||||||
$scope.signUpButtonDisabled = true;
|
|
||||||
}
|
|
||||||
$scope.error = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.checkLogin = function() {
|
|
||||||
if ( $scope.login == null
|
|
||||||
|| $scope.login.length == 0) {
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginIcon = "";
|
|
||||||
$scope.loginHelp = "";
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($scope.login.length < 6) {
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginHelp = "Need 6 characters";
|
|
||||||
$scope.loginIcon = "";
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checkLoginValidity($scope.login) == true) {
|
|
||||||
$scope.loginOK = false;
|
|
||||||
//$scope.loginHelp = "check in progress...";
|
|
||||||
$scope.loginIcon = signUp_iconWait;
|
|
||||||
let data = {
|
|
||||||
"login": $scope.login
|
|
||||||
}
|
|
||||||
let connectionAdresse = createRESTCall("user/check/login");
|
|
||||||
let config = {
|
|
||||||
params: data
|
|
||||||
};
|
|
||||||
let tmpLogin = "" + $scope.login;
|
|
||||||
console.log("call " + connectionAdresse + " data=" + JSON.stringify(data, null, 2));
|
|
||||||
$http.get(connectionAdresse, config)
|
|
||||||
.then(function(response) {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if (tmpLogin !== $scope.login) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
if (response.status == 200) {
|
|
||||||
// the login exist ... ==> it is found...
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginHelp = "Login already used ...";
|
|
||||||
$scope.loginIcon = signUp_iconWrong;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginHelp = "Login already used ... (error 2)";
|
|
||||||
}, function(response) {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if (tmpLogin !== $scope.login) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (response.status == 404) {
|
|
||||||
$scope.loginOK = true;
|
|
||||||
$scope.loginHelp = "";
|
|
||||||
$scope.loginIcon = signUp_iconRight;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginHelp = "Login already used ...";
|
|
||||||
$scope.loginIcon = signUp_iconWrong;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$scope.loginOK = false;
|
|
||||||
$scope.loginHelp = 'Not valid: characters, numbers and "_-."';
|
|
||||||
}
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.checkEmail = function() {
|
|
||||||
if ( $scope.email == null
|
|
||||||
|| $scope.email.length == 0) {
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
$scope.emailIcon = "";
|
|
||||||
$scope.emailHelp = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($scope.email.length < 6) {
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = "Need 6 characters";
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
$scope.passIcon = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checkEmailValidity($scope.email) == true) {
|
|
||||||
$scope.emailOK = true;
|
|
||||||
$scope.emailHelp = "";
|
|
||||||
//$scope.loginHelp = "check in progress...";
|
|
||||||
$scope.emailIcon = signUp_iconWait;
|
|
||||||
let data = {
|
|
||||||
"e-mail": $scope.email
|
|
||||||
}
|
|
||||||
let connectionAdresse = createRESTCall("user/check/email");
|
|
||||||
let config = {
|
|
||||||
params: data
|
|
||||||
};
|
|
||||||
let tmpEmail = "" + $scope.email;
|
|
||||||
console.log("call " + connectionAdresse + " data=" + JSON.stringify(data, null, 2));
|
|
||||||
$http.get(connectionAdresse, config)
|
|
||||||
.then(function(response) {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if (tmpEmail !== $scope.email) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
if (response.status == 200) {
|
|
||||||
// the email exist ... ==> it is found...
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = "email already used ...";
|
|
||||||
$scope.emailIcon = signUp_iconWrong;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = "email already used ... (error 2)";
|
|
||||||
}, function(response) {
|
|
||||||
// check if the answer is correct with the question
|
|
||||||
if (tmpEmail !== $scope.email) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (response.status == 404) {
|
|
||||||
$scope.emailOK = true;
|
|
||||||
$scope.emailHelp = "";
|
|
||||||
$scope.emailIcon = signUp_iconRight;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = "email already used ...";
|
|
||||||
$scope.emailIcon = signUp_iconWrong;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
|
||||||
}
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.checkPassword = function() {
|
|
||||||
if ($scope.password == null) {
|
|
||||||
$scope.passOK = false;
|
|
||||||
$scope.passHelp = "";
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($scope.password.length < 6) {
|
|
||||||
$scope.passOK = false;
|
|
||||||
$scope.passHelp = "Need 6 characters";
|
|
||||||
} else {
|
|
||||||
if (checkPasswordValidity($scope.password) == true) {
|
|
||||||
$scope.passOK = true;
|
|
||||||
$scope.passHelp = "";
|
|
||||||
} else {
|
|
||||||
$scope.passOK = false;
|
|
||||||
$scope.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\<>"';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$scope.updateButtonVisibility();
|
|
||||||
}
|
|
||||||
$scope.onSignUp = function() {
|
|
||||||
if ($scope.signUpButtonDisabled == true) {
|
|
||||||
// TODO: ... notify user ...
|
|
||||||
console.log("Not permited action ... ==> control does not validate this action ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let data = {
|
|
||||||
"methode": "v0",
|
|
||||||
"login": $scope.login,
|
|
||||||
"e-mail": $scope.email,
|
|
||||||
"password": btoa(CryptoJS.SHA1($scope.password)) // btoa encode i base64
|
|
||||||
}
|
|
||||||
let connectionAdresse = createRESTCall("user/add");
|
|
||||||
let config = {
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let tmpEmail = "" + $scope.email;
|
|
||||||
console.log("call " + connectionAdresse + " data=" + JSON.stringify(data, null, 2));
|
|
||||||
$http.post(connectionAdresse, data, config)
|
|
||||||
.then(function(response) {
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
if (response.status == 200) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.emailOK = false;
|
|
||||||
$scope.emailHelp = "email already used ... (error 2)";
|
|
||||||
}, function(response) {
|
|
||||||
console.log("Status " + response.status);
|
|
||||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$scope.onCancel = function() {
|
|
||||||
console.log("onCancel ... '" + $scope.login + "':'" + $scope.password + "'");
|
|
||||||
$rootScope.currentModal = "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
@ -15,6 +15,7 @@ import { SeriesService } from '../../service/series';
|
|||||||
import { VideoService } from '../../service/video';
|
import { VideoService } from '../../service/video';
|
||||||
import { ArianeService } from '../../service/ariane';
|
import { ArianeService } from '../../service/ariane';
|
||||||
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
|
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
|
||||||
|
import { NodeData } from '../../model';
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
value?: number;
|
value?: number;
|
||||||
@ -248,8 +249,8 @@ export class VideoEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
if(this.data.typeId !== undefined) {
|
if(this.data.typeId !== undefined) {
|
||||||
self.typeService.getSubSeries(this.data.typeId, [ 'id', 'name' ])
|
self.typeService.getSubSeries(this.data.typeId)
|
||||||
.then((response2) => {
|
.then((response2: NodeData[]) => {
|
||||||
for(let iii = 0; iii < response2.length; iii++) {
|
for(let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
}
|
}
|
||||||
@ -273,8 +274,8 @@ export class VideoEditScene implements OnInit {
|
|||||||
this.listSeason = [ { value: undefined, label: '---' } ];
|
this.listSeason = [ { value: undefined, label: '---' } ];
|
||||||
let self = this;
|
let self = this;
|
||||||
if(this.data.seriesId !== undefined) {
|
if(this.data.seriesId !== undefined) {
|
||||||
self.seriesService.getSeason(this.data.seriesId, [ 'id', 'name' ])
|
self.seriesService.getSeason(this.data.seriesId)
|
||||||
.then((response3) => {
|
.then((response3: NodeData[]) => {
|
||||||
for(let iii = 0; iii < response3.length; iii++) {
|
for(let iii = 0; iii < response3.length; iii++) {
|
||||||
self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` });
|
self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` });
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="cover-full">
|
<div class="cover-full">
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
<div class="cover-image" *ngIf="cover != null">
|
<div class="cover-image" *ngIf="cover !== null">
|
||||||
<img src="{{cover}}"/>
|
<img src="{{cover}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-no-image" *ngIf="cover == null"></div>
|
<div class="cover-no-image" *ngIf="cover == null"></div>
|
||||||
@ -29,12 +29,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-button-next" *ngIf="haveNext != null">
|
<div class="cover-button-next" *ngIf="haveNext !== null">
|
||||||
<button (click)="onRequireNext($event)" (auxclick)="onRequireNext($event)">
|
<button (click)="onRequireNext($event)" (auxclick)="onRequireNext($event)">
|
||||||
<i class="material-icons big-button">arrow_forward_ios</i>
|
<i class="material-icons big-button">arrow_forward_ios</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-button-previous" *ngIf="havePrevious != null">
|
<div class="cover-button-previous" *ngIf="havePrevious !== null">
|
||||||
<button (click)="onRequirePrevious($event)" (auxclick)="onRequirePrevious($event)">
|
<button (click)="onRequirePrevious($event)" (auxclick)="onRequirePrevious($event)">
|
||||||
<i class="material-icons big-button">arrow_back_ios</i>
|
<i class="material-icons big-button">arrow_back_ios</i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -11,6 +11,7 @@ import { VideoService } from '../../service/video';
|
|||||||
import { SeriesService } from '../../service/series';
|
import { SeriesService } from '../../service/series';
|
||||||
import { SeasonService } from '../../service/season';
|
import { SeasonService } from '../../service/season';
|
||||||
import { ArianeService } from '../../service/ariane';
|
import { ArianeService } from '../../service/ariane';
|
||||||
|
import { isNullOrUndefined } from '../..//utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-video',
|
selector: 'app-video',
|
||||||
@ -249,7 +250,7 @@ export class VideoScene implements OnInit {
|
|||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
for(let iii = 0; iii < response6.length; iii++) {
|
for(let iii = 0; iii < response6.length; iii++) {
|
||||||
if(response6[iii].episode === undefined || response6[iii].episode === null) {
|
if(isNullOrUndefined(response6[iii].episode)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(response6[iii].episode < self.episode) {
|
if(response6[iii].episode < self.episode) {
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @license PROPRIETARY (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthService {
|
|
||||||
constructor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpWrapperService } from './http-wrapper';
|
import { HttpWrapperService } from './http-wrapper';
|
||||||
import { DataInterface, MediaSmall } from './dataInterface';
|
import { DataInterface } from '../utils/dataInterface';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -4,15 +4,16 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CookiesService {
|
export class CookiesService {
|
||||||
constructor() {
|
|
||||||
|
constructor() {
|
||||||
}
|
|
||||||
|
}
|
||||||
set(cname, cvalue, exdays) {
|
|
||||||
|
set(cname: string, cvalue: string, exdays: number): void {
|
||||||
if(this.get(cname) !== '') {
|
if(this.get(cname) !== '') {
|
||||||
// reset previous cookies...
|
// reset previous cookies...
|
||||||
document.cookie = `${cname }=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
|
document.cookie = `${cname }=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
|
||||||
@ -22,12 +23,12 @@ export class CookiesService {
|
|||||||
let expires = `expires=${ddd.toUTCString()}`;
|
let expires = `expires=${ddd.toUTCString()}`;
|
||||||
document.cookie = `${cname }=${ cvalue };${ expires };path=/`;
|
document.cookie = `${cname }=${ cvalue };${ expires };path=/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(cname) {
|
remove(cname: string) : void {
|
||||||
this.set(cname, '', 0);
|
this.set(cname, '', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(cname) {
|
get(cname: string) : string | undefined {
|
||||||
let name = `${cname }=`;
|
let name = `${cname }=`;
|
||||||
let coolies = document.cookie.split(';');
|
let coolies = document.cookie.split(';');
|
||||||
for(let iii = 0; iii < coolies.length; iii++) {
|
for(let iii = 0; iii < coolies.length; iii++) {
|
||||||
@ -41,5 +42,6 @@ export class CookiesService {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
|||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
import { SessionService } from './session';
|
import { SessionService } from './session';
|
||||||
|
import { isNullOrUndefined } from '../utils';
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
@ -33,22 +34,13 @@ export interface HTTPRequest {
|
|||||||
requestType: HTTPRequestModel ;
|
requestType: HTTPRequestModel ;
|
||||||
accept: HTTPMimeType;
|
accept: HTTPMimeType;
|
||||||
contentType: HTTPMimeType;
|
contentType: HTTPMimeType;
|
||||||
params?: any;
|
params?: object;
|
||||||
body?: any;
|
body?: any;
|
||||||
authorization?: string; // c'est un hook de merde ...
|
authorization?: string; // c'est un hook de merde ...
|
||||||
disableTocken?:boolean;
|
disableTocken?:boolean;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
{
|
export interface ModelResponseHttp {
|
||||||
endPoint: ,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.ALL,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params?: ,
|
|
||||||
body?: ,
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
export interface ModelResponseHttp{
|
|
||||||
status: number,
|
status: number,
|
||||||
data: any,
|
data: any,
|
||||||
}
|
}
|
||||||
@ -67,7 +59,7 @@ export class HttpWrapperService {
|
|||||||
addTokenIfNeeded(headerOption:any): any {
|
addTokenIfNeeded(headerOption:any): any {
|
||||||
if(this.session.sessionData !== null) {
|
if(this.session.sessionData !== null) {
|
||||||
if(headerOption.Authorization === undefined) {
|
if(headerOption.Authorization === undefined) {
|
||||||
headerOption.Authorization = `Yota ${ this.session.sessionData.userId }:${ this.session.sessionData.token}`;
|
headerOption.Authorization = `Yota ${this.session.getToken()}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return headerOption;
|
return headerOption;
|
||||||
@ -79,7 +71,8 @@ export class HttpWrapperService {
|
|||||||
|
|
||||||
let connectionAdresse = this.createRESTCall2({
|
let connectionAdresse = this.createRESTCall2({
|
||||||
server: properties.server,
|
server: properties.server,
|
||||||
api: properties.endPoint
|
api: properties.endPoint,
|
||||||
|
inputOptions: properties.params,
|
||||||
});
|
});
|
||||||
let headers: any = {
|
let headers: any = {
|
||||||
'Accept': properties.accept,
|
'Accept': properties.accept,
|
||||||
@ -163,28 +156,33 @@ export class HttpWrapperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: string; inputOptions?: any[]; addURLToken?:boolean }) {
|
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: string; inputOptions?: object; addURLToken?:boolean }) {
|
||||||
let basePage = environment.apiUrl;
|
|
||||||
if (server === "karauth") {
|
if (isNullOrUndefined(server)) {
|
||||||
basePage = environment.apiOAuthUrl;
|
server = environment.defaultServer;
|
||||||
}
|
}
|
||||||
|
const basePage = environment.server[server];
|
||||||
let addressServerRest = `${basePage }/`;
|
let addressServerRest = `${basePage }/`;
|
||||||
let options = inputOptions;
|
let options = inputOptions;
|
||||||
if(options === undefined) {
|
if(isNullOrUndefined(options)) {
|
||||||
options = [];
|
options = {};
|
||||||
}
|
}
|
||||||
let out = addressServerRest + api;
|
let out = addressServerRest + api;
|
||||||
let first = true;
|
let first = true;
|
||||||
for(let iii = 0; iii < options.length; iii++) {
|
let keys = Object.keys(options);
|
||||||
|
for(let iii = 0; iii < keys.length; iii++) {
|
||||||
if(first === false) {
|
if(first === false) {
|
||||||
out = `${out }&`;
|
out = `${out }&`;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }?`;
|
out = `${out }?`;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
out = out + options[iii];
|
out = out + keys[iii];
|
||||||
|
if (options[keys[iii]] != null) {
|
||||||
|
out = out + "=" + options[keys[iii]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(this.session.sessionData !== null) {
|
if (!isNullOrUndefined(this.session.sessionData)) {
|
||||||
if (addURLToken !== undefined && addURLToken === true) {
|
if (addURLToken !== undefined && addURLToken === true) {
|
||||||
if(first === false) {
|
if(first === false) {
|
||||||
out = `${out }&`;
|
out = `${out }&`;
|
||||||
@ -199,7 +197,7 @@ export class HttpWrapperService {
|
|||||||
|
|
||||||
// Deprecated ...
|
// Deprecated ...
|
||||||
createRESTCall(api: string, inputOptions?: any) {
|
createRESTCall(api: string, inputOptions?: any) {
|
||||||
let basePage = environment.apiUrl;
|
let basePage = environment.server[environment.defaultServer];
|
||||||
let addressServerRest = `${basePage }/`;
|
let addressServerRest = `${basePage }/`;
|
||||||
let options = inputOptions;
|
let options = inputOptions;
|
||||||
if(options === undefined) {
|
if(options === undefined) {
|
||||||
|
41
front/src/app/service/index.ts
Normal file
41
front/src/app/service/index.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { ArianeService } from "./ariane";
|
||||||
|
import { BddService } from "./bdd";
|
||||||
|
import { CookiesService } from "./cookies";
|
||||||
|
import { DataService } from "./data";
|
||||||
|
import { HttpWrapperService, ModelResponseHttp, HTTPRequest, HTTPMimeType, HTTPRequestModel } from "./http-wrapper";
|
||||||
|
import { StorageService } from "./local-storage";
|
||||||
|
import { PopInService } from "./popin";
|
||||||
|
import { SeasonService } from "./season";
|
||||||
|
import { SeriesService } from "./series";
|
||||||
|
import { SessionService } from "./session";
|
||||||
|
import { SSOService } from "./sso";
|
||||||
|
import { TypeService } from "./type";
|
||||||
|
import { UniverseService } from "./universe";
|
||||||
|
import { UserService } from "./user";
|
||||||
|
import { VideoService } from "./video";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
CookiesService,
|
||||||
|
HttpWrapperService,
|
||||||
|
ModelResponseHttp,
|
||||||
|
HTTPRequest,
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
StorageService,
|
||||||
|
PopInService,
|
||||||
|
SessionService,
|
||||||
|
UserService,
|
||||||
|
SSOService,
|
||||||
|
ArianeService,
|
||||||
|
BddService,
|
||||||
|
DataService,
|
||||||
|
SeasonService,
|
||||||
|
SeriesService,
|
||||||
|
TypeService,
|
||||||
|
UniverseService,
|
||||||
|
VideoService,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
54
front/src/app/service/local-storage.ts
Normal file
54
front/src/app/service/local-storage.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license PROPRIETARY (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class StorageService {
|
||||||
|
private baseLocalStorageName = environment.applName + '_';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
set(cname: string, cvalue: string): void {
|
||||||
|
console.error(`storage set: ${cname} : ${cvalue}`);
|
||||||
|
localStorage.setItem(this.baseLocalStorageName + cname, cvalue);
|
||||||
|
}
|
||||||
|
// limit at the current session ...
|
||||||
|
setSession(cname: string, cvalue: string): void {
|
||||||
|
sessionStorage.setItem(this.baseLocalStorageName + cname, cvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(cname: string) : void {
|
||||||
|
console.error(`storage remove: ${cname}`);
|
||||||
|
localStorage.removeItem(this.baseLocalStorageName + cname);
|
||||||
|
}
|
||||||
|
removeSession(cname: string) : void {
|
||||||
|
sessionStorage.removeItem(this.baseLocalStorageName + cname);
|
||||||
|
}
|
||||||
|
|
||||||
|
get(cname: string) : string | undefined {
|
||||||
|
console.error(`storage get: ${cname}`);
|
||||||
|
// TODO check expire day...
|
||||||
|
const data = localStorage.getItem(this.baseLocalStorageName + cname);
|
||||||
|
console.log(`get value form the storage (1): ${data}`)
|
||||||
|
if (data === null || data === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
getSession(cname: string) : string | undefined {
|
||||||
|
const data = sessionStorage.getItem(this.baseLocalStorageName + cname);
|
||||||
|
if (data === null || data === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,13 +7,12 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService } from './http-wrapper';
|
import { HttpWrapperService } from './http-wrapper';
|
||||||
import { DataInterface } from './dataInterface';
|
import { DataInterface } from '../utils';
|
||||||
import { BddService } from './bdd';
|
import { BddService } from './bdd';
|
||||||
|
import { TypeCheck } from '../utils/dataInterface';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SeasonService {
|
export class SeasonService {
|
||||||
// 0: Not hide password; 1 hide password;
|
|
||||||
private identificationVersion: number = 1;
|
|
||||||
private serviceName:string = 'season';
|
private serviceName:string = 'season';
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService,
|
constructor(private http: HttpWrapperService,
|
||||||
@ -50,7 +49,14 @@ export class SeasonService {
|
|||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
// let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
|
// let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
|
||||||
let data = response.getsWhere([ [ '==', 'seasonId', id ] ], undefined, [ 'episode', 'name' ]);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'seasonId',
|
||||||
|
value: id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[ 'episode', 'name' ]);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -69,7 +75,12 @@ export class SeasonService {
|
|||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
// let data = response.getsWhere([["==", "seasonId", _id]], ["id", "name", "episode"], ["episode", "name"])
|
// let data = response.getsWhere([["==", "seasonId", _id]], ["id", "name", "episode"], ["episode", "name"])
|
||||||
let data = response.getsWhere([ [ '==', 'seasonId', id ] ], undefined, [ 'episode', 'name' ]);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'seasonId',
|
||||||
|
value: id,
|
||||||
|
} ] );
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService } from './http-wrapper';
|
import { HttpWrapperService } from './http-wrapper';
|
||||||
import { DataInterface } from './dataInterface';
|
import { DataInterface, TypeCheck } from '../utils/dataInterface';
|
||||||
import { BddService } from './bdd';
|
import { BddService } from './bdd';
|
||||||
|
import { isNodeData, NodeData } from '../model';
|
||||||
|
import { isArrayOf, isNullOrUndefined } from '../utils';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SeriesService {
|
export class SeriesService {
|
||||||
// 0: Not hide password; 1 hide password;
|
|
||||||
private identificationVersion: number = 1;
|
|
||||||
private serviceName:string = 'series';
|
private serviceName:string = 'series';
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService,
|
constructor(private http: HttpWrapperService,
|
||||||
@ -22,13 +22,13 @@ export class SeriesService {
|
|||||||
console.log('Start SeriesService');
|
console.log('Start SeriesService');
|
||||||
}
|
}
|
||||||
|
|
||||||
get(id:number):any {
|
get(id:number): Promise<NodeData> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getSeries()
|
self.bdd.getSeries()
|
||||||
.then((response:DataInterface) => {
|
.then((response:DataInterface) => {
|
||||||
let data = response.get(id);
|
let data = response.get(id);
|
||||||
if(data === null || data === undefined) {
|
if(isNullOrUndefined(data)) {
|
||||||
reject('Data does not exist in the local BDD');
|
reject('Data does not exist in the local BDD');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ export class SeriesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getData():any {
|
getData(): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getSeries()
|
self.bdd.getSeries()
|
||||||
@ -54,13 +54,23 @@ export class SeriesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrder():any {
|
getOrder(): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getSeries()
|
self.bdd.getSeries()
|
||||||
.then((response:DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '!=', 'id', null ] ], [ 'id', 'name' ], [ 'name', 'id' ]);
|
let data = response.getsWhere([
|
||||||
resolve(data);
|
{
|
||||||
|
check: TypeCheck.NOT_EQUAL,
|
||||||
|
key: 'id',
|
||||||
|
value: [undefined, null],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[ 'name', 'id' ]);
|
||||||
|
if (isArrayOf(data, isNodeData)) {
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
reject("The model is wrong ...");
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
|
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -68,28 +78,41 @@ export class SeriesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideoAll(id:number):any {
|
getVideo(id:number):Promise<NodeData[]> {
|
||||||
// this.checkLocalBdd();
|
|
||||||
}
|
|
||||||
|
|
||||||
getVideo(id:number):any {
|
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response:DataInterface) => {
|
.then((response:DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'seriesId', id ], [ '==', 'seasonId', null ] ], undefined, [ 'episode', 'name' ]);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'seriesId',
|
||||||
|
value: id,
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'seasonId',
|
||||||
|
value: undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[ 'episode', 'name' ]);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
countVideo(id:number):any {
|
countVideo(id:number): Promise<number> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response:DataInterface) => {
|
.then((response:DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'seriesId', id ] ], undefined, undefined);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'seriesId',
|
||||||
|
value: id,
|
||||||
|
},
|
||||||
|
]);
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -100,26 +123,21 @@ export class SeriesService {
|
|||||||
/**
|
/**
|
||||||
* Get all the season of a specific series
|
* Get all the season of a specific series
|
||||||
* @param id - ID of the series
|
* @param id - ID of the series
|
||||||
* @param select - Selection filter
|
|
||||||
* @returns the required List.
|
* @returns the required List.
|
||||||
*/
|
*/
|
||||||
getSeason(id:number, select:string[] = []):any {
|
getSeason(id:number): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getSeason()
|
self.bdd.getSeason()
|
||||||
.then((response:DataInterface) => {
|
.then((response:DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'parentId', id ] ], [ 'id' ], [ 'number' ]);
|
let data = response.getsWhere([
|
||||||
if(select.length === 0) {
|
{
|
||||||
resolve(data);
|
check: TypeCheck.EQUAL,
|
||||||
return;
|
key: 'parentId',
|
||||||
}
|
value: id,
|
||||||
if(select[0] === '*') {
|
},
|
||||||
let data2 = response.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'number' ]);
|
], [ 'id' ]);
|
||||||
resolve(data2);
|
resolve(data);
|
||||||
return;
|
|
||||||
}
|
|
||||||
let data3 = response.getsWhere([ [ '==', 'id', data ] ], select, [ 'number' ]);
|
|
||||||
resolve(data3);
|
|
||||||
return;
|
return;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
|
@ -14,12 +14,13 @@ export enum UserRoles222 {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SessionService {
|
export class SessionService {
|
||||||
|
private tokenJwt = null;
|
||||||
public sessionData = null;
|
public sessionData = null;
|
||||||
public userLogin = null;
|
public userLogin = null;
|
||||||
public userAdmin = null;
|
public userAdmin = null;
|
||||||
public userEMail = null;
|
public userEMail = null;
|
||||||
public userAvatar = null;
|
public userAvatar = null;
|
||||||
// public tocken = null;
|
public userId = null;
|
||||||
|
|
||||||
@Output() change: EventEmitter<boolean> = new EventEmitter();
|
@Output() change: EventEmitter<boolean> = new EventEmitter();
|
||||||
|
|
||||||
@ -31,18 +32,22 @@ export class SessionService {
|
|||||||
* @brief Create a new session.
|
* @brief Create a new session.
|
||||||
*
|
*
|
||||||
* @param sessionData -
|
* @param sessionData -
|
||||||
|
* @param userId -
|
||||||
* @param userLogin -
|
* @param userLogin -
|
||||||
* @param userEMail -
|
* @param userEMail -
|
||||||
* @param userAdmin -
|
* @param userAdmin -
|
||||||
* @param userAvatar -
|
* @param userAvatar -
|
||||||
*/
|
*/
|
||||||
create(sessionData,
|
create(sessionData,
|
||||||
|
userId: string,
|
||||||
userLogin: string,
|
userLogin: string,
|
||||||
userEMail: string,
|
userEMail: string,
|
||||||
userAdmin: boolean,
|
userAdmin: boolean,
|
||||||
userAvatar: string) {
|
userAvatar: string) {
|
||||||
console.log('Session Create');
|
console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} `);
|
||||||
|
this.tokenJwt = undefined;
|
||||||
this.sessionData = sessionData;
|
this.sessionData = sessionData;
|
||||||
|
this.userId = userId;
|
||||||
this.userLogin = userLogin;
|
this.userLogin = userLogin;
|
||||||
this.userAdmin = userAdmin;
|
this.userAdmin = userAdmin;
|
||||||
this.userEMail = userEMail;
|
this.userEMail = userEMail;
|
||||||
@ -55,16 +60,22 @@ export class SessionService {
|
|||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
console.log('Session REMOVE');
|
console.log('Session REMOVE');
|
||||||
// Cookies.remove("yota-login");
|
|
||||||
// Cookies.remove("yota-password");
|
|
||||||
let last = this.sessionData;
|
let last = this.sessionData;
|
||||||
this.sessionData = null;
|
this.sessionData = null;
|
||||||
|
this.tokenJwt = undefined;
|
||||||
|
this.userId = null;
|
||||||
this.userLogin = null;
|
this.userLogin = null;
|
||||||
this.userAdmin = null;
|
this.userAdmin = null;
|
||||||
this.userEMail = null;
|
this.userEMail = null;
|
||||||
this.userAvatar = null;
|
this.userAvatar = null;
|
||||||
this.change.emit(false);
|
this.change.emit(false);
|
||||||
}
|
}
|
||||||
|
setToken(jwt: string) {
|
||||||
|
this.tokenJwt = jwt;
|
||||||
|
}
|
||||||
|
getToken(): string | undefined {
|
||||||
|
return this.tokenJwt;
|
||||||
|
}
|
||||||
islogged() {
|
islogged() {
|
||||||
return this.sessionData !== null;
|
return this.sessionData !== null;
|
||||||
}
|
}
|
||||||
@ -90,9 +101,9 @@ export class SessionService {
|
|||||||
return this.userLogin;
|
return this.userLogin;
|
||||||
}
|
}
|
||||||
getAvatar() {
|
getAvatar() {
|
||||||
if(this.userAvatar === '') {
|
if(this.userAvatar === false) {
|
||||||
return 'assets/images/avatar_generic.svg';
|
return 'assets/images/avatar_generic.svg';
|
||||||
}
|
}
|
||||||
return this.userAvatar;
|
return this.userId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
front/src/app/service/sso.ts
Normal file
60
front/src/app/service/sso.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license PROPRIETARY (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SSOService {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
console.log('Start SSOService');
|
||||||
|
}
|
||||||
|
utf8_to_b64( str:string ): string {
|
||||||
|
return window.btoa(unescape(encodeURIComponent( str ))).replace("=", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
b64_to_utf8( str:string ): string {
|
||||||
|
return decodeURIComponent(escape(window.atob( str )));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Request SSO connection
|
||||||
|
*/
|
||||||
|
hashLocalData(data?: string): string {
|
||||||
|
if (data != undefined) {
|
||||||
|
return this.utf8_to_b64(data);
|
||||||
|
}
|
||||||
|
return this.utf8_to_b64('home');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Request SSO connection
|
||||||
|
*/
|
||||||
|
unHashLocalData(data: string): string {
|
||||||
|
return this.b64_to_utf8(data);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Request SSO connection
|
||||||
|
*/
|
||||||
|
requestSignIn(name?: string): void {
|
||||||
|
window.location.href = environment.ssoSignIn + this.hashLocalData(name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Request SSO Disconnect
|
||||||
|
*/
|
||||||
|
requestSignOut(name?: string): void {
|
||||||
|
if (name === undefined) {
|
||||||
|
name = 'home';
|
||||||
|
}
|
||||||
|
window.location.href = environment.ssoSignOut + this.hashLocalData(name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Request SSO signUp
|
||||||
|
*/
|
||||||
|
requestSignUp(name?: string): void {
|
||||||
|
window.location.href = environment.ssoSignUp + this.hashLocalData(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,8 +8,9 @@ import { Injectable } from '@angular/core';
|
|||||||
|
|
||||||
import { HttpWrapperService } from './http-wrapper';
|
import { HttpWrapperService } from './http-wrapper';
|
||||||
import { BddService } from './bdd';
|
import { BddService } from './bdd';
|
||||||
import { DataInterface } from './dataInterface';
|
import { DataInterface, isNullOrUndefined } from '../utils';
|
||||||
|
import { NodeData } from '../model';
|
||||||
|
import { TypeCheck } from '../utils/dataInterface';
|
||||||
|
|
||||||
export interface MessageLogIn {
|
export interface MessageLogIn {
|
||||||
id: number;
|
id: number;
|
||||||
@ -17,14 +18,8 @@ export interface MessageLogIn {
|
|||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function SHA512(param1: any): any;
|
|
||||||
declare function dateFormat(param1: any, param2: any): any;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TypeService {
|
export class TypeService {
|
||||||
// 0: Not hide password; 1 hide password;
|
|
||||||
private identificationVersion: number = 1;
|
|
||||||
private serviceName:string = 'type';
|
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService,
|
constructor(private http: HttpWrapperService,
|
||||||
private bdd: BddService) {
|
private bdd: BddService) {
|
||||||
@ -32,7 +27,7 @@ export class TypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getData():any {
|
getData(): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getType()
|
self.bdd.getType()
|
||||||
@ -46,13 +41,13 @@ export class TypeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get(_id:number):any {
|
get(_id:number): Promise<NodeData> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getType()
|
self.bdd.getType()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
let data = response.get(_id);
|
let data = response.get(_id);
|
||||||
if(data === null || data === undefined) {
|
if(isNullOrUndefined(data)) {
|
||||||
reject('Data does not exist in the local BDD');
|
reject('Data does not exist in the local BDD');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,12 +58,17 @@ export class TypeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
countVideo(_id:number):any {
|
countVideo(id:number): Promise<number> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'typeId', _id ] ], undefined, undefined);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'typeId',
|
||||||
|
value: id,
|
||||||
|
} ] );
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -76,64 +76,45 @@ export class TypeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubVideo(_id:number, _select:Array<string> = []):any {
|
getSubVideo(id:number): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
if(_select.length === 0) {
|
let data = response.getsWhere([
|
||||||
let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], undefined, [ 'name' ]);
|
{
|
||||||
resolve(data);
|
check: TypeCheck.EQUAL,
|
||||||
return;
|
key: 'typeId',
|
||||||
}
|
value: id,
|
||||||
if(_select[0] === '*') {
|
}, {
|
||||||
let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], undefined, [ 'name' ]);
|
check: TypeCheck.EQUAL,
|
||||||
resolve(data);
|
key: 'seriesId',
|
||||||
return;
|
value: undefined,
|
||||||
}
|
}, {
|
||||||
let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], _select, [ 'name' ]);
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'universeId',
|
||||||
|
value: undefined,
|
||||||
|
},
|
||||||
|
], [ 'name' ] );
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubSeries(id:number, select:string[] = []):any {
|
getSubSeries(id:number): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
/*
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.getVideo()
|
|
||||||
.then(function(response: DataInterface) {
|
|
||||||
let data = response.getsWhere([["==", "typeId", _id], ["!=", "seriesId", null], ["==", "universeId", null]], ["seriesId"], ["name"]);
|
|
||||||
if (_select.length == 0) {
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.bdd.getSeries()
|
|
||||||
.then(function(response2: DataInterface) {
|
|
||||||
if (_select[0] == "*") {
|
|
||||||
let data2 = response2.getsWhere([["==", "id", data]], undefined, ["name"]);
|
|
||||||
resolve(data2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let data3 = response2.getsWhere([["==", "id", data]], _select, ["name"]);
|
|
||||||
resolve(data3);
|
|
||||||
return;
|
|
||||||
}).catch(function(response2) {
|
|
||||||
reject(response2);
|
|
||||||
});
|
|
||||||
}).catch(function(response) {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getSeries()
|
self.bdd.getSeries()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'parentId', id ] ], undefined, [ 'name' ]);
|
let data = response.getsWhere([
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'parentId',
|
||||||
|
value: id,
|
||||||
|
} ],
|
||||||
|
[ 'name' ]);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -141,42 +122,42 @@ export class TypeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubUniverse(id:number, select:string[] = []):any {
|
getSubUniverse(id:number): Promise<NodeData[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.getVideo()
|
self.bdd.getVideo()
|
||||||
.then((response: DataInterface) => {
|
.then((response: DataInterface) => {
|
||||||
let data = response.getsWhere([ [ '==', 'typeId', id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], [ 'universId' ], [ 'name' ]);
|
let data = response.getsWhere([
|
||||||
if(select.length === 0) {
|
{
|
||||||
resolve(data);
|
check: TypeCheck.EQUAL,
|
||||||
return;
|
key: 'typeId',
|
||||||
}
|
value: id,
|
||||||
self.bdd.getUniverse()
|
}, {
|
||||||
.then((response2: DataInterface) => {
|
check: TypeCheck.EQUAL,
|
||||||
if(select[0] === '*') {
|
key: 'seriesId',
|
||||||
let data2 = response2.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'name' ]);
|
value: [undefined, null],
|
||||||
resolve(data2);
|
}, {
|
||||||
return;
|
check: TypeCheck.NOT_EQUAL,
|
||||||
}
|
key: 'universeId',
|
||||||
let data3 = response2.getsWhere([ [ '==', 'id', data ] ], select, [ 'name' ]);
|
value: undefined,
|
||||||
resolve(data3);
|
},
|
||||||
return;
|
]);
|
||||||
}).catch((response2) => {
|
//, [ 'universId' ]);
|
||||||
reject(response2);
|
resolve(data);
|
||||||
});
|
return;
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getCoverUrl(coverId:number):any {
|
getCoverUrl(coverId:number): string {
|
||||||
return this.http.createRESTCall2({
|
return this.http.createRESTCall2({
|
||||||
api: `data/${coverId}`,
|
api: `data/${coverId}`,
|
||||||
addURLToken: true,
|
addURLToken: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getCoverThumbnailUrl(coverId:number):any {
|
getCoverThumbnailUrl(coverId:number): string {
|
||||||
return this.http.createRESTCall2({
|
return this.http.createRESTCall2({
|
||||||
api: `data/thumbnail/${coverId}`,
|
api: `data/thumbnail/${coverId}`,
|
||||||
addURLToken: true,
|
addURLToken: true,
|
||||||
|
@ -5,8 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
|
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
|
||||||
|
import { StorageService } from './local-storage';
|
||||||
|
import { SessionService } from './session';
|
||||||
|
import { SSOService } from './sso';
|
||||||
|
|
||||||
interface MessageLogIn {
|
interface MessageLogIn {
|
||||||
login: string;
|
login: string;
|
||||||
@ -24,87 +28,105 @@ interface MessageAnswer_USER_CONNECT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare function SHA512(param1: any): any;
|
declare function SHA512(param1: any): any;
|
||||||
declare function dateFormat(param1: any, param2: any): any;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
// 0: Not hide password; 1 hide password;
|
// 0: Not hide password; 1 hide password;
|
||||||
private identificationVersion: number = 1;
|
private identificationVersion: number = 1;
|
||||||
|
private cookiesRememberMe = 'karauth-remember-me';
|
||||||
|
private cookiesToken = 'karauth-token';
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService) {
|
constructor(
|
||||||
|
private storageService: StorageService,
|
||||||
|
private http: HttpWrapperService,
|
||||||
|
private sessionService: SessionService,
|
||||||
|
private ssoService: SSOService) {
|
||||||
console.log('Start UserService');
|
console.log('Start UserService');
|
||||||
}
|
}
|
||||||
|
|
||||||
login(_login: string, _password: string):any {
|
/**
|
||||||
return this.loginSha(_login, SHA512(_password));
|
* Disconnect the user from the current session ==> this remove the curreent Token
|
||||||
|
*/
|
||||||
|
logOut(): void {
|
||||||
|
this.removeSession();
|
||||||
|
this.ssoService.requestSignOut("home");
|
||||||
|
|
||||||
}
|
}
|
||||||
loginSha(login: string, password: string):any {
|
removeSession(): void {
|
||||||
|
this.storageService.remove(this.cookiesRememberMe);
|
||||||
|
this.storageService.removeSession(this.cookiesToken);
|
||||||
|
this.sessionService.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private isTokenUpToDate(token: string): boolean {
|
||||||
|
if (token === null || token === undefined || token.length < 25) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Separate the Data:
|
||||||
|
const elems = token.split('.');
|
||||||
|
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 parsedData = JSON.parse(tokenData);
|
||||||
|
console.error(`Retreive exp data=${new Date(parsedData.exp*1000).toISOString()} < ${new Date().toISOString()}`);
|
||||||
|
const expireIn = new Date(parsedData.exp*1000);
|
||||||
|
const nowTime = new Date();
|
||||||
|
return expireIn > nowTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the system can be connected
|
||||||
|
*/
|
||||||
|
checkAutoConnect(): Promise<void> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
// Need to use the windows global route to prevent the log in cycle ...
|
||||||
|
// And in the mlain application position, the route does not have curently root the page
|
||||||
|
if (window.location.pathname.startsWith("/sso/")) {
|
||||||
|
reject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
// TODO: check validity of th eToken:
|
||||||
|
if (self.isTokenUpToDate(token)) {
|
||||||
|
self.startSession(token, rememberMe).finally(() => {
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log(`Get previous connection ... `);
|
||||||
|
if(rememberMe) {
|
||||||
|
// just to the sso !!!
|
||||||
|
self.ssoService.requestSignIn();
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startSession(token : string, rememberMe: boolean): Promise<string> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.getTocken(login, password).then(
|
self.retreiveMe(token).then(
|
||||||
(value: any) => {
|
(value2: boolean) => {
|
||||||
console.log('Get token ...');
|
if(rememberMe === true) {
|
||||||
self.loginWithToken(value.userId, value.token).then(
|
self.storageService.set(self.cookiesRememberMe, rememberMe?"true":"false");
|
||||||
(value2: any) => {
|
}
|
||||||
// transfer the session token property
|
// transfer the session token property
|
||||||
value2.session = {
|
self.sessionService.setToken(token);
|
||||||
userId: value.userId,
|
self.storageService.setSession(self.cookiesToken, token);
|
||||||
token: value.token,
|
resolve(self.sessionService.getLogin());
|
||||||
endValidityTime: value.endValidityTime
|
}).catch(() => {
|
||||||
};
|
reject('sdfsdfsdf');
|
||||||
resolve(value2);
|
|
||||||
}, (value2) => {
|
|
||||||
reject('sdfsdfsdf');
|
|
||||||
});
|
|
||||||
}, (value) => {
|
|
||||||
console.log('User NOT created');
|
|
||||||
reject('rrfrrrrr');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
retreiveMe(token : string): Promise<boolean> {
|
||||||
getTocken(login : string, password : string) : Promise<any> {
|
console.log(`AuthService.loginWithToken ... '${ token }'`);
|
||||||
console.log(`AuthService.getToken ... '${ login }':'${ password }'`);
|
let self = this;
|
||||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
|
||||||
let data:MessageLogIn;
|
|
||||||
// create request:
|
|
||||||
if(this.identificationVersion === 1) {
|
|
||||||
data = {
|
|
||||||
login: login,
|
|
||||||
method: 'v1',
|
|
||||||
time: currentDate,
|
|
||||||
// we mix the password to be sure that it can not be used an other time ...
|
|
||||||
password: SHA512(`login='${ login }';pass='${ password }';date='${ currentDate }'`)
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log('AuthService.login ... Wrong method ...');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`call users/connect data=${ JSON.stringify(data, null, 2)}`);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.http.requestJson({
|
|
||||||
server: 'karauth',
|
|
||||||
endPoint: 'users/get_token',
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
body: data,
|
|
||||||
disableTocken: true,
|
|
||||||
}).then((response: ModelResponseHttp) =>{
|
|
||||||
console.log(`Data token: id=${ response.data.id}`);
|
|
||||||
console.log(`Data token: userId=${ response.data.userId}`);
|
|
||||||
console.log(`Data token: token=${ response.data.token}`);
|
|
||||||
console.log(`Data token: createTime=${ response.data.createTime}`);
|
|
||||||
console.log(`Data token: endValidityTime=${ response.data.endValidityTime}`);
|
|
||||||
resolve(response.data);
|
|
||||||
}).catch((error:any) => {
|
|
||||||
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
loginWithToken(userId : string, token : string) {
|
|
||||||
console.log(`AuthService.loginWithToken ... '${ userId }':'${ token }'`);
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.http.requestJson({
|
this.http.requestJson({
|
||||||
//server: 'karauth',
|
//server: 'karauth',
|
||||||
@ -112,53 +134,22 @@ export class UserService {
|
|||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
authorization: `Yota ${userId}:${token}`, // special case, the token is set after this request...
|
authorization: `Yota ${token}`, // special case, the token is set after this request...
|
||||||
}).then((response: ModelResponseHttp) =>{
|
}).then((response: ModelResponseHttp) =>{
|
||||||
// TODO: check type ...
|
// TODO: check type ...
|
||||||
console.log(`loginWithToken : get some data to check: ${JSON.stringify(response.data)}`)
|
console.log(`loginWithToken : get some data to check: ${JSON.stringify(response.data)}`)
|
||||||
resolve(response.data);
|
self.sessionService.create(
|
||||||
|
response.data.sessionId,
|
||||||
|
response.data.id,
|
||||||
|
response.data.login,
|
||||||
|
response.data.email,
|
||||||
|
response.data.role,
|
||||||
|
response.data.avatar);
|
||||||
|
resolve(true);
|
||||||
}).catch((error:any) => {
|
}).catch((error:any) => {
|
||||||
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
|
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
console.log("AuthService.login ... '" + _login + "':'" + _password + "'");
|
|
||||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
|
||||||
let data:MessageLogIn;
|
|
||||||
// create request:
|
|
||||||
if (this.identificationVersion == 1) {
|
|
||||||
data = {
|
|
||||||
login: _login,
|
|
||||||
method: "v1",
|
|
||||||
time: currentDate,
|
|
||||||
// we mix the password to be sure that it can not be used an other time ...
|
|
||||||
password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'")
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("AuthService.login ... Wrong method ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
const httpOption = { 'Content-Type': 'application/json' };
|
|
||||||
console.log("call users/connect data=" + JSON.stringify(data, null, 2));
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.httpOAuth.post("users/connect", httpOption, data)
|
|
||||||
.then(function(response: any) {
|
|
||||||
if (response.status == 200) {
|
|
||||||
resolve(response.data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reject("An error occured");
|
|
||||||
}, function(response: any) {
|
|
||||||
if (typeof response.data === 'undefined') {
|
|
||||||
reject("return ERROR undefined");
|
|
||||||
} else {
|
|
||||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create(login : string, email : string, password : string) {
|
create(login : string, email : string, password : string) {
|
||||||
@ -210,50 +201,5 @@ export class UserService {
|
|||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLogin(login: string) {
|
|
||||||
let params = {
|
|
||||||
login: login
|
|
||||||
};
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.http.requestJson({
|
|
||||||
server: 'karauth',
|
|
||||||
endPoint: 'users/check_login',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params,
|
|
||||||
}).then((response: ModelResponseHttp) =>{
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`)
|
|
||||||
resolve(response.data);
|
|
||||||
}).catch((error:any) => {
|
|
||||||
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEMail(email: string) {
|
|
||||||
let params = {
|
|
||||||
email: email
|
|
||||||
};
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.http.requestJson({
|
|
||||||
server: 'karauth',
|
|
||||||
endPoint: 'users/check_email',
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
params,
|
|
||||||
}).then((response: ModelResponseHttp) =>{
|
|
||||||
// TODO: check type ...
|
|
||||||
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`)
|
|
||||||
resolve(response.data);
|
|
||||||
}).catch((error:any) => {
|
|
||||||
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { Injectable } from '@angular/core';
|
|||||||
|
|
||||||
import { HttpWrapperService } from './http-wrapper';
|
import { HttpWrapperService } from './http-wrapper';
|
||||||
import { BddService } from './bdd';
|
import { BddService } from './bdd';
|
||||||
import { DataInterface } from './dataInterface';
|
import { DataInterface } from '../utils/dataInterface';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class VideoService {
|
export class VideoService {
|
||||||
|
@ -4,21 +4,26 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface MediaSmall {
|
import { NodeData } from "../model";
|
||||||
id: number;
|
import { isArray, isNullOrUndefined, isUndefined } from "./validator";
|
||||||
name: string;
|
|
||||||
description?: string;
|
export enum TypeCheck {
|
||||||
dataId?: number;
|
EQUAL = '==',
|
||||||
typeId?: number;
|
NOT_EQUAL = '!=',
|
||||||
universeId?: number;
|
LESS = '<',
|
||||||
seriesId?: number;
|
LESS_EQUAL = '<=',
|
||||||
seasonId?: number;
|
GREATER = '>',
|
||||||
episode?: number;
|
GREATER_EQUAL = '>=',
|
||||||
date?: number;
|
}
|
||||||
time?: number;
|
|
||||||
ageLimit?: string;
|
export interface SelectModel {
|
||||||
covers: number[];
|
check: TypeCheck;
|
||||||
};
|
key: string;
|
||||||
|
value?: number|string|boolean|number[]|string[];
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
{ check: TypeCheck.EQUAL, key: sss, value: null}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
|
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
|
||||||
@ -26,7 +31,7 @@
|
|||||||
export class DataInterface {
|
export class DataInterface {
|
||||||
constructor(
|
constructor(
|
||||||
private name: string,
|
private name: string,
|
||||||
private bdd: MediaSmall[] ) {
|
private bdd: NodeData[] ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTableIndex(id: number) {
|
public getTableIndex(id: number) {
|
||||||
@ -38,22 +43,19 @@ export class DataInterface {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public gets(filter?: any) {
|
public gets(): NodeData[] {
|
||||||
console.log(`[I] gets ${ this.name}`);
|
console.log(`[I] gets ${ this.name}`);
|
||||||
if(filter === undefined) {
|
return this.bdd;
|
||||||
return this.bdd;
|
|
||||||
}
|
|
||||||
return this.filterObjectValues(this.bdd, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getsWhere(select, filter?: string[], orderBy?: string[]) {
|
public getsWhere(select: SelectModel[], orderBy?: string[]): NodeData[] {
|
||||||
// console.log("[I] gets_where " + this.name + " select " + _select);
|
// console.log("[I] gets_where " + this.name + " select " + _select);
|
||||||
let tmpList = this.getSubList(this.bdd, select);
|
let tmpList = this.getSubList(this.bdd, select);
|
||||||
tmpList = this.orderBy(tmpList, orderBy);
|
tmpList = this.orderBy(tmpList, orderBy);
|
||||||
return this.filterObjectValues(tmpList, filter);
|
return tmpList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(id: number) {
|
public get(id: number): NodeData {
|
||||||
// console.log("[I] get " + this.name + " " + _id);
|
// console.log("[I] get " + this.name + " " + _id);
|
||||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||||
if(this.bdd[iii].id === id) {
|
if(this.bdd[iii].id === id) {
|
||||||
@ -64,7 +66,7 @@ export class DataInterface {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNameLikeAll(name: string) {
|
public getNameLikeAll(name: string): NodeData[] {
|
||||||
let out = undefined;
|
let out = undefined;
|
||||||
let nameLower = name.toLowerCase();
|
let nameLower = name.toLowerCase();
|
||||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||||
@ -77,7 +79,7 @@ export class DataInterface {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
public getNameLike(name: string): any[] {
|
public getNameLike(name: string): NodeData[] {
|
||||||
let out = [];
|
let out = [];
|
||||||
let nameLower = name.toLowerCase();
|
let nameLower = name.toLowerCase();
|
||||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||||
@ -89,7 +91,7 @@ export class DataInterface {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public set(id: number, value: any): void {
|
public set(id: number, value: NodeData): void {
|
||||||
console.log(`[I] Set ${ this.name } ${ id}`);
|
console.log(`[I] Set ${ this.name } ${ id}`);
|
||||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||||
console.log(` check: ${ this.bdd[iii].id}`);
|
console.log(` check: ${ this.bdd[iii].id}`);
|
||||||
@ -109,7 +111,7 @@ export class DataInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public find(listToken, values) {
|
public find(listToken, values): NodeData[] {
|
||||||
let out = [];
|
let out = [];
|
||||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||||
let find = true;
|
let find = true;
|
||||||
@ -126,15 +128,15 @@ export class DataInterface {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public count(select = undefined) {
|
public count(select?: SelectModel[]) {
|
||||||
if(select === undefined) {
|
if(isNullOrUndefined(select)) {
|
||||||
return this.bdd.length;
|
return this.bdd.length;
|
||||||
}
|
}
|
||||||
let tmp = this.getSubList(this.bdd, select);
|
let tmp = this.getSubList(this.bdd, select);
|
||||||
return tmp.length;
|
return tmp.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public existIn(value: any, listValues: any) {
|
public existIn(value, listValues: number[]|string[]): boolean {
|
||||||
for(let iii = 0; iii < listValues.length; iii++) {
|
for(let iii = 0; iii < listValues.length; iii++) {
|
||||||
if(value === listValues[iii]) {
|
if(value === listValues[iii]) {
|
||||||
return true;
|
return true;
|
||||||
@ -143,8 +145,8 @@ export class DataInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSubList(values: MediaSmall[], select: any[][] ) {
|
public getSubList(values: NodeData[], select?: SelectModel[] ): NodeData[] {
|
||||||
let out = [];
|
let out = [] as NodeData[];
|
||||||
for(let iiiElem = 0; iiiElem < values.length; iiiElem++) {
|
for(let iiiElem = 0; iiiElem < values.length; iiiElem++) {
|
||||||
let find = true;
|
let find = true;
|
||||||
if(select.length === 0) {
|
if(select.length === 0) {
|
||||||
@ -152,74 +154,58 @@ export class DataInterface {
|
|||||||
}
|
}
|
||||||
// console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
|
// console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
|
||||||
for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
|
for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
|
||||||
if(select[iiiSelect].length !== 3) {
|
let control = select[iiiSelect];
|
||||||
console.log('[E] Internal Server Error: wrong select definition ...');
|
let valueElement = values[iiiElem][control.key]
|
||||||
return undefined;
|
if(isArray(control.value)) {
|
||||||
}
|
if(control.check === TypeCheck.EQUAL) {
|
||||||
let typeCheck = select[iiiSelect][0];
|
if(this.existIn(valueElement, control.value) === false) {
|
||||||
let token = select[iiiSelect][1];
|
find = false;
|
||||||
let value = select[iiiSelect][2];
|
break;
|
||||||
if(Array.isArray(value)) {
|
}
|
||||||
if(values[iiiElem][token] !== undefined) {
|
} else if(control.check === TypeCheck.NOT_EQUAL) {
|
||||||
if(typeCheck === '==') {
|
if(this.existIn(valueElement, control.value) === false) {
|
||||||
if(this.existIn(values[iiiElem][token], value) === false) {
|
find = false;
|
||||||
find = false;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if(typeCheck === '!=') {
|
|
||||||
if(this.existIn(values[iiiElem][token], value) === false) {
|
|
||||||
find = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
find = false;
|
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
||||||
break;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log(" [" + token + "] = " + values[iii_elem][token]);
|
//console.log(" [" + control.key + "] = " + valueElement);
|
||||||
if(values[iiiElem][token] !== undefined) {
|
if(control.check === TypeCheck.EQUAL) {
|
||||||
// console.log(" '" + type_check + "' " + value);
|
if(valueElement !== control.value) {
|
||||||
if(typeCheck === '==') {
|
find = false;
|
||||||
if(values[iiiElem][token] !== value) {
|
break;
|
||||||
find = false;
|
}
|
||||||
break;
|
} else if(control.check === TypeCheck.NOT_EQUAL) {
|
||||||
}
|
if(valueElement === control.value) {
|
||||||
} else if(typeCheck === '!=') {
|
find = false;
|
||||||
if(values[iiiElem][token] === value) {
|
break;
|
||||||
find = false;
|
}
|
||||||
break;
|
} else if(control.check === TypeCheck.LESS) {
|
||||||
}
|
if(valueElement >= control.value) {
|
||||||
} else if(typeCheck === '<') {
|
find = false;
|
||||||
if(values[iiiElem][token] >= value) {
|
break;
|
||||||
find = false;
|
}
|
||||||
break;
|
} else if(control.check === TypeCheck.LESS_EQUAL) {
|
||||||
}
|
if(valueElement > control.value) {
|
||||||
} else if(typeCheck === '<=') {
|
find = false;
|
||||||
if(values[iiiElem][token] > value) {
|
break;
|
||||||
find = false;
|
}
|
||||||
break;
|
} else if(control.check === TypeCheck.GREATER) {
|
||||||
}
|
if(valueElement <= control.value) {
|
||||||
} else if(typeCheck === '>') {
|
find = false;
|
||||||
if(values[iiiElem][token] <= value) {
|
break;
|
||||||
find = false;
|
}
|
||||||
break;
|
} else if(control.check === TypeCheck.GREATER_EQUAL) {
|
||||||
}
|
if(valueElement < control.value) {
|
||||||
} else if(typeCheck === '>=') {
|
find = false;
|
||||||
if(values[iiiElem][token] < value) {
|
break;
|
||||||
find = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
find = false;
|
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
||||||
break;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,8 +219,8 @@ export class DataInterface {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public orderBy(values: any[], order: string[]): any[] {
|
public orderBy(values: NodeData[], order: string[]): NodeData[] {
|
||||||
if(order === undefined) {
|
if(isNullOrUndefined(order)) {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
if(order.length === 0) {
|
if(order.length === 0) {
|
||||||
@ -287,35 +273,5 @@ export class DataInterface {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public filterObjectValues(values: MediaSmall[], filter: string[]): any[] {
|
|
||||||
let out: MediaSmall[] = [];
|
|
||||||
if(filter === undefined) {
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
if(filter.length === 1) {
|
|
||||||
let token = filter[0];
|
|
||||||
for(let iii = 0; iii < values.length; iii++) {
|
|
||||||
if(values[iii][token] === undefined) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(this.existIn(values[iii][token], out) === false) {
|
|
||||||
out.push(values[iii][token]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
for(let iii = 0; iii < values.length; iii++) {
|
|
||||||
let elementOut: any = {};
|
|
||||||
for(let jjj = 0; jjj < filter.length; jjj++) {
|
|
||||||
if(values[iii][filter[jjj]] === undefined) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
elementOut[filter[jjj]] = values[iii][filter[jjj]];
|
|
||||||
}
|
|
||||||
out.push(elementOut);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
21
front/src/app/utils/index.ts
Normal file
21
front/src/app/utils/index.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import { DataInterface } from "./dataInterface";
|
||||||
|
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined } from "./validator";
|
||||||
|
|
||||||
|
export {
|
||||||
|
isNumber,
|
||||||
|
isNumberFinite,
|
||||||
|
isBoolean,
|
||||||
|
isString,
|
||||||
|
isArray,
|
||||||
|
isNull,
|
||||||
|
isUndefined,
|
||||||
|
isNullOrUndefined,
|
||||||
|
isObject,
|
||||||
|
isArrayOf,
|
||||||
|
isOptionalOf,
|
||||||
|
isOptionalArrayOf,
|
||||||
|
DataInterface,
|
||||||
|
}
|
||||||
|
|
52
front/src/app/utils/validator.ts
Normal file
52
front/src/app/utils/validator.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
export function isNumber(data: any): data is number {
|
||||||
|
return typeof data === "number";
|
||||||
|
}
|
||||||
|
export function isNumberFinite(data: any): data is number {
|
||||||
|
return isNumber(data) && isFinite(data);
|
||||||
|
}
|
||||||
|
export function isBoolean(data: any): data is boolean {
|
||||||
|
return typeof data === "boolean";
|
||||||
|
}
|
||||||
|
export function isString(data: any): data is string {
|
||||||
|
return typeof data === "string";
|
||||||
|
}
|
||||||
|
export function isArray(data: any): data is any[] {
|
||||||
|
return Array.isArray(data);
|
||||||
|
}
|
||||||
|
export function isNull(data: any): data is null {
|
||||||
|
return data === null;
|
||||||
|
}
|
||||||
|
export function isUndefined(data: any): data is undefined {
|
||||||
|
return data === undefined;
|
||||||
|
}
|
||||||
|
export function isNullOrUndefined(data: any): data is undefined | null {
|
||||||
|
return data === undefined || data === null;
|
||||||
|
}
|
||||||
|
export function isObject(data: any): data is any {
|
||||||
|
return !isNullOrUndefined(data)
|
||||||
|
&& typeof data === 'object'
|
||||||
|
&& !isArray(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isArrayOf<TYPE>(data: any, typeChecker: (subData: any) => subData is TYPE, length?: number): data is TYPE[] {
|
||||||
|
if (!isArray(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.every(typeChecker)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isUndefined(length) && data.length != length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isOptionalOf<TYPE>(data: any, typeChecker: (subData: any) => subData is TYPE): data is TYPE | undefined {
|
||||||
|
return isUndefined(data) || typeChecker(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isOptionalArrayOf<TYPE>(data: any, typeChecker: (subData: any) => subData is TYPE): data is TYPE[] | undefined {
|
||||||
|
return isUndefined(data) || isArrayOf(data, typeChecker);
|
||||||
|
}
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
/**
|
|
||||||
* @brief create the rest call element of the link
|
|
||||||
*/
|
|
||||||
let createRESTCall = function(api, options) {
|
|
||||||
// http://localhost/exercice
|
|
||||||
let basePage = "" + window.location;
|
|
||||||
if (basePage.endsWith("index.xhtml") == true) {
|
|
||||||
basePage = basePage.substring(0, basePage.length - 11);
|
|
||||||
}
|
|
||||||
if (basePage.endsWith("index.php") == true) {
|
|
||||||
basePage = basePage.substring(0, basePage.length - 10);
|
|
||||||
}
|
|
||||||
let addressServerRest =basePage + "/api/v1/index.php";
|
|
||||||
if (typeof options === 'undefined') {
|
|
||||||
options = [];
|
|
||||||
}
|
|
||||||
let out = addressServerRest + "?REST=" + api;
|
|
||||||
for (let iii=0; iii<options.length; iii++) {
|
|
||||||
out += "&" + options[iii];
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +1,66 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<svg
|
<svg
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="499"
|
width="499"
|
||||||
height="498"
|
height="498"
|
||||||
viewBox="0 0 499 498">
|
viewBox="0 0 499 498"
|
||||||
|
version="1.1"
|
||||||
|
id="svg10"
|
||||||
|
sodipodi:docname="avatar_generic.svg"
|
||||||
|
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs
|
||||||
|
id="defs14" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview12"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="3.5060241"
|
||||||
|
inkscape:cx="344.97766"
|
||||||
|
inkscape:cy="288.78866"
|
||||||
|
inkscape:window-width="3838"
|
||||||
|
inkscape:window-height="2118"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="20"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg10" />
|
||||||
<rect
|
<rect
|
||||||
style="fill:#4c83e5;fill-opacity:1;stroke:none;stroke-width:8.82841587;stroke-opacity:1"
|
style="fill:#4c83e5;fill-opacity:1;stroke:none;stroke-width:8.82841587;stroke-opacity:1"
|
||||||
width="500"
|
width="500"
|
||||||
height="500"
|
height="500"
|
||||||
x="0"
|
x="0"
|
||||||
y="-1.9999847" />
|
y="-1.9999847"
|
||||||
|
id="rect2" />
|
||||||
<path
|
<path
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-opacity:1"
|
style="fill:#4e4e4d;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
|
||||||
d="m 204.04675,299.92172 64.38231,-8.25011 84.38034,95.33059 -50.65607,144.5704 -137.27461,10.07178 -8.02011,-145.66775 z"/>
|
d="m 198.78572,292.40268 -11.97951,28.10434 -7.03868,-39.62542 -32.77188,20.51375 14.30166,-59.1095 -47.70972,20.8692 30.95257,-58.44261 -40.08325,-11.9709 50.99682,-31.08004 -30.32488,-33.92052 41.38608,6.88643 c 0,0 -27.42157,-58.130582 -26.08007,-58.130582 1.34149,0 54.85161,37.962212 54.85161,37.962212 l 6.10019,-52.959427 22.55992,46.026947 33.20732,-51.718401 8.75817,54.113371 53.78031,-55.134502 -14.88381,76.635492 112.00146,-17.67965 -84.26404,54.10353 65.61018,10.26713 -53.91421,37.51917 40.05564,55.00796 -51.48529,-23.57551 7.49544,56.99322 -27.79947,-24.64556 -3.80452,36.62241 -23.37869,-22.14564 -5.89389,23.82189 -20.64297,-29.48769 -15.46209,46.92367 -7.2608,-54.46889 -21.32424,51.07849 z"
|
||||||
|
id="path3162"
|
||||||
|
sodipodi:nodetypes="cccccccccccsccccccccccccccccccccccc" />
|
||||||
<path
|
<path
|
||||||
d="m 151.70726,153.48377 98.32028,-57.471057 56.94703,21.629237 42.18786,87.1369 -8.8547,99.27952 c 0,0 -50.49799,16.08876 -49.46915,20.02305 1.64608,6.29463 -6.63579,19.542 -19.42333,31.06884 -11.04013,9.95169 -21.88069,22.4832 -25.78302,29.80472 -1.77209,3.32477 -3.61064,6.04503 -4.08568,6.04503 -0.47504,0 -2.26404,-4.6125 -3.97555,-10.25 -7.0054,-23.07485 -5.43752,-20.34841 -16.04346,-27.89857 -14.90382,-10.60973 -22.13256,-19.44659 -23.88228,-29.19518 l -0.74599,-4.15625 -49.90362,-18.10466 z"
|
style="fill:#fbd0a6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
style="fill:#fbd0a6"/>
|
d="m 126.90172,351.92657 55.90379,145.23242 168.77912,0.48055 8.10502,-147.83696 -56.19339,-10.73582 -9.91368,3.09728 -8.25753,-48.27446 -8.77147,-41.82541 -73.97306,-0.86753 -4.65072,84.85557 z"
|
||||||
|
id="path3467"
|
||||||
|
sodipodi:nodetypes="ccccccccccc" />
|
||||||
<path
|
<path
|
||||||
d="m 55.528901,495.75001 c 0.527163,-1.2375 3.024666,-9.9 5.550006,-19.25 8.980498,-33.25004 20.717058,-73.14872 24.415208,-83 7.96468,-21.21664 17.411415,-36.82083 25.634775,-42.3437 3.46578,-2.32765 7.75343,-3.40938 27.99561,-7.063 24.83316,-4.48226 37.7984,-7.72387 44.43556,-11.10989 2.13829,-1.09087 4.2852,-1.98341 4.77091,-1.98341 0.48571,0 0.25824,3.0375 -0.50549,6.75 -1.50052,7.29402 -2.99983,49.3173 -1.91392,53.64393 0.99077,3.94752 2.8969,3.16745 7.07154,-2.89393 3.53084,-5.12662 5.54444,-6.78317 5.54444,-4.56129 0,2.60045 5.3114,31.27728 8.05039,43.46495 5.98108,26.61396 16.76339,62.48393 20.54452,68.34634 l 1.4512,2.25 H 141.57203 54.570422 Z m 210.460079,-0.0508 c 2.17179,-3.31457 8.92419,-24.36077 12.96435,-40.40789 4.43614,-17.61992 8.08383,-37.40934 10.50604,-56.99725 1.05232,-8.50988 2.1619,-15.72111 2.46573,-16.02495 0.64309,-0.64309 2.6928,1.66469 9.7848,11.01675 3.42759,4.51989 5.47957,6.45222 6.14506,5.78673 1.18368,-1.18368 -0.68453,-30.51729 -2.75684,-43.28638 -1.74071,-10.72592 -4.37632,-21.1576 -6.74023,-26.67774 -1.03434,-2.41534 -1.68984,-4.5823 -1.45667,-4.81547 0.23317,-0.23317 3.05697,0.90265 6.27513,2.52404 9.1322,4.60104 20.99201,7.95377 45.19529,12.77659 12.28926,2.44879 23.57308,5.08787 25.07515,5.86462 9.57196,4.94985 22.94665,28.40208 32.96941,57.8111 2.76841,8.12314 10.28609,32.19814 16.70596,53.5 6.41986,21.30186 11.88553,39.29316 12.14592,39.98066 0.37646,0.99395 -17.06674,1.25 -85.1566,1.25 H 264.48143 Z M 292.3029,319.27575 c -3.48342,-3.65128 -4.45897,-6.45791 -5.83264,-16.7804 l -1.14521,-8.60577 5.12567,-8.35825 c 7.3769,-12.02924 13.35778,-24.49549 17.52649,-36.53131 3.20476,-9.25271 4.17092,-10.95875 8.13338,-14.36186 5.35782,-4.60148 8.85325,-11.11418 11.48239,-21.39399 2.20459,-8.6199 2.40904,-13.47419 0.83135,-19.73974 -2.07703,-8.24867 -6.91023,-9.75732 -10.39679,-3.24531 -1.1,2.05452 -2.31639,3.73671 -2.70308,3.7382 -0.3867,0.001 -1.47529,-1.6246 -2.41909,-3.61352 -3.45146,-7.2734 -12.43759,-11.95743 -37.37783,-19.4832 -36.97908,-11.15851 -50.57658,-17.84965 -64.69138,-31.83371 -7.11369,-7.0478 -9.1226,-7.45885 -17.07813,-3.49444 -6.3577,3.16818 -14.21568,11.58946 -17.71356,18.98336 -3.59507,7.59935 -6.48828,19.31308 -7.21077,29.19421 -0.33177,4.5375 -0.80892,8.25 -1.06034,8.25 -0.25141,0 -1.79409,-1.125 -3.42819,-2.5 -3.73675,-3.14427 -4.36211,-3.12484 -6.54282,0.20333 -2.23258,3.40736 -2.43946,17.43846 -0.3656,24.79667 2.41169,8.55685 6.77334,16.1351 11.61665,20.18361 3.60598,3.01423 4.89833,4.96775 6.16195,9.31445 2.92343,10.05624 10.27022,26.25548 16.96068,37.3973 l 6.60969,11.0073 -0.6645,10.04867 c -0.74861,11.32069 -1.9804,16.16987 -4.42377,17.41502 -1.56622,0.79815 -24.35316,-0.0941 -35.85864,-1.40416 -6.56738,-0.74777 -11.84347,-4.46271 -17.76801,-12.51063 -12.10229,-16.43979 -15.71037,-32.44915 -13.58553,-60.28013 4.7534,-62.25964 27.2222,-120.24856 52.91047,-136.55478 2.54749,-1.61707 7.03281,-3.64203 9.96737,-4.49991 3.87995,-1.13423 6.9751,-3.07768 11.34521,-7.123635 12.46712,-11.54236 25.74733,-15.92105 46.31922,-15.27215 11.32895,0.35735 14.13371,0.80718 21.81973,3.49945 16.5524,5.798 31.67451,16.565115 46.03801,32.779585 14.3084,16.15227 22.61268,30.83521 30.69285,54.26859 16.39981,47.56123 14.10848,112.15599 -4.86138,137.04726 -4.08556,5.36086 -8.18764,6.77337 -26.3982,9.08991 -9.18994,1.16905 -17.30716,2.35507 -18.03825,2.63562 -0.7311,0.28055 -2.52093,-0.73899 -3.9774,-2.26565 z"
|
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
style="fill:#4e4e4d" />
|
d="m 45.319305,524.24985 50.878125,-168.64351 91.02866,-21.85078 124.81002,189.43887 15.4976,-12.33208 -130.63444,-191.36234 -9.67318,14.25555 124.81002,189.43887"
|
||||||
|
id="path275"
|
||||||
|
sodipodi:nodetypes="cccccccc" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 443.88287,524.02559 393.00474,355.38208 301.97608,333.5313 177.16606,522.97017 161.66846,510.63809 292.3029,319.27575 301.97608,333.5313 177.16606,522.97017"
|
||||||
|
id="path275-6"
|
||||||
|
sodipodi:nodetypes="cccccccc" />
|
||||||
|
<path
|
||||||
|
style="fill:#fbd0a6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 187.52213,139.10279 14.34593,25.22547 9.57434,-32.06638 13.85516,33.79118 18.44245,-38.89028 4.92331,44.11511 20.28515,-38.50102 -2.21466,39.35905 31.27764,-28.90273 -5.47875,45.83312 23.27252,-10.25342 -8.67174,30.59353 c 24.86464,-33.77835 23.21015,12.27629 3.94365,35.3922 l -12.95127,26.98572 -12.80079,22.10524 -26.61623,18.28625 -53.44338,-20.79546 c -21.13665,-20.42844 -23.443,-25.48798 -31.95313,-51.61993 -19.36867,-32.18928 -17.20493,-59.66994 4.27858,-38.00437 l -2.30548,-27.96686 11.07502,10.22035 -14.60569,-33.15484 22.1057,18.70679 z"
|
||||||
|
id="path9531"
|
||||||
|
sodipodi:nodetypes="cccccccccccccccccccccccc" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.0 KiB |
@ -4,12 +4,17 @@
|
|||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
apiUrl: 'http://192.168.1.156/karideo/api',
|
applName: "karideo",
|
||||||
apiOAuthUrl: 'http://192.168.1.156/karauth/api',
|
defaultServer: "karideo",
|
||||||
frontBaseUrl: 'karideo',
|
server: {
|
||||||
apiMode: 'QUERRY',
|
karideo: 'http://192.168.1.156/karideo/api',
|
||||||
// apiMode: "REWRITE",
|
karauth: 'http://192.168.1.156/karauth/api',
|
||||||
localBdd: true
|
},
|
||||||
};
|
ssoSignIn: 'http://192.168.1.156/karso/signin/karideo/',
|
||||||
|
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo/',
|
||||||
|
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo/',
|
||||||
|
frontBaseUrl: '',
|
||||||
|
apiMode: 'REWRITE'
|
||||||
|
};
|
@ -6,12 +6,31 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
// apiUrl: 'http://localhost:15080',
|
applName: "karideo",
|
||||||
// apiUrl: 'http://localhost:18080/karideo/api',
|
defaultServer: "karideo",
|
||||||
apiUrl: 'http://192.168.1.156/karideo/api',
|
server: {
|
||||||
// apiOAuthUrl: 'http://localhost:17080/karauth/api',
|
karideo: 'http://localhost:18080/karideo/api',
|
||||||
apiOAuthUrl: 'http://192.168.1.156/karauth/api',
|
karauth: 'http://192.168.1.156/karauth/api',
|
||||||
|
},
|
||||||
|
ssoSignIn: 'http://192.168.1.156/karso/signin/karideo-dev/',
|
||||||
|
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
|
||||||
|
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
|
||||||
|
frontBaseUrl: '',
|
||||||
|
apiMode: 'REWRITE'
|
||||||
|
};
|
||||||
|
|
||||||
|
export const environment_kjlkjlkjlkj = {
|
||||||
|
production: false,
|
||||||
|
// URL of development API
|
||||||
|
applName: "karideo",
|
||||||
|
defaultServer: "karideo",
|
||||||
|
server: {
|
||||||
|
karideo: 'http://192.168.1.156/karideo/api',
|
||||||
|
karauth: 'http://192.168.1.156/karauth/api',
|
||||||
|
},
|
||||||
|
ssoSignIn: 'http://localhost:4200/signin/karideo-dev/',
|
||||||
|
ssoSignUp: 'http://localhost:4200/signup/karideo-dev/',
|
||||||
|
ssoSignOut: 'http://localhost:4200/signout/karideo-dev/',
|
||||||
frontBaseUrl: '',
|
frontBaseUrl: '',
|
||||||
// apiMode: "QUERRY"
|
|
||||||
apiMode: 'REWRITE'
|
apiMode: 'REWRITE'
|
||||||
};
|
};
|
||||||
|
@ -22,10 +22,6 @@
|
|||||||
<!-- Some tools -->
|
<!-- Some tools -->
|
||||||
<script src="assets/js_3rd_party/dateFormat.min.js"></script>
|
<script src="assets/js_3rd_party/dateFormat.min.js"></script>
|
||||||
<script src="assets/js_3rd_party/sha512.js"></script>
|
<script src="assets/js_3rd_party/sha512.js"></script>
|
||||||
|
|
||||||
<!-- common link with the cloud -->
|
|
||||||
<script src="assets/aaa_interfaceCloud.js"></script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="full-back"> </div>
|
<div class="full-back"> </div>
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es2015",
|
"target": "es2018",
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
],
|
],
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2017",
|
"es2018",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
"module": "es2020",
|
"module": "es2020",
|
||||||
|
Loading…
Reference in New Issue
Block a user