I have the following code in my html-class:
<ag-grid-aurelia #agGrid class="ag-theme-balham" style="width: 100%; height: 350px;" #agGrid grid-ready.call="onGridReady()"
grid-options.bind="filesThatAreMalwareOptions">
<ag-grid-column header-name="date" field="date" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="fileHash" field="fileHash" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="fileName" field="fileName" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="fileSize" field="fileSize" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="mimeType" field="mimeType" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="Malware" field="Malware" width.bind="300"></ag-grid-column>
<ag-grid-column header-name="Virustotal-Link" field="Virustotal-Link" width.bind="300"></ag-grid-column>
</ag-grid-aurelia>
And the following code in my TypeScript-class:
filesThatAreMalwareOptions:GridOptions = {
rowData: []
};
getValueFromRequest(queryEndpoint){
this.http
.fetch(queryEndpoint, {
mode: "cors"
})
.then(result => result.json()
).then(body => {
if (queryEndpoint == "TestFileData"){
this.filesThatAreMalwareOptions.rowData = JSON.parse(body);
}
});
If I want to load the data from the endpoint of my service the gird display "No rows to show". If I hardcode the rowData like:
filesThatAreMalwareOptions:GridOptions = {
rowData: [ {date: '02.04.1990', fileHash: 'X', fileName: 'X', fileSize: 3245, mimeType: 'PDF'}]
};
The data is displayed in the grid. Where is the problem with loading the data from the service?
Instead of setting the property rowData directly, you will need to use an api call:
this.filesThatAreMalwareOptions.api.setRowData(JSON.parse(body));
See the api reference:
https://www.ag-grid.com/javascript-grid-api/
Related
I am trying to bind a camera feed to a video element using Vue 3, but I can not seem to even get a basic example working. Can someone tell me what I am missing?
import { ref, reactive } from 'vue'
let stream: any = reactive({})
let constraints = {
audio: false,
video: {
width: { min: 1024, ideal: 1280, max: 1920 },
height: { min: 576, ideal: 720, max: 1080 },
facingMode: 'environment'
}
}
stream = await navigator.mediaDevices.getUserMedia(constraints)
Then in my template I have tried both of the following ways to bind
<video :srcObject.prop="stream" width="300" height="200" autoplay></video>
<video :srcObject.prope.camel="stream" autoplay playsinline></video>
Your code overwrites stream with the result of getUserMedia(), which effectively removes the original reactive() instance from the component's context.
Solution
Make stream a ref instead of reactive, and set its value property to the result of getUserMedia().
Also, to ensure the user's resources are activated only when necessary, call getUserMedia() in the component's mounted hook, and stop the stream in the beforeUnmount hook.
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue'
const stream = ref(null)
const constraints = {
audio: false,
video: {
width: { min: 1024, ideal: 1280, max: 1920 },
height: { min: 576, ideal: 720, max: 1080 },
facingMode: 'environment',
},
}
onMounted(async () => {
stream.value = await navigator.mediaDevices.getUserMedia(constraints)
})
onBeforeUnmount(() => {
stream.value.getTracks().forEach(track => track.stop())
})
</script>
<template>
<video :srcObject="stream" width="300" height="200" autoplay></video>
</template>
demo
I cannot figure out why ion-image is not displaying my base64 images from Plugins.Camera.getPhoto() but the img is able to render the image:
my html
<img *ngIf="selectedImage" [src]="selectedImage">
<ion-img
role="button"
class="image"
(click)="onPickImage()"
[src]="selectedImage"
*ngIf="selectedImage"
></ion-img>
my .ts
Plugins.Camera.getPhoto({
quality: 50,
source: CameraSource.Prompt,
correctOrientation: true,
height: 320,
width: 200,
resultType: CameraResultType.DataUrl
})
.then(image => {
this.selectedImage = this.sanitizer.bypassSecurityTrustResourceUrl(
image && image.dataUrl
);
this.imagePick.emit(this.selectedImage);
})
.catch(error => {
console.log(error);
});
so what i see is :
as you can see the ion-img is not rendering the image
EDIT
this is the value i get in selectedImage:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz\nODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2Nj\nY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCAFAAMgDASIA\nAhEBAxEB/8QAGgAAAgMBAQ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1viI46T\nQw9iAAR8ZV9tTNOnB/zn9UlEY7R7udR2M+bmgn8Sr2aHzXKuuTKIwostKLt0UDB1yVFqyXBW3uYa\nE1mzRaiNjBASXDsNJ3U5K6ICy3JkETpkkSszswVmOT46rZUbhIA5hZKninotIBCiMqIjo8kOSaNE\nCFzdEChGaiJGaBYRUIkZoYR0CAogIADojA6KCQqbisy1dSuHhxDSQQ3XMf8A4r4HQKm8ZRNEGu2a\nbXAu10mOXmrPUvjJbtGzXuvn529cQxrc3CcxM9h1Ut2jZtQ3z87esIY1ubhOYnloEBWoPqOZdVmP\nsGj3QBzB5ZDiyEjNBlak+o5l5UY6xb9i0OBI/dybxaTqu7ie2qs2Xir1pcy6h1PAJIGuc+YRpEbH\nqVH3QxGuZbu84jWZjqEjKlo9zm3z2uoMMW4BkhvfDnpGqFKtSrT+l6jHx9lhcDHXwemqDfRpllmM
Currently I'm using Vue-Konva.js to help me build a 2d editor for panorama.
Does konva.js support GLSL code for apply image effect (ex: stereographic projection)?
Maybe like this format.
KonvaScens.vue
<template>
<v-stage :config="configKonva">
<v-layer>
<v-image :config="configImage"></v-image>
</v-layer>
</v-stage>
</template>
<script>
import {myVertexShader, myFragmentShader} from 'imageShader'
export default {
data () {
return {
testImg: new Image(100, 100),
configKonva: {
width: 500,
height: 500
}
}
},
computed: {
configImage () {
return {
x: 20,
y: 20,
image: this.testImg,
width: 500,
height: 500,
vertexShader: myVertexShader,
fragmentShader: myFragmentShader
}
}
},
mounted () {
this.testImg.src = "https://konvajs.github.io/assets/lion.png"
}
}
</script>
No, vue-konva doesn't support GLSL. GLSL can be used in webgl canvas context. But Konva uses only 2d context.
I have a working chartist Line chart and I have configured the plugins as suggested in documentations. I don't get any errors when loading the page. Its just that nothing gets reflected on the chart according to plugin. I have added two plugins - they don't show any error and my line chart shows perfectly fine.
But I see no effect of those plugins - tooltip plugin and pointlabel plugin.
And yes they are loaded in the HTML and their css files are also included else would have got errors about plugins not being present.
var options = {
low: 0,
high: 100,
showGridBackground: false,
showArea: true,
axisX: {
showGrid: false
},
axisY: {
},
plugins: [
Chartist.plugins.ctPointLabels({
textAnchor: 'middle',
labelInterpolationFnc: function(value) {console.log("i was called"); return '$' + value}
}),
Chartist.plugins.tooltip({
})
]
};
var m = new Chartist.Line('#myChart', data, options);
Here is simple working example using your code. One thing to watch out for is that the tooltips need additional CSS to display correctly.
https://jsfiddle.net/rxdb576n/1/
var data = {
labels: ["Mon", "Tue", "Wed"],
series: [
[10, 20, 75]
],
}
var options = {
low: 0,
high: 100,
showGridBackground: false,
showArea: true,
axisX: {
showGrid: false
},
axisY: {},
plugins: [
Chartist.plugins.ctPointLabels({
textAnchor: 'middle',
labelInterpolationFnc: function(value) {
console.log("i was called");
return '$' + value
}
}),
Chartist.plugins.tooltip({
})
]
};
var m = new Chartist.Line('#myChart', data, options);
.chartist-tooltip {
opacity: 0;
position: absolute;
margin: 20px 0 0 10px;
background: rgba(0, 0, 0, 0.8);
color: #FFF;
padding: 5px 10px;
border-radius: 4px;
}
.chartist-tooltip.tooltip-show {
opacity: 1;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.11.0/chartist.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.11.0/chartist.min.js"></script>
<script src="https://unpkg.com/chartist-plugin-tooltips#0.0.17"></script>
<script src="https://unpkg.com/chartist-plugin-pointlabels#0.0.6"></script>
<div id="myChart"></div>
I'm trying to render the dgrid without the vertical scrollbar showing up, but for some reason, it always renders larger than the space it's in.
When the grid loads, it renders at 400x300 even though the space is only 300x200 which then causes vertical scrolling. How do I prevent that?
addGrid: function () {
this.grid = (declare([OnDemandGrid, Selection]))({
id: "tgrid" + this.reportId,
loadingMessage: 'Loading data...',
noDataMessage: 'No results found.',
allowTextSelection: true,
scroller: true,
collection: new Memory({
idProperty: "id"
}),
columns: {
trackName: "Name",
urn: {
label: "URN",
renderCell: function(object, value, cell) {
if(typeof value === 'undefined' ) {
cell.bgColor = "red";
} else {
cell.innerHTML = value;
}
}
},
location: "Location",
affiliation: "Affiliation",
eta: "ETA",
lta: "LTA"
}
}, this.gridId);
//next get the tracks using this call
this.getTracks();
}
.dgrid {
height: auto;
}
.dgrid-row {
padding: 3px 0 2px 9px;
}
.dgrid-scroller {
position: relative;
overflow: auto;
max-height: 95%;
}