Skip to content

Commit

Permalink
removed orgupdate related code + edited formatting
Browse files Browse the repository at this point in the history
removed orgupdate related code + edited formatting
  • Loading branch information
vangeliq committed Mar 10, 2022
1 parent 0d73b10 commit 701f2a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@RestController
public class OrganizationsController {

//todo: write the url, user and password somewhere else
@Value("${spring.datasource.url}")
private String url;
@Value("${spring.datasource.username}")
Expand All @@ -34,9 +33,6 @@ public class OrganizationsController {
@Autowired
private JdbcTemplate jdbcTemplate;

public OrganizationsController(WebClientService webClientService, @Value("${config.vanity-hostname}") String vanityHostname) {
}

public PreparedStatement connectAndPrepareStatement(String sql) throws SQLException {
return DriverManager.getConnection(url, user, password).prepareStatement(sql);
}
Expand All @@ -48,14 +44,6 @@ public Collection<Object> getOrganizations() throws SQLException {
"name", rs.getString(organization_name)));
}

@GetMapping("/organizations/{organizationId}")
public Object getOrganization(@PathVariable String organizationId) throws SQLException {
return jdbcTemplate.queryForObject("SELECT * FROM " + database + " WHERE " + organization_id + " = ?", new Object[]{organizationId},
(rs, rowNum) -> Map.of("id", rs.getString(organization_id), "name", rs.getString(organization_name))
);
}


@PostMapping("/organizations")
public void createOrganization(@RequestBody JSONObject body) throws SQLException {
jdbcTemplate.update("insert into " + database + " ("+organization_id + ", " + organization_name + ") values (?,?)",
Expand Down
7 changes: 3 additions & 4 deletions backend/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ spring:
url: jdbc:postgresql:postgres
username: postgres
password: ${POSTGRES_PASSWORD}
database : organizations
organization_id : organization_id
organization_name : organization_name
password_encryption : md5
database: organizations
organization_id: organization_id
organization_name: organization_name
springdoc:
swagger-ui:
path: /docs/swagger-ui.html
Expand Down
46 changes: 3 additions & 43 deletions frontend/src/components/OrganizationDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<v-row no-gutters>
<v-col class="col-7">
<v-form ref="form">
<label for="id" :disabled=" !!organizationId || !editUserDetailsPermission" class="required">Organization ID</label>
<label for="id" class="required">Organization ID</label>
<v-text-field
dense
:disabled="!!organizationId ||!editUserDetailsPermission"
outlined
id="ID"
v-model="organization.id"
Expand All @@ -20,11 +19,10 @@
]"
/>

<label :disabled="!editUserDetailsPermission" for="first-name" class="required">Organization Name</label>
<label for="first-name" class="required">Organization Name</label>
<v-text-field
dense
outlined
:disabled="!editUserDetailsPermission"
id="first-name"
v-model="organization.name"
required
Expand All @@ -33,63 +31,25 @@
</v-form>
</v-col>
</v-row>
<v-btn id="submit-button" v-if="editUserDetailsPermission && !organizationId" class="primary" medium @click="updateOrganization">{{ updateOrCreate }} Organization</v-btn>
<v-btn id="submit-button" class="primary" medium @click="updateOrganization">{{ updateOrCreate }} Organization</v-btn>
</v-card>
</div>
</template>

<script>
import OrganizationsRepository from "@/api/OrganizationsRepository";


export default {
name: "OrganizationDetails",
props: ['organizationId', 'updateOrCreate'],
data() {
return {

organization: {
id: '',
name: '',
},
};
},
async created() {
if(this.organizationId){
await this.getOrganization();
}
},
computed: {
// todo: this checks permission to edit users, not orgs
editUserDetailsPermission: function() {
const onCreateUserPage = !this.id;

const umsClientId = "USER-MANAGEMENT-SERVICE";
const manageUserDetailsRoleName = "manage-user-details";
const createUserRoleName = "create-user";

const hasManageUserDetails = this.$keycloak.tokenParsed.resource_access[umsClientId].roles.includes(manageUserDetailsRoleName);
const hasCreateUser = this.$keycloak.tokenParsed.resource_access[umsClientId].roles.includes(createUserRoleName);

if (onCreateUserPage && hasCreateUser) {
return true
} else if (!onCreateUserPage && hasManageUserDetails) {
return true
}
return false
}
},
methods: {
getOrganization: function() {
OrganizationsRepository.getOrganization(this.organizationId)
.then(response => {
console.log(response.data);
this.organization = response.data;
})
.catch(e => {
console.log(e);
});
},
updateOrganization: function() {
// Validate the Organization Details
if (!this.$refs.form.validate()) {
Expand Down

0 comments on commit 701f2a1

Please sign in to comment.