Skip to content
Snippets Groups Projects
Commit b33e764d authored by Martin Weise's avatar Martin Weise
Browse files

Seeder fixed in frontend

Former-commit-id: 8165ab0a
parent 86986cfb
No related branches found
No related tags found
1 merge request!42Fixed the query service tests
package at.tuwien.config; package at.tuwien.config;
import at.tuwien.seeder.Seeder;
import com.google.common.io.Files; import com.google.common.io.Files;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -14,11 +16,19 @@ import java.io.IOException; ...@@ -14,11 +16,19 @@ import java.io.IOException;
@Configuration @Configuration
public class ReadyConfig { public class ReadyConfig {
private final Seeder seeder;
@Value("${fda.ready.path}") @Value("${fda.ready.path}")
private String readyPath; private String readyPath;
@Autowired
public ReadyConfig(Seeder seeder) {
this.seeder = seeder;
}
@EventListener(ApplicationReadyEvent.class) @EventListener(ApplicationReadyEvent.class)
public void init() throws IOException { public void init() throws IOException {
seeder.seed();
Files.touch(new File(readyPath)); Files.touch(new File(readyPath));
} }
......
package at.tuwien.seeder;
import at.tuwien.entities.container.image.ContainerImage;
import at.tuwien.entities.container.image.ContainerImageEnvironmentItem;
import at.tuwien.entities.container.image.ContainerImageEnvironmentItemType;
import at.tuwien.repository.jpa.ImageRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class Seeder {
private final ImageRepository imageRepository;
private final static Long IMAGE_MARIADB_ID = 1L;
private final static String IMAGE_MARIADB_REPOSITORY = "mariadb";
private final static String IMAGE_MARIADB_TAG = "10.5";
private final static String IMAGE_MARIADB_DIALECT = "org.hibernate.dialect.MariaDBDialect";
private final static String IMAGE_MARIADB_DRIVER = "";
private final static String IMAGE_MARIADB_JDBC = "mariadb";
private final static String IMAGE_MARIADB_LOGO = "";
private final static Integer IMAGE_MARIADB_PORT = 3306;
private final static List<ContainerImageEnvironmentItem> IMAGE_MARIADB_ENVIRONMENT = List.of(
ContainerImageEnvironmentItem.builder()
.iid(IMAGE_MARIADB_ID)
.key("UZERNAME")
.value("root")
.type(ContainerImageEnvironmentItemType.PRIVILEGED_USERNAME)
.build(),
ContainerImageEnvironmentItem.builder()
.iid(IMAGE_MARIADB_ID)
.key("MARIADB_ROOT_PASSWORD")
.value("mariadb")
.type(ContainerImageEnvironmentItemType.PRIVILEGED_PASSWORD)
.build(),
ContainerImageEnvironmentItem.builder()
.iid(IMAGE_MARIADB_ID)
.key("MARIADB_USER")
.value("mariadb")
.type(ContainerImageEnvironmentItemType.USERNAME)
.build(),
ContainerImageEnvironmentItem.builder()
.iid(IMAGE_MARIADB_ID)
.key("MARIADB_PASSWORD")
.value("mariadb")
.type(ContainerImageEnvironmentItemType.PASSWORD)
.build());
private final static ContainerImage IMAGE_MARIADB = ContainerImage.builder()
.dialect(IMAGE_MARIADB_DIALECT)
.driverClass(IMAGE_MARIADB_DRIVER)
.jdbcMethod(IMAGE_MARIADB_JDBC)
.logo(IMAGE_MARIADB_LOGO)
.repository(IMAGE_MARIADB_REPOSITORY)
.tag(IMAGE_MARIADB_TAG)
.environment(IMAGE_MARIADB_ENVIRONMENT)
.defaultPort(IMAGE_MARIADB_PORT)
.build();
@Autowired
public Seeder(ImageRepository imageRepository) {
this.imageRepository = imageRepository;
}
public void seed() {
if (imageRepository.existsById(IMAGE_MARIADB_ID)) {
log.warn("Already seeded. Skip.");
return;
}
final ContainerImage imageMariaDb = imageRepository.save(IMAGE_MARIADB);
log.info("Seeded image {}", imageMariaDb.getId());
log.debug("seeded imge {}", imageMariaDb);
}
}
...@@ -6,7 +6,7 @@ BEGIN; ...@@ -6,7 +6,7 @@ BEGIN;
CREATE TYPE gender AS ENUM ('F', 'M', 'T'); CREATE TYPE gender AS ENUM ('F', 'M', 'T');
CREATE TYPE visibility AS ENUM ('EVERYONE', 'TRUSTED', 'SELF'); CREATE TYPE visibility AS ENUM ('EVERYONE', 'TRUSTED', 'SELF');
CREATE TYPE accesstype AS ENUM ('R', 'W'); CREATE TYPE accesstype AS ENUM ('R', 'W');
CREATE TYPE image_environment_type AS ENUM ('USERNAME', 'PASSWORD', 'DATABASE', 'OTHER'); CREATE TYPE image_environment_type AS ENUM ('USERNAME', 'PASSWORD', 'PRIVILEGED_USERNAME', 'PRIVILEGED_PASSWORD');
CREATE CAST (character varying AS image_environment_type) WITH INOUT AS ASSIGNMENT; CREATE CAST (character varying AS image_environment_type) WITH INOUT AS ASSIGNMENT;
......
...@@ -98,10 +98,7 @@ export default { ...@@ -98,10 +98,7 @@ export default {
this.loading = true this.loading = true
this.error = false this.error = false
res = await this.$axios.get('/api/image/') res = await this.$axios.get('/api/image/')
this.engines = res.data.map((e) => { this.engines = res.data
e.disabled = (e.id !== 3)
return e
})
console.debug('engines', this.engines) console.debug('engines', this.engines)
this.loading = false this.loading = false
} catch (err) { } catch (err) {
......
...@@ -26,7 +26,7 @@ test('create database', pageMacro, async (t, page) => { ...@@ -26,7 +26,7 @@ test('create database', pageMacro, async (t, page) => {
await page.press('#engine', 'ArrowDown') await page.press('#engine', 'ArrowDown')
// Click submit button // Click submit button
await page.click('#createDB') await page.click('button:has-text("Create")')
// See page load // See page load
const success = await page.waitForSelector('.v-toolbar__title') const success = await page.waitForSelector('.v-toolbar__title')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment