Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suse Customizations #3

Merged
merged 15 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,18 @@ src/backend/app-core/load_plugins.go
.v8flags*

*.bak

secrets.yaml
build/dev_config.json
build/dev_config.json

# Customisations

src/frontend/favicon.ico
src/frontend/sass/custom.scss
src/frontend/assets/eula.html
src/frontend/assets/logo.png
src/frontend/assets/login-bg.jpg
src/frontend/app/custom.module.ts
src/frontend/app/custom
src/frontend/assets/custom
src/frontend/sass/custom
87 changes: 87 additions & 0 deletions build/fe-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

var config = require('./gulp.config');
var paths = config.paths;
var fs = require('fs-extra');
var yaml = require('js-yaml');

const CUSTOM_YAML_MANIFEST = path.resolve(__dirname, '../src/frontend/misc/custom/custom.yaml');

// Clean dist dir
gulp.task('clean', function (next) {
Expand All @@ -25,6 +29,89 @@
// Legacy task name
gulp.task('clean:dist', gulp.series('clean'));

// Apply any customizations
// Symlink customizations of the default resources for Stratos
gulp.task('customize', function (cb) {
doCustomize(false);
cb();
});

// Apply defaults instead of any customizations that are available in custom-src
gulp.task('customize-default', function (cb) {
doCustomize(true);
cb();
});

// Remove all customizations (removes all symlinks as if customize had not been run)
gulp.task('customize-reset', function (cb) {
doCustomize(true, true);
cb();
});

function doCustomize(forceDefaults, reset) {
var msg = !forceDefaults ? 'Checking for and applying customizations' : 'Removing customizations and applying defaults';
var msg = !reset ? msg : 'Removing all customizations';
console.log(msg);
var customConfig;

try {
customConfig = yaml.safeLoad(fs.readFileSync(CUSTOM_YAML_MANIFEST, 'utf8'));
} catch (e) {
console.log('Could not read custom.yaml file');
console.log(e);
process.exit(1);
}

const baseFolder = path.resolve(__dirname, '../src/frontend');
const customBaseFolder = path.resolve(__dirname, '../custom-src/frontend');
doCustomizeFiles(forceDefaults, reset, customConfig, baseFolder, customBaseFolder);
doCustomizeFolders(forceDefaults, reset, customConfig, baseFolder, customBaseFolder);
};

function doCustomizeFiles(forceDefaults, reset, customConfig, baseFolder, customBaseFolder) {
const defaultSrcFolder = path.resolve(__dirname, '../src/frontend/misc/custom');
// Symlink custom files
Object.keys(customConfig.files).forEach(file => {
const dest = customConfig.files[file];

var srcFile = path.join(defaultSrcFolder, file);
const destFile = path.join(baseFolder, dest);
const customSrcFile = path.join(customBaseFolder, dest);

// Use the custom file if there is one
if (!forceDefaults && fs.existsSync(customSrcFile)) {
srcFile = customSrcFile;
}

// Doing an exists check on a symlink will tell if the link dest exists, not the link itself
// So try and delete anyway and catch any exception
try {
const existingLink = fs.readlinkSync(destFile);
fs.unlinkSync(destFile);
} catch(e) {}

if (!reset) {
fs.symlinkSync(srcFile, destFile);
}
})

}

function doCustomizeFolders(forceDefaults, reset, customConfig, baseFolder, customBaseFolder) {
// Symlink custom app folders if they are present
customConfig.folders.forEach(folder => {
var destFolder = path.join(baseFolder, folder);
var srcFolder = path.join(customBaseFolder, folder);
if (fs.existsSync(destFolder)) {
fs.unlinkSync(destFolder);
}
if (!reset && fs.existsSync(srcFolder)) {
fs.symlinkSync(srcFolder, destFolder);
}
});
}


gulp.task('ng-build', function (cb) {
var rootFolder = path.resolve(__dirname, '..');
var cmd = 'npm';
Expand Down
9 changes: 9 additions & 0 deletions custom-src/frontend/app/custom.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { NgModule } from '@angular/core';
import { SuseModule } from './custom/suse.module';

@NgModule({
imports: [
SuseModule,
]
})
export class CustomModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div class="suse-login">
<div class="suse-login__header">
<div class="suse-login__title">SUSE Stratos</div>
</div>
<div class="suse-login__content">
<div class="suse-login__intro">
<h1 class="suse-login__headline">SUSE Stratos<br>Cloud Foundry<br>Console</h1>
<p class="suse-login__tagline">Use SUSE Stratos to develop, compose, and manage Cloud Foundry workloads.</p>
</div>
<div class="suse-login__box suse-login__busy" [ngClass]="{'suse-login__busy': busy$ | async }">
<div class="suse-login__form-title">Sign in</div>
<div class="suse-login__form-outer">
<form class="suse-login__form" name="loginForm" (ngSubmit)="login()" #loginForm="ngForm">
<mat-form-field>
<input matInput required [(ngModel)]="username" name="username" placeholder="Username">
</mat-form-field>
<mat-form-field>
<input matInput required type="password" [(ngModel)]="password" name="password" placeholder="Password">
</mat-form-field>
<button class="suse-login__submit" color="primary" *ngIf="!loggedIn" type="submit" mat-button mat-raised-button [disabled]="!loginForm.valid">Login</button>
</form>
</div>
<div class="suse-login__loading">
<mat-progress-bar mode="query"></mat-progress-bar>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bar looked super long when the window was full screen

</div>
<div class="suse-login__message" [ngClass]="{'suse-login__message--show': !!message, 'suse-login__message-error': this.error}">
{{ message }}
</div>
</div>
</div>
<div class="suse-login__footer">
<div class="suse-login__copyright">
<span *ngIf="config.copyright" [innerHTML]="config.copyright"></span>
</div>
<div class="suse-login__logo">
<a href="https://www.suse.com" target="_blank"><img src="/assets/custom/suse_logo.png"></a>
</div>
</div>
</div>
144 changes: 144 additions & 0 deletions custom-src/frontend/app/custom/suse-login/suse-login.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
@import '../../../sass/custom/suse-colors';

.suse-login {
align-items: center;
background-color: $suse-blue;
border-bottom: 10px solid $suse-primary;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;

&__header, &__content, &__footer {
align-items: center;
display: flex;
flex-direction: row;
}
&__header {
background-color: $suse-secondary;
color: $suse-text;
flex: 0 0 60px;
font-size: 24px;
font-weight: 500;
justify-content: center;
width: 100%;
}
&__content {
align-items: flex-start;
color: $suse-text;
flex: 1;
margin-top: 100px;
overflow-y: auto;
width: 90%;
}
&__footer {
flex: 0 0 auto;
width: 90%;
padding: 20px 0;
}
&__title {
width: 90%;
}
&__copyright {
color: $suse-text-gray;
flex: 1;
}
&__logo {
img {
width: 79px;
}
}
&__intro {
flex: 1;
margin-right: 24px;
}
&__box {
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
margin-left: 24px;
height: 260px;
}
&__form {
display: flex;
flex-direction: column;
.mat-form-field:not(.mat-form-field-invalid) {
.mat-input-placeholder {
color: $suse-text-gray;
}
.mat-form-field-underline {
background-color: $suse-text-gray;
}
}
}
&__submit.mat-raised-button {
&.mat-primary[disabled] {
color: $suse-button-gray;
}
margin-top: 24px;
}
&__headline {
color: $suse-primary;
font-size: 52px;
font-weight: 300;
margin: 0;
}
&__tagline {
color: $suse-text-gray;
font-size: 18px;
font-weight: 300;
line-height: 1.5;
margin: 24px 0;
}
&__form-outer {
$cubic: cubic-bezier(.215, .61, .355, 1);
$time: 250ms;
height: 200px;
max-width: 400px;
opacity: 1;
transition: height $time $cubic 100ms, opacity $time * 2 $cubic $time + 50ms;
}
&__form-title {
color: $suse-text;
font-size: 30px;
font-weight: 300;
margin-bottom: 24px;
}
&__loading {
display: none;
}
&__busy {
.suse-login__form {
display: none;
}
.suse-login__form-outer {
height: 0;
opacity: 0;
}
.suse-login__loading {
display: block;
}
}
&__message {
font-size: 18px;
font-weight: 300;
height: 20px;
padding-top: 20px;
}
}

@media(max-width: 768px) {
.suse-login {
&__intro {
display: none;
}
&__box {
margin: 0;
}
&__content {
max-width: 400px;
width: 80%;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SuseLoginComponent } from './suse-login.component';

describe('SuseLoginComponent', () => {
let component: SuseLoginComponent;
let fixture: ComponentFixture<SuseLoginComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SuseLoginComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SuseLoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
23 changes: 23 additions & 0 deletions custom-src/frontend/app/custom/suse-login/suse-login.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { Customizations, CustomizationsMetadata } from '../../core/customizations.types';
import { LoginPageComponent } from '../../features/login/login-page/login-page.component';
import { AppState } from '../../store/app-state';

@Component({
selector: 'app-suse-login',
templateUrl: './suse-login.component.html',
styleUrls: ['./suse-login.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class SuseLoginComponent extends LoginPageComponent {

constructor(
store: Store<AppState>,
router: Router,
@Inject(Customizations) public config: CustomizationsMetadata
) {
super(store, router);
}
}
Loading