Skip to content

Commit

Permalink
Merge branch 'using-react' into work/using-react-with-bootstrap4
Browse files Browse the repository at this point in the history
  • Loading branch information
steinarb committed Mar 26, 2024
2 parents 06b2f99 + a3f6a9f commit 9c3b7ce
Show file tree
Hide file tree
Showing 44 changed files with 229 additions and 244 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>no.priv.bang.pom</groupId>
<artifactId>bang-authservice-client-pom</artifactId>
<version>1.1.48</version>
<version>1.1.49</version>
</parent>
<groupId>no.priv.bang.ukelonn</groupId>
<artifactId>ukelonn</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import java.util.stream.Stream;

import org.apache.shiro.authc.SimpleAccount;
import org.apache.shiro.config.Ini;
import org.apache.shiro.mgt.RealmSecurityManager;
import org.apache.shiro.realm.SimpleAccountRealm;
import org.apache.shiro.web.config.WebIniSecurityManagerFactory;
import org.apache.shiro.web.env.IniWebEnvironment;
import org.apache.shiro.web.mgt.WebSecurityManager;
import no.priv.bang.ukelonn.beans.Account;
import no.priv.bang.ukelonn.beans.Transaction;
Expand Down Expand Up @@ -122,8 +121,10 @@ public class TestUtils {

public static WebSecurityManager getSecurityManager() {
if (securitymanager == null) {
var securityManagerFactory = new WebIniSecurityManagerFactory(Ini.fromResourcePath("classpath:test.shiro.ini"));
securitymanager = (WebSecurityManager) securityManagerFactory.getInstance();
var env = new IniWebEnvironment();
env.setConfigLocations("classpath:test.shiro.ini");
env.init();
securitymanager = env.getWebSecurityManager();
realm = findRealmFromSecurityManager(securitymanager);
}

Expand Down
17 changes: 8 additions & 9 deletions ukelonn.web.frontend/src/main/frontend/sagas/accountSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import {
import { emptyAccount } from '../constants';
import { findUsername } from '../common/login';


function doAccount(username) {
return axios.get('/api/account/' + username );
export default function* accountSaga() {
yield takeLatest(SELECT_ACCOUNT, fetchDataForSelectedAccount);
yield takeLatest(ACCOUNT_REQUEST, requestReceiveAccountSaga);
yield takeLatest(RECEIVED_NOTIFICATION, updateAccountOnNotification);
}

function* requestReceiveAccountSaga(action) {
Expand All @@ -34,6 +35,10 @@ function* requestReceiveAccountSaga(action) {
}
}

function doAccount(username) {
return axios.get('/api/account/' + username );
}

function* fetchDataForSelectedAccount(action) {
const { accountId, username } = action.payload;
if (accountId !== -1) {
Expand All @@ -52,9 +57,3 @@ function* updateAccountOnNotification() {
const username = yield select(findUsername);
yield put(ACCOUNT_REQUEST(username));
}

export default function* accountSaga() {
yield takeLatest(SELECT_ACCOUNT, fetchDataForSelectedAccount);
yield takeLatest(ACCOUNT_REQUEST, requestReceiveAccountSaga);
yield takeLatest(RECEIVED_NOTIFICATION, updateAccountOnNotification);
}
8 changes: 4 additions & 4 deletions ukelonn.web.frontend/src/main/frontend/sagas/accountsSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
ACCOUNTS_FAILURE,
} from '../actiontypes';

function doAccounts() {
return axios.get('/api/accounts');
export default function* accountsSaga() {
yield takeLatest(ACCOUNTS_REQUEST, requestReceiveAccountsSaga);
}

function* requestReceiveAccountsSaga() {
Expand All @@ -20,6 +20,6 @@ function* requestReceiveAccountsSaga() {
}
}

export default function* accountsSaga() {
yield takeLatest(ACCOUNTS_REQUEST, requestReceiveAccountsSaga);
function doAccounts() {
return axios.get('/api/accounts');
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export function* requestActivebonusesSaga() {
yield takeLatest(GET_ACTIVE_BONUSES, receiveActivebonusesSaga);
}

function doActivebonuses() {
return axios.get('/api/activebonuses');
}

// worker saga
function* receiveActivebonusesSaga() {
try {
Expand All @@ -25,3 +21,7 @@ function* receiveActivebonusesSaga() {
yield put(RECEIVE_ACTIVE_BONUSES_FAILURE(error));
}
}

function doActivebonuses() {
return axios.get('/api/activebonuses');
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
RECEIVE_ADMIN_STATUS_ERROR,
} from '../actiontypes';

export default function* adminStatusSaga() {
yield takeLatest(REQUEST_ADMIN_STATUS, requestAdminStatus);
}

function* requestAdminStatus(action) {
try {
const response = yield call(fetchAdminStatus, action.payload);
Expand All @@ -19,7 +23,3 @@ function* requestAdminStatus(action) {
function fetchAdminStatus(user) {
return axios.post('/api/admin/user/adminstatus', user);
}

export default function* adminStatusSaga() {
yield takeLatest(REQUEST_ADMIN_STATUS, requestAdminStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export function* requestAllbonusesSaga() {
yield takeLatest(GET_ALL_BONUSES, receiveAllbonusesSaga);
}

function doAllbonuses() {
return axios.get('/api/allbonuses');
}

// worker saga
function* receiveAllbonusesSaga() {
try {
Expand All @@ -25,3 +21,7 @@ function* receiveAllbonusesSaga() {
yield put(RECEIVE_ALL_BONUSES_FAILURE(error));
}
}

function doAllbonuses() {
return axios.get('/api/allbonuses');
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default function* availableLocalesSaga() {
yield takeLatest(AVAILABLE_LOCALES_REQUEST, receiveAvailableLocalesSaga);
}

function doAvailableLocales() {
return axios.get('/api/availablelocales');
}

// worker saga
function* receiveAvailableLocalesSaga() {
try {
Expand All @@ -25,3 +21,7 @@ function* receiveAvailableLocalesSaga() {
yield put(AVAILABLE_LOCALES_ERROR(error));
}
}

function doAvailableLocales() {
return axios.get('/api/availablelocales');
}
20 changes: 10 additions & 10 deletions ukelonn.web.frontend/src/main/frontend/sagas/bonusSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import {
CLEAR_BONUS,
} from '../actiontypes';

export default function* bonusSaga() {
yield takeLatest(SELECT_BONUS, selectBonus);
yield takeLatest(SAVE_BONUS_CHANGES_BUTTON_CLICKED, saveModifiedBonus);
yield takeLatest(CREATE_NEW_BONUS_BUTTON_CLICKED, saveCreatedBonus);
yield takeLatest(DELETE_SELECTED_BONUS_BUTTON_CLICKED, deleteSelectedBonus);
yield takeLatest(MODIFY_BONUS_RECEIVE, clearBonusForm);
yield takeLatest(CREATE_BONUS_RECEIVE, clearBonusForm);
yield takeLatest(DELETE_BONUS_RECEIVE, clearBonusForm);
}

function* selectBonus(action) {
const bonusId = action.payload;
if (bonusId === -1) {
Expand Down Expand Up @@ -63,13 +73,3 @@ function* deleteSelectedBonus() {
function* clearBonusForm() {
yield put(CLEAR_BONUS());
}

export default function* bonusSaga() {
yield takeLatest(SELECT_BONUS, selectBonus);
yield takeLatest(SAVE_BONUS_CHANGES_BUTTON_CLICKED, saveModifiedBonus);
yield takeLatest(CREATE_NEW_BONUS_BUTTON_CLICKED, saveCreatedBonus);
yield takeLatest(DELETE_SELECTED_BONUS_BUTTON_CLICKED, deleteSelectedBonus);
yield takeLatest(MODIFY_BONUS_RECEIVE, clearBonusForm);
yield takeLatest(CREATE_BONUS_RECEIVE, clearBonusForm);
yield takeLatest(DELETE_BONUS_RECEIVE, clearBonusForm);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CHANGE_USER_PASSWORD_FAILURE,
} from '../actiontypes';

function doChangePassword(passwords) {
return axios.post('/api/admin/user/password', passwords);
export default function* changeUserPasswordSaga() {
yield takeLatest(CHANGE_USER_PASSWORD_REQUEST, requestReceiveChangePasswordSaga);
}

function* requestReceiveChangePasswordSaga(action) {
Expand All @@ -20,6 +20,6 @@ function* requestReceiveChangePasswordSaga(action) {
}
}

export default function* changeUserPasswordSaga() {
yield takeLatest(CHANGE_USER_PASSWORD_REQUEST, requestReceiveChangePasswordSaga);
function doChangePassword(passwords) {
return axios.post('/api/admin/user/password', passwords);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CHANGE_ADMIN_STATUS_ERROR,
} from '../actiontypes';

function fetchAdminStatus(user) {
return axios.post('/api/admin/user/changeadminstatus', user);
export default function* () {
yield takeLatest(CHANGE_ADMIN_STATUS, changeAdminStatus);
}

function* changeAdminStatus(action) {
Expand All @@ -21,6 +21,6 @@ function* changeAdminStatus(action) {
}
}

export default function* () {
yield takeLatest(CHANGE_ADMIN_STATUS, changeAdminStatus);
function fetchAdminStatus(user) {
return axios.post('/api/admin/user/changeadminstatus', user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CREATE_BONUS_FAILURE,
} from '../actiontypes';

function doCreateBonus(bonus) {
return axios.post('/api/admin/createbonus', bonus);
export default function* createBonusSaga() {
yield takeLatest(CREATE_BONUS_REQUEST, requestReceiveCreateBonusSaga);
}

function* requestReceiveCreateBonusSaga(action) {
Expand All @@ -20,6 +20,6 @@ function* requestReceiveCreateBonusSaga(action) {
}
}

export default function* createBonusSaga() {
yield takeLatest(CREATE_BONUS_REQUEST, requestReceiveCreateBonusSaga);
function doCreateBonus(bonus) {
return axios.post('/api/admin/createbonus', bonus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CREATE_JOBTYPE_FAILURE,
} from '../actiontypes';

function doCreateJobtype(jobtype) {
return axios.post('/api/admin/jobtype/create', jobtype);
export default function* createJobtypeSaga() {
yield takeLatest(CREATE_JOBTYPE_REQUEST, sendReceiveCreateJobtype);
}

function* sendReceiveCreateJobtype(action) {
Expand All @@ -20,6 +20,6 @@ function* sendReceiveCreateJobtype(action) {
}
}

export default function* createJobtypeSaga() {
yield takeLatest(CREATE_JOBTYPE_REQUEST, sendReceiveCreateJobtype);
function doCreateJobtype(jobtype) {
return axios.post('/api/admin/jobtype/create', jobtype);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CREATE_PAYMENTTYPE_FAILURE,
} from '../actiontypes';

function doCreatePaymenttype(paymenttype) {
return axios.post('/api/admin/paymenttype/create', paymenttype);
export default function* createPaymenttypeSaga() {
yield takeLatest(CREATE_PAYMENTTYPE_REQUEST, requestReceiveCreatePaymenttype);
}

function* requestReceiveCreatePaymenttype(action) {
Expand All @@ -20,6 +20,6 @@ function* requestReceiveCreatePaymenttype(action) {
}
}

export default function* createPaymenttypeSaga() {
yield takeLatest(CREATE_PAYMENTTYPE_REQUEST, requestReceiveCreatePaymenttype);
function doCreatePaymenttype(paymenttype) {
return axios.post('/api/admin/paymenttype/create', paymenttype);
}
10 changes: 5 additions & 5 deletions ukelonn.web.frontend/src/main/frontend/sagas/createUserSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
CREATE_USER_FAILURE,
} from '../actiontypes';

function doCreateUser(passwords) {
delete passwords.user.fullname;
return axios.post('/api/admin/user/create', passwords);
export default function* createUserSaga() {
yield takeLatest(CREATE_USER_REQUEST, requestReceiveCreateUserSaga);
}

function* requestReceiveCreateUserSaga(action) {
Expand All @@ -21,6 +20,7 @@ function* requestReceiveCreateUserSaga(action) {
}
}

export default function* createUserSaga() {
yield takeLatest(CREATE_USER_REQUEST, requestReceiveCreateUserSaga);
function doCreateUser(passwords) {
delete passwords.user.fullname;
return axios.post('/api/admin/user/create', passwords);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default function* defaultLocaleSaga() {
yield takeLatest(DEFAULT_LOCALE_REQUEST, receiveDefaultLocaleSaga);
}

function doDefaultLocale() {
return axios.get('/api/defaultlocale');
}

// worker saga
function* receiveDefaultLocaleSaga() {
try {
Expand All @@ -25,3 +21,7 @@ function* receiveDefaultLocaleSaga() {
yield put(DEFAULT_LOCALE_ERROR(error));
}
}

function doDefaultLocale() {
return axios.get('/api/defaultlocale');
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
DELETE_BONUS_FAILURE,
} from '../actiontypes';

function doDeleteBonus(bonus) {
return axios.post('/api/admin/deletebonus', bonus);
export default function* deleteBonusSaga() {
yield takeLatest(DELETE_BONUS_REQUEST, receiveDeleteBonusSaga);
}

function* receiveDeleteBonusSaga(action) {
Expand All @@ -20,6 +20,6 @@ function* receiveDeleteBonusSaga(action) {
}
}

export default function* deleteBonusSaga() {
yield takeLatest(DELETE_BONUS_REQUEST, receiveDeleteBonusSaga);
function doDeleteBonus(bonus) {
return axios.post('/api/admin/deletebonus', bonus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
DELETE_JOBS_FAILURE,
} from '../actiontypes';

function doDeleteJobs(accountWithJobIds) {
return axios.post('/api/admin/jobs/delete', accountWithJobIds);
export default function* deleteJobsSaga() {
yield takeLatest(DELETE_JOBS_REQUEST, requestReceiveDeleteJobsSaga);
}

function* requestReceiveDeleteJobsSaga(action) {
Expand All @@ -23,6 +23,6 @@ function* requestReceiveDeleteJobsSaga(action) {
}
}

export default function* deleteJobsSaga() {
yield takeLatest(DELETE_JOBS_REQUEST, requestReceiveDeleteJobsSaga);
function doDeleteJobs(accountWithJobIds) {
return axios.post('/api/admin/jobs/delete', accountWithJobIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export default function* displayTextsSaga() {
yield takeLatest(UPDATE_LOCALE, receiveDisplayTextsSaga);
}

function doDisplayTexts(locale) {
return axios.get('/api/displaytexts?' + stringify({ locale }));
}

// worker saga
function* receiveDisplayTextsSaga(action) {
try {
Expand All @@ -28,3 +24,7 @@ function* receiveDisplayTextsSaga(action) {
yield put(DISPLAY_TEXTS_ERROR(error));
}
}

function doDisplayTexts(locale) {
return axios.get('/api/displaytexts?' + stringify({ locale }));
}
Loading

0 comments on commit 9c3b7ce

Please sign in to comment.