Upgrade to Mithril 2.0

This commit is contained in:
Shweelan Samson authored and Zaid Abdulla committed 2019-07-13 01:42:33 -07:00
1 parent 3485bb8d1b
commit ae870c3155
6 files changed
+34 -26

No files matched your search

+6 -2
View File
@@ -40,7 +40,9 @@ const component: ClosureComponent = (): Component => {
type: "text",
value: vnode.state["username"],
disabled: !!username,
oninput: m.withAttr("value", v => (vnode.state["username"] = v)),
oninput: e => {
vnode.state["username"] = e.target.value;
},
oncreate: _vnode => {
(_vnode.dom as HTMLSelectElement).focus();
}
@@ -64,7 +66,9 @@ const component: ClosureComponent = (): Component => {
name: f,
type: "password",
value: vnode.state[f],
oninput: m.withAttr("value", v => (vnode.state[f] = v))
oninput: e => {
vnode.state[f] = e.target.value;
}
})
)
);
+8 -7
View File
@@ -104,13 +104,14 @@ function putActionHandler(action, _object): Promise<ValidationErrors> {
object
);
m.request({
method: "PUT",
headers: headers,
url: `/api/files/${encodeURIComponent(id)}`,
serialize: body => body, // Identity function to prevent JSON.parse on blob data
data: file
})
store
.xhrRequest({
method: "PUT",
headers: headers,
url: `/api/files/${encodeURIComponent(id)}`,
serialize: body => body, // Identity function to prevent JSON.parse on blob data
body: file
})
.then(() => {
notifications.push(
"success",
+6 -2
View File
@@ -48,7 +48,9 @@ export const component: ClosureComponent = (): Component => {
oncreate: vnode2 => {
(vnode2.dom as HTMLInputElement).focus();
},
oninput: m.withAttr("value", v => (vnode.state["username"] = v))
oninput: e => {
vnode.state["username"] = e.target.value;
}
})
),
m(
@@ -58,7 +60,9 @@ export const component: ClosureComponent = (): Component => {
name: "password",
type: "password",
value: vnode.state["password"],
oninput: m.withAttr("value", v => (vnode.state["password"] = v))
oninput: e => {
vnode.state["password"] = e.target.value;
}
})
),
m(
+7 -7
View File
@@ -555,7 +555,7 @@ export function postTasks(deviceId, tasks): Promise<string> {
return xhrRequest({
method: "POST",
url: `/api/devices/${encodeURIComponent(deviceId)}/tasks`,
data: tasks,
body: tasks,
extract: xhr => {
if (xhr.status !== 200) throw new Error(xhr.response);
const connectionRequestStatus = xhr.getResponseHeader(
@@ -576,7 +576,7 @@ export function updateTags(deviceId, tags): Promise<void> {
return xhrRequest({
method: "POST",
url: `/api/devices/${encodeURIComponent(deviceId)}/tags`,
data: tags
body: tags
});
}
@@ -593,7 +593,7 @@ export function putResource(resourceType, id, object): Promise<void> {
return xhrRequest({
method: "PUT",
url: `/api/${resourceType}/${encodeURIComponent(id)}`,
data: object
body: object
});
}
@@ -631,13 +631,13 @@ export function changePassword(
newPassword,
authPassword?
): Promise<void> {
const data = { newPassword };
if (authPassword) data["authPassword"] = authPassword;
const body = { newPassword };
if (authPassword) body["authPassword"] = authPassword;
return xhrRequest({
method: "PUT",
url: `/api/users/${username}/password`,
background: true,
data
body
});
}
@@ -646,7 +646,7 @@ export function logIn(username, password): Promise<void> {
method: "POST",
url: "/login",
background: true,
data: { username, password }
body: { username, password }
});
}