[DEV] change model of the DB ==> faster for our usecase

This commit is contained in:
Edouard DUPIN 2022-07-24 12:29:57 +02:00
parent cf221ec2bb
commit e92b6c7651
14 changed files with 397 additions and 148 deletions

View File

@ -5,7 +5,11 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.kar.karusic.annotation.SQLAutoIncrement;
import org.kar.karusic.annotation.SQLComment;
@ -15,6 +19,7 @@ import org.kar.karusic.annotation.SQLNotNull;
import org.kar.karusic.annotation.SQLNotRead;
import org.kar.karusic.annotation.SQLPrimaryKey;
import org.kar.karusic.annotation.SQLTableLinkGeneric;
import org.kar.karusic.annotation.SQLTableLinkGeneric.ModelLink;
import org.kar.karusic.annotation.SQLTableName;
import org.kar.karusic.annotation.SQLUpdateTime;
import org.kar.karusic.db.DBEntry;
@ -143,7 +148,7 @@ public class SqlWrapper {
if (rs.wasNull()) {
field.set(data, null);
} else {
System.out.println(" ==> " + tmp);
//System.out.println(" ==> " + tmp);
field.set(data, tmp);
}
} else if (type == long.class ) {
@ -232,6 +237,13 @@ public class SqlWrapper {
}
}
}
public static ModelLink getLinkMode(Field elem) {
SQLTableLinkGeneric[] decorators = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class);
if (decorators == null || decorators.length == 0) {
return SQLTableLinkGeneric.ModelLink.NONE;
}
return decorators[0].value();
}
public static <T> T insert(T data) throws Exception {
Class<?> clazz = data.getClass();
@ -254,8 +266,8 @@ public class SqlWrapper {
if (primaryKey) {
continue;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric == ModelLink.EXTERNAL) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -305,8 +317,8 @@ public class SqlWrapper {
primaryKeyField = elem;
continue;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric == ModelLink.EXTERNAL) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -317,15 +329,27 @@ public class SqlWrapper {
if (updateTime) {
continue;
}
Class<?> type = elem.getType();
if (!type.isPrimitive()) {
Object tmp = elem.get(data);
if(tmp == null && elem.getDeclaredAnnotationsByType(SQLDefault.class).length != 0) {
continue;
if (linkGeneric == ModelLink.NONE) {
Class<?> type = elem.getType();
if (!type.isPrimitive()) {
Object tmp = elem.get(data);
if(tmp == null && elem.getDeclaredAnnotationsByType(SQLDefault.class).length != 0) {
continue;
}
}
setValuedb(type, data, iii++, elem, ps);
} else {
// transform the data in string to insert it ...
Object tmp = elem.get(data);
if (tmp == null) {
ps.setNull(iii++, Types.BIGINT);
} else {
@SuppressWarnings("unchecked")
String dataTmp = getStringOfIds((List<Long>)tmp);
ps.setString(iii++, dataTmp);
}
}
count++;
setValuedb(type, data, iii++, elem, ps);
}
// execute the request
int affectedRows = ps.executeUpdate();
@ -403,8 +427,8 @@ public class SqlWrapper {
primaryKeyField = elem;
continue;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric == ModelLink.EXTERNAL) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -450,8 +474,8 @@ public class SqlWrapper {
if (primaryKey) {
continue;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric == ModelLink.EXTERNAL) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -463,15 +487,27 @@ public class SqlWrapper {
if (updateTime || !filterValue.contains(name)) {
continue;
}
Class<?> type = elem.getType();
if (!type.isPrimitive()) {
Object tmp = elem.get(data);
if(tmp == null && elem.getDeclaredAnnotationsByType(SQLDefault.class).length != 0) {
continue;
if (linkGeneric == ModelLink.NONE) {
Class<?> type = elem.getType();
if (!type.isPrimitive()) {
Object tmp = elem.get(data);
if(tmp == null && elem.getDeclaredAnnotationsByType(SQLDefault.class).length != 0) {
continue;
}
}
setValuedb(type, data, iii++, elem, ps);
} else {
// transform the data in string to insert it ...
Object tmp = elem.get(data);
if (tmp == null) {
ps.setNull(iii++, Types.BIGINT);
} else {
@SuppressWarnings("unchecked")
String dataTmp = getStringOfIds((List<Long>)tmp);
ps.setString(iii++, dataTmp);
}
}
count++;
setValuedb(type, data, iii++, elem, ps);
}
ps.setLong(iii++, id);
// execute the request
@ -505,8 +541,8 @@ public class SqlWrapper {
if (primaryKey) {
primaryKeyField = elem;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric != ModelLink.NONE) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -555,8 +591,8 @@ public class SqlWrapper {
Object data = clazz.getConstructors()[0].newInstance();
count = 1;
for (Field elem : clazz.getFields()) {
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric != ModelLink.NONE) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -606,8 +642,8 @@ public class SqlWrapper {
if (primaryKey) {
primaryKeyField = elem;
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric != ModelLink.NONE) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -628,6 +664,7 @@ public class SqlWrapper {
query.append(" ");
query.append(tableName);
query.append(".");
query.append(name);
}
query.append(" FROM `");
@ -655,8 +692,8 @@ public class SqlWrapper {
Object data = clazz.getConstructors()[0].newInstance();
count = 1;
for (Field elem : clazz.getFields()) {
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric != ModelLink.NONE) {
continue;
}
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
@ -685,9 +722,18 @@ public class SqlWrapper {
return out;
}
private enum StateLoad {
DISABLE,
NORMAL,
ARRAY
};
public static String getCurrentTimeStamp() {
return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
}
public static <T> List<T> gets(Class<T> clazz, boolean fool) throws Exception {
System.out.println("request get " + clazz.getCanonicalName() + " start @" + getCurrentTimeStamp());
DBEntry entry = new DBEntry(WebLauncher.dbConfig);
List<T> out = new ArrayList<>();
// real add in the BDD:
@ -701,10 +747,13 @@ public class SqlWrapper {
boolean firstField = true;
int count = 0;
StateLoad[] autoClasify = new StateLoad[clazz.getFields().length];
int indexAutoClasify = 0;
for (Field elem : clazz.getFields()) {
boolean notRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0;
if (!fool && notRead) {
autoClasify[indexAutoClasify++] = StateLoad.DISABLE;
continue;
}
String name = elem.getName();
@ -714,8 +763,9 @@ public class SqlWrapper {
} else {
query.append(",");
}
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
if (linkGeneric) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric == ModelLink.EXTERNAL) {
autoClasify[indexAutoClasify++] = StateLoad.ARRAY;
String localName = name;
if (name.endsWith("s")) {
localName = name.substring(0, name.length()-1);
@ -754,6 +804,11 @@ public class SqlWrapper {
" GROUP BY tmp.node_id) AS covers" +
*/
} else {
if (linkGeneric == ModelLink.NONE) {
autoClasify[indexAutoClasify++] = StateLoad.NORMAL;
} else {
autoClasify[indexAutoClasify++] = StateLoad.ARRAY;
}
query.append(" ");
query.append(tableName);
query.append(".");
@ -773,31 +828,45 @@ public class SqlWrapper {
query.append(".deleted = false ");
firstField = true;
System.out.println("generate the querry: '" + query.toString() + "'");
System.out.println("request get " + clazz.getCanonicalName() + " prepare @" + getCurrentTimeStamp());
// prepare the request:
PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
System.out.println("request get " + clazz.getCanonicalName() + " query @" + getCurrentTimeStamp());
// execute the request
ResultSet rs = ps.executeQuery();
System.out.println("request get " + clazz.getCanonicalName() + " transform @" + getCurrentTimeStamp());
while (rs.next()) {
indexAutoClasify = 0;
Object data = clazz.getConstructors()[0].newInstance();
count = 1;
for (Field elem : clazz.getFields()) {
/*
boolean notRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0;
*/
boolean notRead = autoClasify[indexAutoClasify] == StateLoad.DISABLE;
if (!fool && notRead) {
indexAutoClasify++;
continue;
}
String name = elem.getName();
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
//String name = elem.getName();
//boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
boolean linkGeneric = autoClasify[indexAutoClasify] == StateLoad.ARRAY;
if (linkGeneric) {
List<Long> idList = getListOfIds(rs, count);
elem.set(data, idList);
} else {
setValueFromDb(elem.getType(), data, count, elem, rs);
}
indexAutoClasify++;
count++;
}
//System.out.println("Read: " + (T)data);
out.add((T)data);
}
System.out.println("request get " + clazz.getCanonicalName() + " ready @" + getCurrentTimeStamp());
} catch (SQLException ex) {
ex.printStackTrace();
@ -863,6 +932,13 @@ public class SqlWrapper {
}
}
/**
* extract a list of "-" separated element from a SQL input data.
* @param rs Result Set of the BDD
* @param iii Id in the result set
* @return The list of Long value
* @throws SQLException if an error is generated in the sql request.
*/
protected static List<Long> getListOfIds(ResultSet rs, int iii) throws SQLException {
String trackString = rs.getString(iii);
if (rs.wasNull()) {
@ -876,10 +952,22 @@ public class SqlWrapper {
}
return out;
}
/**
* Convert the list if external Ids in a string '-' separated
* @param ids List of value (null are removed)
* @return '-' string separated
*/
protected static String getStringOfIds(List<Long> ids) {
List<Long> tmp = new ArrayList<>();
for (Long elem : ids) {
tmp.add(elem);
}
return tmp.stream().map(x->String.valueOf(x)).collect(Collectors.joining("-"));
}
public static void delete(Class<?> clazz, long id) throws Exception {
// TODO: I am not sure this is a real good idea.
}
public static void setDelete(Class<?> clazz, long id) throws Exception {
String tableName = getTableName(clazz);
@ -899,45 +987,45 @@ public class SqlWrapper {
}
public static String createTable(Class<?> clazz) throws Exception {
String tableName = getTableName(clazz);
boolean createIfNotExist = clazz.getDeclaredAnnotationsByType(SQLIfNotExists.class).length != 0;
StringBuilder out = new StringBuilder();
StringBuilder otherTable = new StringBuilder();
// Drop Table
if (createIfNotExist) {
String tableName = getTableName(clazz);
boolean createIfNotExist = clazz.getDeclaredAnnotationsByType(SQLIfNotExists.class).length != 0;
StringBuilder out = new StringBuilder();
StringBuilder otherTable = new StringBuilder();
// Drop Table
if (createIfNotExist) {
out.append("DROP TABLE IF EXISTS `");
out.append(tableName);
out.append("`;\n");
}
// create Table:
out.append("CREATE TABLE `");
out.append(tableName);
out.append("` (");
boolean firstField = true;
System.out.println("===> TABLE `" + tableName + "`");
String primaryKeyValue = null;
for (Field elem : clazz.getFields()) {
String name = elem.getName();
Integer limitSize = getLimitSize(elem);
boolean notNull = elem.getDeclaredAnnotationsByType(SQLNotNull.class).length != 0;
boolean autoIncrement = elem.getDeclaredAnnotationsByType(SQLAutoIncrement.class).length != 0;
boolean primaryKey = elem.getDeclaredAnnotationsByType(SQLPrimaryKey.class).length != 0;
//boolean sqlNotRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0;
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
boolean updateTime = elem.getDeclaredAnnotationsByType(SQLUpdateTime.class).length != 0;
boolean linkGeneric = elem.getDeclaredAnnotationsByType(SQLTableLinkGeneric.class).length != 0;
String comment = getComment(elem);
String defaultValue = getDefault(elem);
System.out.println(" ==> elem `" + name + "` primaryKey=" + primaryKey + " linkGeneric=" + linkGeneric);
}
// create Table:
out.append("CREATE TABLE `");
out.append(tableName);
out.append("` (");
boolean firstField = true;
System.out.println("===> TABLE `" + tableName + "`");
String primaryKeyValue = null;
for (Field elem : clazz.getFields()) {
String name = elem.getName();
Integer limitSize = getLimitSize(elem);
boolean notNull = elem.getDeclaredAnnotationsByType(SQLNotNull.class).length != 0;
boolean autoIncrement = elem.getDeclaredAnnotationsByType(SQLAutoIncrement.class).length != 0;
boolean primaryKey = elem.getDeclaredAnnotationsByType(SQLPrimaryKey.class).length != 0;
//boolean sqlNotRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0;
boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0;
boolean updateTime = elem.getDeclaredAnnotationsByType(SQLUpdateTime.class).length != 0;
ModelLink linkGeneric = getLinkMode(elem);
String comment = getComment(elem);
String defaultValue = getDefault(elem);
//System.out.println(" ==> elem `" + name + "` primaryKey=" + primaryKey + " linkGeneric=" + linkGeneric);
if (primaryKey) {
primaryKeyValue = name;
}
// special case with external link table:
if (linkGeneric) {
if (primaryKey) {
primaryKeyValue = name;
}
// special case with external link table:
if (linkGeneric == ModelLink.EXTERNAL) {
String localName = name;
if (name.endsWith("s")) {
localName = name.substring(0, name.length()-1);
@ -966,60 +1054,66 @@ public class SqlWrapper {
otherTable.append("_id` bigint NOT NULL,\n");
otherTable.append("\tPRIMARY KEY (`id`)\n");
otherTable.append("\t) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n\n");
} else {
if (firstField) {
out.append("\n\t\t`");
firstField = false;
} else {
out.append(",\n\t\t`");
}
out.append(name);
out.append("` ");
String typeValue = convertTypeInSQL(elem.getType());
if (typeValue.equals("text")) {
if (limitSize != null) {
out.append("varchar(");
out.append(limitSize);
out.append(")");
} else {
out.append("text CHARACTER SET utf8");
}
} else {
out.append(typeValue);
}
out.append(" ");
if (notNull) {
out.append("NOT NULL ");
if (defaultValue == null) {
if (updateTime || createTime) {
out.append("DEFAULT CURRENT_TIMESTAMP(3) ");
}
} else {
out.append("DEFAULT ");
out.append(defaultValue);
out.append(" ");
}
} else if (defaultValue == null) {
if (updateTime || createTime) {
out.append("DEFAULT CURRENT_TIMESTAMP(3) ");
} else {
out.append("DEFAULT NULL ");
}
} else {
out.append("DEFAULT ");
out.append(defaultValue);
out.append(" ");
} else {
if (firstField) {
out.append("\n\t\t`");
firstField = false;
} else {
out.append(",\n\t\t`");
}
out.append(name);
out.append("` ");
String typeValue = null;
if (linkGeneric == ModelLink.INTERNAL) {
typeValue = convertTypeInSQL(String.class);
out.append(typeValue);
} else {
typeValue = convertTypeInSQL(elem.getType());
if (typeValue.equals("text")) {
if (limitSize != null) {
out.append("varchar(");
out.append(limitSize);
out.append(")");
} else {
out.append("text CHARACTER SET utf8");
}
} else {
out.append(typeValue);
}
}
out.append(" ");
if (notNull) {
out.append("NOT NULL ");
if (defaultValue == null) {
if (updateTime || createTime) {
out.append("DEFAULT CURRENT_TIMESTAMP(3) ");
}
} else {
out.append("DEFAULT ");
out.append(defaultValue);
out.append(" ");
}
} else if (defaultValue == null) {
if (updateTime || createTime) {
out.append("DEFAULT CURRENT_TIMESTAMP(3) ");
} else {
out.append("DEFAULT NULL ");
}
} else {
out.append("DEFAULT ");
out.append(defaultValue);
out.append(" ");
}
if (autoIncrement) {
out.append("AUTO_INCREMENT ");
}
}
if (autoIncrement) {
out.append("AUTO_INCREMENT ");
}
if (comment != null) {
out.append("COMMENT '");
out.append(comment.replaceAll("'", "\'"));
out.append("' ");
}
if (comment != null) {
out.append("COMMENT '");
out.append(comment.replaceAll("'", "\'"));
out.append("' ");
}
}
}
if (primaryKeyValue != null) {

View File

@ -1,6 +1,8 @@
package org.kar.karusic;
import java.net.URI;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import javax.ws.rs.core.UriBuilder;
@ -23,6 +25,7 @@ import org.kar.karusic.db.DBConfig;
import org.kar.karusic.filter.AuthenticationFilter;
import org.kar.karusic.filter.CORSFilter;
import org.kar.karusic.filter.OptionFilter;
import org.kar.karusic.model.Track;
import org.kar.karusic.util.ConfigVariable;
import org.kar.karusic.util.JWTWrapper;
@ -46,6 +49,7 @@ public class WebLauncher {
}
public static void main(String[] args) {
//
// if (false) {
// Track tmpTrack = new Track();
@ -72,20 +76,20 @@ public class WebLauncher {
// }
//
// if (false) {
// // generate the BDD:
// try {
// String out = "";
// out += SqlWrapper.createTable(User.class);
// out += SqlWrapper.createTable(Track.class);
// generate the BDD:
try {
String out = "";
//out += SqlWrapper.createTable(User.class);
out += SqlWrapper.createTable(Track.class);
// out += SqlWrapper.createTable(Artist.class);
// out += SqlWrapper.createTable(Gender.class);
// out += SqlWrapper.createTable(Playlist.class);
// out += SqlWrapper.createTable(Album.class);
// System.out.println(out);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
System.out.println(out);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// return;
// }
// if (false) {

View File

@ -5,8 +5,16 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SQLTableLinkGeneric {
public enum ModelLink {
NONE,
INTERNAL,
EXTERNAL
};
ModelLink value() default ModelLink.EXTERNAL;
}

View File

@ -1,5 +1,6 @@
package org.kar.karusic.api;
import org.glassfish.jersey.internal.guava.Lists;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.karusic.SqlWrapper;
@ -225,10 +226,17 @@ public class TrackResource {
trackElem.albumId = albumElem!=null?albumElem.id:null;
trackElem.genderId = genderElem!=null?genderElem.id:null;
trackElem.dataId = data.id;
// Now list of artis has an internal management:
if (artistElem != null) {
trackElem.artists = List.of(artistElem.id);
}
trackElem = SqlWrapper.insert(trackElem);
/*
Old mode of artist insertion (removed due to the slowlest request of getting value
if (artistElem != null) {
SqlWrapper.addLink(Track.class, trackElem.id, "artist", artistElem.id);
}
*/
return Response.ok(trackElem).build();
} catch (Exception ex) {
System.out.println("Catch an unexpected error ... " + ex.getMessage());

View File

@ -28,7 +28,7 @@ public class Track extends NodeSmall {
public Long albumId = null;
public Long track = null;
public Long dataId = null;
@SQLTableLinkGeneric
@SQLTableLinkGeneric(SQLTableLinkGeneric.ModelLink.INTERNAL)
public List<Long> artists = null;
@Override
public String toString() {

View File

@ -29,10 +29,7 @@ import { GenderService, DataService, PlaylistService, ArtistService, AlbumServic
import { BddService, CookiesService, HttpWrapperService, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service';
import { ErrorViewerScene, SsoScene } from 'common/scene';
import { UploadScene } from './scene/upload/upload';
import { ElementSeriesComponent } from './component/element-series/element-series';
import { ElementVideoComponent } from './component/element-video/element-video';
import { ElementSeasonComponent } from './component/element-season/element-season';
import { ElementPlayerAudioComponent } from './component/element-player-audio/element-player-audio';
import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent } from './component';
@NgModule({
declarations: [
@ -42,6 +39,7 @@ import { ElementPlayerAudioComponent } from './component/element-player-audio/el
ElementDataImageComponent,
ElementTypeComponent,
ElementSeriesComponent,
ElementTrackComponent,
ElementSeasonComponent,
ElementVideoComponent,
ElementPlayerAudioComponent,

View File

@ -0,0 +1,11 @@
<div class="item-list-element">
<div class="season-small">
{{prefixName}} {{numberAlbum}}
</div>
<div class="description-small" *ngIf="count > 1">
{{count}} Episodes
</div>
<div class="description-small" *ngIf="count == 1">
{{count}} Episode
</div>
</div>

View File

@ -0,0 +1,47 @@
.item-list-element {
font-size: 20px;
padding: 1px;
height: 55px;
width: 80%;
margin: 5px auto 5px auto;
padding: 5px;
overflow: hidden;
line-height: normal;
border: none;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 500;
will-change: box-shadow;
outline: none;
cursor: pointer;
background: rgba(256, 256, 256, 0.3);
border-radius: 7px;
.material-icons {
vertical-align: middle;
}
.material-icons {
position: absolute;
top: 50%;
left: 50%;
transform: ~"translate(-12px,-12px)";
line-height: 24px;
width: 24px;
}
}
.title-small {
height: 50px;
//width: 100%;
font-size: 35px;
display:inline-block;
font-weight: bold;
}
.description-small {
height: 30px;
font-size: 16px;
overflow:hidden;
vertical-align: middle;
}

View File

@ -0,0 +1,51 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import {Component, OnInit, Input } from '@angular/core';
import { AlbumService, DataService } from 'app/service';
import { NodeData } from 'common/model';
import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-element-track',
templateUrl: './element-track.html',
styleUrls: [ './element-track.less' ]
})
export class ElementTrackComponent implements OnInit {
// input parameters
@Input() element:NodeData;
@Input() prefix:String;
prefixName: string = "";
numberAlbum: string;
count: number;
covers: string[];
description: string;
constructor(
private albumService: AlbumService,
private dataService: DataService) {
}
ngOnInit() {
this.prefix = this.prefixName??"";
if (isNullOrUndefined(this.element)) {
this.numberAlbum = undefined;
this.covers = undefined;
this.description = undefined;
}
this.numberAlbum = this.element.name;
this.description = this.element.description;
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
let self = this;
this.albumService.countTrack(this.element.id)
.then((response) => {
self.count = response;
}).catch((response) => {
self.count = null;
});
}
}

View File

@ -0,0 +1,16 @@
import { ElementPlayerAudioComponent } from "./element-player-audio/element-player-audio";
import { ElementSeasonComponent } from "./element-season/element-season";
import { ElementSeriesComponent } from "./element-series/element-series";
import { ElementTrackComponent } from "./element-track/element-track";
import { ElementVideoComponent } from "./element-video/element-video";
export {
ElementSeriesComponent,
ElementVideoComponent,
ElementSeasonComponent,
ElementPlayerAudioComponent,
ElementTrackComponent,
};

View File

@ -7,7 +7,10 @@
</div>
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
<div class="title">
{{name}} / {{albumName}}
{{name}}
</div>
<div class="title">
{{albumName}}
</div>
<div class="description" *ngIf="albumDescription">
{{albumDescription}}
@ -18,9 +21,11 @@
<div class="clear"></div>
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
<div class="title" *ngIf="tracks.length == 1">Track:</div>
<div *ngFor="let data of tracks" class="item-list" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
<app-element-season [element]="data"></app-element-season>
</div>
<app-element-track
*ngFor="let data of tracks"
[element]="data"
(click)="onSelectTrack($event, data.id)"
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
</div>
<div class="clear"></div>
</div>

View File

@ -52,9 +52,9 @@ export class UploadScene implements OnInit {
parsedFailedElement: FileFailParsedElement[] = [];
uploadFileValue: string = '';
selectedFiles: FileList;
genderId: number = undefined;
artistId: number = undefined;
albumId: number = undefined;
genderId: number = null;
artistId: number = null;
albumId: number = null;
needSend: boolean = false;
// list of all files already registered in the bdd to compare with the curent list of files.
@ -279,9 +279,9 @@ export class UploadScene implements OnInit {
this.parsedFailedElement = [];
this.listFileInBdd = undefined;
this.genderId = undefined;
this.artistId = undefined;
this.albumId = undefined;
this.genderId = null;
this.artistId = null;
this.albumId = null;
//this.listGender = [ { value: null, label: '---' } ];
this.listAlbum = [ { value: null, label: '---' } ];
}

View File

@ -27,7 +27,7 @@
id="filter5338">
<feFlood
flood-opacity="1"
flood-color="rgb(255,255,255)"
flood-color="rgb(0,255,0)"
result="flood"
id="feFlood5328" />
<feComposite

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,7 @@
export function isMobileAgent() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}