Skip to content

Commit

Permalink
Build UI dev container
Browse files Browse the repository at this point in the history
See #947
  • Loading branch information
theotherp committed May 18, 2024
1 parent 876fdaa commit df4a97d
Show file tree
Hide file tree
Showing 20 changed files with 7,131 additions and 7,020 deletions.
30 changes: 30 additions & 0 deletions .run/docker_uiDev_Dockerfile.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
~ (C) Copyright 2024 TheOtherP ([email protected])
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<component name="ProjectRunConfigurationManager">
<configuration default="false" name="docker/uiDev/Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="nzbhydra/ui-dev:latest"/>
<option name="containerName" value="nzbhydra-ui-dev"/>
<option name="contextFolderPath" value="."/>
<option name="showCommandPreview" value="true"/>
<option name="sourceFilePath" value="docker/uiDev/Dockerfile"/>
</settings>
</deployment>
<method v="2"/>
</configuration>
</component>
2 changes: 1 addition & 1 deletion core/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@
"angular-ui-select": "^0.18.0",
"objectpath": "~1.2.1",
"tv4": "~1.2.7",
"angular": "1.7.8"
"angular": "1.8.3"
}
}
54 changes: 38 additions & 16 deletions core/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//Expected file structure:
//Folder with this file contains the folders ui-src and bower_components

var gulp = require('gulp');
var sort = require('gulp-sort');
var wiredep = require('wiredep');
Expand All @@ -17,19 +20,30 @@ var argv = require('yargs').argv;
var log = require('fancy-log');


var staticFolder = argv.static === undefined ? 'src/main/resources/static' : argv.static;
var liveReloadActive = false;

var staticFolder = process.env.STATIC_FOLDER || 'src/main/resources/static';
var uiSrcFolder = process.env.UI_SRC_FOLDER || 'ui-src';

