Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 3169ae5

Browse files
authored
Merge pull request #10 from pmandrik/dropdown_fix
Fix dropdown bug & JSON REDIS
2 parents b1db86e + fec938f commit 3169ae5

File tree

11 files changed

+151
-100
lines changed

11 files changed

+151
-100
lines changed

readme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ If there is a human error, for example if a user sometimes batch-updates runs an
7575
sudo chmod -R 777 /srv/
7676
forever stopall
7777
rm -rf node
78-
sudo wget https://nodejs.org/dist/v12.17.0/node-v12.17.0-linux-x64.tar.xz
79-
sudo tar -xf node-v12.17.0-linux-x64.tar.xz
80-
sudo mv node-v12.17.0-linux-x64 node
81-
sudo rm node-v12.17.0-linux-x64.tar.xz
78+
sudo wget https://nodejs.org/dist/v12.20.0/node-v12.20.0-linux-x64.tar.xz
79+
sudo tar -xf node-v12.20.0-linux-x64.tar.xz
80+
sudo mv node-v12.20.0-linux-x64 node
81+
sudo rm node-v12.20.0-linux-x64.tar.xz
8282
sudo chmod -R 777 /srv/
8383
cd node && export HOME=$PWD
8484
cd ..
@@ -121,10 +121,10 @@ Logs can be found by running a command: `forever logs`
121121
sudo chmod -R 777 /srv/
122122
forever stopall
123123
rm -rf node
124-
sudo wget https://nodejs.org/dist/v12.17.0/node-v12.17.0-linux-x64.tar.xz
125-
sudo tar -xf node-v12.17.0-linux-x64.tar.xz
126-
sudo mv node-v12.17.0-linux-x64 node
127-
sudo rm node-v12.17.0-linux-x64.tar.xz
124+
sudo wget https://nodejs.org/dist/v12.20.0/node-v12.20.0-linux-x64.tar.xz
125+
sudo tar -xf node-v12.20.0-linux-x64.tar.xz
126+
sudo mv node-v12.20.0-linux-x64 node
127+
sudo rm node-v12.20.0-linux-x64.tar.xz
128128
sudo chmod -R 777 /srv/
129129
cd node && export HOME=$PWD
130130
cd ..

readme_faq.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,21 @@ docker push registry.cern.ch/cmsweb/runregistry-frontend:0.2-cmsweb
4848
There is also tow images we were not able to pull from docker.com:
4949
cmssw/runregistry-workers-oms-fetching
5050
cmssw/runregistry-workers-json-processing
51+
52+
#### Redis server
53+
REDIS server is used by BULL JS package to store configs used to generate JSONs in a queue
54+
```
55+
sudo yum install redis
56+
sudo nano /etc/redis.conf
57+
supervised no -> supervised systemd
58+
sudo systemctl restart redis.service
59+
```
60+
Check:
61+
```
62+
redis-cli
63+
ping
64+
```
65+
Set REDIS_URL to local redis server `redis://127.0.0.1:6379`
66+
67+
68+

