Skip to content

Commit

Permalink
Merge branch 'master' into feature_project_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinKato committed Oct 23, 2023
2 parents f9d20d8 + 6a90558 commit f733e63
Show file tree
Hide file tree
Showing 53 changed files with 1,876 additions and 224 deletions.
15 changes: 14 additions & 1 deletion back/config/schemas/settings.schema.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,18 @@
}
},

"power_bi": {
"type": "object",
"title": "Power BI",
"description": "Allows downloading of pre-configured templates for PowerBI.",
"additionalProperties": false,
"required": ["allowed", "enabled"],
"properties": {
"allowed": { "type": "boolean", "default": false },
"enabled": { "type": "boolean", "default": false }
}
},

"import_printed_forms": {
"type": "object",
"title": "Import printed forms",
Expand Down Expand Up @@ -1321,7 +1333,8 @@
"id_oostende_rrn": ["verification"],
"id_id_card_lookup": ["verification"],

"permission_option_email_confirmation": ["user_confirmation"]
"permission_option_email_confirmation": ["user_confirmation"],
"power_bi": ["public_api_tokens"]
},
"definitions": {
"multiloc_string": {
Expand Down
4 changes: 4 additions & 0 deletions back/engines/commercial/multi_tenancy/db/seeds/tenants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ def create_localhost_tenant
enabled: true,
allowed: true
},
power_bi: {
enabled: true,
allowed: true
},
import_printed_forms: {
enabled: true,
allowed: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module PublicApi
class WebApi::V1::PowerBiTemplatesController < ApplicationController
# Download a template - files behind a controller to give permission only to admins
def show
authorize :'public_api/power_bi_template'

case params[:id]
when 'dataflow'
template = Rails.root.join('engines/commercial/public_api/files/power_bi/dataflow.json')
# Search and replace API base URL
file_text = open(template).read
host = AppConfiguration.instance.base_backend_uri
replaced = file_text.gsub(/##BASE_URL##/, "#{host}/api/v2/")
send_data replaced, type: 'application/octet-stream'
when 'report'
template = Rails.root.join('engines/commercial/public_api/files/power_bi/report.pbit')
send_data open(template).read, type: 'application/octet-stream'
else
render json: { error: 'Not found' }, status: :not_found
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module PublicApi
class PowerBiTemplatePolicy < ApplicationPolicy
def show?
active? && admin?
end
end
end
1 change: 1 addition & 0 deletions back/engines/commercial/public_api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
namespace :web_api, defaults: { format: :json } do
namespace :v1 do
resources :api_clients, except: [:update]
resources :power_bi_templates, only: [:show]
end
end
end
879 changes: 879 additions & 0 deletions back/engines/commercial/public_api/files/power_bi/dataflow.json

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

require 'rails_helper'
require 'rspec_api_documentation/dsl'

resource 'Power BI templates' do
explanation 'Download the two power BI templates - admin only'

before { header 'Content-Type', 'application/json' }

get 'web_api/v1/power_bi_templates/:id' do
context 'as an admin' do
before { admin_header_token }

context 'dataflow' do
let(:id) { 'dataflow' }

example_request 'Dataflow template' do
assert_status 200
end
end

context 'report' do
let(:id) { 'report' }

example_request 'Reporting template' do
assert_status 200
end
end

context 'anything else' do
let(:id) { 'anything' }

example_request 'Not found' do
assert_status 404
end
end
end

context 'unauthenticated' do
let(:id) { 'dataflow.json' }

context 'as a normal user' do
before { header_token_for create(:user) }

example_request 'Unauthorised dataflow template' do
assert_status 401
end
end

context 'as a public user' do
example_request 'Unauthorised dataflow template' do
assert_status 401
end
end
end
end
end
2 changes: 1 addition & 1 deletion back/engines/free/email_campaigns/config/locales/de-DE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ de:
no_projects: 'Noch keine Projekte erhalten'
preheader: 'Ein Admin der Beteiligungsplattform %{organizationName} hat Sie soeben zu einer:einem Manager:in des folgenden Projektordners ernannt'
subject: 'Sie wurden zu einer:einem Ordnermanager:in auf der Plattform von %{organizationName} ernannt'
text_manage_folder: 'Mit einem Ordner können Sie mehrere Beteiligungsprojekte zusammen organisieren. Als Ordner-Manager*in können Sie den Ordner und die Ordnerbeschreibung bearbeiten und neue Projekte erstellen (um Projekte zu löschen, müssen Sie Ihren Plattform-Admin kontaktieren). Sie werden außerdem Projektmanagementrechte für alle Projekte innerhalb des Ordners erhalten. So können Sie die Projekte bearbeiten, die Eingaben verwalten und E-Mails an Teilnehmende senden.'
text_manage_folder: 'Mit einem Ordner können Sie mehrere Beteiligungsprojekte zusammen organisieren. Als Ordner-Manager*in können Sie den Ordner und die Ordnerbeschreibung bearbeiten und neue Projekte erstellen (um Projekte zu löschen, müssen Sie Ihren Plattform-Admin kontaktieren). Sie werden außerdem Projektmanagementrechte für alle Projekte innerhalb des Ordners erhalten. So können Sie die Projekte bearbeiten, die Beiträge verwalten und E-Mails an Teilnehmende senden.'
text_moderate_analyse_input: 'Sobald die Projekte gestartet wurden, werden die ersten Beiträge eingehen. Sie werden wöchentliche Berichte mit den wichtigsten Aktivitäten erhalten, damit Sie den Überblick behalten können. Mit dem Beitragsmanager in Ihrer Admin-Ansicht können Sie sich die Beiträge ansehen und sie verwalten (z. B. können Sie einen Status zuweisen und auf Beiträge und Kommentare antworten).'
text_design_participatory_process: 'Sie können die verschiedenen Beteiligungsprojekte in Ihrem Ordner verwalten – konfigurieren Sie die Teilnahmemethode, fügen Sie eine Projektbeschreibung hinzu, hängen Sie Bilder an und informieren Sie über relevante Ereignisse. Sie können auch festlegen, wie Teilnehmende bei Ihren Projekten mitwirken können. Zum Beispiel können Sie die Zugriffsrechte festlegen und die Beitrags-, Abstimmungs- und Kommentareinstellungen konfigurieren.'
title_design_participatory_process: 'Gestalten Sie den partizipativen Prozess'
Expand Down
4 changes: 2 additions & 2 deletions back/engines/free/email_campaigns/config/locales/nl-BE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ nl-BE:
content_type:
comments: 'Reacties'
content_moderation: 'Inhoudelijke moderatie'
events: 'Evenementen'
events: 'Activiteiten'
general: 'Algemeen'
inputs: 'Bijdragen'
internal_comments: 'Interne reacties'
Expand Down Expand Up @@ -638,4 +638,4 @@ nl-BE:
voting_basket_submitted: 'Stemmen zijn verzonden'
7_days_after_invite_is_sent: '7 dagen na verzending van de uitnodiging'
7_days_before_the_project_changes_phase: '7 dagen voor het project van fase verandert'
registration_to_event: 'Registratie voor een evenement'
registration_to_event: 'Registratie voor een activiteit'
10 changes: 5 additions & 5 deletions back/engines/free/email_campaigns/config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,13 @@ pt:
body_3: 'Recomendamos que você analise os resultados e fique atento para mais atualizações sobre as próximas etapas.'
cta_see_results: 'Veja os resultados na plataforma'
event_registration_confirmation:
subject: "Está inscrito! A sua inscrição em \"%{eventTitle}\" está confirmada"
header_message: "%{firstName}obrigado por se registar em"
subject: "Você está dentro! Sua inscrição para \"%{eventTitle}\" está confirmada"
header_message: "%{firstName}, obrigado por registrar-se para"
event_details:
labels:
date: 'Data'
location: 'Localização'
online_link: 'Ligação em linha'
online_link: 'Link on-line'
description: 'Descrição'
project: 'Projeto'
cta_go_to_event: 'Ver o evento'
Expand All @@ -561,7 +561,7 @@ pt:
managers: 'Gestores'
admins_assigned_to_a_proposal: 'Administradores atribuídos a uma proposta'
admins_and_managers_assigned_to_the_input: 'Administradores e gestores atribuídos à entrada'
new_attendee: 'Utilizador recentemente registado'
new_attendee: 'Usuário recém-registrado'
user_who_is_invited_to_cosponsor_a_proposal: 'Utilizador que é convidado a co-patrocinar uma proposta'
user_who_is_receiving_admin_rights: 'Usuário que está recebendo direitos de administrador'
user_who_is_receiving_folder_moderator_rights: 'Usuário que está recebendo direitos de moderador de pasta'
Expand Down Expand Up @@ -638,4 +638,4 @@ pt:
voting_basket_submitted: 'Os votos são enviados'
7_days_after_invite_is_sent: '7 dias após o envio do convite'
7_days_before_the_project_changes_phase: '7 dias antes da fase de mudanças do projeto'
registration_to_event: 'Inscrição num evento'
registration_to_event: 'Inscrição em um evento'
9 changes: 6 additions & 3 deletions front/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@
## Setup

1. `git clone` the repository
2. Run `npm install` in the root of the repository
2. Run `npm run install:all` in the root of the repository

## Running

If you have [citizenlab/back][cl2back] running on the same machine, with the default port (4000):

```
npm start
npm run start:front
```

If [citizenlab/back][cl2back] runs on a different machine / port:

```
API_HOST=XXX API_PORT=YYY npm start
API_HOST=XXX API_PORT=YYY npm run start:front
```

(replace `XXX` with the hostname or ip and `YYY` with the port of your instance of cl2-back)

Please note that `npm run start:front` only watches changes made to the front folder. To run and watch changes made in both
the front folder and the component library, please run `npm run start:cl-linked`

## E2E tests

The E2E tests are run whenever a change to the Master branch occurs. You can view the results on CircleCI.
Expand Down
1 change: 1 addition & 0 deletions front/app/api/app_configuration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export interface IAppConfigurationSettings {
follow?: AppConfigurationFeature;
konveio_document_annotation?: AppConfigurationFeature;
public_api_tokens?: AppConfigurationFeature;
power_bi?: AppConfigurationFeature;
analysis?: AppConfigurationFeature;
import_printed_forms?: AppConfigurationFeature;
}
Expand Down
15 changes: 14 additions & 1 deletion front/app/components/UI/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import React, { PureComponent } from 'react';
import styled, { css } from 'styled-components';
import { colors } from 'utils/styleUtils';

const Fallback = styled.div<{ src: string | undefined }>`
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-image: url(${({ src }) => src});
`;

const ImageElement = styled.img<{
cover: boolean;
fadeIn: boolean;
Expand Down Expand Up @@ -80,7 +87,7 @@ export default class Image extends PureComponent<Props, State> {
const { isLazy } = this.props;
const { loaded } = this.state;

return (
let image = (
<ImageElement
src={src}
alt={alt}
Expand All @@ -96,5 +103,11 @@ export default class Image extends PureComponent<Props, State> {
loading={isLazy ? 'lazy' : 'eager'}
/>
);

if (cover) {
image = <Fallback src={src} className={className} />;
}

return image;
}
}
105 changes: 105 additions & 0 deletions front/app/containers/Admin/tools/PowerBI/PowerBITemplates/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React from 'react';

// components
import {
Box,
Button,
colors,
Text,
Title,
} from '@citizenlab/cl2-component-library';
import GoBackButton from 'components/UI/GoBackButton';

// intl
import { FormattedMessage, useIntl } from 'utils/cl-intl';
import messages from './messages';

// hooks
import useFeatureFlag from 'hooks/useFeatureFlag';

// utils
import { isNilOrError } from 'utils/helperUtils';
import clHistory from 'utils/cl-router/history';
import Link from 'utils/cl-router/Link';

import { saveTemplateFile } from './saveTemplateFile';

const PowerBITemplates = () => {
const isPowerBIEnabled = useFeatureFlag({ name: 'power_bi' });
const { formatMessage } = useIntl();

const handleDownloadTemplate = async (fileName, fileExtension) => {
if (isNilOrError(fileName)) return;
await saveTemplateFile({ fileName, fileExtension });
};

const downloadReportingTemplate = () => {
handleDownloadTemplate('report', 'pbit');
};

const downloadDataFlowTemplate = () => {
handleDownloadTemplate('dataflow', 'json');
};

if (!isPowerBIEnabled) return null;

return (
<>
<Box w="100%">
<GoBackButton onClick={clHistory.goBack} />
</Box>

<Title variant="h1" mb="0">
{formatMessage(messages.title)}
</Title>
<Text>
<FormattedMessage
{...messages.intro}
values={{
link: (
<Link to="/admin/tools/public-api-tokens">
{formatMessage(messages.publicApiLinkText)}
</Link>
),
}}
/>
</Text>
<Box background="white" px="20px" pb="10px" mb="20px">
<Title variant="h2" mb="0">
{formatMessage(messages.reportTemplateTitle)}
</Title>
<Box display="flex">
<Text mr="20px">
{formatMessage(messages.reportTemplateDescription)}
</Text>
<Button
icon="download"
color={colors.primary}
onClick={downloadReportingTemplate}
>
{formatMessage(messages.reportTemplateDownload)} (.pbit)
</Button>
</Box>
</Box>
<Box background="white" px="20px" pb="10px" mb="20px">
<Title variant="h2" mb="0">
{formatMessage(messages.dataflowTemplateTitle)}
</Title>
<Box display="flex">
<Text mr="20px">
{formatMessage(messages.dataflowTemplateDescription)}
</Text>
<Button
icon="download"
color={colors.primary}
onClick={downloadDataFlowTemplate}
>
{formatMessage(messages.dataflowTemplateDownload)} (.json)
</Button>
</Box>
</Box>
</>
);
};

export default PowerBITemplates;
Loading

0 comments on commit f733e63

Please sign in to comment.