gulp.task('vendor-scripts', function () {
var dest = staticFolder + '/js';
//Jquery must be loaded before angular for the bootstrap-switch to work
return gulp.src(wiredep(
{overrides: {
{
overrides: {
"angular": {
"dependencies": {
"jquery": "1.x"
}
}
}}
, "angular-formly": {
"dependencies": {
"angular": "*",
"api-check": "*"
}
}
}
}
).js)
.pipe(cached("vendor-scripts"))
.pipe(sourcemaps.init())
Expand Down Expand Up @@ -60,16 +74,16 @@ gulp.task('vendor-css', function () {


gulp.task('templates', function () {
return gulp.src('ui-src/html/**/*.html')
//.pipe(cached("templates")) //Doesn't work properly, will only contain last updated file
return gulp.src(uiSrcFolder + '/html/**/*.html')
//.pipe(cached("templates")) //Doesn't work properly, will only contain last updated file
.pipe(angularTemplateCache("templates.js", {root: "static/html/"}))
.pipe(concat('templates.js'))
.pipe(gulp.dest(staticFolder + '/js'));
});

gulp.task('scripts', function () {
var dest = staticFolder + '/js';
return gulp.src("ui-src/js/**/*.js")
return gulp.src(uiSrcFolder + "/js/**/*.js")
.pipe(angularFilesort())
.on('error', swallowError)
.pipe(ngAnnotate())
Expand All @@ -85,7 +99,7 @@ gulp.task('scripts', function () {

gulp.task('less', function () {
var dest = staticFolder + '/css';
var brightTheme = gulp.src('ui-src/less/bright.less')
var brightTheme = gulp.src(uiSrcFolder + '/less/bright.less')
.pipe(cached("bright"))
.on('error', swallowError)
.pipe(sourcemaps.init())
Expand All @@ -95,7 +109,7 @@ gulp.task('less', function () {
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(dest));

var greyTheme = gulp.src('ui-src/less/grey.less')
var greyTheme = gulp.src(uiSrcFolder + '/less/grey.less')
.pipe(cached("grey"))
.on('error', swallowError)
.pipe(sourcemaps.init())
Expand All @@ -105,7 +119,7 @@ gulp.task('less', function () {
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(dest));

var darkTheme = gulp.src('ui-src/less/dark.less')
var darkTheme = gulp.src(uiSrcFolder + '/less/dark.less')
.pipe(cached("dark"))
.on('error', swallowError)
.pipe(sourcemaps.init())
Expand All @@ -129,11 +143,11 @@ gulp.task('copy-assets', function () {
.pipe(gulp.dest(fontDest));

var imgDest = staticFolder + '/img';
var img = gulp.src("ui-src/img/**/*")
var img = gulp.src(uiSrcFolder + "/img/**/*")
.pipe(cached("images"))
.pipe(gulp.dest(imgDest));

var favIcon = gulp.src("ui-src/img/**/favicon.ico")
var favIcon = gulp.src(uiSrcFolder + "/img/**/favicon.ico")
.pipe(cached("favicon"))
.pipe(gulp.dest(staticFolder));

Expand All @@ -142,7 +156,9 @@ gulp.task('copy-assets', function () {


gulp.task('reload', function () {
livereload();
if (liveReloadActive)
livereload.reload();
log("Triggering live reload")
});

gulp.task('delMainLessCache', function () {
Expand All @@ -158,9 +174,12 @@ gulp.task('copyStaticToClasses', function () {
});

gulp.task('index', function () {
log("Will build from '" + uiSrcFolder + "'");
log("Will build files into folder '" + staticFolder + "'");
runSequence(
['scripts', 'less', 'templates', 'vendor-scripts', 'vendor-css', 'copy-assets'],
['copyStaticToClasses']
['copyStaticToClasses'],
['reload']
);
});

Expand All @@ -171,8 +190,11 @@ function swallowError(error) {


gulp.task('default', function () {
//livereload.listen();
log("Starting livereload server on port 1234")
livereload.listen({"port": 1234});
liveReloadActive = true;
log("Will watch '" + uiSrcFolder + "'");
log("Will build files into folder '" + staticFolder + "'");
gulp.watch(['ui-src/less/nzbhydra.less'], ['delMainLessCache']);
gulp.watch(['ui-src/**/*'], ['index']);
gulp.watch([uiSrcFolder + '/less/nzbhydra.less'], ['delMainLessCache']);
gulp.watch([uiSrcFolder + '/**/*'], ['index']);
});
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public GenericResponse restore(String filename) {
public GenericResponse restoreFromFile(InputStream inputStream) {
File tempFile = null;
try {
tempFile = tempFileProvider.get TempFile("restore", ".zip");
tempFile = tempFileProvider.getTempFile("restore", ".zip");
FileUtils.copyInputStreamToFile(inputStream, tempFile);
tempFile.deleteOnExit();
restoreFromFile(tempFile);
Expand Down
22 changes: 13 additions & 9 deletions core/src/main/java/org/nzbhydra/web/WebConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,28 @@ public class WebConfiguration extends WebMvcConfigurationSupport {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String[] locations = new String[]{"classpath:/static/"};
if (NzbHydra.getDataFolder() != null) {
File staticFolderFile = new File(new File(NzbHydra.getDataFolder()).getParentFile(), "static");
File staticFolderFile = new File(new File(NzbHydra.getDataFolder()), "static");
try {
String fileStatic = staticFolderFile.toURI().toURL().toString();
locations = (fileStatic != null && staticFolderFile.exists()) ? new String[]{fileStatic, "classpath:/static/"} : new String[]{"classpath:/static/"};
logger.info("Found folder {}. Will load UI resources from there", staticFolderFile.getAbsolutePath());
if (staticFolderFile.exists()) {
String fileStatic = staticFolderFile.toURI().toURL().toString();
locations = new String[]{fileStatic};
logger.warn("Found folder {}. Will load UI resources from there instead", staticFolderFile.getAbsolutePath());
} else {
logger.debug("Static resources folder {} does not exist - using baked in resources", staticFolderFile);
}
} catch (MalformedURLException e) {
logger.error("Unable to build path for local static files");
}
}
registry.addResourceHandler("/static/**")
.addResourceLocations(locations)
.setCacheControl(CacheControl.noCache())
.resourceChain(false);
.addResourceLocations(locations)
.setCacheControl(CacheControl.noCache())
.resourceChain(false);

//Otherwise swagger is not loaded using /swagger-ui/index.html
registry.addResourceHandler("/swagger-ui/**")
// Must match the dependency for swagger-ui
.addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/4.10.3/");
// Must match the dependency for swagger-ui
.addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/4.10.3/");


registry.setOrder(0);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/static/css/bright.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/main/resources/static/css/dark.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/main/resources/static/css/grey.css.map

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions core/src/main/resources/static/js/alllibs.js

This file was deleted.

1 change: 0 additions & 1 deletion core/src/main/resources/static/js/alllibs.js.map

This file was deleted.

Loading

0 comments on commit df4a97d

Please sign in to comment.