runregistry_backend/config/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = {
9696
OMS_URL: `https://cmsoms.cern.ch/agg/api/v1`,
9797
AUTH_SERVICE_URL:
9898
'https://auth.cern.ch/auth/realms/cern/protocol/openid-connect/token',
99-
REDIS_URL: `redis://dev-rr-redis.runregistry.svc.cluster.local`,
99+
REDIS_URL: `redis://127.0.0.1:6379`, // `redis://dev-rr-redis.runregistry.svc.cluster.local`,
100100
OMS_RUNS: (number_of_runs = 10) =>
101101
`runs?sort=-last_update&page[limit]=${number_of_runs}`,
102102
OMS_SPECIFIC_RUN: (run_number) => `runs?filter[run_number]=${run_number}`,
@@ -136,7 +136,7 @@ module.exports = {
136136
OMS_URL: `https://cmsoms.cern.ch/agg/api/v1`,
137137
AUTH_SERVICE_URL:
138138
'https://auth.cern.ch/auth/realms/cern/protocol/openid-connect/token',
139-
REDIS_URL: `redis://cmsweb-test4-yvri27sszw3m-node-2:31505`,
139+
REDIS_URL: `redis://127.0.0.1:6379`, // redis://cmsweb-test4-yvri27sszw3m-node-2:31505`,
140140
OMS_RUNS: (number_of_runs = 10) =>
141141
`runs?sort=-last_update&page[limit]=${number_of_runs}`,
142142
OMS_SPECIFIC_RUN: (run_number) => `runs?filter[run_number]=${run_number}`,

runregistry_backend/controllers/run.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const {
1616
const { update_or_create_dataset } = require('./dataset');
1717
const { create_new_version } = require('./version');
1818
const { fill_dataset_triplet_cache } = require('./dataset_triplet_cache');
19-
const { manually_update_a_run } = require('../cron/2.save_or_update_runs');
19+
const { manually_update_a_run , manually_update_a_run_reset_rr_attributes } = require('../cron/2.save_or_update_runs');
2020
const {
2121
create_offline_waiting_datasets,
2222
} = require('../cron_datasets/1.create_datasets');
@@ -578,6 +578,32 @@ exports.refreshRunClassAndComponents = async (req, res) => {
578578
res.json(saved_run);
579579
};
580580

581+
exports.resetAndRefreshRunRRatributes = async (req, res) => {
582+
const { run_number } = req.params;
583+
const email = req.get('email');
584+
const previously_saved_run = await Run.findByPk(run_number);
585+
if (previously_saved_run === null) {
586+
throw 'Run not found';
587+
}
588+
if (previously_saved_run.rr_attributes.state !== 'OPEN') {
589+
throw 'Run must be in state OPEN to be refreshed';
590+
}
591+
592+
await manually_update_a_run_reset_rr_attributes(run_number, {
593+
email,
594+
comment: `${email} requested reset and refresh from OMS`,
595+
});
596+
const saved_run = await Run.findByPk(run_number, {
597+
include: [
598+
{
599+
model: DatasetTripletCache,
600+
attributes: ['triplet_summary'],
601+
},
602+
],
603+
});
604+
res.json(saved_run);
605+
};
606+
581607
exports.moveRun = async (req, res) => {
582608
const { to_state } = req.params;
583609
const { run_number } = req.body;

runregistry_backend/cron/2.save_or_update_runs.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,34 @@ exports.manually_update_a_run = async (
270270
});
271271
};
272272

273+
exports.manually_update_a_run_reset_rr_attributes = async (
274+
run_number,
275+
{ email, comment, manually_significant, atomic_version }
276+
) => {
277+
// get rr_attributes:
278+
const { data: saved_run } = await axios.get(`${API_URL}/runs/${run_number}`);
279+
const previous_rr_attributes = saved_run.rr_attributes;
280+
if (previous_rr_attributes.state !== 'OPEN') {
281+
throw 'Run must be in state OPEN to be refreshed';
282+
}
273283

274-
284+
// get oms_attributes:
285+
const endpoint = `${OMS_URL}/${OMS_SPECIFIC_RUN(run_number)}`;
286+
const {
287+
data: { data: fetched_run },
288+
} = await instance.get(endpoint, {
289+
headers: {
290+
Authorization: `Bearer ${await getToken()}`,
291+
},
292+
});
293+
const empty_var = false;
294+
const run_oms_attributes = fetched_run[0].attributes;
295+
await exports.update_runs([run_oms_attributes], 0, {
296+
empty_var,
297+
email,
298+
comment,
299+
manually_significant,
300+
atomic_version,
301+
});
302+
};
275303

runregistry_backend/models/permission.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// About sequelize.define
2+
// https://sequelize.org/v3/docs/models-definition/
3+
// To define mappings between a model and a table, use the define method. Sequelize will then automatically add the attributes createdAt and updatedAt to it.
14
module.exports = (sequelize, DataTypes) => {
25
const Permission = sequelize.define(
36
'Permission',
@@ -12,7 +15,7 @@ module.exports = (sequelize, DataTypes) => {
1215
allowNull: false
1316
},
1417
routes: {
15-
type: DataTypes.JSONB,
18+
type: DataTypes.JSONB, // JSONB - JSON input text in a decomposed binary form
1619
allowNull: false
1720
}
1821
},
@@ -22,11 +25,7 @@ module.exports = (sequelize, DataTypes) => {
2225
);
2326

2427
Permission.associate = function(models) {
25-
Permission.belongsToMany(models.PermissionList, {
26-
through: models.PermissionEntries,
27-
foreignKey: 'id',
28-
otherKey: 'PL_id'
29-
});
28+
Permission.belongsToMany(models.PermissionList, { through: models.PermissionEntries, foreignKey: 'id', otherKey: 'PL_id' });
3029
};
3130
return Permission;
3231
};

runregistry_backend/routes/run.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ module.exports = app => {
2525
// Shifter actions:
2626
app.post('/runs/mark_significant', auth, catchAPI(Run.markSignificant));
2727
app.post('/runs/move_run/:from_state/:to_state', auth, catchAPI(Run.moveRun));
28-
app.post(
29-
'/runs/refresh_run/:run_number',
30-
catchAPI(Run.refreshRunClassAndComponents)
31-
);
28+
app.post('/runs/refresh_run/:run_number', catchAPI(Run.refreshRunClassAndComponents));
29+
app.post('/runs/reset_and_refresh_run/:run_number', catchAPI(Run.resetAndRefreshRunRRatributes));
3230
};

runregistry_frontend/components/json_portal/configuration/json_configuration/JSONConfiguration.js

Lines changed: 20 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React, { Component } from 'react';
22
import dynamic from 'next/dynamic';
33
import { connect } from 'react-redux';
4-
import { AutoComplete, Menu, Button, Input } from 'antd';
4+
import { AutoComplete, Menu, Button, Input, Dropdown } from 'antd';
55
import {
66
PlusCircleOutlined,
77
CloseCircleOutlined,
88
EditOutlined,
99
DeleteOutlined,
10+
DownOutlined,
1011
} from '@ant-design/icons';
1112
import Swal from 'sweetalert2';
1213
import {
@@ -288,65 +289,25 @@ class Configuration extends Component {
288289
borderRadius: '2px',
289290
}}
290291
>
291-
<div
292-
style={{
293-
width: '10%',
294-
display: 'flex',
295-
alignItems: 'center',
296-
marginLeft: '5px',
297-
height: '48px',
298-
}}
299-
>
300-
<strong>configurations created by me:</strong>
301-
</div>
302-
<div style={{ width: '88%' }}>
303-
<Menu
304-
onClick={({ key }) => this.handleMenuChange(key)}
305-
selectedKeys={[menu_selection]}
306-
mode="horizontal"
307-
>
308-
{json_configurations_array
309-
.filter(
310-
({ created_by }) => created_by === this.props.email
311-
)
312-
.map(({ name }) => (
313-
<Menu.Item key={name}>{name}</Menu.Item>
314-
))}
315-
</Menu>
316-
</div>
317-
</div>
318-
<br />
319-
<div
320-
style={{
321-
display: 'flex',
322-
border: '1px solid #d9d9d9',
323-
borderRadius: '2px',
324-
}}
325-
>
326-
<div
327-
style={{
328-
width: '10%',
329-
display: 'flex',
330-
alignItems: 'center',
331-
marginLeft: '5px',
332-
}}
333-
>
334-
<strong>all configurations:</strong>
335-
</div>
336-
<div style={{ width: '88%' }}>
337-
<Menu
338-
onClick={({ key }) => this.handleMenuChange(key)}
339-
selectedKeys={[menu_selection]}
340-
mode="horizontal"
341-
>
342-
<Menu.Item key="arbitrary">
343-
arbitrary configuration
344-
</Menu.Item>
345-
{json_configurations_array.map(({ name }) => (
346-
<Menu.Item key={name}>{name}</Menu.Item>
347-
))}
292+
//<Menu onClick={({ key }) => this.handleMenuChange(key)} selectedKeys={[menu_selection]} mode="horizontal">
293+
// {json_configurations_array.filter( ({ created_by }) => created_by === this.props.email).map(({ name }) => ( <Menu.Item key={name}>{name}</Menu.Item> ))}
294+
//</Menu>
295+
296+
<Menu onClick={({ key }) => this.handleMenuChange(key)} selectedKeys={[menu_selection]} mode="horizontal">
297+
<Menu.Item key="arbitrary"> New Configuration </Menu.Item>
348298
</Menu>
349-
</div>
299+
300+
<Dropdown overlay={ <Menu style={{ overflowY: 'scroll', maxHeight: '300px' }} onClick={({ key }) => this.handleMenuChange(key)} selectedKeys={[menu_selection]}>
301+
{json_configurations_array.filter( ({ created_by }) => created_by === this.props.email).map(({ name }) => ( <Menu.Item key={name}>{name}</Menu.Item> ))}
302+
</Menu> } destroyPopupOnHide={true}>
303+
<a style={{ marginTop: '12px' }} className="ant-dropdown-link" onClick={e => e.preventDefault()}> My Configurations <DownOutlined /> </a>
304+
</Dropdown>
305+
306+
<Dropdown overlay={ <Menu style={{ overflowY: 'scroll', maxHeight: '300px' }} onClick={({ key }) => this.handleMenuChange(key)} selectedKeys={[menu_selection]}>
307+
{json_configurations_array.map(({ name }) => ( <Menu.Item key={name}>{name}</Menu.Item>))}
308+
</Menu> } destroyPopupOnHide={true}>
309+
<a style={{ marginTop: '12px' }} className="ant-dropdown-link" onClick={e => e.preventDefault()}> All Configurations <DownOutlined /> </a>
310+
</Dropdown>
350311
</div>
351312
</center>
352313
)}

