...
 
Commits (29)
......@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.ToString;
import org.springframework.util.Assert;
import java.io.Serializable;
/**
* Immutable representation of organization that user belongs to.
*
......@@ -13,7 +15,8 @@ import org.springframework.util.Assert;
@EqualsAndHashCode(of = "code")
@Getter
@ToString
public class RihaOrganization {
public class RihaOrganization implements Serializable {
private static final long serialVersionUID = 0;
private String code;
private String name;
......
......@@ -26,14 +26,14 @@ public class RihaUserDetails implements UserDetails, OidcUser {
private UserDetails delegate;
private Map<String, RihaOrganization> organizationsByCode;
private ImmutableMap<String, RihaOrganization> organizationsByCode;
private RihaOrganization activeOrganization;
private String personalCode;
private String firstName;
private String lastName;
private Multimap<RihaOrganization, GrantedAuthority> organizationAuthorities;
private OidcUserRequest userRequest;
private ImmutableMultimap<RihaOrganization, GrantedAuthority> organizationAuthorities;
private transient OidcUserRequest userRequest;
public RihaUserDetails(UserDetails delegate, String personalCode) {
this(delegate, personalCode, null);
......
......@@ -37,13 +37,11 @@ import org.springframework.security.oauth2.core.OAuth2Error;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
import org.springframework.web.util.UriUtils;
import javax.servlet.Filter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.Map;
......@@ -164,7 +162,7 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
((RihaUserDetails) authentication.getPrincipal()).getTaraAmr()
);
String fromUrl = (String) request.getSession(false).getAttribute("fromUrl");
String fromUrl = (String) request.getSession(false).getAttribute(REDIRECT_URL_PARAMETER_MARKER);
if (fromUrl != null) {
// fromUrl param has the following format:
......
package ee.ria.riha.conf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
......@@ -15,12 +14,8 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
@Configuration
@Profile("dev")
public class WebSecurityDevConfiguration extends WebSecurityConfiguration {
@Autowired
DeveloperAuthenticationManager authenticationManager;
@Bean
protected UsernamePasswordAuthenticationFilter authenticationFilter() {
protected UsernamePasswordAuthenticationFilter authenticationFilter(DeveloperAuthenticationManager authenticationManager) {
UsernamePasswordAuthenticationFilter authenticationFilter = new UsernamePasswordAuthenticationFilter();
authenticationFilter.setAuthenticationManager(authenticationManager);
authenticationFilter.setAuthenticationSuccessHandler(successHandler());
......
......@@ -477,10 +477,7 @@ public class InfoSystem {
filesNode.removeAll();
currentFilesMetadataList.forEach(currentFileMetadata -> {
Optional<? extends InfoSystemFileMetadata> foundPrevFileMetadata = prevFilesMetadataList.stream().filter(prevFileMetadata ->
prevFileMetadata.getUrl().equals(currentFileMetadata.getUrl())
|| prevFileMetadata.getName().equals(currentFileMetadata.getName())
).findFirst();
Optional<? extends InfoSystemFileMetadata> foundPrevFileMetadata = getPrevFileMetadata(prevFilesMetadataList, currentFileMetadata);
if (foundPrevFileMetadata.isPresent()) {
//found prev version of same doc
......@@ -495,25 +492,37 @@ public class InfoSystem {
currentFileMetadata.setCreationTimestamp(this.getUpdateTimestamp());
}
ObjectNode docNode = filesNode.addObject().put(FILE_METADATA_NAME_KEY, currentFileMetadata.getName())
.put(FILE_METADATA_URL_KEY, currentFileMetadata.getUrl());
updateFilesNode(filesNode, currentFileMetadata);
});
}
if (currentFileMetadata.getType() != null) {
docNode.put(FILE_METADATA_TYPE_KEY, currentFileMetadata.getType());
}
if (currentFileMetadata.getCreationTimestamp() != null) {
docNode.put(META_CREATION_TIMESTAMP_KEY, currentFileMetadata.getCreationTimestamp());
}
if (currentFileMetadata.getUpdateTimestamp() != null) {
docNode.put(META_UPDATE_TIMESTAMP_KEY, currentFileMetadata.getUpdateTimestamp());
}
private void updateFilesNode(ArrayNode filesNode, InfoSystemFileMetadata currentFileMetadata) {
ObjectNode docNode = filesNode.addObject().put(FILE_METADATA_NAME_KEY, currentFileMetadata.getName())
.put(FILE_METADATA_URL_KEY, currentFileMetadata.getUrl());
if (currentFileMetadata instanceof InfoSystemDocumentMetadata &&
((InfoSystemDocumentMetadata) currentFileMetadata).getAccessRestrictionJson() != null) {
docNode.set(FILE_METADATA_ACCESS_RESTRICTION_KEY,
((InfoSystemDocumentMetadata) currentFileMetadata).getAccessRestrictionJson());
}
});
if (currentFileMetadata.getType() != null) {
docNode.put(FILE_METADATA_TYPE_KEY, currentFileMetadata.getType());
}
if (currentFileMetadata.getCreationTimestamp() != null) {
docNode.put(META_CREATION_TIMESTAMP_KEY, currentFileMetadata.getCreationTimestamp());
}
if (currentFileMetadata.getUpdateTimestamp() != null) {
docNode.put(META_UPDATE_TIMESTAMP_KEY, currentFileMetadata.getUpdateTimestamp());
}
if (currentFileMetadata instanceof InfoSystemDocumentMetadata &&
((InfoSystemDocumentMetadata) currentFileMetadata).getAccessRestrictionJson() != null) {
docNode.set(FILE_METADATA_ACCESS_RESTRICTION_KEY,
((InfoSystemDocumentMetadata) currentFileMetadata).getAccessRestrictionJson());
}
}
private Optional<? extends InfoSystemFileMetadata> getPrevFileMetadata(List<? extends InfoSystemFileMetadata> prevFilesMetadataList,
InfoSystemFileMetadata currentFileMetadata) {
return prevFilesMetadataList.stream().filter(prevFileMetadata ->
prevFileMetadata.getUrl().equals(currentFileMetadata.getUrl())
|| prevFileMetadata.getName().equals(currentFileMetadata.getName())
).findFirst();
}
public void replaceFileUrl(String oldUrl, String newUrl) {
......
package ee.ria.riha.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.time.LocalDate;
import java.util.Date;
......@@ -20,6 +17,7 @@ import static ee.ria.riha.domain.model.IssueEntityType.ISSUE;
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Issue implements IssueEntity {
private Long id;
......@@ -36,9 +34,6 @@ public class Issue implements IssueEntity {
private IssueResolutionType resolutionType;
private LocalDate decisionDeadline;
public Issue() {
}
@Override
public IssueEntityType getEntityType() {
return ISSUE;
......
package ee.ria.riha.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.util.Date;
......@@ -18,6 +15,7 @@ import static ee.ria.riha.domain.model.IssueEntityType.ISSUE_COMMENT;
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IssueComment implements IssueEntity {
private Long id;
......@@ -29,9 +27,6 @@ public class IssueComment implements IssueEntity {
private String organizationName;
private String organizationCode;
public IssueComment() {
}
@Override
public IssueEntityType getEntityType() {
return ISSUE_COMMENT;
......
package ee.ria.riha.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.util.Date;
import java.util.UUID;
......@@ -14,9 +11,9 @@ import java.util.UUID;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Relation {
private Long id;
private Date creationDate;
private Date modifiedDate;
......@@ -33,9 +30,6 @@ public class Relation {
private boolean reversed;
public Relation() {
}
public Relation reverse() {
return Relation.builder()
.id(this.id)
......
......@@ -9,7 +9,7 @@ package ee.ria.riha.service;
public class CodedBrowserException extends BrowserException {
private final String code;
private final Object[] args;
private final transient Object[] args;
public CodedBrowserException(String code) {
super(code);
......
......@@ -166,7 +166,7 @@ public class FileService {
private List<InfoSystemFileMetadata> getMatchingFileMetadata(InfoSystem infoSystem, UUID fileUuid) {
return Stream.concat(infoSystem.getDocumentMetadata().stream(), infoSystem.getDataFileMetadata().stream())
.filter(i -> i.getUrl().equalsIgnoreCase("file://" + fileUuid.toString()))
.filter(i -> i.getUrl().equalsIgnoreCase(FILE_URL_PREFIX + fileUuid.toString()))
.collect(toList());
}
......
......@@ -13,9 +13,9 @@ import java.util.List;
*/
public class JsonValidationException extends BrowserException {
private final ProcessingReport processingReport;
private final transient ProcessingReport processingReport;
public JsonValidationException(ProcessingReport processingReport) {
JsonValidationException(ProcessingReport processingReport) {
this.processingReport = processingReport;
}
......
......@@ -56,8 +56,10 @@ public class NotificationService {
new NewIssueDecisionEmailNotification(),
decisionEvent.getIssueId(),
decisionEvent.getComment());
notificationModel.setDecision(decisionEvent.getResolutionType());
emailNotificationSenderService.sendNotification(notificationModel);
if (notificationModel != null) {
notificationModel.setDecision(decisionEvent.getResolutionType());
emailNotificationSenderService.sendNotification(notificationModel);
}
}
private <T extends NewIssueCommentEmailNotification> T createIssueCommentNotification(T notificationModel,
......
......@@ -13,7 +13,7 @@ import java.util.stream.Collectors;
public class DateUtils {
public static final Set<LocalDate> daysOffWork = NationalHolidays.get().stream()
private static final Set<LocalDate> daysOffWork = NationalHolidays.get().stream()
.filter(DateUtils::isDayOffFromWork)
.map(NationalHoliday::getDate)
.collect(Collectors.toSet());
......@@ -34,15 +34,15 @@ public class DateUtils {
return date;
}
public static boolean isWorkDay(LocalDate date) {
private static boolean isWorkDay(LocalDate date) {
return !isWeekend(date) && !isHoliday(date);
}
public static boolean isWeekend(LocalDate date) {
private static boolean isWeekend(LocalDate date) {
return EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).contains(date.getDayOfWeek());
}
public static boolean isHoliday(LocalDate date) {
private static boolean isHoliday(LocalDate date) {
return daysOffWork.contains(date);
}
......@@ -51,7 +51,8 @@ public class DateUtils {
case NATIONAL_HOLIDAY:
case PUBLIC_HOLIDAY:
return true;
default:
return false;
}
return false;
}
}
package ee.ria.riha.web;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import javax.servlet.http.HttpServletRequest;
import ee.ria.riha.authentication.RihaUserDetails;
import ee.ria.riha.service.UserService;
import ee.ria.riha.storage.util.*;
import ee.ria.riha.web.model.UserDetailsModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -17,17 +15,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ee.ria.riha.service.UserService;
import ee.ria.riha.storage.util.ApiPageableAndCompositeRequestParams;
import ee.ria.riha.storage.util.CompositeFilterRequest;
import ee.ria.riha.storage.util.PageRequest;
import ee.ria.riha.storage.util.Pageable;
import ee.ria.riha.storage.util.PagedResponse;
import ee.ria.riha.web.model.UserDetailsModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static ee.ria.riha.conf.ApplicationProperties.API_V1_PREFIX;
......@@ -38,16 +30,18 @@ import static ee.ria.riha.conf.ApplicationProperties.API_V1_PREFIX;
public class OrganizationController {
private static final String SORT_DELIMITER = "-";
private static final Map<String, Function<UserDetailsModel, ? extends Comparable>> sortFunctions;
static final Map<String, Comparator<UserDetailsModel>> USER_DETAILS_COMPARATORS;
static {
sortFunctions = new HashMap<>();
sortFunctions.put("firstName", UserDetailsModel::getFirstName);
sortFunctions.put("lastName", UserDetailsModel::getLastName);
sortFunctions.put("email", UserDetailsModel::getEmail);
sortFunctions.put("approver", UserDetailsModel::getApprover);
sortFunctions.put("producer", UserDetailsModel::getProducer);
USER_DETAILS_COMPARATORS = new HashMap<>();
USER_DETAILS_COMPARATORS.put("firstName", Comparator.comparing(UserDetailsModel::getFirstName, Comparator.nullsLast(String::compareToIgnoreCase)));
USER_DETAILS_COMPARATORS.put("lastName", Comparator.comparing(UserDetailsModel::getLastName, Comparator.nullsLast(String::compareToIgnoreCase)));
USER_DETAILS_COMPARATORS.put("email", Comparator.comparing(UserDetailsModel::getEmail, Comparator.nullsLast(String::compareToIgnoreCase)));
USER_DETAILS_COMPARATORS.put("approver", Comparator.comparing(UserDetailsModel::getApprover, Comparator.nullsLast(Boolean::compareTo)));
USER_DETAILS_COMPARATORS.put("producer", Comparator.comparing(UserDetailsModel::getProducer, Comparator.nullsLast(Boolean::compareTo)));
}
@Autowired
private UserService userService;
......@@ -64,7 +58,15 @@ public class OrganizationController {
List<UserDetailsModel> users = userService.getUsersByOrganization(rihaUserDetails.getActiveOrganization().getCode());
int totalUsers = users.size();
sortUsers(filterRequest, users);
String sortParameter = getSortFieldFromFilterRequest(filterRequest);
Comparator<UserDetailsModel> sortFunction =
sortParameter != null
? USER_DETAILS_COMPARATORS.get(sortParameter.replace(SORT_DELIMITER, ""))
: null;
if (sortParameter != null && sortFunction != null) {
sortUsers(users, sortFunction, sortParameter.startsWith(SORT_DELIMITER));
}
users = applyPaging(pageable, users);
return ResponseEntity.ok(new PagedResponse(
......@@ -73,17 +75,14 @@ public class OrganizationController {
users));
}
private void sortUsers(CompositeFilterRequest filterRequest, List<UserDetailsModel> users) {
List<String> sortParameters = filterRequest.getSortParameters();
if (!sortParameters.isEmpty()) {
String sort = sortParameters.get(0);
Function<UserDetailsModel, ? extends Comparable> sortFunction = sortFunctions.get(sort.replace(SORT_DELIMITER, ""));
if (sortFunction == null) {
return;
}
Comparator<UserDetailsModel> comparator = Comparator.comparing(sortFunction);
users.sort(sort.startsWith(SORT_DELIMITER) ? comparator.reversed() : comparator);
}
private String getSortFieldFromFilterRequest(CompositeFilterRequest filterRequest) {
return filterRequest != null && filterRequest.getSortParameters() != null && !filterRequest.getSortParameters().isEmpty()
? filterRequest.getSortParameters().get(0)
: null;
}
static void sortUsers(List<UserDetailsModel> users, Comparator<UserDetailsModel> sortFunction, boolean reverseSort) {
users.sort(reverseSort ? sortFunction.reversed() : sortFunction);
}
private List<UserDetailsModel> applyPaging(Pageable pageable, List<UserDetailsModel> users) {
......
......@@ -4,6 +4,7 @@ import ee.ria.riha.domain.model.IssueResolutionType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Model of an issue approval decision request
......@@ -13,11 +14,8 @@ import lombok.Data;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IssueApprovalDecisionModel {
private String comment;
private IssueResolutionType decisionType;
public IssueApprovalDecisionModel() {
}
}
......@@ -3,6 +3,7 @@ package ee.ria.riha.web.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Model of an issue comment request
......@@ -12,10 +13,7 @@ import lombok.Data;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IssueCommentModel {
private String comment;
public IssueCommentModel() {
}
}
......@@ -5,6 +5,7 @@ import ee.ria.riha.domain.model.IssueStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Model of an issue status update request
......@@ -14,12 +15,9 @@ import lombok.Data;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IssueStatusUpdateModel {
private String comment;
private IssueStatus status;
private IssueResolutionType resolutionType;
public IssueStatusUpdateModel() {
}
}
package ee.ria.riha.web.model;
import ee.ria.riha.domain.model.RelationType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
/**
* Model of info system relationship request.
......@@ -15,12 +12,9 @@ import lombok.Setter;
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RelationModel {
private Long id;
private String infoSystemShortName;
private RelationType type;
public RelationModel() {
}
}
package ee.ria.riha.web.model;
import ee.ria.riha.domain.model.RelationType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.util.UUID;
......@@ -17,14 +14,11 @@ import java.util.UUID;
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RelationSummaryModel {
private Long id;
private UUID infoSystemUuid;
private String infoSystemName;
private String infoSystemShortName;
private RelationType type;
public RelationSummaryModel() {
}
}
package ee.ria.riha.web;
import ee.ria.riha.storage.util.CompositeFilterRequest;
import ee.ria.riha.web.model.UserDetailsModel;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
public class OrganizationControllerTest {
@Test
public void sortUsers() {
List<UserDetailsModel> testUsers = Arrays.asList(
UserDetailsModel.builder().email("test0@test.aa").build(),
UserDetailsModel.builder().email(null).build(),
UserDetailsModel.builder().email("test1@test.aa").build(),
UserDetailsModel.builder().email("test2@test.aa").build()
);
CompositeFilterRequest filterRequest = new CompositeFilterRequest(Collections.emptyList(), Collections.singletonList("asc"));
OrganizationController.sortUsers(testUsers, OrganizationController.USER_DETAILS_COMPARATORS.get("email"),false);
assertThat(testUsers.get(3).getEmail(), nullValue());
OrganizationController.sortUsers(testUsers, OrganizationController.USER_DETAILS_COMPARATORS.get("email"),true);
assertThat(testUsers.get(0).getEmail(), nullValue());
}
}
\ No newline at end of file
......@@ -72,7 +72,6 @@ sudo npm install -g karma-jasmine-ajax
sudo npm install -g karma-coverage
sudo npm install -g karma-phantomjs2-launcher
sudo npm install -g coffee-script@1.8.0
sudo npm install -g bower-installer@0.8.4
~~~
## Build
......@@ -88,17 +87,6 @@ Frontend is a Angular 4 module generated by Angular CLI version 1.0.4. It can be
mvn frontend:install-node-and-yarn frontend:yarn
~~~
#### Install bower
Build process requires bower. Please note that bower can't run as root user or using sudo. If you absolutely have to, add `{ "allow_root": true }` to `~/.bowerrc`.
~~~bash
echo "{ \"allow_root\": true }" > ~/.bowerrc
~~~
Install bower
~~~bash
mvn frontend:yarn@install-bower
~~~
#### Build using maven
Build project using maven `frontend:yarn` task and calling `build` script from `package.json`. Compiled artifacts will be outputted to the `dist` directory.
~~~bash
......
......@@ -26,9 +26,10 @@ export class AppComponent {
// 'en' not supported yet
translate.use('et');
let googleAnalyticsId = this.environmentService.globalEnvironment.getGoogleAnalyticsId();
const googleAnalyticsId = this.environmentService.globalEnvironment ?
this.environmentService.globalEnvironment.getGoogleAnalyticsId() : null;
this.router.routeReuseStrategy.shouldReuseRoute = function(future, curr){
this.router.routeReuseStrategy.shouldReuseRoute = function(future, curr) {
return false;
};
......
......@@ -53,7 +53,7 @@ export class DiscussionsListComponent implements OnInit, DoCheck {
}
ngDoCheck() {
var changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.environmentService.getUserMatrix().isOrganizationSelected)){
this.loaded = false;
this.getActiveDiscussions();
......
......@@ -26,7 +26,7 @@ export class SystemsForApprovalListComponent implements OnInit {
}
public isOverdue(date){
let momentDate = moment(date);
const momentDate = moment(date);
return moment().diff(momentDate, 'days') > 0;
}
......@@ -40,10 +40,10 @@ export class SystemsForApprovalListComponent implements OnInit {
this.approvalReqestsForDisplay.push(ar);
} else if (ar.events){
let hasDecision = false;
let eventsCount = ar.events.length;
const eventsCount = ar.events.length;
for (let i = 0; i < eventsCount; i++){
let event = ar.events[i];
let activeOrganization = this.environmentService.getActiveUser().getActiveOrganization();
const event = ar.events[i];
const activeOrganization = this.environmentService.getActiveUser().getActiveOrganization();
if (event.type == this.classifiers.event_type.DECISION.code && activeOrganization && activeOrganization.code == event.organizationCode){
hasDecision = true;
break;
......@@ -75,7 +75,7 @@ export class SystemsForApprovalListComponent implements OnInit {
}
ngDoCheck() {
var changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.environmentService.getUserMatrix().isOrganizationSelected)){
this.loaded = false;
this.getOpenApprovalRequestsWithoutDecisions();
......
......@@ -103,7 +103,7 @@ export class ApproverIssueDetailsComponent implements OnInit {
canResolveGeneral(){
let ret = false;
if (this.feedback.status == 'OPEN'){
let bHasApproverRole = this.environmentService.getUserMatrix().hasApproverRole;
const bHasApproverRole = this.environmentService.getUserMatrix().hasApproverRole;
if (this.feedback.type != classifiers.issue_type.TAKE_INTO_USE_REQUEST.code
&& this.feedback.type != classifiers.issue_type.MODIFICATION_REQUEST.code
&& this.feedback.type != classifiers.issue_type.FINALIZATION_REQUEST.code
......@@ -120,7 +120,7 @@ export class ApproverIssueDetailsComponent implements OnInit {
|| this.feedback.type == classifiers.issue_type.MODIFICATION_REQUEST.code
|| this.feedback.type == classifiers.issue_type.FINALIZATION_REQUEST.code
|| this.feedback.type == classifiers.issue_type.ESTABLISHMENT_REQUEST.code){
let userMatrix = this.environmentService.getUserMatrix();
const userMatrix = this.environmentService.getUserMatrix();
ret = userMatrix.hasApproverRole && userMatrix.isRiaMember;
}
}
......
......@@ -23,8 +23,8 @@ export class ApproverSystemCheckComponent implements OnInit {
private startSystemCheck(){
this.hasErrors = false;
let statusPending = classifiers.system_check_status.PENDING.code;
let statusInProgress = classifiers.system_check_status.IN_PROGRESS.code;
const statusPending = classifiers.system_check_status.PENDING.code;
const statusInProgress = classifiers.system_check_status.IN_PROGRESS.code;
this.systemCheckMatrix = {
systemStatus: statusInProgress,
developmentStatus: statusPending,
......@@ -40,7 +40,7 @@ export class ApproverSystemCheckComponent implements OnInit {
this.checkSystemStatus();
}, err => {
this.helper.showError();
let statusCancelled = classifiers.system_check_status.CANCELLED.code;
const statusCancelled = classifiers.system_check_status.CANCELLED.code;
this.systemCheckMatrix = {
systemStatus: statusCancelled,
developmentStatus: statusCancelled,
......@@ -135,7 +135,7 @@ export class ApproverSystemCheckComponent implements OnInit {
}
private setErrorStatus(){
for (let k in this.systemCheckMatrix) {
for (const k in this.systemCheckMatrix) {
if (this.systemCheckMatrix[k] == classifiers.system_check_status.FAILED.code){
this.hasErrors = true;
}
......
......@@ -44,13 +44,13 @@ export class BrowserFilesListComponent implements OnInit {
public getDataObjectFiles(page?){
// if (this.filters.searchText && this.filters.searchText.length > 1){
let params = this.helper.cloneObject(this.filters);
const params = this.helper.cloneObject(this.filters);
let sortProperty = this.gridData.getSortProperty();
const sortProperty = this.gridData.getSortProperty();
if (sortProperty) {
params.sort = sortProperty;
}
let sortOrder = this.gridData.getSortOrder();
const sortOrder = this.gridData.getSortOrder();
if (sortOrder) {
params.dir = sortOrder;
}
......@@ -60,7 +60,7 @@ export class BrowserFilesListComponent implements OnInit {
this.gridData.page = page || 0;
let q = this.helper.generateQueryString(params);
const q = this.helper.generateQueryString(params);
this.location.replaceState('/Andmeobjektid', q);
this.systemsService.getSystemsDataObjects(this.filters, this.gridData).subscribe(res =>{
......@@ -107,7 +107,7 @@ export class BrowserFilesListComponent implements OnInit {
private filtersNotEmpty() : boolean {
for (let key in this.filters) {
for (const key in this.filters) {
if (this.filters[key]){
return true;
}
......
......@@ -44,7 +44,7 @@ export class BrowserListComponent implements OnInit, AfterViewInit {
}
_loadSystems(filters, page?) {
let params = this.generalHelperService.cloneObject(filters);
const params = this.generalHelperService.cloneObject(filters);
params.searchText = this.searchText;
if (params.dateCreatedFrom) {
......@@ -60,11 +60,11 @@ export class BrowserListComponent implements OnInit, AfterViewInit {
params.dateUpdatedTo = this.systemsService.dateObjToTimestamp(params.dateUpdatedTo, true);
}
let sortProperty = this.gridData.getSortProperty();
const sortProperty = this.gridData.getSortProperty();
if (sortProperty) {
params.sort = sortProperty;
}
let sortOrder = this.gridData.getSortOrder();
const sortOrder = this.gridData.getSortOrder();
if (sortOrder) {
params.dir = sortOrder;
}
......@@ -72,7 +72,7 @@ export class BrowserListComponent implements OnInit, AfterViewInit {
params.page = page + 1;
}
let q = this.generalHelperService.generateQueryString(params);
const q = this.generalHelperService.generateQueryString(params);
this.location.replaceState('/Infosüsteemid', q);
this.gridData.page = page || 0;
this.systemsService.getSystems(params, this.gridData).subscribe(
......
<section>
<div class="card-deck mb-2 mb-sm-3">
<div *ngFor="let card of cards" class="card feature">
<div class="card-block">
<div class="card-body">
<h4 class="card-title">
<span class="fa" [ngClass]="card.iconType">
</span>{{card.title}}</h4>
......
......@@ -46,7 +46,7 @@ export class FileHintComponent implements OnInit {
private getRestrictionReason(){
if (this.file.accessRestriction && this.file.accessRestriction.reasonCode){
let reason = this.generalHelperService.toArray(this.classifiers.access_restriction_reasons).filter( r => r.code == this.file.accessRestriction.reasonCode)[0].value;
const reason = this.generalHelperService.toArray(this.classifiers.access_restriction_reasons).filter( r => r.code == this.file.accessRestriction.reasonCode)[0].value;
return JSON.parse(reason);
} else {
return null;
......
......@@ -21,19 +21,19 @@ export class LoginFormComponent implements OnInit {
this.environmentService.doLogin().subscribe(res => {
this.environmentService.loadEnvironmentData().subscribe(env => {
this.sessionHelper.refreshSessionTimer();
let prevLocation = this.router.routerState.snapshot.root.queryParams.fromUrl;
const prevLocation = this.router.routerState.snapshot.root.queryParams.fromUrl;
if (prevLocation){
this.router.navigate([decodeURIComponent(prevLocation)]);
} else {
this.router.navigate(['/']);
}
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
if (user == null) {
return;
}
let organizations = user.getOrganizations();
const organizations = user.getOrganizations();
if (organizations.length > 1){
this.modalService.open(ActiveOrganizationChooserComponent);
} else if (organizations.length == 1){
......
......@@ -40,7 +40,6 @@ export class ProducerAddComponent implements OnInit, DoCheck {
}
openOrganizationsModal() {
const modalRef = this.modalService.open(ActiveOrganizationChooserComponent);
return false;
}
......@@ -59,8 +58,7 @@ export class ProducerAddComponent implements OnInit, DoCheck {
}
ngDoCheck() {
var changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes){
if (this.differ.diff(this.environmentService.globalEnvironment)){
this.userMatrix = this.environmentService.getUserMatrix();
}
}
......
......@@ -49,7 +49,7 @@ export class ProducerDashboardComponent implements OnInit, DoCheck {
}
ngDoCheck() {
let changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.userMatrix.isOrganizationSelected)){
this.userMatrix = this.environmentService.getUserMatrix();
this.getOwnOpenIssues();
......
......@@ -69,7 +69,7 @@ export class ProducerDetailsIssuesComponent implements OnInit {
modalRef.componentInstance.system = this.system;
modalRef.result.then(res => {
this.refreshIssues();
let issueType = res && res.issueType ? res.issueType : null;
const issueType = res && res.issueType ? res.issueType : null;
this.onIssueResolve.emit(issueType);
this.location.replaceState(`/Infosüsteemid/Vaata/${ this.system.details.short_name }`);
},
......
......@@ -23,8 +23,8 @@ export class ProducerDetailsComponent implements OnInit, DoCheck {
private differ: any;
isEditingAllowed(){
const user = this.environmentService.getActiveUser();
let editable = false;
let user = this.environmentService.getActiveUser();
if (user) {
editable = user.canEdit(this.system.getOwnerCode());
}
......@@ -32,7 +32,7 @@ export class ProducerDetailsComponent implements OnInit, DoCheck {
}
isBlockVisible(blockName){
let editable = this.isEditingAllowed();
const editable = this.isEditingAllowed();
let ret = false;
switch (blockName) {
case 'legislations': {
......@@ -88,7 +88,7 @@ export class ProducerDetailsComponent implements OnInit, DoCheck {
isCannotViewCommentsErrorVisible(){
this.userMatrix = this.environmentService.getUserMatrix();
if (this.loaded && this.userMatrix.isLoggedIn){
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
return this.issueId && this.userMatrix.isLoggedIn && !(user.canEdit(this.system.getOwnerCode()) || this.userMatrix.hasApproverRole);
} else {
return false;
......@@ -102,7 +102,7 @@ export class ProducerDetailsComponent implements OnInit, DoCheck {
this.loaded = true;
setTimeout(()=>{this.generalHelperService.adjustSection(this.issueId ? '#tagasiside' : null)}, 0);
}, err => {
let status = err.status;
const status = err.status;
if (status == '404'){
this.notFound = true;
this.generalHelperService.setRihaPageTitle('Lehekülge ei leitud');
......@@ -142,7 +142,7 @@ export class ProducerDetailsComponent implements OnInit, DoCheck {
}
ngDoCheck() {
let changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.userMatrix.isOrganizationSelected)){
this.userMatrix = this.environmentService.getUserMatrix();
}
......
......@@ -65,7 +65,7 @@ export class ProducerEditContactsComponent implements OnInit {
private generalHelperService: GeneralHelperService) { }
ngOnInit() {
let system = this.generalHelperService.cloneObject(this.system);
const system = this.generalHelperService.cloneObject(this.system);
this.contacts = system.details.contacts || [];
}
}
......@@ -126,7 +126,7 @@ export class ProducerEditDocumentsComponent implements OnInit {
clearAccessRestriction(e, i){
if (e){
let d = new Date();
const d = new Date();
this.documents[i].accessRestriction = {
startDate: {
day: d.getDate(),
......@@ -152,7 +152,7 @@ export class ProducerEditDocumentsComponent implements OnInit {
public generalHelperService: GeneralHelperService) { }
ngOnInit() {
let system = this.generalHelperService.cloneObject(this.system);
const system = this.generalHelperService.cloneObject(this.system);
this.documents = this.prepareForDisplay(system.details.documents || []);
}
......
......@@ -66,7 +66,7 @@ export class ProducerEditGeneralComponent implements OnInit {
}
canDescribe(){
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
let ret = false;
if (user){
ret = user.canEdit(this.system.getOwnerCode());
......
......@@ -68,7 +68,7 @@ export class ProducerEditLegislationsComponent implements OnInit {
public generalHelperService: GeneralHelperService) { }
ngOnInit() {
let system = this.generalHelperService.cloneObject(this.system);
const system = this.generalHelperService.cloneObject(this.system);
this.legislations = system.details.legislations || [];
}
......
......@@ -109,7 +109,7 @@ export class ProducerEditObjectsComponent implements OnInit {
}
ngOnInit() {
let system = this.generalHelperService.cloneObject(this.system);
const system = this.generalHelperService.cloneObject(this.system);
this.stored_data = system.details.stored_data || [];
this.data_files = system.details.data_files || [];
}
......
......@@ -7,7 +7,7 @@ import { GeneralHelperService } from '../../../services/general-helper.service';
import { ModalHelperService } from '../../../services/modal-helper.service';
import {Observable} from 'rxjs';
import {debounceTime, distinctUntilChanged, map} from 'rxjs/operators';
import {debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators';
@Component({
selector: 'app-producer-edit-relations',
......@@ -37,7 +37,7 @@ export class ProducerEditRelationsComponent implements OnInit {
return text$
.pipe(debounceTime(800),
distinctUntilChanged(),
map(term => term.length < 2 ? []
switchMap(term => term.length < 2 ? []
: this.systemsService.getSystemsForAutocomplete(term, this.system.details.short_name))
);
};
......@@ -45,7 +45,7 @@ export class ProducerEditRelationsComponent implements OnInit {
addRelation(addForm){
if (addForm.valid){
let infoSystemShortName = typeof this.relation.infoSystem === 'string' ? this.relation.infoSystem : this.relation.infoSystem.details.short_name;
const infoSystemShortName = typeof this.relation.infoSystem === 'string' ? this.relation.infoSystem : this.relation.infoSystem.details.short_name;
this.systemsService.addSystemRelation(this.system.details.short_name, {infoSystemShortName: infoSystemShortName,
type: this.relation.type}).subscribe(res => {
this.refreshRelations();
......
......@@ -115,7 +115,7 @@ export class ProducerEditSecurityComponent implements OnInit {
private generalHelperService: GeneralHelperService) { }
ngOnInit(){
let system = this.generalHelperService.cloneObject(this.system);
const system = this.generalHelperService.cloneObject(this.system);
this.security = system.details.security || {
standard: null,
class: null,
......
......@@ -23,7 +23,7 @@ export class ProducerEditComponent implements OnInit {
this.system = new System(this.systemsService.prepareSystemForDisplay(system));
this.loaded = true;
}, err => {
let status = err.status;
const status = err.status;
if (status == '404'){
this.notFound = true;
this.generalHelperService.setRihaPageTitle('Lehekülge ei leitud');
......
......@@ -51,7 +51,7 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
return;
}
let params = filters;
const params = filters? filters: [];
params.searchText = this.searchText;
delete params.ownerName;
delete params.ownerCode;
......@@ -67,11 +67,11 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
if (params.dateUpdatedTo) {
params.dateUpdatedTo = this.systemsService.dateObjToTimestamp(params.dateUpdatedTo, true);
}
let sortProperty = this.gridData.getSortProperty();
const sortProperty = this.gridData.getSortProperty();
if (sortProperty) {
params.sort = sortProperty;
}
let sortOrder = this.gridData.getSortOrder();
const sortOrder = this.gridData.getSortOrder();
if (sortOrder) {
params.dir = sortOrder;
}
......@@ -81,7 +81,7 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
this.gridData.page = 0;
}
let q = this.generalHelperService.generateQueryString(params);
const q = this.generalHelperService.generateQueryString(params);
this.location.replaceState('/Kirjelda', q);
this.systemsService.getOwnSystems(params, this.gridData).subscribe(
......@@ -104,7 +104,7 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
getOwnSystems(page?): void {
this._loadSystems(this.filterPanel.getFilters(), page);
this._loadSystems(this.filterPanel ? this.filterPanel.getFilters() : null, page);
}
openOrganizationsModal() {
......@@ -118,7 +118,7 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
}
hasActiveFilters(): boolean{
return this.filterPanel.hasActiveFilters();
return this.filterPanel && this.filterPanel.hasActiveFilters();
}
clearFilters(){
......@@ -175,7 +175,7 @@ export class ProducerListComponent implements OnInit, AfterViewInit, DoCheck {
}
ngDoCheck() {
var changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.userMatrix.isOrganizationSelected)){
this.userMatrix = this.environmentService.getUserMatrix();
this.getOwnSystems();
......
......@@ -8,7 +8,6 @@ import {Location} from "@angular/common";
import {SystemsService} from "../../services/systems.service";
import {ToastrService} from "ngx-toastr";
import {User} from "../../models/user";
import {ActiveOrganizationChooserComponent} from "../active-organization-chooser/active-organization-chooser.component";
import {ModalHelperService} from "../../services/modal-helper.service";
@Component({
......@@ -36,12 +35,12 @@ export class ProducerOrganizationComponent implements OnInit, DoCheck {
getUsers(page?): void {
if (this.userMatrix.isLoggedIn && this.userMatrix.isOrganizationSelected) {
let params = {'sort': null, 'dir': null, 'page': null};
let sortProperty = this.gridData.getSortProperty();
const params = {'sort': null, 'dir': null, 'page': null};
const sortProperty = this.gridData.getSortProperty();
if (sortProperty) {
params.sort = sortProperty;
}
let sortOrder = this.gridData.getSortOrder();
const sortOrder = this.gridData.getSortOrder();
if (sortOrder) {
params.dir = sortOrder;
}
......@@ -49,7 +48,7 @@ export class ProducerOrganizationComponent implements OnInit, DoCheck {
params.page = page + 1;
}
let q = this.generalHelperService.generateQueryString(params);
const q = this.generalHelperService.generateQueryString(params);
this.location.replaceState('/Minu/Organisatsioon', q);
this.gridData.page = page || 0;
......@@ -68,7 +67,6 @@ export class ProducerOrganizationComponent implements OnInit, DoCheck {
}
openOrganizationsModal() {
const modalRef = this.modalService.open(ActiveOrganizationChooserComponent);
return false;
}
......@@ -93,7 +91,7 @@ export class ProducerOrganizationComponent implements OnInit, DoCheck {
}
ngDoCheck() {
var changes = this.differ.diff(this.environmentService.globalEnvironment);
const changes = this.differ.diff(this.environmentService.globalEnvironment);
if (changes && (this.loaded || !this.userMatrix.isOrganizationSelected)){
this.userMatrix = this.environmentService.getUserMatrix();
this.getUsers();
......
......@@ -54,7 +54,7 @@ export class ProducerSearchFilterComponent implements OnInit {
getFilters(): any {
let params = this.generalHelperService.cloneObject(this.filters);
const params = this.generalHelperService.cloneObject(this.filters);
if (params.dateCreatedFrom) {
params.dateCreatedFrom = this.systemsService.dateObjToTimestamp(params.dateCreatedFrom, true);
......@@ -74,7 +74,7 @@ export class ProducerSearchFilterComponent implements OnInit {
hasActiveFilters(): boolean {
for (let key in this.filters) {
for (const key in this.filters) {
if (key != 'searchText' && this.filters[key]) {
return true;
}
......
<div class="header-top hidden-xs-down">
<div class="header-top d-none d-md-block">
<div class="container">
<div class="left">
......@@ -41,7 +41,7 @@
<a class="nav-link" [routerLink]="'/Avaleht'">Avaleht</a>
</li>
<li class="nav-item" [ngClass]="{'active': isListOrSubView()}">
<a class="nav-link" [routerLink]="'/Infosüsteemid'" [queryParams]="{_dc: getRand()}">RIHA kataloog</a>
<a class="nav-link" [routerLink]="'/Infosüsteemid'" [queryParams]="{_dc: _dc}">RIHA kataloog</a>
</li>
<li *ngIf="environmentService.getUserMatrix().hasApproverRole" class="nav-item" routerLinkActive="active">
<a class="nav-link" [routerLink]="'/Hinda'">Hinda</a>
......
import {Component, OnInit} from '@angular/core';
import {AfterContentChecked, Component, OnInit} from '@angular/core';
import {EnvironmentService} from '../../services/environment.service';
import {User} from '../../models/user';
import {ModalHelperService} from '../../services/modal-helper.service';
......@@ -13,14 +13,15 @@ import * as $ from 'jquery';
templateUrl: './riha-navbar.component.html',
styleUrls: ['./riha-navbar.component.scss']
})
export class RihaNavbarComponent implements OnInit {
export class RihaNavbarComponent implements OnInit, AfterContentChecked {
public activeUser: User = null;
public _dc: number = 0;
isUserLoggedIn(): boolean {
return this.environmentService.getActiveUser() != null;
}
getRand(){
getRand() {
return new Date().getSeconds();
}
......@@ -33,19 +34,19 @@ export class RihaNavbarComponent implements OnInit {
* in version 4.1.3 it seems to be broken when working with queryParams,
* even with applied [routerLinkActiveOptions]="{exact: false}
*/
isListOrSubView(){
let cat = encodeURI('/Infosüsteemid?');
let obj = encodeURI('/Andmeobjektid');
let sub = encodeURI('/Infosüsteemid/Vaata');
let full = encodeURI('/Infosüsteemid');
if (this.router.url && typeof this.router.url === 'string'){
isListOrSubView() {
const cat = encodeURI('/Infosüsteemid?');
const obj = encodeURI('/Andmeobjektid');
const sub = encodeURI('/Infosüsteemid/Vaata');
const full = encodeURI('/Infosüsteemid');
if (this.router.url && typeof this.router.url === 'string') {
return (-1 != this.router.url.indexOf(cat) || -1 != this.router.url.indexOf(obj) || -1 != this.router.url.indexOf(sub) || this.router.url === full);
} else {
return false;
}
}
logout(){
logout() {
this.environmentService.doLogout().subscribe(res => {
this.environmentService.loadEnvironmentData().subscribe(env => {
this.sessionHelperService.refreshSessionTimer();
......@@ -59,28 +60,28 @@ export class RihaNavbarComponent implements OnInit {
return false;
}
openNoOrganizationWarningModal() :boolean {
openNoOrganizationWarningModal(): boolean {
const modalRef = this.modalService.open(NoOrganizationModalComponent);
return false;
}
isAllowedToChangeOrganization(): boolean {
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
return user.getOrganizations().length > 1 || (user.getOrganizations().length == 1 && user.getActiveOrganization() == null);
}
isNoOrganizationPresent(): boolean {
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
return user.getOrganizations().length == 0;
}
noOrganizationSelected(): boolean {
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
return user.getActiveOrganization() == null;
}
getUserText(): string {
let user = this.environmentService.getActiveUser();
const user = this.environmentService.getActiveUser();
return user.getFullNameWithActiveOrganization();
}
......@@ -102,6 +103,10 @@ export class RihaNavbarComponent implements OnInit {
ngOnInit() {
}
ngAfterContentChecked() {
this._dc = this.getRand();
}
openNavigationMenu() {
$('body').toggleClass('nav-open');
}
......
......@@ -11,6 +11,7 @@ import { InfoModalComponent } from '../info-modal/info-modal.component';
styleUrls: ['./warning-modal.component.scss']
})
export class WarningModalComponent implements OnInit, OnDestroy {
private static readonly ERROR_MESSAGE = 'Serveri viga.';
@Input() timerStart;
public minutesLeft: number;
......@@ -22,7 +23,7 @@ export class WarningModalComponent implements OnInit, OnDestroy {
startCountdown(){
this.timerId = setTimeout(() =>{
let ml = this.getMilisecondsLeft();
const ml = this.getMilisecondsLeft();
if (ml > 0) {
this.minutesLeft = Math.floor((this.getMilisecondsLeft()/1000)/60);