Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed elocker for latest registry #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50,756 changes: 35,427 additions & 15,329 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions proxy.conf.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{
"/elocker/api/v1": {
"target": "https://elocker.sunbirdrc.dev",
"/registry/api/v1": {
"target": "http://localhost:80",
"changeOrigin": true,
"logLevel": "debug",
"secure": false

},

"/elocker/api": {
"target": "https://elocker.sunbirdrc.dev",
"/registry/api": {
"target": "http://localhost:80",
"changeOrigin": true,
"logLevel": "debug",
"secure": false
},

"/elocker/api/docs": {
"target": "https://elocker.sunbirdrc.dev",
"/registry/api/docs": {
"target": "http://localhost:80",
"changeOrigin": true,
"logLevel": "debug",
"secure": false

},
"/auth": {
"target": "http://keycloak:8080",
"changeOrigin": true,
"logLevel": "debug",
"secure": false
Expand Down
41 changes: 19 additions & 22 deletions src/app/documents/doc-detail-view/doc-detail-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,27 @@ export class DocDetailViewComponent implements OnInit {
}

this.id = params.id;
this.generalService.getData(params.type + '/' + params.id).subscribe((res) => {
console.log('pub res', res);

if (res.name == 'attestation-SELF') {
this.docName = res['additionalInput'].name;
if (res['additionalInput']['fileUrl']) {
res['additionalInput']['fileUrl'].forEach(doc => {
var tempObject = {}
console.log("element", doc)
tempObject['name'] = doc.split('-').slice(-1)[0];
tempObject['type'] = res['name'];
tempObject['file'] = this.baseUrl + '/' + doc;
tempObject['extension'] = doc.split('.').slice(-1)[0];
tempObject['osid'] = res['osid'];
this.document.push(tempObject)
});
}
this.loader = false;
this.generalService.getData(params.entity).subscribe((res) => {
let fileUrls = res[0]["attestation-SELF"]
?.find(d => d.osid === params.id)
?.additionalInput?.fileUrl;
if (!!fileUrls && Array.isArray(fileUrls)) {
fileUrls.forEach(doc => {
var tempObject = {}
console.log("element", doc)
tempObject['name'] = doc.split('-').slice(-1)[0];
tempObject['type'] = res['name'];
tempObject['file'] = this.baseUrl + '/' + doc;
tempObject['extension'] = doc.split('.').slice(-1)[0];
tempObject['osid'] = res['osid'];
this.document.push(tempObject)
});
console.log("added files to document: ", this.document);
} else {
console.log("invalid file urls: ", fileUrls, typeof fileUrls)
}
console.log('this.document', this.document)
}, (err) => {
// this.toastMsg.error('error', err.error.params.errmsg)
console.log('error', err)
});


}

Expand Down
8 changes: 7 additions & 1 deletion src/app/layouts/doc-view/doc-view.component.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.img-mb {
margin-top: 20%;
margin-top: 5rem;
}

.html-viewer {
height: calc(100vh - 8rem);
border: 4px solid;
border-radius: 5px;
}

footer {
Expand Down
14 changes: 14 additions & 0 deletions src/app/layouts/doc-view/doc-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,26 @@ <h4>Document</h4>
</div>
</ng-template>

<ng-template [ngIf]="extension === 'html'">
<div class="text-center img-mb">
<iframe class="html-viewer" height="100%" width="100%" [srcdoc]="docUrl"></iframe>
</div>
</ng-template>

<ng-template [ngIf]="extension === 'text' || extension === 'txt'">
<div class="text-center img-mb">
<p>{{docUrl}}</p>
</div>
</ng-template>

<ng-template [ngIf]="extension === 'pdf'">
<div class="text-center img-mb">
<ngx-extended-pdf-viewer [src]="docUrl | authImage | async"></ngx-extended-pdf-viewer>
</div>
</ng-template>





<ng-template [ngIf]="docDetails" class="mt-4">
Expand Down
224 changes: 131 additions & 93 deletions src/app/layouts/doc-view/doc-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,106 +47,144 @@ export class DocViewComponent implements OnInit {
this.route.params.subscribe(async params => {
if(params.id && params.type){
this.id = params.id;
this.generalService.getData(params.type+'/'+params.id).subscribe((res) => {
console.log('pub res', res);
if(res.name == 'attestation-SELF'){
this.docName = res['additionalInput'].name;
for (const [key, value] of Object.entries(res['additionalInput'])) {
var tempObject = {}
if(key === 'fileUrl'){
this.docUrl = this.baseUrl + '/' + value;
this.extension = this.docUrl.split('.').slice(-1)[0];
}
if (typeof value != 'object') {
if (!this.excludedFields.includes(key)) {
tempObject['key'] = key;
tempObject['value'] = value;
tempObject['type'] = res['name'];
tempObject['osid'] = res['osid'];
if(res['logoUrl']){
tempObject['logoUrl'] = res['logoUrl']
}
this.document.push(tempObject);
}
} else {
if (!this.excludedFields.includes(key)) {
tempObject['key'] = key;
tempObject['value'] = value[0];
tempObject['type'] = res['name'];
tempObject['osid'] = res['osid'];
if(res['logoUrl']){
tempObject['logoUrl'] = res['logoUrl']
}
this.document.push(tempObject);
}
}
}
this.loader = false;
}else if (res.name == 'attestation-DIVOC')
{
this.generalService.getData(params.entity).subscribe((res) => {
let fileUrls = res[0]["attestation-SELF"]
?.find(d => d.osid === params.id)
?.additionalInput?.fileUrl;
if (!!fileUrls && Array.isArray(fileUrls)) {
fileUrls.forEach(doc => {
var tempObject = {}
console.log("element", doc)
tempObject['name'] = doc.split('-').slice(-1)[0];
tempObject['type'] = res['name'];
tempObject['file'] = this.baseUrl + '/' + doc;
tempObject['extension'] = doc.split('.').slice(-1)[0];
tempObject['osid'] = res['osid'];
// this.docUrl = this.baseUrl + '/' + doc;
this.extension = doc.split('.').slice(-1)[0];
this.document.push(tempObject);
this.generalService.getDocument(this.baseUrl + '/' + doc).subscribe((pdf) => {
console.log("doc url: ", pdf, this.extension);
if(["text", "txt", "html", "xhtml", "json"].includes(this.extension)) {
let reader = new FileReader();
reader.addEventListener('loadend', (e) => {
this.docUrl = e.target.result.toString();
console.log(this.docUrl);
});
reader.readAsText(pdf)
console.log("file after reading as text: ", reader.result);
// this.docUrl = pdf;
} else {
this.docUrl = URL.createObjectURL(pdf);
}
this.loader = false;
});
});
console.log("added files to document: ", this.document);
} else {
console.log("invalid file urls: ", fileUrls, typeof fileUrls)
}
});
// this.generalService.getData(params.type+'/'+params.id).subscribe((res) => {
// console.log('pub res', res);
// if(res.name == 'attestation-SELF'){
// this.docName = res['additionalInput'].name;
// for (const [key, value] of Object.entries(res['additionalInput'])) {
// var tempObject = {}
// if(key === 'fileUrl'){
// this.docUrl = this.baseUrl + '/' + value;
// this.extension = this.docUrl.split('.').slice(-1)[0];
// }
// if (typeof value != 'object') {
// if (!this.excludedFields.includes(key)) {
// tempObject['key'] = key;
// tempObject['value'] = value;
// tempObject['type'] = res['name'];
// tempObject['osid'] = res['osid'];
// if(res['logoUrl']){
// tempObject['logoUrl'] = res['logoUrl']
// }
// this.document.push(tempObject);
// }
// } else {
// if (!this.excludedFields.includes(key)) {
// tempObject['key'] = key;
// tempObject['value'] = value[0];
// tempObject['type'] = res['name'];
// tempObject['osid'] = res['osid'];
// if(res['logoUrl']){
// tempObject['logoUrl'] = res['logoUrl']
// }
// this.document.push(tempObject);
// }
// }
// }
// this.loader = false;
// }else if (res.name == 'attestation-DIVOC')
// {

this.docDetails = (JSON.parse(res['additionalInput'])).signedCredentials.credentialSubject;
this.docName = this.docDetails.name;
console.log(this.docDetails);
// this.docDetails = (JSON.parse(res['additionalInput'])).signedCredentials.credentialSubject;
// this.docName = this.docDetails.name;
// console.log(this.docDetails);

this.loader = false;
let _self = this;
Object.keys( this.docDetails).forEach(function (key) {
var temp_object : any = {};
if (_self.docDetails[key] != undefined && typeof _self.docDetails[key] != 'object') {
console.log({key});
temp_object['title'] = key;
temp_object['value'] = _self.docDetails[key];
_self.document.push(temp_object);
}
});
// this.loader = false;
// let _self = this;
// Object.keys( this.docDetails).forEach(function (key) {
// var temp_object : any = {};
// if (_self.docDetails[key] != undefined && typeof _self.docDetails[key] != 'object') {
// console.log({key});
// temp_object['title'] = key;
// temp_object['value'] = _self.docDetails[key];
// _self.document.push(temp_object);
// }
// });



}else{
if(res['_osAttestedData'] && JSON.parse(res['_osAttestedData'])['files']){
this.docUrl = this.baseUrl + '/' + JSON.parse(res['_osAttestedData'])['files'][0];
this.extension = this.docUrl.split('.').slice(-1)[0];
}
for (const [key, value] of Object.entries(res['additionalInput'])) {
var tempObject = {}
if(key === 'fileUrl'){
this.docUrl = this.baseUrl + '/' + value;
this.extension = this.docUrl.split('.').slice(-1)[0];
}
if (typeof value != 'object') {
if (!this.excludedFields.includes(key)) {
tempObject['key'] = key;
tempObject['value'] = value;
tempObject['type'] = res['name'];
tempObject['osid'] = res['osid'];
if(res['logoUrl']){
tempObject['logoUrl'] = res['logoUrl']
}
this.document.push(tempObject);
}
} else {
if (!this.excludedFields.includes(key)) {
tempObject['key'] = key;
tempObject['value'] = value[0];
tempObject['type'] = res['name'];
tempObject['osid'] = res['osid'];
if(res['logoUrl']){
tempObject['logoUrl'] = res['logoUrl']
}
this.document.push(tempObject);
}
}
// }else{
// if(res['_osAttestedData'] && JSON.parse(res['_osAttestedData'])['files']){
// this.docUrl = this.baseUrl + '/' + JSON.parse(res['_osAttestedData'])['files'][0];
// this.extension = this.docUrl.split('.').slice(-1)[0];
// }
// for (const [key, value] of Object.entries(res['additionalInput'])) {
// var tempObject = {}
// if(key === 'fileUrl'){
// this.docUrl = this.baseUrl + '/' + value;
// this.extension = this.docUrl.split('.').slice(-1)[0];
// }
// if (typeof value != 'object') {
// if (!this.excludedFields.includes(key)) {
// tempObject['key'] = key;
// tempObject['value'] = value;
// tempObject['type'] = res['name'];
// tempObject['osid'] = res['osid'];
// if(res['logoUrl']){
// tempObject['logoUrl'] = res['logoUrl']
// }
// this.document.push(tempObject);
// }
// } else {
// if (!this.excludedFields.includes(key)) {
// tempObject['key'] = key;
// tempObject['value'] = value[0];
// tempObject['type'] = res['name'];
// tempObject['osid'] = res['osid'];
// if(res['logoUrl']){
// tempObject['logoUrl'] = res['logoUrl']
// }
// this.document.push(tempObject);
// }
// }


}
this.loader = false;
}
console.log('this.document',this.document)
}, (err) => {
// this.toastMsg.error('error', err.error.params.errmsg)
console.log('error', err)
});
// }
// this.loader = false;
// }
// console.log('this.document',this.document)
// }, (err) => {
// // this.toastMsg.error('error', err.error.params.errmsg)
// console.log('error', err)
// });

}

Expand Down
14 changes: 9 additions & 5 deletions src/app/services/data/data-request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,22 @@ export class DataService {

}

getDocument(url: string): Observable<any> {
getDocument(url: string, responseType: string): Observable<any> {
return new Observable((observer: Subscriber<any>) => {
let objectUrl: string = null;

this.http
.get(url, {
headers: this.getHeader(),
responseType: 'blob'
headers: {
...this.getHeader(),
accept: "application/octet-stream"
},
responseType: "blob"
})
.subscribe(m => {
objectUrl = URL.createObjectURL(m);
observer.next(objectUrl);
// objectUrl = URL.createObjectURL(m);
// observer.next(objectUrl);
observer.next(m);
});

return () => {
Expand Down
Loading