runregistry_frontend/components/online/manage_run/manageRun/editRunLumisections/EditRunLumisections.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import axios from 'axios';
66

77
import EditComponent from '../../../../../components/common/editComponent/EditComponent';
88
import { api_url } from '../../../../../config/config';
9-
import { refreshRun } from '../../../../../ducks/online/runs';
9+
import { refreshRun, resetAndRefreshRun } from '../../../../../ducks/online/runs';
1010
import { showManageRunModal } from '../../../../../ducks/online/ui';
1111
import { addLumisectionRange } from '../../../../../ducks/online/lumisections';
1212
import { certifiable_online_components } from '../../../../../config/config';
@@ -71,9 +71,7 @@ class EditRunLumisections extends Component {
7171
reverseButtons: true,
7272
});
7373
if (value) {
74-
const updated_run = await this.props.refreshRun(
75-
run.run_number
76-
);
74+
const updated_run = await this.props.refreshRun( run.run_number );
7775
await Swal(`Run updated`, '', 'success');
7876
await this.props.showManageRunModal(updated_run);
7977
this.fetchLumisections();
@@ -83,6 +81,28 @@ class EditRunLumisections extends Component {
8381
>
8482
Manually refresh component's statuses
8583
</Button>
84+
&nbsp;
85+
<Button
86+
onClick={async (evt) => {
87+
const { value } = await Swal({
88+
type: 'warning',
89+
title: `If a status was previously edited by a shifter, it will not be updated, it will only change those untouched.`,
90+
text: '',
91+
showCancelButton: true,
92+
confirmButtonText: 'Yes',
93+
reverseButtons: true,
94+
});
95+
if (value) {
96+
const updated_run = await this.props.resetAndRefreshRun( run.run_number );
97+
await Swal(`Run updated`, '', 'success');
98+
await this.props.showManageRunModal(updated_run);
99+
this.fetchLumisections();
100+
}
101+
}}
102+
type="primary"
103+
>
104+
Reset RR attributes and refresh
105+
</Button>
86106
</div>
87107
<br />
88108

@@ -213,6 +233,7 @@ const mapStateToProps = (state) => {
213233

214234
export default connect(mapStateToProps, {
215235
refreshRun,
236+
resetAndRefreshRun,
216237
showManageRunModal,
217238
addLumisectionRange,
218239
})(EditRunLumisections);

runregistry_frontend/components/ui/breadcrumb/Breadcrumb.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,10 @@ class BreadcrumbCmp extends Component {
107107
</div>
108108
<div className="progresscircle_container">
109109
<div>
110-
<a
111-
className="jira"
112-
target="_blank"
113-
href="https://its.cern.ch/jira/projects/NEWRUNREGISTRY/issues/"
114-
>
115-
Feedback is welcome! (JIRA)
116-
</a>
110+
<a className="jira" target="_blank" href="https://its.cern.ch/jira/projects/NEWRUNREGISTRY/issues/"> Feedback is welcome! (JIRA) </a>
117111
</div>
118-
<Dropdown overlay={online ? this.online_menu : this.offline_menu}>
119-
<Button
120-
style={{ marginTop: '-6px' }}
121-
onClick={(e) => e.preventDefault()}
122-
>
123-
Configuration
124-
<DownOutlined />
125-
</Button>
112+
<Dropdown overlay={online ? this.online_menu : this.offline_menu} destroyPopupOnHide={true}>
113+
<Button style={{ marginTop: '-6px' }} onClick={(e) => e.preventDefault()} > Configuration <DownOutlined /> </Button>
126114
</Dropdown>
127115
</div>
128116

0 commit comments

Comments
 (0)