Skip to content

Commit

Permalink
Angular UI deployment (#399)
Browse files Browse the repository at this point in the history
* django views urls switched off (#392)

* old urls retrieved so the tests pass; redirection to the new ui page added (#395)

* UI deployment (#396)

* old urls retrieved so the tests pass; redirection to the new ui page added

* test_views removed as we are not using django views anymore

* UI deployment (#397)

* old urls retrieved so the tests pass; redirection to the new ui page added

* test_views removed as we are not using django views anymore

* instead of using settings_conf settings are used

* urls to django views commented

* url updated with the new UI

* code refinement done

* 'Open' button updated with a new UI url

* reverse removed from imports

* reverse removed from imports

* django views removed

* validator urls removed

* redirection to the new result page added

* redirection to the new result page added

* not used import removed

* UI deployment (#398)

* old urls retrieved so the tests pass; redirection to the new ui page added

* test_views removed as we are not using django views anymore

* instead of using settings_conf settings are used

* urls to django views commented

* url updated with the new UI

* code refinement done

* 'Open' button updated with a new UI url

* reverse removed from imports

* reverse removed from imports

* django views removed

* validator urls removed

* redirection to the new result page added

* redirection to the new result page added

* not used import removed

* maintenance_mode field added

* Maintenance mode taken into account

* not needed templates and graphic files removed
  • Loading branch information
sheenaze authored Feb 17, 2022
1 parent 3f603a4 commit eb2d843
Show file tree
Hide file tree
Showing 61 changed files with 71 additions and 6,283 deletions.
14 changes: 7 additions & 7 deletions UI/src/app/modules/core/services/global/settings.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {SettingsDto} from './settings.dto';
import {Observable} from "rxjs";
import {environment} from "../../../../../environments/environment";
import {shareReplay} from "rxjs/operators";
import {DataCache} from "../../tools/DataCache";
import {Observable} from 'rxjs';
import {environment} from '../../../../../environments/environment';
import {shareReplay} from 'rxjs/operators';
import {DataCache} from '../../tools/DataCache';

const settingsURL: string = environment.API_URL + 'api/settings';
const CACHE_KEY_ALL_SETTINGS = -1;
Expand All @@ -23,7 +23,7 @@ export class SettingsService {
if (this.arrayRequestCache.isCached(CACHE_KEY_ALL_SETTINGS)) {
return this.arrayRequestCache.get(CACHE_KEY_ALL_SETTINGS);
} else {
let settings$ = this.httpClient.get<SettingsDto[]>(settingsURL).pipe(shareReplay());
const settings$ = this.httpClient.get<SettingsDto[]>(settingsURL).pipe(shareReplay());
this.arrayRequestCache.push(CACHE_KEY_ALL_SETTINGS, settings$);
return settings$;
}
Expand Down
9 changes: 8 additions & 1 deletion UI/src/app/pages/validate/validate.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
p-lg-10 p-lg-offset-1
p-xl-8 p-xl-offset-2">

<div class="p-grid" style="justify-content: center">
<div *ngIf="!maintenanceMode" class="p-grid" style="justify-content: center">

<!-- data column-->
<div class="p-md-5 p-col-10">
Expand Down Expand Up @@ -177,6 +177,13 @@
</div>

</div>

<div *ngIf="maintenanceMode" class="container text-center mb-5 mt-4" style="max-width: 40rem;">
<h1 class="jumbotron-heading">Maintenance...</h1>
<p class="lead text-muted">Sorry! Currently, you can't start new validations because we're doing maintenance on
the service. Please come back later.</p>
</div>

</div>
<qa-existing-validation *ngIf="isExistingValidationWindowOpen"
[isThereValidation]="isThereValidation"
Expand Down
5 changes: 5 additions & 0 deletions UI/src/app/pages/validate/validate.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@import "src/styles";

div {
font-family: $base-font;
}
::ng-deep .map-panel.p-panel {
.p-panel-content {
padding: 0px;
Expand Down
28 changes: 23 additions & 5 deletions UI/src/app/pages/validate/validate.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {DatasetService} from '../../modules/core/services/dataset/dataset.service';
import {DatasetComponentSelectionModel} from '../../modules/dataset/components/dataset/dataset-component-selection-model';
import {
DatasetComponentSelectionModel
} from '../../modules/dataset/components/dataset/dataset-component-selection-model';
import {DatasetVersionService} from '../../modules/core/services/dataset/dataset-version.service';
import {DatasetVariableService} from '../../modules/core/services/dataset/dataset-variable.service';
import {DatasetConfigModel, ISMN_DEPTH_FILTER_ID, ISMN_NETWORK_FILTER_ID} from './dataset-config-model';
import {FilterService} from '../../modules/core/services/filter/filter.service';
import {FilterModel} from '../../modules/filter/components/basic-filter/filter-model';
import {ValidationModel} from './validation-model';
import {SpatialSubsetModel} from '../../modules/spatial-subset/components/spatial-subset/spatial-subset-model';
import {ValidationPeriodModel} from '../../modules/validation-period/components/validation-period/validation-period-model';
import {
ValidationPeriodModel
} from '../../modules/validation-period/components/validation-period/validation-period-model';
import {AnomaliesModel} from '../../modules/anomalies/components/anomalies/anomalies-model';
import {ANOMALIES_NONE, ANOMALIES_NONE_DESC, AnomaliesComponent} from '../../modules/anomalies/components/anomalies/anomalies.component';
import {
ANOMALIES_NONE,
ANOMALIES_NONE_DESC,
AnomaliesComponent
} from '../../modules/anomalies/components/anomalies/anomalies.component';
import {SCALING_METHOD_DEFAULT, ScalingComponent} from '../../modules/scaling/components/scaling/scaling.component';
import {ValidationRunConfigDto, ValidationRunDatasetConfigDto, ValidationRunMetricConfigDto} from './service/validation-run-config-dto';
import {
ValidationRunConfigDto,
ValidationRunDatasetConfigDto,
ValidationRunMetricConfigDto
} from './service/validation-run-config-dto';
import {ValidationRunConfigService} from './service/validation-run-config.service';

import {ToastService} from '../../modules/core/services/toast/toast.service';
Expand All @@ -22,6 +34,7 @@ import {MapComponent} from '../../modules/map/components/map/map.component';
import {ModalWindowService} from '../../modules/core/services/global/modal-window.service';
import {ExistingValidationDto} from '../../modules/core/services/validation-run/existing-validation.dto';
import {delay} from 'rxjs/operators';
import {SettingsService} from '../../modules/core/services/global/settings.service';


const MAX_DATASETS_FOR_VALIDATION = 5; // TODO: this should come from either config file or the database
Expand Down Expand Up @@ -65,6 +78,7 @@ export class ValidateComponent implements OnInit, AfterViewInit {
validationEnd: Date = new Date();
isThereValidation: ExistingValidationDto;
public isExistingValidationWindowOpen: boolean;
maintenanceMode = false;

constructor(private datasetService: DatasetService,
private versionService: DatasetVersionService,
Expand All @@ -74,14 +88,18 @@ export class ValidateComponent implements OnInit, AfterViewInit {
private toastService: ToastService,
private router: Router,
private route: ActivatedRoute,
private modalWindowService: ModalWindowService) {
private modalWindowService: ModalWindowService,
private settingsService: SettingsService) {
}

ngAfterViewInit(): void {
// child init could be done here
}

ngOnInit(): void {
this.settingsService.getAllSettings().subscribe(setting => {
this.maintenanceMode = setting[0].maintenance_mode;
});
this.modalWindowService.watch().subscribe(state => {
this.isExistingValidationWindowOpen = state === 'open';
});
Expand Down
9 changes: 9 additions & 0 deletions api/frontend_urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from django.shortcuts import redirect

from valentina.settings_conf import SITE_URL

angular_paths = [
{'path': 'home', 'name': 'home'},
{'path': 'login', 'name': 'login'},
Expand Down Expand Up @@ -44,3 +48,8 @@ def get_angular_url(url_name, parameter=None):
searched_path = searched_element['path']

return '/ui/' + searched_path


def redirect_result_page(request, result_uuid):
new_url = SITE_URL + get_angular_url('result', result_uuid)
return redirect(new_url)
1 change: 1 addition & 0 deletions api/views/settings_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class Meta:
model = Settings
fields = ['id',
'news',
'maintenance_mode'
]
12 changes: 10 additions & 2 deletions valentina/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.views.generic.base import RedirectView
from django.urls import include, path

from django.conf import settings

from api.frontend_urls import redirect_result_page

urlpatterns = [
path('', include('validator.urls')),
path('', RedirectView.as_view(url=settings.SITE_URL+'/ui/home/')),
path('old_ui/', include('validator.urls')),
path('api/', include('api.urls')),

# redirection to the new result page, it is needed for old published validations
path('result/<uuid:result_uuid>/', redirect_result_page),
]
6 changes: 4 additions & 2 deletions validator/admin/validation_run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.conf import settings
from django.utils.html import format_html
from django.urls.base import reverse
from django.contrib.admin.options import ModelAdmin, TabularInline

from api.frontend_urls import get_angular_url
from validator.models.dataset_configuration import DatasetConfiguration

# see https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#inlinemodeladmin-objects
Expand All @@ -26,7 +28,7 @@ def __init__(self, model, admin_site):
def open_button(self, valrun):
return format_html(
'<a class="button" target="_blank" href="{}">Open</a>',
reverse('result', args=[valrun.id]),
settings.SITE_URL + get_angular_url('result', valrun.id),
)
open_button.short_description = 'Open'
open_button.allow_tags = True
6 changes: 4 additions & 2 deletions validator/forms/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

from django.conf import settings
from django.core.exceptions import ValidationError
from django.urls.base import reverse

import django.forms as forms

from api.frontend_urls import get_angular_url


def validate_orcid(orcid):
if orcid:
r = reg_search(settings.ORICD_REGEX, orcid)
Expand Down Expand Up @@ -42,7 +44,7 @@ def __init__(self, data=None, validation=None, *args, **kwargs):
super(PublishingForm, self).__init__(data, *args, **kwargs)

def _validation_url(self, val_id):
return settings.SITE_URL + reverse('result', kwargs={'result_uuid': val_id})
return settings.SITE_URL + get_angular_url('result', val_id)

def _formdata_from_validation(self, validation):
title = "Validation of " + (" vs ".join(['{} {}'.format(dc.dataset.pretty_name, dc.version.pretty_name) for dc in validation.dataset_configurations.all()]))
Expand Down
Binary file removed validator/static/images/map_us_spearman.png
Binary file not shown.
Binary file not shown.
Binary file removed validator/static/images/smos.jpg
Binary file not shown.
Binary file removed validator/static/images/ui-icons_00AAE3_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_444444_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_555555_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_777620_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_777777_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_cc0000_256x240.png
Binary file not shown.
Binary file removed validator/static/images/ui-icons_ffffff_256x240.png
Binary file not shown.
35 changes: 0 additions & 35 deletions validator/templates/auth/login.html

This file was deleted.

24 changes: 0 additions & 24 deletions validator/templates/auth/login_base.html

This file was deleted.

21 changes: 0 additions & 21 deletions validator/templates/auth/password_reset_complete.html

This file was deleted.

65 changes: 0 additions & 65 deletions validator/templates/auth/password_reset_confirm.html

This file was deleted.

21 changes: 0 additions & 21 deletions validator/templates/auth/password_reset_done.html

This file was deleted.

11 changes: 0 additions & 11 deletions validator/templates/auth/password_reset_email.html

This file was deleted.

Loading

0 comments on commit eb2d843

Please sign in to comment.