Angular2 dispatch DragEvent - drag-and-drop

I need to dispatch and Create a new DragEvent
var dispatchedDragEvent = DOM.createEvent('DragEvent');
dispatchedDragEvent.initDragEvent('dragstart', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
DOM.dispatchEvent(this.htmlElement, dispatchedDragEvent);
but I get the error initDragEvent is not a function, because DOM.createEvent('DragEvent') returns a object of Event and not 'DragEvent'
Can someone help me to create manually a DragEvent and dispatch it?
I need to convert a TouchStart to a DragStart.

Here's what I have done:
#HostListener('touchstart', ['$event'])
onTouchStart(event) {
let event1 = new DragEvent('dragstart');
this._renderer.invokeElementMethod(this._elementRef.nativeElement, 'dispatchEvent', [event1]);
}
This might give a warning on compile, but works nonetheless.

Related

Problem with SQL workbench crash on MacOS

I'm trying to make MySQL work on my MacBook (intel CPU). I have downloaded the Server and I'm using the workbench to write the SQL. But whenever I try to make a database the workbench crashes and gives me the error:
Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process: exc handler [933]
I have not changed any settings, it's all factory settings.
CREATE DATABASE Fisk;
USE Fisk;
create table fisk (
fisk_id int not null,
navn char(25) not null,
max_laengde_cm int not null,
primary key (fisk_id)
);
create table plads (
plads_id int not null,
navn char(25) not null,
afstand_fra_hjem_km int not null,
primary key(plads_id)
);
create table redskab(
redskab_id int not null,
navn char(25) not null,
vaegt_gram int not null,
primary key (redskab_id)
);
create table fisketur(
fisketur_id int not null,
dato date not null,
plads_id int not null,
primary key (fisketur_id),
foreign key (plads_id) references plads(plads_id)
);
create table fangst(
fangst_id int not null,
tid time not null,
laengde_cm int not null,
fisk_id int not null,
fisketur_id int not null,
redskab_id int not null,
primary key (fangst_id),
foreign key (fisk_id) references fisk(fisk_id),
foreign key (fisketur_id) references fisketur(fisketur_id),
foreign key (redskab_id) references redskab(redskab_id)
);
insert into fisk values
(1,'Hornfisk',90),
(2,'Torsk',120),
(3,'Skrubbe',50),
(4,'Makrel',45),
(5,'Laks',120);
insert into plads values
(1,'Knudshoved',31),
(2,'Vresen',45),
(3,'Fyns Hoved',48),
(4,'Gabet',24),
(5,'Kajbjerg',34);
insert into redskab values
(1,'R¯dt blink',25),
(2,'Gr¯n flue',5),
(3,'Forfang',55),
(4,'Blankt blink',35),
(5,'Gult blink',28);
insert into fisketur values
(1,'2018-10-18',4),
(2,'2019-11-23',2),
(3,'2019-06-12',3),
(4,'2019-12-11',1),
(5,'2020-01-02',1),
(6,'2014-10-14',5);
insert into fangst values
(1,'12:17:00',48,4,5,1),
(2,'15:38:00',35,3,4,3),
(3,'19:30:00',50,2,3,5),
(4,'09:28:00',41,1,2,4),
(5,'07:12:00',43,5,1,2),
(6,'05:48:00',55,1,3,2),
(7,'09:56:00',62,2,6,4);
SHOW TABLES;

Can't store user_id into another table in flutter

I need to create a table that will add the user_id as another data in the table. But somehow my solution does not work.
The table user looks like this:
CREATE TABLE user(
user_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
username TEXT NOT NULL,
password TEXT NOT NULL,
f_name TEXT NOT NULL,
l_name TEXT NOT NULL,
email TEXT NOT NULL,
phone INTEGER NOT NULL
)
After the login, the user have to fill in a form, the data goes to the table, flowerbook:
CREATE TABLE flowerbook(
book_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
deliver_date TEXT NOT NULL,
arrangement TEXT NOT NULL,
flower_type TEXT NOT NULL,
user_id INTEGER NOT NULL
)
I tried doing this, on the submit button of the form:
onPressed: () {
Flowerbook flowerbook = Flowerbook(
deliver_date: dateController.text,
flower_type: checkboxController.text,
arrangement: dropdownController.text,
user_id: widget.user.user_id,
);
Flowerbook.register(flowerbook);
},
But I still get this error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DatabaseException(NOT NULL constraint failed: flowerbook.user_id (code 1299 SQLITE_CONSTRAINT_NOTNULL)) sql 'INSERT OR REPLACE INTO flowerbook (book_id, deliver_date, arrangement, flower_type, user_id) VALUES (NULL, ?, ?, ?, NULL)' args [1/1/2023 12:00:00, Box, Carnation]
As you can see, the delivery_date, flower_type, and arrangement is successfully added as an argument. But user_id is NULL.
What seems to be the problem here?
I did log the widget.user.user_id, and it is indeed NULL.
Maybe there's something wrong at my menu page? Here's my code:
final List<Widget> _widgetOptions = <Widget>[
FormPage(user: widget.user),
OrderPage(user: widget.user),
AccountPage(user: widget.user),
];

MassTransit Entity Framework Audit Store SentTime Unavailable

I've set up auditing for MassTransit messages using the Entity Framework store and SQL Server. By default, the audit records table has the following schema:
CREATE TABLE [dbo].[EfCoreAudit](
[AuditRecordId] [int] IDENTITY(1,1) NOT NULL,
[MessageId] [uniqueidentifier] NULL,
[ConversationId] [uniqueidentifier] NULL,
[CorrelationId] [uniqueidentifier] NULL,
[InitiatorId] [uniqueidentifier] NULL,
[RequestId] [uniqueidentifier] NULL,
[SourceAddress] [nvarchar](max) NULL,
[DestinationAddress] [nvarchar](max) NULL,
[ResponseAddress] [nvarchar](max) NULL,
[FaultAddress] [nvarchar](max) NULL,
[InputAddress] [nvarchar](max) NULL,
[ContextType] [nvarchar](max) NULL,
[MessageType] [nvarchar](max) NULL,
[Custom] [nvarchar](max) NULL,
[Headers] [nvarchar](max) NULL,
[Message] [nvarchar](max) NULL,
CONSTRAINT [PK_EfCoreAudit]
PRIMARY KEY CLUSTERED ([AuditRecordId] ASC)
)
Which does not include a SentTime column. Instead of adding that property to all application message types so it's contained in the Message column data, I am looking for a more generic solution.
One option would be to add that information in the message headers and another to add a KeyValuePair in the MessageAuditMetadata.Custom dictionary. But it seems to me that the SentTime information should be there by default.
Is there any reason why there is not a SentTime column?
I've looked at the MassTransit code and I see that SendContext and PublishContext interfaces do not have that property, while MessageContext (and consequently ConsumeContext) does.
Is there any other alternative to add that information to the audit records that would be more recommended than the ones mentioned above?

Java-client: Best way to check operation delete operation completion?

I'm wondering what is the best way to confirm a delete operation is successful via the Java client? Just because we get a successful status after the API call does not mean the resources, in my case a pod, has been finally deleted.
Currently my approach to do a delete api call, then to do a list pods with watch waiting for a delete event. This feels a bit brittle to me.
I have a couple questions:
Do watches on delete calls work? I tried to add one but all my items were null. Which is why I do a list call afterwards.
Is there a more streamlined way to check for the complete deletion of a pod?
Below is a rough example of what I've been trying.
clientConfig.deleteCollectionNamespacedPod(entity.getNamespace(), null, null, null,
String.format(NAME_FIELD_SELECTOR, entity.getName()), null, null, null, null, null);
Call call = clientConfig.listNamespacedPodCall(entity.getNamespace(), null, null, null,
String.format(NAME_FIELD_SELECTOR, entity.getName()), null, null, null, null, Boolean.TRUE,
null, null);
Watch<V1Pod> watch = Watch.createWatch(BaseClient.newBaseClient(clientConfig), call, new TypeToken<Watch.Response<V1Pod>>() {
}.getType());
for (Watch.Response<V1Pod> item : watch) {
if (item.type == "DELETED") {
// return that the deletion of the object was successful
}
}

Facebook feed - page keeps reloading

I am trying to post something on a facebook users feed and then afterwards redirect the user to another page, but it seems like the page just keeps reloading without any promt for sending user feed.
FB.Connect.showFeedDialog(1111111, null, null, null, null, null, redirectTo(), null, null);
function redirectTo()
{
window.top.location = "/mywebsite";
}
If I just call the show feed with the id it works properly.
FB.Connect.showFeedDialog(1111111, null, null, null, null, null, redirectTo(), null, null);
Anyone who knows why the first lines of code keeps reloading the page in an infinitive loop?
When registering the callback function, you want to pass the reference to the function and not actually call the function. Remove the parentheses from redirectTo in your first line:
FB.Connect.showFeedDialog(1111111, null, null, null, null, null, redirectTo, null, null);
function redirectTo(){
window.top.location = "/mywebsite";
}