summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorralph isenmann2021-02-17 11:01:44 +0100
committerralph isenmann2021-02-17 11:01:44 +0100
commit0169f5fa9a19fcd825be0328902db558c1c0b88a (patch)
tree7d12a211cdda3cbef0ef94fac8d8373cad53059e /dozentenmodul
parent[client] Fix changeMonitor in Lecture- and Imagesdetails (diff)
downloadtutor-module-0169f5fa9a19fcd825be0328902db558c1c0b88a.tar.gz
tutor-module-0169f5fa9a19fcd825be0328902db558c1c0b88a.tar.xz
tutor-module-0169f5fa9a19fcd825be0328902db558c1c0b88a.zip
[client] container: allow user to upload a pre build container image
- A container image saved as tar archive from "docker save ..." can now be selected in Creation Wizard. It will be attached to state.diskfile and uploaded after the user finishes the process.
Diffstat (limited to 'dozentenmodul')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java11
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java79
-rw-r--r--dozentenmodul/src/main/properties/i18n/page_layout.properties1
-rw-r--r--dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties1
4 files changed, 82 insertions, 10 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java
index bd49a500..600dbb7a 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java
@@ -23,6 +23,8 @@ public class ContainerUploadPageLayout extends WizardPage {
protected final JTabbedPane tpInput;
protected final JTextField txtGitRepo;
+ protected final JTextField txtContainerImageFile;
+
/**
* Constructor to define the Layout
*/
@@ -75,6 +77,15 @@ public class ContainerUploadPageLayout extends WizardPage {
grid.add(txtImageName, 2, 1).fill(true, false).expand(true, false);
grid.nextRow();
+ QLabel lblContainerImageFile = new QLabel("Prebuild Container Image");
+ lblContainerImageFile.setToolTipText(
+ I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ContainerImageFile.ToolTipText"));
+ txtContainerImageFile = new JTextField();
+ txtContainerImageFile.setEnabled(false);
+ grid.add(lblContainerImageFile);
+ grid.add(txtContainerImageFile, 2).fill(true, false).expand(true, false);
+ grid.nextRow();
+
// -- Software license changed - shown only in UploadWizard --
chkLicenseRestricted = new JCheckBox(
I18n.PAGE_LAYOUT.getString("ContainerUploadPage.CheckBox.ContainsLicenseRestricted.text"));
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
index ca39f170..e7e7adf5 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
@@ -28,6 +28,8 @@ import javax.swing.event.ChangeListener;
import javax.swing.filechooser.FileFilter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
@@ -40,7 +42,6 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
private final Logger LOGGER = Logger.getLogger(ContainerUploadPage.class);
-
private final UploadWizardState state;
private final ImageDetailsRead existingImage;
private final ContainerDefinition containerDefinition;
@@ -122,9 +123,48 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
}
});
+ txtContainerImageFile.addMouseListener(new MouseListener() {
+ @Override public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() >= 2)
+ browseContainerImageFile();
+ }
+
+ @Override public void mousePressed(MouseEvent e) {
+
+ }
+
+ @Override public void mouseReleased(MouseEvent e) {
+
+ }
+
+ @Override public void mouseEntered(MouseEvent e) {
+
+ }
+
+ @Override public void mouseExited(MouseEvent e) {
+
+ }
+ });
+
btnBrowseForImage.requestFocus();
}
+ private void browseContainerImageFile() {
+ QFileChooser fc = new QFileChooser(Config.getUploadPath(), false);
+ fc.setAcceptAllFileFilterUsed(false);
+ fc.addChoosableFileFilter(new ContainerImageFileFiler());
+
+ int action = fc.showOpenDialog(getDialog());
+ File file = fc.getSelectedFile();
+ if (action != JFileChooser.APPROVE_OPTION || file == null) {
+ txtContainerImageFile.setText("");
+ return;
+ }
+
+ txtContainerImageFile.setText(file.getAbsolutePath());
+ LOGGER.info("Tar File selected");
+ }
+
private void browseFile() {
QFileChooser fc = new QFileChooser(Config.getUploadPath(), false);
@@ -149,10 +189,8 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
String imageName = file.getParentFile().getName();
File imageTarFile = new File(file.getParentFile(), imageName.concat(".tar"));
if (imageTarFile.exists()) {
- LOGGER.info("Upload also an created Image");
- state.diskFile = imageTarFile;
- } else {
- state.diskFile = getDummyFile();
+ txtContainerImageFile.setText(imageTarFile.getAbsolutePath());
+ LOGGER.info("Prebuild Container Image found");
}
Config.setUploadPath(file.getParent());
@@ -215,13 +253,20 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
ContainerMeta containerMeta = containerDefinition.getContainerMeta();
containerMeta.setBuildContextMethod(getBuildContextMethod().ordinal());
containerMeta.setImageName(txtImageName.getText());
+
+
+ File containerImageFile = new File(txtContainerImageFile.getText());
+ if (containerImageFile.exists())
+ state.diskFile = containerImageFile;
+ else
+ state.diskFile = getDummyFile();
+
switch (containerDefinition.getBuildContextMethod()) {
case FILE:
containerDefinition.setContainerRecipe(state.descriptionFile);
break;
case GIT_REPOSITORY:
containerMeta.setBuildContextUrl(txtGitRepo.getText());
- state.diskFile = getDummyFile();
state.descriptionFile = getDummyFile();
break;
}
@@ -231,15 +276,14 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
/**
* This function starts the image creation process. It is triggered by the
* "Next" button.
- *
+ * <p>
* Depending on the state, it will first try to get a UUID for the new image by
* calling createImage() of the thrift API. If a UUID is received, it will
* request an upload with requestImageVersionUpload(). If granted, it will
* finally start a thread for the UploadTask.
- *
+ * <p>
* Then a callback to the Gui is executed where we can process the upload state
* and give the user feedback about it.
- *
*/
@Override protected boolean wantNextOrFinish() {
// are we creating a new image? then either:
@@ -285,7 +329,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
private static class DockerfileFilter extends FileFilter {
@Override public boolean accept(File f) {
-
+
Pattern p = Pattern.compile("[Dd]ockerfile");
Matcher m = p.matcher(f.getName());
@@ -299,4 +343,19 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
return "Dockerfile";
}
}
+
+ private static class ContainerImageFileFiler extends FileFilter {
+
+ @Override public boolean accept(File f) {
+
+ boolean accept = false;
+ if ((f.isFile() && f.toString().endsWith(".tar")) || f.isDirectory())
+ accept = true;
+ return accept;
+ }
+
+ @Override public String getDescription() {
+ return "Container Image (.tar)";
+ }
+ }
}
diff --git a/dozentenmodul/src/main/properties/i18n/page_layout.properties b/dozentenmodul/src/main/properties/i18n/page_layout.properties
index f6047781..19910681 100644
--- a/dozentenmodul/src/main/properties/i18n/page_layout.properties
+++ b/dozentenmodul/src/main/properties/i18n/page_layout.properties
@@ -64,6 +64,7 @@ ContainerUploadPage.DockerFile.label=Docker File
ContainerUploadPage.GitRepository.label=Git Repository
ContainerUploadPage.GitRepository.toolTipText=Set clone address of Git Repository [git@ | http://] [.git]. Currently no Checks!
ContainerUploadPage.CheckBox.ContainsLicenseRestricted.text=Contains license restricted software
+ContainerUploadPage.ContainerImageFile.ToolTipText="Displays the path to a container image file archived as tar. Add manually with double click."
ContainerUploadPage.Infobox.label=Information
ContainerUploadPage.Infobox.text=Please provide all the information needed to define a container image.
diff --git a/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties b/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties
index 8eced6c6..0695ed6c 100644
--- a/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties
+++ b/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties
@@ -64,6 +64,7 @@ ContainerUploadPage.DockerFile.label=Docker File
ContainerUploadPage.GitRepository.label=Git Repository
ContainerUploadPage.GitRepository.toolTipText=Clone Addresse des Git Repositories setzen. [git@ | http://] [.git]. Momentan noch keine Checks!
ContainerUploadPage.CheckBox.ContainsLicenseRestricted.text=Enthält lizenzpflichtige Software
+ContainerUploadPage.ContainerImageFile.ToolTipText="Zeigt den Pfad zu einer als tar archivierten Container-Image-Datei an. Manuell Hinzufügen mit Doppelklick"
ContainerUploadPage.Infobox.label=Hinweis
ContainerUploadPage.Infobox.text=In dieser Maske sind alle Infromationen zur Definition eines Container Images anzugeben.